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

Go to the SVN repository for this file.

1 #ifndef SERIALDEF__HPP
2 #define SERIALDEF__HPP
3 
4 /* $Id: serialdef.hpp 84443 2018-11-08 19:59:04Z gouriano $
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 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * Constants used in serial library
33 */
34 
35 #include <corelib/ncbistd.hpp>
36 
37 
38 /** @addtogroup GenClassSupport
39  *
40  * @{
41  */
42 
43 
45 
46 // forward declaration of two main classes
47 class CTypeRef;
48 class CTypeInfo;
49 
51 
52 class CObjectIStream;
53 class CObjectOStream;
54 
56 
57 // typedef for object references (constant and nonconstant)
58 typedef void* TObjectPtr;
59 typedef const void* TConstObjectPtr;
60 
61 // shortcut typedef: almost everywhere in code we have pointer to const CTypeInfo
62 typedef const CTypeInfo* TTypeInfo;
63 typedef TTypeInfo (*TTypeInfoGetter)(void);
66 typedef CTypeInfo* (*TTypeInfoCreator)(void);
67 typedef CTypeInfo* (*TTypeInfoCreator1)(TTypeInfo);
68 typedef CTypeInfo* (*TTypeInfoCreator2)(TTypeInfo, TTypeInfo);
69 
70 /// Data file format
73  eSerial_AsnText = 1, ///< ASN.1 text
74  eSerial_AsnBinary = 2, ///< ASN.1 binary
75  eSerial_Xml = 3, ///< XML
76  eSerial_Json = 4 ///< JSON
77 };
78 
79 /// Formatting flags
81  fSerial_AsnText_NoIndentation = 1<<7, ///< do not use indentation
82  fSerial_AsnText_NoEol = 1<<6 ///< do not write end-of-line symbol
83 };
84 typedef unsigned int TSerial_AsnText_Flags;
85 
87  fSerial_Xml_NoIndentation = 1<<7, ///< do not use indentation
88  fSerial_Xml_NoEol = 1<<6, ///< do not write end-of-line symbol
89  fSerial_Xml_NoXmlDecl = 1<<5, ///< do not write XMLDecl
90  fSerial_Xml_NoRefDTD = 1<<4, ///< do not use reference to a DTD
91  fSerial_Xml_RefSchema = 1<<3, ///< use reference to a Schema
92  fSerial_Xml_NoSchemaLoc = 1<<2 ///< do not write schemaLocation data
93 };
94 typedef unsigned int TSerial_Xml_Flags;
95 
97  fSerial_Json_NoIndentation = 1<<7, ///< do not use indentation
98  fSerial_Json_NoEol = 1<<6 ///< do not write end-of-line symbol
99 };
100 typedef unsigned int TSerial_Json_Flags;
101 
102 #define SERIAL_VERIFY_DATA_GET "SERIAL_VERIFY_DATA_GET"
103 #define SERIAL_VERIFY_DATA_WRITE "SERIAL_VERIFY_DATA_WRITE"
104 #define SERIAL_VERIFY_DATA_READ "SERIAL_VERIFY_DATA_READ"
105 
106 /// Data verification parameters
108  eSerialVerifyData_Default = 0, ///< use current default
109  eSerialVerifyData_No, ///< do not verify
110  eSerialVerifyData_Never, ///< never verify (even if set to verify later on)
111  eSerialVerifyData_Yes, ///< do verify
112  eSerialVerifyData_Always, ///< always verify (even if set not to later on)
113  eSerialVerifyData_DefValue, ///< initialize field with default
114  eSerialVerifyData_DefValueAlways ///< initialize field with default
115 };
116 
117 /// Skip unknown members parameters
119  eSerialSkipUnknown_Default = 0, ///< use current default
120  eSerialSkipUnknown_No, ///< do not skip (throw exception)
121  eSerialSkipUnknown_Never, ///< never skip (even if set to skip later on)
123  eSerialSkipUnknown_Always ///< always skip (even if set not to later on)
124 };
125 
126 /// File open flags
128  eSerial_StdWhenEmpty = 1 << 0, ///< use std stream when filename is empty
129  eSerial_StdWhenDash = 1 << 1, ///< use std stream when filename is "-"
130  eSerial_StdWhenStd = 1 << 2, ///< use std when filename is "stdin"/"stdout"
133  eSerial_UseFileForReread = 1 << 4
134 };
135 typedef int TSerialOpenFlags;
136 
137 /// Type family
144 };
145 
146 /// Primitive value type
148  ePrimitiveValueSpecial, ///< null, void
151  ePrimitiveValueInteger, ///< (signed|unsigned) (char|short|int|long)
152  ePrimitiveValueReal, ///< float|double
153  ePrimitiveValueString, ///< string|char*|const char*
155  ePrimitiveValueOctetString, ///< vector<(signed|unsigned)? char>
157 #ifdef NCBI_STRICT_GI
158  //ePrimitiveValueGi,
159 #endif
162 };
163 
165  eContainerVector, ///< allows indexing & access to size
166  eContainerList, ///< only sequential access
169 };
170 
171 
172 /// How to process non-printing character in the ASN VisibleString
174  eFNP_Skip, ///< skip, post no error message
175  eFNP_Allow, ///< pass through unchanged, post no error message
176  eFNP_Replace, ///< replace with '#' silently
177  eFNP_ReplaceAndWarn, ///< replace with '#', post an error of severity ERROR
178  eFNP_Throw, ///< replace with '#', throw an exception
179  eFNP_Abort, ///< replace with '#', post an error of severity FATAL
180 
182 };
183 
184 /// String type
186  eStringTypeVisible, ///< VisibleString (in ASN.1 sense)
187  eStringTypeUTF8 ///< UTF8-encoded string
188 };
189 
190 /// How to assign and compare child sub-objects of serial objects
192  eRecursive, ///< Recursively
193  eShallow, ///< Assign/Compare pointers only
194  eShallowChildless ///< Set sub-object pointers to 0
195 };
196 
197 /// Defines namespace qualification of XML tags
202 };
203 
204 enum class EDataSpec {
205  eUnknown = 0,
206  eASN = 0,
207  eDTD,
208  eXSD,
209  eJSON
210 };
211 
212 enum class ESerialFacet {
213  eMinLength = 1,
214  eMaxLength,
215  eLength,
216  ePattern,
217 
222  eMultipleOf,
223 
224  eMinItems,
225  eMaxItems,
227 };
228 
229 /// Type used for indexing class members and choice variants
230 typedef size_t TMemberIndex;
231 
232 typedef int TEnumValueType;
233 
234 /// Start if member indexing
236 /// Special value returned from FindMember
238 /// Special value for marking empty choice
240 
242 
243 
244 /* @} */
245 
246 
248 
249 #endif /* SERIALDEF__HPP */
CObjectIStream –.
Definition: objistr.hpp:93
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
Include a standard set of the NCBI C++ Toolkit most basic headers.
ENsQualifiedMode
Defines namespace qualification of XML tags.
Definition: serialdef.hpp:198
ESerialRecursionMode
How to assign and compare child sub-objects of serial objects.
Definition: serialdef.hpp:191
unsigned int TSerial_Json_Flags
Definition: serialdef.hpp:100
const TMemberIndex kEmptyChoice
Special value for marking empty choice.
Definition: serialdef.hpp:239
ESerial_AsnText_Flags
Formatting flags.
Definition: serialdef.hpp:80
ESerialOpenFlags
File open flags.
Definition: serialdef.hpp:127
ESerialSkipUnknown
Skip unknown members parameters.
Definition: serialdef.hpp:118
EFixNonPrint
How to process non-printing character in the ASN VisibleString.
Definition: serialdef.hpp:173
int TSerialOpenFlags
Definition: serialdef.hpp:135
void * TObjectPtr
Definition: serialdef.hpp:55
int TEnumValueType
Definition: serialdef.hpp:232
unsigned int TSerial_AsnText_Flags
Definition: serialdef.hpp:84
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
const TMemberIndex kFirstMemberIndex
Start if member indexing.
Definition: serialdef.hpp:235
TTypeInfo(* TTypeInfoGetter)(void)
Definition: serialdef.hpp:63
ESerialFacet
Definition: serialdef.hpp:212
const TMemberIndex kInvalidMember
Special value returned from FindMember.
Definition: serialdef.hpp:237
ESerialVerifyData
Data verification parameters.
Definition: serialdef.hpp:107
const void * TConstObjectPtr
Definition: serialdef.hpp:59
ESerial_Xml_Flags
Definition: serialdef.hpp:86
const CTypeInfo * TTypeInfo
Definition: serialdef.hpp:62
EContainerType
Definition: serialdef.hpp:164
TTypeInfo(* TTypeInfoGetter1)(TTypeInfo)
Definition: serialdef.hpp:64
TTypeInfo(* TTypeInfoGetter2)(TTypeInfo, TTypeInfo)
Definition: serialdef.hpp:65
EPrimitiveValueType
Primitive value type.
Definition: serialdef.hpp:147
ETypeFamily
Type family.
Definition: serialdef.hpp:138
EStringType
String type.
Definition: serialdef.hpp:185
ssize_t TPointerOffsetType
Definition: serialdef.hpp:241
ESerial_Json_Flags
Definition: serialdef.hpp:96
unsigned int TSerial_Xml_Flags
Definition: serialdef.hpp:94
EDataSpec
Definition: serialdef.hpp:204
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
@ eNSQualified
Definition: serialdef.hpp:201
@ eNSQNotSet
Definition: serialdef.hpp:199
@ eNSUnqualified
Definition: serialdef.hpp:200
@ eShallow
Assign/Compare pointers only.
Definition: serialdef.hpp:193
@ eRecursive
Recursively.
Definition: serialdef.hpp:192
@ eShallowChildless
Set sub-object pointers to 0.
Definition: serialdef.hpp:194
@ fSerial_AsnText_NoEol
do not write end-of-line symbol
Definition: serialdef.hpp:82
@ fSerial_AsnText_NoIndentation
do not use indentation
Definition: serialdef.hpp:81
@ eSerial_StdWhenMask
Definition: serialdef.hpp:131
@ eSerial_StdWhenStd
use std when filename is "stdin"/"stdout"
Definition: serialdef.hpp:130
@ eSerial_StdWhenAny
Definition: serialdef.hpp:132
@ eSerial_StdWhenDash
use std stream when filename is "-"
Definition: serialdef.hpp:129
@ eSerial_StdWhenEmpty
use std stream when filename is empty
Definition: serialdef.hpp:128
@ eSerial_UseFileForReread
Definition: serialdef.hpp:133
@ eSerialSkipUnknown_Never
never skip (even if set to skip later on)
Definition: serialdef.hpp:121
@ eSerialSkipUnknown_No
do not skip (throw exception)
Definition: serialdef.hpp:120
@ eSerialSkipUnknown_Yes
do skip
Definition: serialdef.hpp:122
@ eSerialSkipUnknown_Always
always skip (even if set not to later on)
Definition: serialdef.hpp:123
@ eSerialSkipUnknown_Default
use current default
Definition: serialdef.hpp:119
@ eFNP_Allow
pass through unchanged, post no error message
Definition: serialdef.hpp:175
@ eFNP_Skip
skip, post no error message
Definition: serialdef.hpp:174
@ eFNP_Throw
replace with '#', throw an exception
Definition: serialdef.hpp:178
@ eFNP_Abort
replace with '#', post an error of severity FATAL
Definition: serialdef.hpp:179
@ eFNP_ReplaceAndWarn
replace with '#', post an error of severity ERROR
Definition: serialdef.hpp:177
@ eFNP_Default
Definition: serialdef.hpp:181
@ eFNP_Replace
replace with '#' silently
Definition: serialdef.hpp:176
@ eSerialVerifyData_Never
never verify (even if set to verify later on)
Definition: serialdef.hpp:110
@ eSerialVerifyData_DefValueAlways
initialize field with default
Definition: serialdef.hpp:114
@ eSerialVerifyData_DefValue
initialize field with default
Definition: serialdef.hpp:113
@ eSerialVerifyData_Yes
do verify
Definition: serialdef.hpp:111
@ eSerialVerifyData_Always
always verify (even if set not to later on)
Definition: serialdef.hpp:112
@ eSerialVerifyData_No
do not verify
Definition: serialdef.hpp:109
@ eSerialVerifyData_Default
use current default
Definition: serialdef.hpp:108
@ fSerial_Xml_NoEol
do not write end-of-line symbol
Definition: serialdef.hpp:88
@ fSerial_Xml_NoIndentation
do not use indentation
Definition: serialdef.hpp:87
@ fSerial_Xml_NoSchemaLoc
do not write schemaLocation data
Definition: serialdef.hpp:92
@ fSerial_Xml_NoXmlDecl
do not write XMLDecl
Definition: serialdef.hpp:89
@ fSerial_Xml_RefSchema
use reference to a Schema
Definition: serialdef.hpp:91
@ fSerial_Xml_NoRefDTD
do not use reference to a DTD
Definition: serialdef.hpp:90
@ eContainerSet
Definition: serialdef.hpp:167
@ eContainerVector
allows indexing & access to size
Definition: serialdef.hpp:165
@ eContainerMap
Definition: serialdef.hpp:168
@ eContainerList
only sequential access
Definition: serialdef.hpp:166
@ ePrimitiveValueSpecial
null, void
Definition: serialdef.hpp:148
@ ePrimitiveValueOctetString
vector<(signed|unsigned)? char>
Definition: serialdef.hpp:155
@ ePrimitiveValueString
string|char*|const char*
Definition: serialdef.hpp:153
@ ePrimitiveValueOther
Definition: serialdef.hpp:161
@ ePrimitiveValueInteger
(signed|unsigned) (char|short|int|long)
Definition: serialdef.hpp:151
@ ePrimitiveValueAny
Definition: serialdef.hpp:160
@ ePrimitiveValueChar
char
Definition: serialdef.hpp:150
@ ePrimitiveValueBool
bool
Definition: serialdef.hpp:149
@ ePrimitiveValueEnum
enum
Definition: serialdef.hpp:154
@ ePrimitiveValueReal
float|double
Definition: serialdef.hpp:152
@ ePrimitiveValueBitString
Definition: serialdef.hpp:156
@ eTypeFamilyClass
Definition: serialdef.hpp:140
@ eTypeFamilyContainer
Definition: serialdef.hpp:142
@ eTypeFamilyChoice
Definition: serialdef.hpp:141
@ eTypeFamilyPointer
Definition: serialdef.hpp:143
@ eTypeFamilyPrimitive
Definition: serialdef.hpp:139
@ eStringTypeUTF8
UTF8-encoded string.
Definition: serialdef.hpp:187
@ eStringTypeVisible
VisibleString (in ASN.1 sense)
Definition: serialdef.hpp:186
@ fSerial_Json_NoIndentation
do not use indentation
Definition: serialdef.hpp:97
@ fSerial_Json_NoEol
do not write end-of-line symbol
Definition: serialdef.hpp:98
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
@ eSerial_Xml
XML.
Definition: serialdef.hpp:75
@ eSerial_Json
JSON.
Definition: serialdef.hpp:76
@ eSerial_None
Definition: serialdef.hpp:72
@ eSerial_AsnBinary
ASN.1 binary.
Definition: serialdef.hpp:74
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
int ssize_t
Definition: ncbiconf_msvc.h:92
Modified on Thu Dec 07 10:09:20 2023 by modify_doxy.py rev. 669887