Skip to content

Commit 1243aea

Browse files
committed
clang-tidy
1 parent 74a9330 commit 1243aea

File tree

141 files changed

+1030
-1024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+1030
-1024
lines changed

doc/Examples.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ while (!reader.eof())
157157
if (!reader.eof())
158158
{
159159
json j = decoder.get_result();
160-
std::cout << j << std::endl;
160+
std::cout << j << '\n';
161161
}
162162
}
163163
```
@@ -369,7 +369,7 @@ if (ec)
369369
std::cout << ec.message()
370370
<< " on line " << reader.line()
371371
<< " and column " << reader.column()
372-
<< std::endl;
372+
<< '\n';
373373
}
374374
```
375375
Output:
@@ -395,7 +395,7 @@ std::string s = R"(
395395
396396
// Default
397397
json j = json::parse(s);
398-
std::cout << "(1) " << j << std::endl;
398+
std::cout << "(1) " << j << '\n';
399399
400400
// Strict
401401
try
@@ -410,7 +410,7 @@ try
410410
}
411411
catch (const ser_error& e)
412412
{
413-
std::cout << "(2) " << e.what() << std::endl;
413+
std::cout << "(2) " << e.what() << '\n';
414414
}
415415
```
416416
Output:
@@ -434,7 +434,7 @@ try
434434
}
435435
catch (const ser_error& e)
436436
{
437-
std::cout << e.what() << std::endl;
437+
std::cout << e.what() << '\n';
438438
}
439439
```
440440
Output:
@@ -457,16 +457,16 @@ ojson j = ojson::parse(R"(
457457
"country" : "Canada"
458458
}
459459
)");
460-
std::cout << "(1)\n" << pretty_print(j) << std::endl;
460+
std::cout << "(1)\n" << pretty_print(j) << '\n';
461461

462462
// Insert "postal_code" at end
463463
j.insert_or_assign("postal_code", "M5H 2N2");
464-
std::cout << "(2)\n" << pretty_print(j) << std::endl;
464+
std::cout << "(2)\n" << pretty_print(j) << '\n';
465465

466466
// Insert "province" before "country"
467467
auto it = j.find("country");
468468
j.insert_or_assign(it,"province","Ontario");
469-
std::cout << "(3)\n" << pretty_print(j) << std::endl;
469+
std::cout << "(3)\n" << pretty_print(j) << '\n';
470470
```
471471
Output:
472472
```
@@ -599,9 +599,9 @@ j.dump(std::cout, indenting::indent); // pretty print
599599
```
600600
or
601601
```
602-
std::cout << j << std::endl; // compressed
602+
std::cout << j << '\n'; // compressed
603603
604-
std::cout << pretty_print(j) << std::endl; // pretty print
604+
std::cout << pretty_print(j) << '\n'; // pretty print
605605
```
606606

607607
<div id="B3"/>
@@ -618,9 +618,9 @@ j.dump(std::cout, options, indenting::indent); // pretty print
618618
```
619619
or
620620
```
621-
std::cout << print(j, options) << std::endl; // compressed
621+
std::cout << print(j, options) << '\n'; // compressed
622622
623-
std::cout << pretty_print(j, options) << std::endl; // pretty print
623+
std::cout << pretty_print(j, options) << '\n'; // pretty print
624624
```
625625

626626
<div id="B4"/>
@@ -642,15 +642,15 @@ auto options = json_options{}
642642
std::ostringstream os;
643643
os << pretty_print(j, options);
644644

645-
std::cout << "(1)\n" << os.str() << std::endl;
645+
std::cout << "(1)\n" << os.str() << '\n';
646646

647647
json j2 = json::parse(os.str(),options);
648648

649-
std::cout << "\n(2) " << j2["field1"].as<double>() << std::endl;
650-
std::cout << "(3) " << j2["field2"].as<double>() << std::endl;
651-
std::cout << "(4) " << j2["field3"].as<double>() << std::endl;
649+
std::cout << "\n(2) " << j2["field1"].as<double>() << '\n';
650+
std::cout << "(3) " << j2["field2"].as<double>() << '\n';
651+
std::cout << "(4) " << j2["field3"].as<double>() << '\n';
652652

