CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
BcfUnset.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef _BCF_UNSET_H
25#define _BCF_UNSET_H
26
27#include "OdaCommon.h"
28#include "SmartPtr.h"
29
30#define STL_USING_MAP
31#include "OdaSTL.h"
32
33#include "OdGUID.h"
34#include "OdString.h"
35#include "BcfConsts.h"
36
40namespace OdBcf
41{
45 namespace Utils
46 {
51 template <class TUnsetable>
52 const TUnsetable& getUnset() { ODA_ASSERT(0 && "Unknown type. Add getUnset for it."); static TUnsetable unsettled = 0; return unsettled; }
53
58 template <> inline const double& getUnset<double>() { return Consts::OdNan; }
59
64 template <> inline const long& getUnset<long>() { return Consts::OdLongUnset; }
65
70 template <> inline const int& getUnset<int>() { return Consts::OdIntUnset; }
71
78 template <> inline const OdString& getUnset<OdString>() { static OdString stringUnset = Consts::OdStringUnset; return stringUnset; }
79
86 template <> inline const OdAnsiString& getUnset<OdAnsiString>() { static OdAnsiString stringUnset = Consts::OdStringUnset; return stringUnset; }
87
94 template <> inline const OdGUID& getUnset<OdGUID>() { return OdGUID::kNull; }
95
100 inline bool isUnset(const bool & value) { return false; }
101
106 inline bool isUnset(const float & value) { return value != value; }
107
112 inline bool isUnset(const double & value) { return value != value; }
113
118 inline bool isUnset(const long value) { return value == Consts::OdLongUnset; }
119
124 inline bool isUnset(const int value) { return value == Consts::OdIntUnset; }
125
132 inline bool isUnset(const OdString & value) { return value.getLength() == Consts::OdStringUnsetLength && value.compare(Consts::OdStringUnset) == 0; }
133
140 inline bool isUnset(const OdAnsiString & value) { return value.getLength() == Consts::OdStringUnsetLength && value.compare(Consts::OdStringUnset) == 0; }
141
146 inline bool isUnset(const char * value) { return strlen(value) == Consts::OdStringUnsetLength && strcmp(value, Consts::OdStringUnset) == 0; }
147
154 inline bool isUnset(const OdGUID & value) { return value == OdGUID::kNull; }
155
160 template <class TInner>
161 inline bool isUnset(const OdSmartPtr<TInner> & value) { return value.isNull(); }
162
167 template <class TInner>
168 inline bool isUnset(const OdArray<TInner> & value) { return value.empty(); }
169
174 template <class TKey, class TValue>
175 inline bool isUnset(const std::map<TKey, TValue> & value) { return value.empty(); }
176
181 template<class TUnsetable>
182 void initUnset(TUnsetable &value) { value = getUnset<TUnsetable>(); }
183 }
184}
185
186#endif // _BCF_UNSET_H
187
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
Definition: OdGUID.h:33
static FIRSTDLL_EXPORT_STATIC const OdGUID kNull
Definition: OdGUID.h:47
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
const TUnsetable & getUnset()
Definition: BcfUnset.h:52
const OdString & getUnset< OdString >()
Definition: BcfUnset.h:78
const long & getUnset< long >()
Definition: BcfUnset.h:64
void initUnset(TUnsetable &value)
Definition: BcfUnset.h:182
const double & getUnset< double >()
Definition: BcfUnset.h:58
bool isUnset(const OdBcf::OdBcfFileAttributesGroup &value)
const int & getUnset< int >()
Definition: BcfUnset.h:70
const OdGUID & getUnset< OdGUID >()
Definition: BcfUnset.h:94
const OdAnsiString & getUnset< OdAnsiString >()
Definition: BcfUnset.h:86