CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
BcfUtils.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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_UTILS_H
25#define _BCF_UTILS_H
26
27#include "BcfCommon.h"
28#include "StringArray.h"
29
30#include <cstdint>
31
32#include "BcfUnset.h"
33
37class TiXmlElement;
38
42namespace OdBcf {
43
44 class OdBcfTimeStamp;
45 typedef OdSmartPtr<OdBcfTimeStamp> OdBcfTimeStampPtr;
46
47 class OdBcfElement;
48
52 namespace Utils
53 {
54
60 bool parseBool(const OdString &value);
61
68
77
83 BCF_EXPORT int createDir(const OdString &dir);
84
90
97
104
112 OdResult createTextChild(TiXmlElement *pParent, const char *name, const char *value);
113
114#define CREATE_TEXT_CHILD(pParent, Name, Value) \
115 \
116if(OdResult pParent##Res = OdBcf::Utils::createTextChild(pParent, Name, Value)) \
117{ \
118 return pParent##Res; \
119}
120
128 OdResult createConstructedChild(TiXmlElement *pParent, const char *name, const OdBcf::OdBcfElement *pValue);
129
130#define CREATE_CONSTRUCTED_CHILD(pParent, Name, Value) \
131 \
132if(OdResult pParent##Res = OdBcf::Utils::createConstructedChild(pParent, Name, Value)) \
133{ \
134 return pParent##Res; \
135}
136
137#define VALIDATE_SIMPLE_FIELD(Field) \
138 \
139if(OdBcf::Utils::isUnset(Field)) \
140{ \
141 return false; \
142}
143
144#define VALIDATE_REQUIRED_NON_EMPTY_STRING_FIELD(Field) \
145 \
146if(OdBcf::Utils::isUnset(Field) || !OdBcf::Utils::validateNonEmptyString(Field)) \
147{ \
148 return false; \
149}
150
151#define VALIDATE_UNREQUIRED_NON_EMPTY_STRING_FIELD(Field) \
152 \
153if(!OdBcf::Utils::isUnset(Field)) \
154{ \
155 if(!OdBcf::Utils::validateNonEmptyString(Field)) \
156 { \
157 return false; \
158 } \
159}
160
161#define VALIDATE_UNREQUIRED_CONSTRUCTED_FIELD(Field) \
162 \
163if(!OdBcf::Utils::isUnset(Field)) \
164{ \
165 if(Field->validate() == false) \
166 { \
167 return false; \
168 } \
169}
170
171#define VALIDATE_REQUIRED_CONSTRUCTED_FIELD(Field) \
172 \
173if(!OdBcf::Utils::isUnset(Field)) \
174{ \
175 if(Field->validate() == false) \
176 { \
177 return false; \
178 } \
179} \
180else \
181{ \
182 return false; \
183}
184
185#define VALIDATE_UNREQUIRED_CONSTRUCTED_COLLECTION(Collection) \
186 \
187for(const auto& element : Collection) \
188{ \
189 VALIDATE_UNREQUIRED_CONSTRUCTED_FIELD(element); \
190}
191
192#define VALIDATE_REQUIRED_CONSTRUCTED_COLLECTION(Collection) \
193 \
194VALIDATE_UNREQUIRED_CONSTRUCTED_COLLECTION(Collection); \
195if(Collection.size() == 0) \
196{ \
197 return false; \
198}
199
200 } //namespace Utils
201
202} //namespace OdBcf
203
204#endif // _BCF_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 validateNonEmptyString(const OdString &str)
const OdString & boolToString(bool value)
bool parseBool(const OdString &value)
OdResult createConstructedChild(TiXmlElement *pParent, const char *name, const OdBcf::OdBcfElement *pValue)
OdBcfTimeStampPtr getCurrentTime()
BCF_EXPORT int createDir(const OdString &dir)
bool validateColorString(const OdString &str)
BCF_EXPORT OdString formatDir(const OdString &dir)
OdResult createTextChild(TiXmlElement *pParent, const char *name, const char *value)
OdSmartPtr< OdBcfTimeStamp > OdBcfTimeStampPtr