653-
std::cout << "\n(5)\n" << pretty_print(j2,options) << std::endl;
653+
std::cout << "\n(5)\n" << pretty_print(j2,options) << '\n';
654654
```
655655

656656
Output:
@@ -3205,7 +3205,7 @@ for (std::size_t i = 0; i < a.size(); ++i)
32053205
}
32063206
}
32073207
}
3208-
std::cout << pretty_print(j) << std::endl;
3208+
std::cout << pretty_print(j) << '\n';
32093209
```
32103210
Output:
32113211
```json
@@ -3428,24 +3428,24 @@ int main()
34283428
34293429
// Using index or `at` accessors
34303430
std::string result1 = j["reputons"][0]["rated"].as<std::string>();
3431-
std::cout << "(1) " << result1 << std::endl;
3431+
std::cout << "(1) " << result1 << '\n';
34323432
std::string result2 = j.at("reputons").at(0).at("rated").as<std::string>();
3433-
std::cout << "(2) " << result2 << std::endl;
3433+
std::cout << "(2) " << result2 << '\n';
34343434
34353435
// Using JSON Pointer
34363436
std::string result3 = jsonpointer::get(j, "/reputons/0/rated").as<std::string>();
3437-
std::cout << "(3) " << result3 << std::endl;
3437+
std::cout << "(3) " << result3 << '\n';
34383438
34393439
// Using JSONPath
34403440
json result4 = jsonpath::json_query(j, "$.reputons.0.rated");
34413441
if (result4.size() > 0)
34423442
{
3443-
std::cout << "(4) " << result4[0].as<std::string>() << std::endl;
3443+
std::cout << "(4) " << result4[0].as<std::string>() << '\n';
34443444
}
34453445
json result5 = jsonpath::json_query(j, "$..0.rated");
34463446
if (result5.size() > 0)
34473447
{
3448-
std::cout << "(5) " << result5[0].as<std::string>() << std::endl;
3448+
std::cout << "(5) " << result5[0].as<std::string>() << '\n';
34493449
}
34503450
}
34513451
```
@@ -3516,7 +3516,7 @@ json j(json_array_arg, {1,2,3,4});
35163516

35173517
for (auto val : j.array_range())
35183518
{
3519-
std::cout << val << std::endl;
3519+
std::cout << val << '\n';
35203520
}
35213521
```
35223522
@@ -3533,13 +3533,13 @@ json j(json_object_arg, {
35333533
35343534
for (const auto& member : j.object_range())
35353535
{
3536-
std::cout << member.key() << " => " << member.value() << std::endl;
3536+
std::cout << member.key() << " => " << member.value() << '\n';
35373537
}
35383538
35393539
// or, since 0.176.0, using C++ 17 structured binding
35403540
for (const auto& [key, value] : j.object_range())
35413541
{
3542-
std::cout << key << " => " << value << std::endl;
3542+
std::cout << key << " => " << value << '\n';
35433543
}
35443544
```
35453545

@@ -3556,7 +3556,7 @@ cities.push_back("Vancouver");
35563556
// Insert "Montreal" at beginning of array
35573557
cities.insert(cities.array_range().begin(),"Montreal");
35583558

