File indexing completed on 2025-01-18 10:13:56
0001
0002
0003 #ifndef VGDMLAuxiliary_h
0004 #define VGDMLAuxiliary_h
0005
0006 #include <string>
0007 #include <memory>
0008 #include <vector>
0009
0010 namespace vgdml {
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class Auxiliary {
0034 public:
0035
0036 using AuxiliaryList = std::vector<Auxiliary>;
0037
0038
0039
0040 Auxiliary() = default;
0041
0042
0043 ~Auxiliary() = default;
0044
0045
0046 Auxiliary(const Auxiliary &rhs)
0047 : type(rhs.type), value(rhs.value), unit(rhs.unit), children(new AuxiliaryList{*(rhs.children)})
0048 {
0049 }
0050
0051
0052 Auxiliary(Auxiliary &&rhs) : Auxiliary() { swap(*this, rhs); }
0053
0054
0055 Auxiliary &operator=(const Auxiliary &rhs)
0056 {
0057 Auxiliary tmp(rhs);
0058 swap(*this, tmp);
0059 return *this;
0060 }
0061
0062
0063 Auxiliary &operator=(Auxiliary &&rhs)
0064 {
0065 swap(*this, rhs);
0066 return *this;
0067 }
0068
0069
0070 const std::string &GetType() const { return type; }
0071
0072
0073 const std::string &GetValue() const { return value; }
0074
0075
0076 const std::string &GetUnit() const { return unit; }
0077
0078
0079 const AuxiliaryList &GetChildren() const { return *children; }
0080
0081
0082 void SetType(const std::string &s) { type = s; }
0083
0084
0085 void SetValue(const std::string &s) { value = s; }
0086
0087
0088 void SetUnit(const std::string &s) { unit = s; }
0089
0090
0091 void AddChild(const Auxiliary &a) { children->push_back(a); }
0092
0093
0094
0095
0096
0097 friend void swap(Auxiliary &lhs, Auxiliary &rhs)
0098 {
0099 using std::swap;
0100 swap(lhs.type, rhs.type);
0101 swap(lhs.value, rhs.value);
0102 swap(lhs.unit, rhs.unit);
0103 swap(lhs.children, rhs.children);
0104 }
0105
0106 private:
0107 std::string type = "";
0108 std::string value = "";
0109 std::string unit = "";
0110 std::unique_ptr<AuxiliaryList> children{new AuxiliaryList};
0111 };
0112
0113
0114
0115
0116 inline bool operator==(const Auxiliary &lhs, const Auxiliary &rhs)
0117 {
0118 if (lhs.GetType() != rhs.GetType()) return false;
0119 if (lhs.GetValue() != rhs.GetValue()) return false;
0120 if (lhs.GetUnit() != rhs.GetUnit()) return false;
0121 if (lhs.GetChildren() != rhs.GetChildren()) return false;
0122
0123 return true;
0124 }
0125
0126
0127 inline bool operator!=(const Auxiliary &lhs, const Auxiliary &rhs)
0128 {
0129 return !(lhs == rhs);
0130 }
0131
0132 }
0133
0134 #endif