17 #ifndef SDF_ELEMENT_HH_ 
   18 #define SDF_ELEMENT_HH_ 
   38 #pragma warning(disable: 4251) 
   46   inline namespace SDF_VERSION_NAMESPACE {
 
   74     public std::enable_shared_from_this<Element>
 
  107     public: 
void SetParent(
const ElementPtr _parent);
 
  111     public: 
void SetName(
const std::string &_name);
 
  115     public: 
const std::string &GetName() 
const;
 
  124     public: 
void SetRequired(
const std::string &_req);
 
  129     public: 
const std::string &GetRequired() 
const;
 
  136     public: 
void SetExplicitlySetInFile(
const bool _value);
 
  140     public: 
bool GetExplicitlySetInFile() 
const;
 
  145     public: 
void SetCopyChildren(
bool _value);
 
  150     public: 
bool GetCopyChildren() 
const;
 
  154     public: 
void SetReferenceSDF(
const std::string &_value);
 
  158     public: std::string ReferenceSDF() 
const;
 
  162     public: 
void PrintDescription(
const std::string &_prefix) 
const;
 
  167     public: 
void PrintValues(std::string _prefix,
 
  175     public: 
void PrintValues(
const std::string &_prefix,
 
  176                              bool _includeDefaultElements,
 
  177                              bool _includeDefaultAttributes,
 
  186     public: 
void PrintDocLeftPane(std::string &_html,
 
  187                                   int _spacing, 
int &_index) 
const;
 
  194     public: 
void PrintDocRightPane(std::string &_html,
 
  195                                   int _spacing, 
int &_index) 
const;
 
  201     public: std::string ToString(
 
  202         const std::string &_prefix,
 
  214     public: std::string ToString(
 
  215         const std::string &_prefix,
 
  216         bool _includeDefaultElements,
 
  217         bool _includeDefaultAttributes,
 
  227     public: 
void AddAttribute(
const std::string &_key,
 
  228                               const std::string &_type,
 
  229                               const std::string &_defaultvalue,
 
  231                               const std::string &_description = 
"");
 
  241     public: 
void AddAttribute(
const std::string &_key,
 
  242                               const std::string &_type,
 
  243                               const std::string &_defaultvalue,
 
  246                               const std::string &_description = 
"");
 
  254     public: 
void AddValue(
const std::string &_type,
 
  255                           const std::string &_defaultValue, 
bool _required,
 
  256                           const std::string &_description = 
"");
 
  265     public: 
void AddValue(
const std::string &_type,
 
  266                           const std::string &_defaultValue, 
bool _required,
 
  268                           const std::string &_description = 
"");
 
  279     public: 
void AddValue(
const std::string &_type,
 
  280                           const std::string &_defaultValue, 
bool _required,
 
  281                           const std::string &_minValue,
 
  282                           const std::string &_maxValue,
 
  283                           const std::string &_description = 
"");
 
  295     public: 
void AddValue(
const std::string &_type,
 
  296                           const std::string &_defaultValue, 
bool _required,
 
  297                           const std::string &_minValue,
 
  298                           const std::string &_maxValue,
 
  300                           const std::string &_description = 
"");
 
  305     public: 
ParamPtr GetAttribute(
const std::string &_key) 
const;
 
  309     public: 
size_t GetAttributeCount() 
const;
 
  313     public: 
const Param_V &GetAttributes() 
const;
 
  318     public: 
ParamPtr GetAttribute(
unsigned int _index) 
const;
 
  322     public: 
size_t GetElementDescriptionCount() 
const;
 
  327     public: 
ElementPtr GetElementDescription(
unsigned int _index) 
const;
 
  332     public: 
ElementPtr GetElementDescription(
const std::string &_key) 
const;
 
  337     public: 
bool HasElementDescription(
const std::string &_name) 
const;
 
  342     public: 
bool HasAttribute(
const std::string &_key) 
const;
 
  347     public: 
bool GetAttributeSet(
const std::string &_key) 
const;
 
  351     public: 
void RemoveAttribute(
const std::string &_key);
 
  354     public: 
void RemoveAllAttributes();
 
  364     public: std::any GetAny(
const std::string &_key = 
"") 
const;
 
  372                             const std::string &_key = 
"") 
const;
 
  380     public: 
template<
typename T>
 
  381             T Get(
const std::string &_key = 
"") 
const;
 
  389     public: 
template<
typename T>
 
  390             std::pair<T, bool> Get(
const std::string &_key,
 
  391                                    const T &_defaultValue) 
const;
 
  399     public: 
template<
typename T>
 
  400             bool Get(
const std::string &_key,
 
  402                      const T &_defaultValue) 
const;
 
  407     public: 
template<
typename T>
 
  408             bool Set(
const T &_value);
 
  413     public: 
bool HasElement(
const std::string &_name) 
const;
 
  431     public: 
ElementPtr GetNextElement(
const std::string &_name = 
"") 
const;
 
  435     public: std::set<std::string> GetElementTypeNames() 
const;
 
  444     public: 
bool HasUniqueChildNames(
const std::string &_type = 
"") 
const;
 
  456     public: 
bool HasUniqueChildNames(
 
  457                 const std::string &_type,
 
  458                 const std::vector<std::string> &_ignoreElements) 
const;
 
  467     public: std::map<std::string, std::size_t>
 
  468             CountNamedElements(
const std::string &_type = 
"") 
const;
 
  480     public: std::map<std::string, std::size_t> CountNamedElements(
 
  481                 const std::string &_type,
 
  482                 const std::vector<std::string> &_ignoreElements) 
const;
 
  494     public: 
ElementPtr GetElement(
const std::string &_name);
 
  507     public: 
ElementPtr GetElement(
const std::string &_name,
 
  519     public: 
ElementPtr FindElement(
const std::string &_name);
 
  535     public: 
ElementPtr AddElement(
const std::string &_name);
 
  541     public: 
ElementPtr AddElement(
const std::string &_name,
 
  553     public: 
void InsertElement(
ElementPtr _elem, 
bool _setParentToSelf);
 
  556     public: 
void RemoveFromParent();
 
  568     public: 
void ClearElements();
 
  572     public: 
void Clear();
 
  576     public: 
void Update();
 
  581     public: 
void Reset();
 
  598     public: 
void SetFilePath(
const std::string &_path);
 
  602     public: 
const std::string &FilePath() 
const;
 
  606     public: 
void SetLineNumber(
int _lineNumber);
 
  611     public: std::optional<int> LineNumber() 
const;
 
  627     public: 
void SetXmlPath(
const std::string &_path);
 
  631     public: 
const std::string &XmlPath() 
const;
 
  635     public: 
void SetOriginalVersion(
const std::string &_version);
 
  639     public: 
const std::string &OriginalVersion() 
const;
 
  643     public: std::string GetDescription() 
const;
 
  647     public: 
void SetDescription(
const std::string &_desc);
 
  651     public: 
void AddElementDescription(
ElementPtr _elem);
 
  656     public: 
ElementPtr GetElementImpl(
const std::string &_name) 
const;
 
  661     public: 
static std::vector<std::string> NameUniquenessExceptions();
 
  669     private: 
void ToString(
const std::string &_prefix,
 
  670                            bool _includeDefaultElements,
 
  671                            bool _includeDefaultAttributes,
 
  673                            std::ostringstream &_out) 
const;
 
  681     private: 
void PrintValuesImpl(
const std::string &_prefix,
 
  682                                   bool _includeDefaultElements,
 
  683                                   bool _includeDefaultAttributes,
 
  685                                   std::ostringstream &_out) 
const;
 
  696     private: 
ParamPtr CreateParam(
const std::string &_key,
 
  697                                   const std::string &_type,
 
  698                                   const std::string &_defaultValue,
 
  701                                   const std::string &_description = 
"");
 
  704     private: std::unique_ptr<ElementPrivate> dataPtr;
 
  784                                  std::ostringstream &_out) 
const;
 
  793     std::pair<T, bool> ret = this->Get<T>(_key, result);
 
  802                     const T &_defaultValue)
 const 
  804     std::pair<T, bool> ret = this->Get<T>(_key, _defaultValue);
 
  812                                   const T &_defaultValue)
 const 
  814     std::pair<T, bool> result(_defaultValue, 
true);
 
  816     if (_key.empty() && this->dataPtr->value)
 
  818       this->dataPtr->value->Get<T>(result.first);
 
  820     else if (!_key.empty())
 
  825         param->Get(result.first);
 
  837         result.second = 
false;
 
  842       result.second = 
false;
 
  852     if (this->dataPtr->value)
 
  854       this->dataPtr->value->Set(_value);