Commit 45465a9 1 parent 8dd3e9b commit 45465a9 Copy full SHA for 45465a9
File tree 9 files changed +50
-16
lines changed
9 files changed +50
-16
lines changed Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 2.8)
2
+
3
+ project (SimpleJson)
4
+
5
+ add_library (SimpleJSON json.cpp)
6
+
7
+ foreach (example
8
+ array
9
+ init
10
+ iter
11
+ json
12
+ load
13
+ prim
14
+ )
15
+ add_executable (SimpleJson_${example} _example examples/${example} _example.cpp)
16
+ target_link_libraries (SimpleJson_${example} _example SimpleJSON)
17
+ endforeach ()
Original file line number Diff line number Diff line change 1
1
2
- #include " json.hpp"
2
+ #include " ../ json.hpp"
3
3
#include < iostream>
4
4
5
5
using json::JSON;
Original file line number Diff line number Diff line change 1
1
2
- #include " json.hpp"
2
+ #include " ../ json.hpp"
3
3
#include < iostream>
4
4
#include < cstddef>
5
5
Original file line number Diff line number Diff line change 1
1
2
- #include " json.hpp"
2
+ #include " ../ json.hpp"
3
3
#include < iostream>
4
4
5
5
using json::JSON;
Original file line number Diff line number Diff line change 1
1
2
- #include " json.hpp"
2
+ #include " ../ json.hpp"
3
3
#include < iostream>
4
4
5
5
using json::JSON;
Original file line number Diff line number Diff line change 1
1
2
- #include " json.hpp"
2
+ #include " ../ json.hpp"
3
3
#include < iostream>
4
4
5
5
using namespace std ;
Original file line number Diff line number Diff line change 1
1
2
- #include " json.hpp"
2
+ #include " ../ json.hpp"
3
3
#include < iostream>
4
4
#include < ios>
5
5
Original file line number Diff line number Diff line change
1
+ #include " json.hpp"
2
+
3
+ namespace json {
4
+ JSON JSON::Load ( const string &str ) {
5
+ size_t offset = 0 ;
6
+ return std::move ( parse_next ( str, offset ) );
7
+ }
8
+
9
+ JSON Object () {
10
+ return std::move ( JSON::Make ( JSON::Class::Object ) );
11
+ }
12
+
13
+ std::ostream& operator <<( std::ostream &os, const JSON &json ) {
14
+ os << json.dump ();
15
+ return os;
16
+ }
17
+
18
+ } // namespace json
Original file line number Diff line number Diff line change @@ -418,6 +418,7 @@ class JSON
418
418
Class Type = Class::Null;
419
419
};
420
420
421
+ template <class T >
421
422
JSON Array () {
422
423
return std::move ( JSON::Make ( JSON::Class::Array ) );
423
424
}
@@ -429,14 +430,15 @@ JSON Array( T... args ) {
429
430
return std::move ( arr );
430
431
}
431
432
432
- JSON Object () {
433
- return std::move ( JSON::Make ( JSON::Class::Object ) );
433
+ template <typename ... T>
434
+ JSON Array () {
435
+ JSON arr = JSON::Make ( JSON::Class::Array );
436
+ return std::move ( arr );
434
437
}
435
438
436
- std::ostream& operator <<( std::ostream &os, const JSON &json ) {
437
- os << json.dump ();
438
- return os;
439
- }
439
+ JSON Object ();
440
+
441
+ std::ostream& operator <<( std::ostream &os, const JSON &json );
440
442
441
443
namespace {
442
444
JSON parse_next ( const string &, size_t & );
@@ -641,9 +643,6 @@ namespace {
641
643
}
642
644
}
643
645
644
- JSON JSON::Load ( const string &str ) {
645
- size_t offset = 0 ;
646
- return std::move ( parse_next ( str, offset ) );
647
- }
646
+
648
647
649
648
} // End Namespace json
You can’t perform that action at this time.
0 commit comments