3559-
std::cout << cities << std::endl;
3559+
std::cout << cities << '\n';
35603560
```
35613561
Output:
35623562
```
@@ -3592,7 +3592,7 @@ json j = json::parse(R"(
35923592
)");
35933593
35943594
j.merge(std::move(another));
3595-
std::cout << pretty_print(j) << std::endl;
3595+
std::cout << pretty_print(j) << '\n';
35963596
```
35973597
Output:
35983598
```json
@@ -3654,7 +3654,7 @@ int main()
36543654
}
36553655
catch (const std::exception& e)
36563656
{
3657-
std::cout << e.what() << std::endl;
3657+
std::cout << e.what() << '\n';
36583658
}
36593659
}
36603660
```
@@ -3779,13 +3779,13 @@ int main()
37793779
//json_reader reader(is, filter1); // (until 0.164.0)
37803780
json_stream_reader reader(is, filter1); // (since 0.164.0)
37813781
reader.read();
3782-
std::cout << std::endl;
3782+
std::cout << '\n';
37833783

37843784
// or
37853785
std::cout << "(2) ";
37863786
ojson j = ojson::parse(s);
37873787
j.dump(filter1);
3788-
std::cout << std::endl;
3788+
std::cout << '\n';
37893789
}
37903790
```
37913791
Output:
@@ -3843,7 +3843,7 @@ int main()
38433843
};
38443844
jsonpath::json_replace(j, "$.books[?(@.isbn == '0048080489')].price", f); // (since 0.161.0)
38453845

3846-
std::cout << pretty_print(j) << std::endl;
3846+
std::cout << pretty_print(j) << '\n';
38473847
}
38483848
```
38493849
Output:

doc/Pages/index.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ for (const auto& book : books.array_range())
389389
{
390390
std::string author = book["author"].as<std::string>();
391391
std::string title = book["title"].as<std::string>();
392-
std::cout << author << ", " << title << std::endl;
392+
std::cout << author << ", " << title << '\n';
393393
}
394394
```
395395
or begin-end iterators
@@ -400,7 +400,7 @@ for (auto it = books.array_range().begin();
400400
{
401401
std::string author = (*it)["author"].as<std::string>();
402402
std::string title = (*it)["title"].as<std::string>();
403-
std::cout << author << ", " << title << std::endl;
403+
std::cout << author << ", " << title << '\n';
404404
}
405405
```
406406
or a traditional for loop
@@ -410,7 +410,7 @@ for (std::size_t i = 0; i < books.size(); ++i)
410410
json& book = books[i];
411411
std::string author = book["author"].as<std::string>();
412412
std::string title = book["title"].as<std::string>();
413-
std::cout << author << ", " << title << std::endl;
413+
std::cout << author << ", " << title << '\n';
414414
}
415415
```
416416
Output:
@@ -426,7 +426,7 @@ Loop through the members of the third book element, using a range-based for loop
426426
for (const auto& member : books[2].object_range())
427427
{
428428
std::cout << member.key() << "="
429-
<< member.value() << std::endl;
429+
<< member.value() << '\n';
430430
}
431431
```
432432

@@ -438,7 +438,7 @@ for (auto it = books[2].object_range().begin();
438438
++it)
439439
{
440440
std::cout << (*it).key() << "="
441-
<< (*it).value() << std::endl;
441+
<< (*it).value() << '\n';
442442
}
443443
```
444444
Output:
@@ -475,7 +475,7 @@ else
475475
The default `json` constructor produces an empty json object. For example
476476
```cpp
477477
json image_sizing;
478-
std::cout << image_sizing << std::endl;
478+
std::cout << image_sizing << '\n';
479479
```
480480
produces
481481
```json
@@ -534,7 +534,7 @@ creates `"File Format Options"` as an object and puts `"Color Spaces"` in it.
534534

535535
Serializing
536536
```cpp
537-
std::cout << pretty_print(file_export) << std::endl;
537+
std::cout << pretty_print(file_export) << '\n';
538538
```
539539
produces
540540
```json
@@ -652,7 +652,7 @@ j["verts"] = json(json_array_arg, {1, 2, 3});
652652
j["normals"] = json(json_array_arg, {1, 0, 1});
653653
j["uvs"] = json(json_array_arg, {0, 0, 1, 1});
654654

655-
std::cout << pretty_print(j) << std::endl;
655+
std::cout << pretty_print(j) << '\n';
656656
```
657657
produces
658658
@@ -670,7 +670,7 @@ To display the array scalar values on a new line, set the `object_array_line_spl
670670
```cpp
671671
auto options = json_options{}
672672
.object_array_line_splits(line_split_kind::new_line);
673-
std::cout << pretty_print(val,options) << std::endl;
673+
std::cout << pretty_print(val,options) << '\n';
674674
```
675675
produces
676676
```json
@@ -690,7 +690,7 @@ To display the elements of array values on multiple lines, set the `object_array
690690
```cpp
691691
auto options = json_options{}
692692
.object_array_line_splits(line_split_kind::multi_line);
693-
std::cout << pretty_print(val,options) << std::endl;
693+
std::cout << pretty_print(val,options) << '\n';
694694
```
695695
produces
696696
```json
@@ -741,13 +741,13 @@ int main()
741741
//json_reader reader(s, filter1); // (until 0.164.0)
742742
json_string_reader reader(s, filter1); // (since 0.164.0)
743743
reader.read();
744-
std::cout << std::endl;
744+
std::cout << '\n';
745745

746746
// or a json_visitor
747747
std::cout << "(2) ";
748748
ojson j = ojson::parse(s);
749749
j.dump(filter1);
750-
std::cout << std::endl;
750+
std::cout << '\n';
751751
}
752752
```
753753
Output:
@@ -802,27 +802,27 @@ json booklist = json::parse(is);
802802

803803
// The authors of books that are cheaper than $10
804804
json result1 = json_query(booklist, "$.store.book[?(@.price < 10)].author");
805-
std::cout << "(1) " << result1 << std::endl;
805+
std::cout << "(1) " << result1 << '\n';
806806

807807
// The number of books
808808
json result2 = json_query(booklist, "$..book.length");
809-
std::cout << "(2) " << result2 << std::endl;
809+
std::cout << "(2) " << result2 << '\n';
810810

811811
// The third book
812812
json result3 = json_query(booklist, "$..book[2]");
813-
std::cout << "(3)\n" << pretty_print(result3) << std::endl;
813+
std::cout << "(3)\n" << pretty_print(result3) << '\n';
814814

815815
// All books whose author's name starts with Evelyn
816816
json result4 = json_query(booklist, "$.store.book[?(@.author =~ /Evelyn.*?/)]");
817-
std::cout << "(4)\n" << pretty_print(result4) << std::endl;
817+
std::cout << "(4)\n" << pretty_print(result4) << '\n';
818818

819819
// The titles of all books that have isbn number
820820
json result5 = json_query(booklist, "$..book[?(@.isbn)].title");
821-
std::cout << "(5) " << result5 << std::endl;
821+
std::cout << "(5) " << result5 << '\n';
822822

823823
// All authors and titles of books
824824
json result6 = json_query(booklist, "$['store']['book']..['author','title']");
825-
std::cout << "(6)\n" << pretty_print(result6) << std::endl;
825+
std::cout << "(6)\n" << pretty_print(result6) << '\n';
826826
```
827827
Output:
828828
```json
@@ -928,7 +928,7 @@ ojson o = ojson::parse(R"(
928928
}
929929
)");
930930
931-
std::cout << pretty_print(o) << std::endl;
931+
std::cout << pretty_print(o) << '\n';
932932
```
933933
Output:
934934
```json
@@ -943,7 +943,7 @@ Insert "postal_code" at end
943943
```cpp
944944
o.insert_or_assign("postal_code", "M5H 2N2");
945945

946-
std::cout << pretty_print(o) << std::endl;
946+
std::cout << pretty_print(o) << '\n';
947947
```
948948
Output:
949949
```json
@@ -960,7 +960,7 @@ Insert "province" before "country"
960960
auto it = o.find("country");
961961
o.insert_or_assign(it,"province","Ontario");
962962

963-
std::cout << pretty_print(o) << std::endl;
963+
std::cout << pretty_print(o) << '\n';
964964
```
965965
Output:
966966
```json

0 commit comments

Comments
 (0)