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
1 parent 4b14160 commit ac5191c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 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
10 changes: 4 additions & 6 deletions iguana/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static bool g_has_error = false;
class reader_t {
public:
reader_t(const char *ptr = nullptr, size_t len = -1)
: ptr_((char *)ptr), len_(len) {
: len_(len), ptr_((char *)ptr) {
if (ptr == nullptr) {
end_mark_ = true;
} else if (len == 0) {
Expand Down Expand Up @@ -437,7 +437,7 @@ class reader_t {

inline char char_to_hex(char v) {
if (v < 'f') {
v = table[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 @@ -1104,7 +1104,6 @@ template <typename U, typename T> inline void assign(reader_t &rd, T &t) {
template <typename T>
inline std::enable_if_t<is_tuple<std::decay_t<T>>::value, bool>
from_json(T &&t, const char *buf, size_t len = -1) {
using U = std::decay_t<T>;
g_has_error = false;
reader_t rd(buf, len);
rd.next();
Expand Down Expand Up @@ -1154,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

0 comments on commit ac5191c

Please sign in to comment.