Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Oct 30, 2022
2 parents e02ae29 + ac5191c commit fc4b979
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
*.app

build
.vscode
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -std=c++17")
endif(MSVC)
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
set(IGUANA_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
2 changes: 1 addition & 1 deletion example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void test_json()
{
person p;
const char * json = "{ \"name\" : \"tom\", \"age\" : 20}";
auto r = iguana::json::from_json0(p, json);
[[maybe_unused]]auto r = iguana::json::from_json0(p, json);

iguana::string_stream ss;
iguana::json::to_json(ss, p);
Expand Down
6 changes: 3 additions & 3 deletions example/json_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void test_disorder()

student s1{};
std::string str = "{\"name\":\"tom\",\"id\":1,\"age\":20}";
bool r = iguana::json::from_json0(s1, str.data(), str.length());
[[maybe_unused]]bool r = iguana::json::from_json0(s1, str.data(), str.length());
std::string str1 = "{\"name\":\"tom\",\"age\":20,\"id\":1}";
r = iguana::json::from_json0(s1, str1.data(), str1.length());

Expand Down Expand Up @@ -139,10 +139,10 @@ int main(void)
std::cout << p2.name << " - " << p2.age << std::endl;


// 测试异常数据,之前的版本会在do.while中死循环
// �����쳣����,֮ǰ�İ汾����do.while����ѭ��
client::person p3;
json_str = "unknownType";
bool bOK = iguana::json::from_json0(p3, json_str.data(), json_str.length()); //no limitation, but slower
[[maybe_unused]]bool bOK = iguana::json::from_json0(p3, json_str.data(), json_str.length()); //no limitation, but slower

return 0;
}
4 changes: 2 additions & 2 deletions iguana/detail/string_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace iguana
enum { INIT_BUFF_SIZE = 1024 };

basic_string_stream()
: m_length(INIT_BUFF_SIZE)
, m_status(good)
: m_status(good)
, m_length(INIT_BUFF_SIZE)
{
this->m_header_ptr = this->alloc.allocate(INIT_BUFF_SIZE);
this->m_read_ptr = this->m_header_ptr;
Expand Down
7 changes: 3 additions & 4 deletions iguana/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class reader_t {

inline char char_to_hex(char v) {
if (v < 'f') {
v = table[(int)v];
v = table[int(v)];
} else {
v = 16;
}
Expand Down Expand Up @@ -896,7 +896,7 @@ read_json(reader_t &rd, T &val, bool unorder = false) {
}

#define MIN_NUMBER_VALUE 1e-8
inline void read_json(reader_t &rd, bool &val) {
inline void read_json(reader_t &rd, bool &val, bool unorder = false) {
auto &tok = rd.peek();
switch (tok.type) {
case token::t_string: {
Expand Down Expand Up @@ -930,7 +930,7 @@ inline void read_json(reader_t &rd, bool &val) {
rd.next();
}

inline void read_json(reader_t &rd, std::string &val) {
inline void read_json(reader_t &rd, std::string &val, bool unorder = false) {
auto &tok = rd.peek();
if (tok.type == token::t_string) {
val.assign(tok.str.str, tok.str.len);
Expand Down Expand Up @@ -1153,7 +1153,6 @@ inline bool from_json0(T &&t, const char *buf, size_t len = -1) {
template <typename T, typename = std::enable_if_t<is_reflection<T>::value>>
constexpr void do_read0(reader_t &rd, T &&t) {
using M = decltype(iguana_reflect_members(std::forward<T>(t)));
constexpr auto Count = M::value();

auto tp = M::apply_impl();
constexpr auto Size = M::value();
Expand Down
2 changes: 1 addition & 1 deletion iguana/reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ MAKE_META_DATA(STRUCT_NAME, GET_ARG_COUNT(__VA_ARGS__), __VA_ARGS__)
};

template <typename T>
struct is_reflection<T, std::void_t<decltype(std::declval<Reflect_members<T>>().arr())>> : std::true_type
struct is_reflection<T, std::void_t<decltype(Reflect_members<T>::arr())>> : std::true_type
{
};

Expand Down

0 comments on commit fc4b979

Please sign in to comment.