24 template <
typename Writer>
28#if RAPIDJSON_HAS_STDSTRING
31 writer.
String(name_.c_str(),
static_cast<SizeType>(name_.length()));
47 Education(
const std::string& school,
double GPA) : school_(school), GPA_(GPA) {}
50 template <
typename Writer>
55#if RAPIDJSON_HAS_STDSTRING
58 writer.
String(school_.c_str(),
static_cast<SizeType>(school_.length()));
82 education_ = (rhs.education_ == 0) ? 0 :
new Education(*rhs.education_);
86 template <
typename Writer>
92 writer.
String(
"education");
117 static_cast<Person&
>(*this) = rhs;
118 dependents_ = rhs.dependents_;
119 married_ = rhs.married_;
124 dependents_.push_back(dependent);
127 template <
typename Writer>
134 writer.
Bool(married_);
136 writer.
String((
"dependents"));
138 for (std::vector<Dependent>::const_iterator dependentItr = dependents_.begin(); dependentItr != dependents_.end(); ++dependentItr)
139 dependentItr->Serialize(writer);
146 std::vector<Dependent> dependents_;
154 std::vector<Employee> employees;
156 employees.push_back(
Employee(
"Milo YIP", 34,
true));
157 employees.back().AddDependent(
Dependent(
"Lua YIP", 3,
new Education(
"Happy Kindergarten", 3.5)));
158 employees.back().AddDependent(
Dependent(
"Mio YIP", 1));
160 employees.push_back(
Employee(
"Percy TSE", 30,
false));
166 for (std::vector<Employee>::const_iterator employeeItr = employees.begin(); employeeItr != employees.end(); ++employeeItr)
167 employeeItr->Serialize(writer);
Dependent(const Dependent &rhs)
void Serialize(Writer &writer) const
Dependent & operator=(const Dependent &rhs)
Dependent(const std::string &name, unsigned age, Education *education=0)
Education(const Education &rhs)
void Serialize(Writer &writer) const
Education(const std::string &school, double GPA)
Employee(const std::string &name, unsigned age, bool married)
Employee & operator=(const Employee &rhs)
Employee(const Employee &rhs)
void Serialize(Writer &writer) const
void AddDependent(const Dependent &dependent)
const Ch * GetString() const
Person & operator=(const Person &rhs)
void Serialize(Writer &writer) const
Person(const Person &rhs)
Person(const std::string &name, unsigned age)
Writer with indentation and spacing.
bool EndArray(SizeType memberCount=0)
bool EndObject(SizeType memberCount=0)
bool Double(double d)
Writes the given double value to the stream.
bool String(const Ch *str, SizeType length, bool copy=false)
bool EndArray(SizeType elementCount=0)
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)