CFx SDK Documentation  2022 SP0
BcfUtils.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2020, 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-2020 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 _BFC_UTILS_H
25 #define _BFC_UTILS_H
26 
27 #include "BcfCommon.h"
28 #include "StringArray.h"
29 
30 #include <cstdint>
31 
32 #include "BcfUnset.h"
33 
37 class TiXmlElement;
38 
39 namespace OdBcf {
40 
41  class OdBcfTimeStamp;
43 
44  class OdBcfElement;
45 
46  namespace Utils
47  {
48 
54  bool parseBool(const OdString &value);
55 
61  const OdString& boolToString(bool value);
62 
71 
72 
78  BCF_EXPORT int createDir(const OdString &dir);
79 
85 
93  OdResult createTextChild(TiXmlElement *pParent, const char *name, const char *value);
94 
95 #define CREATE_TEXT_CHILD(pParent, Name, Value) \
96  \
97 if(OdResult pParent##Res = OdBcf::Utils::createTextChild(pParent, Name, Value)) \
98 { \
99  return pParent##Res; \
100 }
101 
109  OdResult createConstructedChild(TiXmlElement *pParent, const char *name, const OdBcfElement *pValue);
110 
111 #define CREATE_CONSTRUCTED_CHILD(pParent, Name, Value) \
112  \
113 if(OdResult pParent##Res = OdBcf::Utils::createConstructedChild(pParent, Name, Value)) \
114 { \
115  return pParent##Res; \
116 }
117 
118 #define VALIDATE_SIMPLE_FIELD(Field) \
119  \
120 if(OdBcf::Utils::isUnset(Field)) \
121 { \
122  return false; \
123 }
124 
125 #define VALIDATE_UNREQUIRED_CONSTRUCTED_FIELD(Field) \
126  \
127 if(!OdBcf::Utils::isUnset(Field)) \
128 { \
129  if(Field->validate() == false) \
130  { \
131  return false; \
132  } \
133 }
134 
135 #define VALIDATE_REQUIRED_CONSTRUCTED_FIELD(Field) \
136  \
137 if(!OdBcf::Utils::isUnset(Field)) \
138 { \
139  if(Field->validate() == false) \
140  { \
141  return false; \
142  } \
143 } \
144 else \
145 { \
146  return false; \
147 }
148 
149 #define VALIDATE_UNREQUIRED_CONSTRUCTED_COLLECTION(Collection) \
150  \
151 for(const auto& element : Collection) \
152 { \
153  VALIDATE_UNREQUIRED_CONSTRUCTED_FIELD(element); \
154 }
155 
156 #define VALIDATE_REQUIRED_CONSTRUCTED_COLLECTION(Collection) \
157  \
158 VALIDATE_UNREQUIRED_CONSTRUCTED_COLLECTION(Collection); \
159 if(Collection.size() == 0) \
160 { \
161  return false; \
162 }
163 
164  } //namespace Utils
165 
166 } //namespace OdBcf
167 
168 #endif // _BFC_UTILS_H
#define BCF_EXPORT
OdResult
Definition: OdResult.h:29
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
bool parseBool(const OdString &value)
const OdString & boolToString(bool value)
OdBcfTimeStampPtr getCurrentTime()
BCF_EXPORT int createDir(const OdString &dir)
BCF_EXPORT OdString formatDir(const OdString &dir)
OdResult createConstructedChild(TiXmlElement *pParent, const char *name, const OdBcfElement *pValue)
OdResult createTextChild(TiXmlElement *pParent, const char *name, const char *value)
OdSmartPtr< OdBcfTimeStamp > OdBcfTimeStampPtr
Definition: BcfComment.h:37