NCBI C++ ToolKit
vector_serial.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef ALGO_TEXT___VECTOR_SERIAL__HPP
2 #define ALGO_TEXT___VECTOR_SERIAL__HPP
3 
4 /* $Id: vector_serial.hpp 45267 2010-03-26 16:15:07Z satskyse $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Mike DiCuccio
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <util/simple_buffer.hpp>
37 
38 #include <algo/text/vector.hpp>
39 
41 
42 /// @name Serialization interfaces
43 /// @{
44 
45 ///
46 /// Generics
47 /// These throw an exception; we must implement serialization for each type
48 ///
49 template <class Key, class Score>
51 {
53  "Serialize(): Serialization type unknown");
54 }
55 
56 template <class Key, class Score>
58 {
60  "Deserialize(): Deserialization type unknown");
61 }
62 
63 template <class Key, class Score>
65 {
67  "Serialize(): Serialization type unknown");
68 }
69 
70 template <class Key, class Score>
72 {
74  "Deserialize(): Deserialization type unknown");
75 }
76 
77 
78 
79 template <class Key, class Score>
81  vector<char>& data)
82 {
84  "Encode(): Serialization type unknown");
85 }
86 
87 template <class Key, class Score>
89  vector<unsigned char>& data)
90 {
92  "Encode(): Serialization type unknown");
93 }
94 
95 template <class Key, class Score>
98 {
100  "Encode(): Serialization type unknown");
101 }
102 
103 
104 template <class Key, class Score>
105 void Decode(const vector<char>& data, CRawScoreVector<Key, Score>& vec)
106 {
108  "Decode(): Deserialization type unknown");
109 }
110 
111 template <class Key, class Score>
112 void Decode(const vector<unsigned char>& data, CRawScoreVector<Key, Score>& vec)
113 {
115  "Decode(): Deserialization type unknown");
116 }
117 
118 template <class Key, class Score>
120 {
122  "Decode(): Deserialization type unknown");
123 }
124 
125 template <class Key, class Score>
126 void Decode(const void* data, size_t size, CRawScoreVector<Key, Score>& vec)
127 {
129  "Decode(): Deserialization type unknown");
130 }
131 
132 
133 template <class Key, class Score>
135  vector<char>& data)
136 {
138  "Encode(): Serialization type unknown");
139 }
140 
141 template <class Key, class Score>
143  vector<unsigned char>& data)
144 {
146  "Encode(): Serialization type unknown");
147 }
148 
149 template <class Key, class Score>
152 {
154  "Encode(): Serialization type unknown");
155 }
156 
157 
158 template <class Key, class Score>
159 void Decode(const vector<char>& data, CScoreVector<Key, Score>& vec)
160 {
162  "Decode(): Deserialization type unknown");
163 }
164 
165 template <class Key, class Score>
166 void Decode(const vector<unsigned char>& data, CScoreVector<Key, Score>& vec)
167 {
169  "Decode(): Deserialization type unknown");
170 }
171 
172 template <class Key, class Score>
174 {
176  "Decode(): Deserialization type unknown");
177 }
178 
179 template <class Key, class Score>
180 void Decode(const void* data, size_t size, CScoreVector<Key, Score>& vec)
181 {
183  "Decode(): Deserialization type unknown");
184 }
185 
186 
187 ///
188 /// Specializations for known types
189 ///
190 
191 
192 
193 ///
194 /// Uint4-based keys
195 ///
196 
197 template<>
199  const CRawScoreVector<Uint4, float>& vec);
200 template<>
203 
204 template<>
206  vector<unsigned char>& data);
207 template<>
209  vector<char>& data);
210 template<>
213 template<>
216 
217 template<>
218 void Decode<Uint4, float>(const vector<unsigned char>& data,
220 template<>
221 void Decode<Uint4, float>(const vector<char>& data,
223 template<>
226 template<>
227 void Decode<Uint4, float>(const void* data, size_t size,
229 
230 
231 template<>
233  const CScoreVector<Uint4, float>& vec);
234 template<>
237 
238 template<>
240  vector<char>& data);
241 template<>
243  vector<unsigned char>& data);
244 template<>
247 template<>
250 
251 template<>
252 void Decode<Uint4, float>(const vector<char>& data,
254 template<>
255 void Decode<Uint4, float>(const vector<unsigned char>& data,
257 template<>
260 template<>
261 void Decode<Uint4, float>(const void* data, size_t size,
263 
264 
265 ///
266 /// String based keys
267 /// Raw vector encoding is not supported
268 ///
269 
270 template<>
272  const CScoreVector<string, float>& vec);
273 template<>
276 
277 template<>
279  vector<unsigned char>& data);
280 template<>
282  vector<char>& data);
283 template<>
286 template<>
287 void Decode<string, float>(const vector<unsigned char>& data,
289 template<>
290 void Decode<string, float>(const vector<char>& data,
292 template<>
295 template<>
296 void Decode<string, float>(const void* data, size_t size,
298 
299 
300 /// @}
301 
302 
304 
305 #endif // ALGO_TEXT___VECTOR_SERIAL__HPP
void Encode< Uint4, float >(const CRawScoreVector< Uint4, float > &vec, vector< unsigned char > &data)
void Decode(const vector< char > &data, CRawScoreVector< Key, Score > &vec)
static CUser_object data
class CRawScoreVector stores its data in a (sorted) STL vector this gives a better memory profile and...
Definition: vector.hpp:43
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
void Serialize< string, float >(CNcbiOstream &ostr, const CScoreVector< string, float > &vec)
String based keys Raw vector encoding is not supported.
void Serialize< Uint4, float >(CNcbiOstream &ostr, const CRawScoreVector< Uint4, float > &vec)
Specializations for known types.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:150
void Decode< string, float >(const vector< unsigned char > &data, CScoreVector< string, float > &vec)
void Deserialize< Uint4, float >(CNcbiIstream &istr, CRawScoreVector< Uint4, float > &vec)
int size
Reallocable memory buffer (no memory copy overhead) Mimics vector<>, without the overhead of explicit...
void Decode< Uint4, float >(const vector< unsigned char > &data, CRawScoreVector< Uint4, float > &vec)
void Encode(const CRawScoreVector< Key, Score > &vec, vector< char > &data)
void Serialize(CNcbiOstream &ostr, const CRawScoreVector< Key, Score > &vec)
Generics These throw an exception; we must implement serialization for each type. ...
CException –.
Definition: ncbiexpt.hpp:709
void Deserialize(CNcbiIstream &istr, CRawScoreVector< Key, Score > &vec)
void Deserialize< string, float >(CNcbiIstream &istr, CScoreVector< string, float > &vec)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string...
Definition: ncbiexpt.hpp:546
void Encode< string, float >(const CScoreVector< string, float > &vec, vector< unsigned char > &data)
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:147
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
Modified on Mon Jul 06 13:57:45 2015 by modify_doxy.py rev. 426318