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

Method WriteStartElement

example/jsonx/jsonx.cpp:129–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127 }
128
129 bool WriteStartElement(const char* type, bool emptyElement = false) {
130 if (level_ == 0)
131 if (!WriteString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"))
132 return false;
133
134 if (!WriteString("<json:") || !WriteString(type))
135 return false;
136
137 // For root element, need to add declarations
138 if (level_ == 0) {
139 if (!WriteString(
140 " xsi:schemaLocation=\"http://www.datapower.com/schemas/json jsonx.xsd\""
141 " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
142 " xmlns:json=\"http://www.ibm.com/xmlns/prod/2009/jsonx\""))
143 return false;
144 }
145
146 if (hasName_) {
147 hasName_ = false;
148 if (!WriteString(" name=\"") ||
149 !WriteEscapedAttributeValue(name_.GetString(), name_.GetSize()) ||
150 !WriteString("\""))
151 return false;
152 }
153
154 if (emptyElement)
155 return WriteString("/>");
156 else {
157 level_++;
158 return WriteString(">");
159 }
160 }
161
162 bool WriteEndElement(const char* type) {
163 if (!WriteString("</json:") ||

Callers

nothing calls this directly

Calls 1

GetSizeMethod · 0.80

Tested by

no test coverage detected