128 if (
i == m.
end() ) {
129 string name_alt =
string(name);
130 name_alt[0] = (char)
toupper((
unsigned char)name_alt[0]);
131 i = m.
find(name_alt);
132 if (
i == m.
end() ) {
134 "invalid value of enumerated type: " +
string(name));
143 return ( m.
find(name) != m.
end() );
147 bool allowBadValue)
const
151 if (
i == m.
end() ) {
152 if ( allowBadValue ) {
164 bool allowBadValue)
const
178 TValueToName::const_reverse_iterator
i = m.rbegin();
179 for (
i = m.rbegin();
i != m.rend(); ++
i) {
180 if ((
i->first & v) ==
i->first) {
184 res.insert(0,*(
i->second));
207 if ( name.empty() ) {
209 "empty enum value name");
237 (*m)[
i->second] = &
i->first;
256 const string& s =
i->first;
257 pair<TNameToValue::iterator, bool> p =
261 "duplicate enum value name: " + s);
288 if ( !module_name.empty() )
336 if ( !
Values().IsInteger() ) {
348 if ( !
Values().IsInteger() ) {
372 if ( !
Values().IsInteger() ) {
386 if ( !
Values().IsInteger() ) {
404 const string&
value)
const
431 in.ThrowError(
in.fInvalidData,
"invalid enum value");
449 out.ThrowError(
out.fInvalidData,
"invalid enum value");
481 in.ThrowError(
in.fInvalidData,
"invalid enum value");
Root class for all serialization exceptions.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
container_type::const_iterator const_iterator
const_iterator end() const
iterator_bool insert(const value_type &val)
container_type::value_type value_type
const_iterator find(const key_type &key) const
Include a standard set of the NCBI C++ Toolkit most basic headers.
DEFINE_STATIC_FAST_MUTEX(s_EnumValuesMutex)
std::ofstream out("events_result.xml")
main entry point for tests
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_RETHROW_SAME(prev_exception, message)
Generic macro to re-throw the same exception.
void AddValue(const string &name, TEnumValueType value, TValueFlags flags=eNone)
Add name-value pair.
const string & FindName(TEnumValueType value, bool allowBadValue) const
Find name of the enum by its numeric value.
const string & GetAccessName(void) const
Return internal or regular name.
list< pair< string, TEnumValueType > > TValues
bool IsInternal(void) const
Check if this enum describes internal unnamed type.
TValueFlags GetValueFlags(TEnumValueType) const
~CEnumeratedTypeValues(void)
void SetModuleName(const string &name)
Set ASN.1 module name.
bool IsBitset(void) const
const string & GetModuleName(void) const
Get ASN.1 module name.
void SetInternalName(const string &name)
Mark this enum as internal.
const TNameToValue & NameToValue(void) const
Get name-to-value map.
atomic< TValueToName * > m_ValueToName
unsigned int TValueFlags
Binary OR of EValueFlags.
map< TEnumValueType, TValueFlags > m_ValueFlags
bool IsValidName(const CTempString &name) const
Check whether enum with this name is defined.
const string & GetInternalModuleName(void) const
Return internal type's owner module name.
TEnumValueType FindValue(const CTempString &name) const
Find numeric value by the name of the enum.
const string & GetName(void) const
const string & GetInternalName(void) const
Return internal type access string e.g. Int-fuzz.lim.
string GetDisplayName(TEnumValueType value) const
const TValueToName & ValueToName(void) const
Get value-to-name map.
const string & FindNameEx(TEnumValueType value, bool allowBadValue) const
const string & GetAccessModuleName(void) const
Return internal or regular module name.
CEnumeratedTypeValues(const char *name, bool isInteger)
atomic< TNameToValue * > m_NameToValue
ESerialRecursionMode
How to assign and compare child sub-objects of serial objects.
const void * TConstObjectPtr
static const TObjectType * SafeCast(TTypeInfo type)
@ ePrimitiveValueInteger
(signed|unsigned) (char|short|int|long)
@ ePrimitiveValueEnum
enum
CObjectIStream & In(void) const
CObjectOStream & Out(void) const
virtual void CopyEnum(const CEnumeratedTypeValues &values, CObjectIStream &in)=0
@ fInvalidData
Input data is incorrect (e.g. invalid enum)
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
void SetWriteFunction(TTypeWriteFunction func)
static void WriteEnum(CObjectOStream &out, TTypeInfo objectType, TConstObjectPtr objectPtr)
virtual void SetValueInt8(TObjectPtr objectPtr, Int8 value) const override
virtual bool Equals(TConstObjectPtr, TConstObjectPtr, ESerialRecursionMode how=eRecursive) const override
Check if both objects contain the same values.
virtual void SetDefault(TObjectPtr dst) const override
Set object to default value.
virtual bool IsSigned(void) const override
void SetValueInt(TObjectPtr objectPtr, int value) const
virtual bool IsDefault(TConstObjectPtr object) const override
Check, whether the object contains default value.
virtual Uint4 GetValueUint4(TConstObjectPtr objectPtr) const
virtual bool Equals(TConstObjectPtr, TConstObjectPtr, ESerialRecursionMode how=eRecursive) const override
Check if both objects contain the same values.
static TObjectPtr CreateEnum(TTypeInfo objectType, CObjectMemoryPool *memoryPool)
virtual void SetDefault(TObjectPtr dst) const override
Set object to default value.
int GetValueInt(TConstObjectPtr objectPtr) const
virtual void SetValueString(TObjectPtr objectPtr, const string &value) const override
EPrimitiveValueType GetPrimitiveValueType(void) const
virtual Uint4 GetValueUint4(TConstObjectPtr objectPtr) const override
virtual void SetValueInt8(TObjectPtr objectPtr, Int8 value) const
virtual void SetValueInt4(TObjectPtr objectPtr, Int4 value) const
CEnumeratedTypeInfo(size_t size, const CEnumeratedTypeValues *values, bool sign=false)
virtual CTypeInfo * SetTag(CAsnBinaryDefs::TLongTag tag, CAsnBinaryDefs::ETagClass tagclass=CAsnBinaryDefs::eUniversal, CAsnBinaryDefs::ETagType tagtype=CAsnBinaryDefs::eAutomatic)
void SetModuleName(const string &name)
Set module name.
static void CopyEnum(CObjectStreamCopier &copier, TTypeInfo objectType)
virtual void SetValueUint8(TObjectPtr objectPtr, Uint8 value) const override
const CPrimitiveTypeInfo * m_ValueType
virtual void GetValueString(TConstObjectPtr objectPtr, string &value) const override
virtual Int4 GetValueInt4(TConstObjectPtr objectPtr) const
virtual Int8 GetValueInt8(TConstObjectPtr objectPtr) const override
void SetInternalName(const string &name)
Mark this type as internal.
virtual Int4 GetValueInt4(TConstObjectPtr objectPtr) const override
virtual void SetValueUint4(TObjectPtr objectPtr, Uint4 value) const override
virtual void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive) const override
Set object to copy of another one.
void SetSkipFunction(TTypeSkipFunction func)
static void ReadEnum(CObjectIStream &in, TTypeInfo objectType, TObjectPtr objectPtr)
virtual void SetValueUint8(TObjectPtr objectPtr, Uint8 value) const
virtual void SetValueUint4(TObjectPtr objectPtr, Uint4 value) const
virtual void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive) const override
Set object to copy of another one.
virtual bool IsSigned(void) const
void SetCreateFunction(TTypeCreate func)
virtual Uint8 GetValueUint8(TConstObjectPtr objectPtr) const override
static void SkipEnum(CObjectIStream &in, TTypeInfo objectType)
virtual void SetValueInt4(TObjectPtr objectPtr, Int4 value) const override
virtual bool IsDefault(TConstObjectPtr object) const override
Check, whether the object contains default value.
void SetCopyFunction(TTypeCopyFunction func)
const CEnumeratedTypeValues & Values(void) const
virtual Int8 GetValueInt8(TConstObjectPtr objectPtr) const
TObjectPtr Create(CObjectMemoryPool *memoryPool=0) const
Create object of this type on heap (can be deleted by operator delete)
virtual Uint8 GetValueUint8(TConstObjectPtr objectPtr) const
void SetReadFunction(TTypeReadFunction func)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Common macro to detect used sanitizers and suppress memory leaks if run under LeakSanitizer.
#define NCBI_LSAN_DISABLE_GUARD
Multi-threading – classes, functions, and features.
Useful/utility classes and methods.
std::istream & in(std::istream &in_, double &x_)