| 188 | |
| 189 | protected: |
| 190 | void PrettyPrefix(Type type) { |
| 191 | (void)type; |
| 192 | if (Base::level_stack_.GetSize() != 0) { // this value is not at root |
| 193 | typename Base::Level* level = Base::level_stack_.template Top<typename Base::Level>(); |
| 194 | |
| 195 | if (level->inArray) { |
| 196 | if (level->valueCount > 0) { |
| 197 | Base::os_->Put(','); // add comma if it is not the first element in array |
| 198 | if (formatOptions_ & kFormatSingleLineArray) |
| 199 | Base::os_->Put(' '); |
| 200 | } |
| 201 | |
| 202 | if (!(formatOptions_ & kFormatSingleLineArray)) { |
| 203 | Base::os_->Put('\n'); |
| 204 | WriteIndent(); |
| 205 | } |
| 206 | } |
| 207 | else { // in object |
| 208 | if (level->valueCount > 0) { |
| 209 | if (level->valueCount % 2 == 0) { |
| 210 | Base::os_->Put(','); |
| 211 | Base::os_->Put('\n'); |
| 212 | } |
| 213 | else { |
| 214 | Base::os_->Put(':'); |
| 215 | Base::os_->Put(' '); |
| 216 | } |
| 217 | } |
| 218 | else |
| 219 | Base::os_->Put('\n'); |
| 220 | |
| 221 | if (level->valueCount % 2 == 0) |
| 222 | WriteIndent(); |
| 223 | } |
| 224 | if (!level->inArray && level->valueCount % 2 == 0) |
| 225 | RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name |
| 226 | level->valueCount++; |
| 227 | } |
| 228 | else { |
| 229 | RAPIDJSON_ASSERT(!Base::hasRoot_); // Should only has one and only one root. |
| 230 | Base::hasRoot_ = true; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | void WriteIndent() { |
| 235 | size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_; |