22 #include <boost/shared_ptr.hpp>
23 #include <boost/enable_shared_from_this.hpp>
38 typedef boost::shared_ptr<SDF>
SDFPtr;
58 std::string
findFile(
const std::string &_filename,
59 bool _searchLocalPath =
true,
60 bool _useCallback =
false);
67 void addURIPath(
const std::string &_uri,
const std::string &_path);
74 void setFindCallback(boost::function<std::string (
const std::string &)> _cb);
79 public boost::enable_shared_from_this<Element>
89 public: boost::shared_ptr<Element> Clone()
const;
102 public:
void SetParent(
const ElementPtr _parent);
106 public:
void SetName(
const std::string &_name);
110 public:
const std::string &GetName()
const;
118 public:
void SetRequired(
const std::string &_req);
123 public:
const std::string &GetRequired()
const;
128 public:
void SetCopyChildren(
bool _value);
133 public:
bool GetCopyChildren()
const;
137 public:
void PrintDescription(
const std::string &_prefix);
141 public:
void PrintValues(std::string _prefix);
143 public:
void PrintWiki(std::string _prefix);
151 public:
void PrintDocLeftPane(std::string &_html,
152 int _spacing,
int &_index);
159 public:
void PrintDocRightPane(std::string &_html,
160 int _spacing,
int &_index);
165 public: std::string ToString(
const std::string &_prefix)
const;
173 public:
void AddAttribute(
const std::string &_key,
174 const std::string &_type,
175 const std::string &_defaultvalue,
177 const std::string &_description=
"");
184 public:
void AddValue(
const std::string &_type,
185 const std::string &_defaultValue,
bool _required,
186 const std::string &_description=
"");
191 public:
ParamPtr GetAttribute(
const std::string &_key);
194 public:
unsigned int GetAttributeCount()
const;
197 public:
ParamPtr GetAttribute(
unsigned int _index)
const;
200 public:
unsigned int GetElementDescriptionCount()
const;
203 public:
ElementPtr GetElementDescription(
unsigned int _index)
const;
206 public:
ElementPtr GetElementDescription(
const std::string &_key)
const;
209 public:
bool HasElementDescription(
const std::string &_name);
211 public:
bool HasAttribute(
const std::string &_key);
214 public:
bool GetAttributeSet(
const std::string &_key);
219 public:
bool GetValueBool(
221 public:
int GetValueInt(
223 public:
float GetValueFloat(
225 public:
double GetValueDouble(
227 public:
unsigned int GetValueUInt(
229 public:
char GetValueChar(
231 public: std::string GetValueString(
246 public:
template<
typename T>
247 T Get(
const std::string &_key =
"")
251 if (_key.empty() && this->value)
252 this->value->Get<T>(result);
253 else if (!_key.empty())
255 ParamPtr param = this->GetAttribute(_key);
258 else if (this->HasElement(_key))
259 result = this->GetElementImpl(_key)->Get<T>();
260 else if (this->HasElementDescription(_key))
261 result = this->GetElementDescription(_key)->
Get<T>();
263 sdferr <<
"Unable to find value for key[" << _key <<
"]\n";
268 public:
template<
typename T>
269 bool Set(
const T &_value)
273 this->value->Set(_value);
279 public:
bool HasElement(
const std::string &_name)
const;
281 public:
ElementPtr GetElement(
const std::string &_name)
const;
284 public:
ElementPtr GetNextElement(
const std::string &_name =
"")
const;
286 public:
ElementPtr GetElement(
const std::string &_name);
287 public:
ElementPtr AddElement(
const std::string &_name);
291 public:
void RemoveFromParent();
298 public:
void ClearElements();
300 public:
void Update();
301 public:
void Reset();
303 public:
void SetInclude(
const std::string &_filename);
304 public: std::string GetInclude()
const;
307 public: std::string GetDescription()
const;
310 public:
void SetDescription(
const std::string &_desc);
313 public:
void AddElementDescription(
ElementPtr _elem);
315 private:
void ToString(
const std::string &_prefix,
316 std::ostringstream &_out)
const;
319 private: boost::shared_ptr<Param> CreateParam(
const std::string &_key,
320 const std::string &_type,
const std::string &_defaultValue,
321 bool _required,
const std::string &_description=
"");
323 public:
ElementPtr GetElementImpl(
const std::string &_name)
const;
325 private: std::string name;
326 private: std::string required;
327 private: std::string description;
345 private: std::string includeFilename;
353 public:
void PrintDescription();
354 public:
void PrintValues();
355 public:
void PrintWiki();
356 public:
void PrintDoc();
357 public:
void Write(
const std::string &_filename);
358 public: std::string ToString()
const;
361 public:
void SetFromString(
const std::string &_sdfData);