MCPcopy Create free account
hub / github.com/Tencent/rapidjson / Employee

Class Employee

example/serialize/serialize.cpp:110–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110class Employee : public Person {
111public:
112 Employee(const std::string& name, unsigned age, bool married) : Person(name, age), dependents_(), married_(married) {}
113 Employee(const Employee& rhs) : Person(rhs), dependents_(rhs.dependents_), married_(rhs.married_) {}
114 virtual ~Employee();
115
116 Employee& operator=(const Employee& rhs) {
117 static_cast<Person&>(*this) = rhs;
118 dependents_ = rhs.dependents_;
119 married_ = rhs.married_;
120 return *this;
121 }
122
123 void AddDependent(const Dependent& dependent) {
124 dependents_.push_back(dependent);
125 }
126
127 template <typename Writer>
128 void Serialize(Writer& writer) const {
129 writer.StartObject();
130
131 Person::Serialize(writer);
132
133 writer.String("married");
134 writer.Bool(married_);
135
136 writer.String(("dependents"));
137 writer.StartArray();
138 for (std::vector<Dependent>::const_iterator dependentItr = dependents_.begin(); dependentItr != dependents_.end(); ++dependentItr)
139 dependentItr->Serialize(writer);
140 writer.EndArray();
141
142 writer.EndObject();
143 }
144
145private:
146 std::vector<Dependent> dependents_;
147 bool married_;
148};
149
150Employee::~Employee() {
151}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected