Skip to content

Commit 956683e

Browse files
committed
tidy code
1 parent 41ea92e commit 956683e

File tree

11 files changed

+44
-76
lines changed

11 files changed

+44
-76
lines changed

include/jsoncons/detail/grisu3.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ minor modifications.
4242
#include <cstring> // std::memmove
4343
#include <stdlib.h>
4444

45-
#include <jsoncons/detail/write_number.hpp>
46-
4745
namespace jsoncons { namespace detail {
4846

4947
// diy_fp

include/jsoncons_ext/bson/decode_bson.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace bson {
197197
return val;
198198
}
199199

200-
} // bson
200+
} // namespace bson
201201
} // namespace jsoncons
202202

203203
#endif // JSONCONS_EXT_BSON_DECODE_BSON_HPP

include/jsoncons_ext/bson/encode_bson.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ namespace bson {
139139
}
140140
}
141141

142-
} // bson
142+
} // namespace bson
143143
} // namespace jsoncons
144144

145145
#endif // JSONCONS_EXT_BSON_DECODE_BSON_HPP

include/jsoncons_ext/csv/csv_options.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void parse_column_types(const std::basic_string<CharT>& types,
257257
}
258258
}
259259

260-
} // detail
260+
} // namespace detail
261261

262262
template <typename CharT>
263263
class basic_csv_options;

include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace jsoncons { namespace jsonpatch {
7171
return std::error_code(static_cast<int>(result),jsonpatch_error_category());
7272
}
7373

74-
} // jsonpatch
74+
} // namespace jsonpatch
7575
} // namespace jsoncons
7676

7777
namespace std {
@@ -117,7 +117,7 @@ namespace jsoncons { namespace jsonpatch {
117117
}
118118
};
119119

120-
} // jsonpatch
120+
} // namespace jsonpatch
121121
} // namespace jsoncons
122122

123123
#endif // JSONCONS_EXT_JSONPATCH_JSONPATCH_ERROR_HPP

include/jsoncons_ext/jsonpath/expression.hpp

Lines changed: 34 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -481,14 +481,11 @@ namespace detail {
481481
{
482482
return Json(-val.template as<int64_t>(), semantic_tag::none);
483483
}
484-
else if (val.is_double())
484+
if (val.is_double())
485485
{
486486
return Json(-val.as_double(), semantic_tag::none);
487487
}
488-
else
489-
{
490-
return Json::null();
491-
}
488+
return Json::null();
492489
}
493490
};
494491

@@ -546,9 +543,6 @@ namespace detail {
546543
{
547544
return "binary operator";
548545
}
549-
550-
protected:
551-
~binary_operator() = default;
552546
};
553547

554548
// Implementations
@@ -609,10 +603,7 @@ namespace detail {
609603
{
610604
return rhs;
611605
}
612-
else
613-
{
614-
return lhs;
615-
}
606+
return lhs;
616607
}
617608

618609
std::string to_string(int level) const override
@@ -703,7 +694,7 @@ namespace detail {
703694
{
704695
return lhs < rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
705696
}
706-
else if (lhs.is_string() && rhs.is_string())
697+
if (lhs.is_string() && rhs.is_string())
707698
{
708699
return lhs < rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
709700
}
@@ -740,7 +731,7 @@ namespace detail {
740731
{
741732
return lhs <= rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
742733
}
743-
else if (lhs.is_string() && rhs.is_string())
734+
if (lhs.is_string() && rhs.is_string())
744735
{
745736
return lhs <= rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
746737
}
@@ -779,7 +770,7 @@ namespace detail {
779770
{
780771
return lhs > rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
781772
}
782-
else if (lhs.is_string() && rhs.is_string())
773+
if (lhs.is_string() && rhs.is_string())
783774
{
784775
return lhs > rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
785776
}
@@ -816,7 +807,7 @@ namespace detail {
816807
{
817808
return lhs >= rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
818809
}
819-
else if (lhs.is_string() && rhs.is_string())
810+
if (lhs.is_string() && rhs.is_string())
820811
{
821812
return lhs >= rhs ? Json(true, semantic_tag::none) : Json(false, semantic_tag::none);
822813
}
@@ -853,18 +844,15 @@ namespace detail {
853844
{
854845
return Json::null();
855846
}
856-
else if (lhs.is_int64() && rhs.is_int64())
847+
if (lhs.is_int64() && rhs.is_int64())
857848
{
858849
return Json(((lhs.template as<int64_t>() + rhs.template as<int64_t>())), semantic_tag::none);
859850
}
860-
else if (lhs.is_uint64() && rhs.is_uint64())
851+
if (lhs.is_uint64() && rhs.is_uint64())
861852
{
862853
return Json((lhs.template as<uint64_t>() + rhs.template as<uint64_t>()), semantic_tag::none);
863854
}
864-
else
865-
{
866-
return Json((lhs.as_double() + rhs.as_double()), semantic_tag::none);
867-
}
855+
return Json((lhs.as_double() + rhs.as_double()), semantic_tag::none);
868856
}
869857

870858
std::string to_string(int level) const override
@@ -897,18 +885,15 @@ namespace detail {
897885
{
898886
return Json::null();
899887
}
900-
else if (lhs.is_int64() && rhs.is_int64())
888+
if (lhs.is_int64() && rhs.is_int64())
901889
{
902890
return Json(((lhs.template as<int64_t>() - rhs.template as<int64_t>())), semantic_tag::none);
903891
}
904-
else if (lhs.is_uint64() && rhs.is_uint64())
892+
if (lhs.is_uint64() && rhs.is_uint64())
905893
{
906894
return Json((lhs.template as<uint64_t>() - rhs.template as<uint64_t>()), semantic_tag::none);
907895
}
908-
else
909-
{
910-
return Json((lhs.as_double() - rhs.as_double()), semantic_tag::none);
911-
}
896+
return Json((lhs.as_double() - rhs.as_double()), semantic_tag::none);
912897
}
913898

914899
std::string to_string(int level) const override
@@ -941,18 +926,15 @@ namespace detail {
941926
{
942927
return Json::null();
943928
}
944-
else if (lhs.is_int64() && rhs.is_int64())
929+
if (lhs.is_int64() && rhs.is_int64())
945930
{
946931
return Json(((lhs.template as<int64_t>() * rhs.template as<int64_t>())), semantic_tag::none);
947932
}
948-
else if (lhs.is_uint64() && rhs.is_uint64())
933+
if (lhs.is_uint64() && rhs.is_uint64())
949934
{
950935
return Json((lhs.template as<uint64_t>() * rhs.template as<uint64_t>()), semantic_tag::none);
951936
}
952-
else
953-
{
954-
return Json((lhs.as_double() * rhs.as_double()), semantic_tag::none);
955-
}
937+
return Json((lhs.as_double() * rhs.as_double()), semantic_tag::none);
956938
}
957939

958940
std::string to_string(int level) const override
@@ -987,18 +969,15 @@ namespace detail {
987969
{
988970
return Json::null();
989971
}
990-
else if (lhs.is_int64() && rhs.is_int64())
972+
if (lhs.is_int64() && rhs.is_int64())
991973
{
992974
return Json(((lhs.template as<int64_t>() / rhs.template as<int64_t>())), semantic_tag::none);
993975
}
994-
else if (lhs.is_uint64() && rhs.is_uint64())
976+
if (lhs.is_uint64() && rhs.is_uint64())
995977
{
996978
return Json((lhs.template as<uint64_t>() / rhs.template as<uint64_t>()), semantic_tag::none);
997979
}
998-
else
999-
{
1000-
return Json((lhs.as_double() / rhs.as_double()), semantic_tag::none);
1001-
}
980+
return Json((lhs.as_double() / rhs.as_double()), semantic_tag::none);
1002981
}
1003982

1004983
std::string to_string(int level) const override
@@ -1033,18 +1012,15 @@ namespace detail {
10331012
{
10341013
return Json::null();
10351014
}
1036-
else if (lhs.is_int64() && rhs.is_int64())
1015+
if (lhs.is_int64() && rhs.is_int64())
10371016
{
10381017
return Json(((lhs.template as<int64_t>() % rhs.template as<int64_t>())), semantic_tag::none);
10391018
}
1040-
else if (lhs.is_uint64() && rhs.is_uint64())
1019+
if (lhs.is_uint64() && rhs.is_uint64())
10411020
{
10421021
return Json((lhs.template as<uint64_t>() % rhs.template as<uint64_t>()), semantic_tag::none);
10431022
}
1044-
else
1045-
{
1046-
return Json(fmod(lhs.as_double(), rhs.as_double()), semantic_tag::none);
1047-
}
1023+
return Json(fmod(lhs.as_double(), rhs.as_double()), semantic_tag::none);
10481024
}
10491025

10501026
std::string to_string(int level) const override
@@ -1074,8 +1050,14 @@ namespace detail {
10741050
{
10751051
}
10761052

1053+
function_base(const function_base&) = default;
1054+
function_base(function_base&&) = default;
1055+
10771056
virtual ~function_base() noexcept = default;
10781057

1058+
function_base& operator=(const function_base&) = default;
1059+
function_base& operator=(function_base&&) = default;
1060+
10791061
jsoncons::optional<std::size_t> arity() const
10801062
{
10811063
return arg_count_;
@@ -1232,10 +1214,7 @@ namespace detail {
12321214
{
12331215
return value_type(true, semantic_tag::none);
12341216
}
1235-
else
1236-
{
1237-
return value_type(false, semantic_tag::none);
1238-
}
1217+
return value_type(false, semantic_tag::none);
12391218
}
12401219

12411220
std::string to_string(int level) const override
@@ -1294,10 +1273,7 @@ namespace detail {
12941273
{
12951274
return value_type(true, semantic_tag::none);
12961275
}
1297-
else
1298-
{
1299-
return value_type(false, semantic_tag::none);
1300-
}
1276+
return value_type(false, semantic_tag::none);
13011277
}
13021278

13031279
std::string to_string(int level) const override
@@ -1590,7 +1566,7 @@ namespace detail {
15901566
{
15911567
return value_type(sn, semantic_tag::none);
15921568
}
1593-
jsoncons::detail::chars_to to_double;
1569+
jsoncons::detail::chars_to to_double{};
15941570
try
15951571
{
15961572
auto s = arg0.as_string();
@@ -2405,7 +2381,7 @@ namespace detail {
24052381
{
24062382
}
24072383

2408-
virtual std::string to_string(int = 0) const
2384+
virtual std::string to_string(int) const
24092385
{
24102386
return std::string();
24112387
}
@@ -2528,15 +2504,9 @@ namespace detail {
25282504
ec = jsonpath_errc::unknown_function;
25292505
return nullptr;
25302506
}
2531-
else
2532-
{
2533-
return it2->second.get();
2534-
}
2535-
}
2536-
else
2537-
{
2538-
return it->second.get();
2507+
return it2->second.get();
25392508
}
2509+
return it->second.get();
25402510
}
25412511

25422512
const unary_operator<Json>* get_unary_not() const

include/jsoncons_ext/jsonpath/jsonpath_error.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ namespace jsoncons { namespace jsonpath {
164164
return std::error_code(static_cast<int>(result),jsonpath_error_category());
165165
}
166166

167-
} // jsonpath
167+
} // namespace jsonpath
168168
} // namespace jsoncons
169169

170170
namespace std {

include/jsoncons_ext/msgpack/decode_msgpack.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace msgpack {
198198
return val;
199199
}
200200

201-
} // msgpack
201+
} // namespace msgpack
202202
} // namespace jsoncons
203203

204204
#endif // JSONCONS_EXT_MSGPACK_DECODE_MSGPACK_HPP

include/jsoncons_ext/msgpack/encode_msgpack.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ namespace msgpack {
137137
}
138138
}
139139

140-
} // msgpack
140+
} // namespace msgpack
141141
} // namespace jsoncons
142142

143143
#endif // JSONCONS_EXT_MSGPACK_ENCODE_MSGPACK_HPP

include/jsoncons_ext/ubjson/decode_ubjson.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace ubjson {
197197
return val;
198198
}
199199

200-
} // ubjson
200+
} // namespace ubjson
201201
} // namespace jsoncons
202202

203203
#endif // JSONCONS_EXT_UBJSON_DECODE_UBJSON_HPP

0 commit comments

Comments
 (0)