Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sortkeys.cpp File Reference
#include "rapidjson/document.h"
#include "rapidjson/filewritestream.h"
#include <rapidjson/prettywriter.h>
#include <algorithm>
#include <iostream>
Include dependency graph for sortkeys.cpp:

Go to the source code of this file.

Classes

struct  NameComparator
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 25 of file sortkeys.cpp.

25 {
27 Document::AllocatorType &allocator = d.GetAllocator();
28
29 d.AddMember("zeta", Value().SetBool(false), allocator);
30 d.AddMember("gama", Value().SetString("test string", allocator), allocator);
31 d.AddMember("delta", Value().SetInt(123), allocator);
32 d.AddMember("alpha", Value(kArrayType).Move(), allocator);
33
34 printIt(d);
35
36/*
37{
38 "zeta": false,
39 "gama": "test string",
40 "delta": 123,
41 "alpha": []
42}
43*/
44
45// C++11 supports std::move() of Value so it always have no problem for std::sort().
46// Some C++03 implementations of std::sort() requires copy constructor which causes compilation error.
47// Needs a sorting function only depends on std::swap() instead.
48#if __cplusplus >= 201103L || !defined(__GLIBCXX__)
49 std::sort(d.MemberBegin(), d.MemberEnd(), NameComparator());
50#endif
51
52 printIt(d);
53
54/*
55{
56 "alpha": [],
57 "delta": 123,
58 "gama": "test string",
59 "zeta": false
60}
61*/
62}
Default memory allocator used by the parser and DOM.
Definition allocators.h:115
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition document.h:2110
bip::allocator< T, pinnable_mapped_file::segment_manager > allocator
Definition chainbase.hpp:56
@ kObjectType
object
Definition rapidjson.h:648
@ kArrayType
array
Definition rapidjson.h:649
CK_ULONG d