Ver código fonte

1、测试mqtt;

LiuZe 1 ano atrás
pai
commit
53e6fcd4e6
81 arquivos alterados com 1153 adições e 9296 exclusões
  1. 7 37
      CMakeLists.txt
  2. 0 60
      include/CMakeLists.txt
  3. 0 16
      include/error_code/CMakeLists.txt
  4. 0 20
      include/error_code/test.cpp
  5. 0 29
      include/error_code/test.h
  6. 0 25
      include/file/CMakeLists.txt
  7. 0 115
      include/file/pathcreator.cpp
  8. 0 29
      include/file/pathcreator.h
  9. 0 5
      include/file/test.cpp
  10. 0 3
      include/file/test.h
  11. 0 39
      include/json/CMakeLists.txt
  12. 0 89
      include/json/allocator.h
  13. 0 61
      include/json/assertions.h
  14. 0 150
      include/json/config.h
  15. 0 43
      include/json/forwards.h
  16. 0 16
      include/json/json.h
  17. 0 62
      include/json/json_features.h
  18. 0 48
      include/json/json_file.hpp
  19. 0 2004
      include/json/json_reader.cpp
  20. 0 138
      include/json/json_tool.h
  21. 0 1634
      include/json/json_value.cpp
  22. 0 156
      include/json/json_valueiterator.inl
  23. 0 1259
      include/json/json_writer.cpp
  24. 0 406
      include/json/reader.h
  25. 0 5
      include/json/test.cpp
  26. 0 3
      include/json/test.h
  27. 0 936
      include/json/value.h
  28. 0 28
      include/json/version.h
  29. 0 370
      include/json/writer.h
  30. 0 32
      include/log/CMakeLists.txt
  31. 0 5
      include/log/log.cpp
  32. 0 5
      include/log/test.cpp
  33. 0 3
      include/log/test.h
  34. 1 14
      include/message/CMakeLists.txt
  35. 14 0
      include/pahoc/CMakeLists.txt
  36. 13 0
      include/pahoc/main.cpp
  37. 349 0
      include/pahoc/mqtt_async.cpp
  38. 155 0
      include/pahoc/mqtt_async.h
  39. 33 0
      include/pahoc/mqtt_async.proto
  40. 35 0
      include/pahoc/mqtt_communication.cpp
  41. 34 0
      include/pahoc/mqtt_communication.h
  42. 0 32
      include/pcl/CMakeLists.txt
  43. 0 140
      include/pcl/point2D_tool.cpp
  44. 0 92
      include/pcl/point2D_tool.h
  45. 0 130
      include/pcl/point3D_tool.cpp
  46. 0 56
      include/pcl/point3D_tool.h
  47. 0 5
      include/pcl/test.cpp
  48. 0 3
      include/pcl/test.h
  49. 0 49
      include/plc/CMakeLists.txt
  50. 0 19
      include/plc/plcJsonConfig.cpp
  51. 0 21
      include/plc/plcJsonConfig.h
  52. 0 78
      include/plc/s7_plc.cpp
  53. 0 39
      include/plc/s7_plc.h
  54. 0 217
      include/plc/snap7_buf.cpp
  55. 0 98
      include/plc/snap7_buf.h
  56. 0 292
      include/plc/snap7_communication_base.cpp
  57. 0 115
      include/plc/snap7_communication_base.h
  58. 0 8
      include/plc/test.cpp
  59. 0 8
      include/plc/test.h
  60. 3 15
      include/rabbitmq/CMakeLists.txt
  61. 3 3
      include/rabbitmq/rabbitmq_base.h
  62. 1 1
      include/rabbitmq/rabbitmq_message.h
  63. 0 5
      include/rabbitmq/test.cpp
  64. 0 3
      include/rabbitmq/test.h
  65. 1 6
      include/thread/CMakeLists.txt
  66. 0 4
      include/thread/singleton.cpp
  67. 0 5
      include/thread/test.cpp
  68. 0 3
      include/thread/test.h
  69. 1 1
      include/thread/time_tool.h
  70. 0 0
      include/tool/error_code.hpp
  71. 1 1
      include/protobuf/load_protobuf.hpp
  72. 1 1
      include/log/log.h
  73. 118 0
      include/tool/pathcreator.hpp
  74. 227 0
      include/tool/point2D_tool.hpp
  75. 155 0
      include/tool/point3D_tool.hpp
  76. 0 0
      include/tool/singleton.hpp
  77. 0 0
      include/tool/thread_pool.hpp
  78. 0 0
      include/tool/thread_safe_list.hpp
  79. 0 0
      include/tool/thread_safe_queue.hpp
  80. 0 0
      include/tool/trans_coor.hpp
  81. 1 1
      project/clamp_lidar

+ 7 - 37
CMakeLists.txt

@@ -12,20 +12,9 @@ else ()
     add_definitions(-DETC_PATH="${CMAKE_INSTALL_PREFIX}/etc/")
 endif ()
 
-set(CMAKE_BUILD_TYPE "Debug")
+set(CMAKE_BUILD_TYPE "Release")
 # 第三方库
 find_package(PkgConfig REQUIRED)
-# pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
-# find_path(YAML_CPP_INCLUDE_DIR
-#         NAMES yaml_cpp.h
-#         PATHS ${YAML_CPP_INCLUDE_DIRS})
-# find_library(YAML_CPP_LIBRARY
-#         NAMES YAML_CPP
-#         PATHS ${YAML_CPP_LIBRARY_DIRS})
-# if (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5")
-#     add_definitions(-DHAVE_NEW_YAMLCPP)
-# endif (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5")
-# add_subdirectory(thirdpart/rs_driver)
 
 # Don't search with REQUIRED as we can continue without gflags.
 find_package(gflags 2.2.0)
@@ -49,35 +38,16 @@ find_package(PCL REQUIRED)
 find_package(Eigen3 REQUIRED)
 find_package(OpenCV REQUIRED)
 find_package(Protobuf CONFIG)
-#if(NOT Protobuf_FOUND)
-#    find_package(Protobuf REQUIRED)
-#endif()
-
-find_package(absl REQUIRED)
-set(absl_LIBRARIES
-        absl::algorithm
-        absl::base
-        absl::debugging
-        absl::flat_hash_map
-        absl::memory
-        absl::meta
-        absl::numeric
-        absl::str_format
-        absl::strings
-        absl::synchronization
-        absl::time
-        absl::utility
+include_directories(
+        ${CMAKE_SOURCE_DIR}/include
 )
 
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/rabbitmq)
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/thread)
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/message)
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/pahoc)
 #execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/protoc.sh ${CMAKE_CURRENT_LIST_DIR})
 
-if (EXISTS "${CMAKE_SOURCE_DIR}/include/CMakeLists.txt")
-    include_directories(${CMAKE_SOURCE_DIR}/include)
-    add_subdirectory(${CMAKE_SOURCE_DIR}/include)
-else ()
-    message("Can't find dir: " "${CMAKE_SOURCE_DIR}/include/CMakeLists.txt")
-endif ()
-
 if (EXISTS "${CMAKE_SOURCE_DIR}/project/CMakeLists.txt")
     add_subdirectory(${CMAKE_SOURCE_DIR}/project)
 else ()

+ 0 - 60
include/CMakeLists.txt

@@ -1,60 +0,0 @@
-
-message("===== compile library =====")
-
-unset(ENABLE_LIBRARY_ERROR_CODE CACHE)
-OPTION(ENABLE_LIBRARY_ERROR_CODE "" ON)
-unset(ENABLE_LIBRARY_GOOGLE_LOG CACHE)
-OPTION(ENABLE_LIBRARY_GOOGLE_LOG "" ON)
-unset(ENABLE_LIBRARY_PCL CACHE)
-OPTION(ENABLE_LIBRARY_PCL "" ON)
-unset(ENABLE_LIBRARY_RABBITMQ CACHE)
-OPTION(ENABLE_LIBRARY_RABBITMQ "" ON)
-unset(ENABLE_LIBRARY_THREAD CACHE)
-OPTION(ENABLE_LIBRARY_THREAD "" ON)
-unset(ENABLE_LIBRARY_PLC CACHE)
-OPTION(ENABLE_LIBRARY_PLC "" OFF)
-unset(ENABLE_LIBRARY_JSON CACHE)
-OPTION(ENABLE_LIBRARY_JSON "" ON)
-unset(ENABLE_LIBRARY_FILE CACHE)
-OPTION(ENABLE_LIBRARY_FILE "" ON)
-
-add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/message)
-message("==> ENABLE_LIBRARY_ERROR_CODE " ${ENABLE_LIBRARY_ERROR_CODE})
-if (ENABLE_LIBRARY_ERROR_CODE)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/error_code)
-endif ()
-
-message("==> ENABLE_LIBRARY_GOOGLE_LOG " ${ENABLE_LIBRARY_GOOGLE_LOG})
-if (ENABLE_LIBRARY_GOOGLE_LOG)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/log)
-endif ()
-
-message("==> ENABLE_LIBRARY_PCL " ${ENABLE_LIBRARY_PCL})
-if (ENABLE_LIBRARY_PCL)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/pcl)
-endif ()
-
-message("==> ENABLE_LIBRARY_RABBITMQ " ${ENABLE_LIBRARY_RABBITMQ})
-if (ENABLE_LIBRARY_RABBITMQ)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/rabbitmq)
-endif ()
-
-message("==> ENABLE_LIBRARY_THREAD " ${ENABLE_LIBRARY_THREAD})
-if (ENABLE_LIBRARY_THREAD)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/thread)
-endif ()
-
-message("==> ENABLE_LIBRARY_PLC " ${ENABLE_LIBRARY_PLC})
-if (ENABLE_LIBRARY_PLC)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/plc)
-endif ()
-
-message("==> ENABLE_LIBRARY_JSON " ${ENABLE_LIBRARY_JSON})
-if (ENABLE_LIBRARY_JSON)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/json)
-endif ()
-
-message("==> ENABLE_LIBRARY_FILE " ${ENABLE_LIBRARY_FILE})
-if (ENABLE_LIBRARY_FILE)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/file)
-endif ()

+ 0 - 16
include/error_code/CMakeLists.txt

@@ -1,16 +0,0 @@
-set(LIBRARY_NAME error_code)
-
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
-message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
-
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-            ${CMAKE_CURRENT_LIST_DIR}/error_code.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 0 - 20
include/error_code/test.cpp

@@ -1,20 +0,0 @@
-//
-// Created by zx on 2023/10/20.
-//
-#include "test.h"
-
-//int main(int argc, char** argv) {
-//#if OPTION_ERROR_CODE_DESCRIPTE
-//    std::cout << OPTION_ERROR_CODE_DESCRIPTE;
-//    ErrorManager err(zx::ErrorCode::WARNING, zx::ErrorLevel::NORMAL);
-//    std::cout << err.to_string();
-//#endif
-//    return EXIT_SUCCESS;
-//}
-
-int main(int argc, char** argv) {
-    TestCode tc;
-    tc.setValue(SUCCESS);
-    std::cout << tc.value();
-    return EXIT_SUCCESS;
-}

+ 0 - 29
include/error_code/test.h

@@ -1,29 +0,0 @@
-#pragma once
-
-//#include "error_code.hpp"
-//#include "error_level.hpp"
-#include "error_code.hpp"
-
-class Code {
-public:
-    enum ErrorCode {
-        SUCCESS = 1
-    };
-    virtual ErrorCode value() {
-        return m_code;
-    }
-
-    void setValue(ErrorCode &code) {
-        m_code = code;
-    }
-private:
-    ErrorCode m_code;
-};
-
-//using ErrorManager = Error<zx::ErrorCode, zx::ErrorLevel>;
-class TestCode: public Code {
-public:
-    enum ErrorCode {
-        SUCCESS = 2
-    };
-};

+ 0 - 25
include/file/CMakeLists.txt

@@ -1,25 +0,0 @@
-set(LIBRARY_NAME libfile)
-
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
-message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
-
-set(LIBRARY_SOURCE_LIST
-        ${CMAKE_CURRENT_LIST_DIR}/pathcreator.h
-        ${CMAKE_CURRENT_LIST_DIR}/pathcreator.cpp
-)
-
-set(LIBRARY_DEPEND_LIST)
-
-add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
-target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
-
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 0 - 115
include/file/pathcreator.cpp

@@ -1,115 +0,0 @@
-#include "pathcreator.h"
-
-#include <sys/types.h>
-#include <time.h>
-#include <stdint.h>
-#include <stdio.h>
-
-PathCreator::PathCreator()
-{
-
-}
-
-PathCreator::~PathCreator()
-{
-
-}
-
-std::string PathCreator::GetCurPath()
-{
-    return m_current_path;
-}
-bool PathCreator::Mkdir(std::string dirName)
-{
-    uint32_t beginCmpPath = 0;
-    uint32_t endCmpPath = 0;
-    std::string fullPath = "";
-
-    if('/' != dirName[0])
-    {
-        fullPath = getcwd(nullptr, 0);
-        beginCmpPath = fullPath.size();
-        fullPath = fullPath + "/" + dirName;
-    }
-    else
-    {
-        //Absolute path
-        fullPath = dirName;
-        beginCmpPath = 1;
-    }
-    if (fullPath[fullPath.size() - 1] != '/')
-    {
-        fullPath += "/";
-    }
-    endCmpPath = fullPath.size();
-
-    //create dirs;
-    for(uint32_t i = beginCmpPath; i < endCmpPath ; i++ )
-    {
-        if('/' == fullPath[i])
-        {
-            std::string curPath = fullPath.substr(0, i);
-            if(access(curPath.c_str(), F_OK) != 0)
-            {
-                if(mkdir(curPath.c_str(), /*S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH*/0777) == -1)
-                {
-                    printf("mkdir(%s) failed\n", curPath.c_str());
-                    return false;
-                }
-            }
-        }
-    }
-    m_current_path=fullPath;
-    return true;
-
-}
-
-bool PathCreator::CreateDatePath(std::string root, bool add_time)
-{
-    time_t tt;
-    time( &tt );
-    tt = tt + 8*3600;  // transform the time zone
-    tm* t= gmtime( &tt );
-    char buf[255]={0};
-    if (add_time)
-    {
-        sprintf(buf, "%s/%d%02d%02d-%02d%02d%02d", root.c_str(),
-                t->tm_year + 1900,
-                t->tm_mon + 1,
-                t->tm_mday,
-                t->tm_hour,
-                t->tm_min,
-                t->tm_sec);
-    }
-    else
-    {
-        sprintf(buf, "%s/%d%02d%02d", root.c_str(),
-                t->tm_year + 1900,
-                t->tm_mon + 1,
-                t->tm_mday);
-    }
-    return Mkdir(buf);
-}
-
-bool PathCreator::IsPathExist(const std::string& path) {
-    if (access(path.c_str(), 0) == F_OK) {
-        return true;
-    }
-    return false;
-}
-bool PathCreator::IsFile(const std::string& path) {
-    if (!IsPathExist(path)) {
-        printf("%s:%d %s not exist\n", __FILE__, __LINE__, path.c_str());
-        return false;
-    }
-    struct stat buffer;
-    return (stat(path.c_str(), &buffer) == 0 && S_ISREG(buffer.st_mode));
-}
-
-bool PathCreator::IsFolder(const std::string& path) {
-    if (!IsPathExist(path)) {
-        return false;
-    }
-    struct stat buffer;
-    return (stat(path.c_str(), &buffer) == 0 && S_ISDIR(buffer.st_mode));
-}

+ 0 - 29
include/file/pathcreator.h

@@ -1,29 +0,0 @@
-#ifndef PATHCREATOR_H
-#define PATHCREATOR_H
-#include <string>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fstream>
-
-class PathCreator
-{
-public:
-    PathCreator();
-    ~PathCreator();
-    std::string GetCurPath();
-    bool Mkdir(std::string dir);
-    bool CreateDatePath(std::string root, bool add_time = true);
-
-
-    static bool IsPathExist(const std::string& path);
-
-    static bool IsFile(const std::string& path);
-
-    static bool IsFolder(const std::string& path);
-
-protected:
-    std::string m_current_path;
-};
-
-
-#endif // PATHCREATOR_H

+ 0 - 5
include/file/test.cpp

@@ -1,5 +0,0 @@
-#include "test.h"
-
-int main(int argc, char** argv) {
-    return EXIT_SUCCESS;
-}

+ 0 - 3
include/file/test.h

@@ -1,3 +0,0 @@
-#pragma once
-
-#include <iostream>

+ 0 - 39
include/json/CMakeLists.txt

@@ -1,39 +0,0 @@
-set(LIBRARY_NAME libjson)
-
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
-message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
-
-set(LIBRARY_SOURCE_LIST
-        ${CMAKE_CURRENT_LIST_DIR}/allocator.h
-        ${CMAKE_CURRENT_LIST_DIR}/assertions.h
-        ${CMAKE_CURRENT_LIST_DIR}/config.h
-        ${CMAKE_CURRENT_LIST_DIR}/forwards.h
-        ${CMAKE_CURRENT_LIST_DIR}/json.h
-        ${CMAKE_CURRENT_LIST_DIR}/json_features.h
-        ${CMAKE_CURRENT_LIST_DIR}/json_file.hpp
-        ${CMAKE_CURRENT_LIST_DIR}/json_reader.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/json_tool.h
-        ${CMAKE_CURRENT_LIST_DIR}/json_value.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/json_valueiterator.inl
-        ${CMAKE_CURRENT_LIST_DIR}/json_writer.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/reader.h
-        ${CMAKE_CURRENT_LIST_DIR}/value.h
-        ${CMAKE_CURRENT_LIST_DIR}/version.h
-        ${CMAKE_CURRENT_LIST_DIR}/writer.h
-)
-
-set(LIBRARY_DEPEND_LIST)
-
-add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
-target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
-
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 0 - 89
include/json/allocator.h

@@ -1,89 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_ALLOCATOR_H_INCLUDED
-#define JSON_ALLOCATOR_H_INCLUDED
-
-#include <cstring>
-#include <memory>
-
-#pragma pack(push)
-#pragma pack()
-
-namespace Json {
-template <typename T> class SecureAllocator {
-public:
-  // Type definitions
-  using value_type = T;
-  using pointer = T*;
-  using const_pointer = const T*;
-  using reference = T&;
-  using const_reference = const T&;
-  using size_type = std::size_t;
-  using difference_type = std::ptrdiff_t;
-
-  /**
-   * Allocate memory for N items using the standard allocator.
-   */
-  pointer allocate(size_type n) {
-    // allocate using "global operator new"
-    return static_cast<pointer>(::operator new(n * sizeof(T)));
-  }
-
-  /**
-   * Release memory which was allocated for N items at pointer P.
-   *
-   * The memory block is filled with zeroes before being released.
-   */
-  void deallocate(pointer p, size_type n) {
-    // memset_s is used because memset may be optimized away by the compiler
-    memset_s(p, n * sizeof(T), 0, n * sizeof(T));
-    // free using "global operator delete"
-    ::operator delete(p);
-  }
-
-  /**
-   * Construct an item in-place at pointer P.
-   */
-  template <typename... Args> void construct(pointer p, Args&&... args) {
-    // construct using "placement new" and "perfect forwarding"
-    ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
-  }
-
-  size_type max_size() const { return size_t(-1) / sizeof(T); }
-
-  pointer address(reference x) const { return std::addressof(x); }
-
-  const_pointer address(const_reference x) const { return std::addressof(x); }
-
-  /**
-   * Destroy an item in-place at pointer P.
-   */
-  void destroy(pointer p) {
-    // destroy using "explicit destructor"
-    p->~T();
-  }
-
-  // Boilerplate
-  SecureAllocator() {}
-  template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
-  template <typename U> struct rebind { using other = SecureAllocator<U>; };
-};
-
-template <typename T, typename U>
-bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
-  return true;
-}
-
-template <typename T, typename U>
-bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
-  return false;
-}
-
-} // namespace Json
-
-#pragma pack(pop)
-
-#endif // JSON_ALLOCATOR_H_INCLUDED

+ 0 - 61
include/json/assertions.h

@@ -1,61 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_ASSERTIONS_H_INCLUDED
-#define JSON_ASSERTIONS_H_INCLUDED
-
-#include <cstdlib>
-#include <sstream>
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "config.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-/** It should not be possible for a maliciously designed file to
- *  cause an abort() or seg-fault, so these macros are used only
- *  for pre-condition violations and internal logic errors.
- */
-#if JSON_USE_EXCEPTION
-
-// @todo <= add detail about condition in exception
-#define JSON_ASSERT(condition)                                                 \
-  do {                                                                         \
-    if (!(condition)) {                                                        \
-      Json::throwLogicError("assert json failed");                             \
-    }                                                                          \
-  } while (0)
-
-#define JSON_FAIL_MESSAGE(message)                                             \
-  do {                                                                         \
-    OStringStream oss;                                                         \
-    oss << message;                                                            \
-    Json::throwLogicError(oss.str());                                          \
-    abort();                                                                   \
-  } while (0)
-
-#else // JSON_USE_EXCEPTION
-
-#define JSON_ASSERT(condition) assert(condition)
-
-// The call to assert() will show the failure message in debug builds. In
-// release builds we abort, for a core-dump or debugger.
-#define JSON_FAIL_MESSAGE(message)                                             \
-  {                                                                            \
-    OStringStream oss;                                                         \
-    oss << message;                                                            \
-    assert(false && oss.str().c_str());                                        \
-    abort();                                                                   \
-  }
-
-#endif
-
-#define JSON_ASSERT_MESSAGE(condition, message)                                \
-  do {                                                                         \
-    if (!(condition)) {                                                        \
-      JSON_FAIL_MESSAGE(message);                                              \
-    }                                                                          \
-  } while (0)
-
-#endif // JSON_ASSERTIONS_H_INCLUDED

+ 0 - 150
include/json/config.h

@@ -1,150 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_CONFIG_H_INCLUDED
-#define JSON_CONFIG_H_INCLUDED
-#include <cstddef>
-#include <cstdint>
-#include <istream>
-#include <memory>
-#include <ostream>
-#include <sstream>
-#include <string>
-#include <type_traits>
-
-// If non-zero, the library uses exceptions to report bad input instead of C
-// assertion macros. The default is to use exceptions.
-#ifndef JSON_USE_EXCEPTION
-#define JSON_USE_EXCEPTION 1
-#endif
-
-// Temporary, tracked for removal with issue #982.
-#ifndef JSON_USE_NULLREF
-#define JSON_USE_NULLREF 1
-#endif
-
-/// If defined, indicates that the source file is amalgamated
-/// to prevent private header inclusion.
-/// Remarks: it is automatically defined in the generated amalgamated header.
-// #define JSON_IS_AMALGAMATION
-
-// Export macros for DLL visibility
-#if defined(JSON_DLL_BUILD)
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#define JSON_API __declspec(dllexport)
-#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
-#elif defined(__GNUC__) || defined(__clang__)
-#define JSON_API __attribute__((visibility("default")))
-#endif // if defined(_MSC_VER)
-
-#elif defined(JSON_DLL)
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#define JSON_API __declspec(dllimport)
-#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
-#endif // if defined(_MSC_VER)
-#endif // ifdef JSON_DLL_BUILD
-
-#if !defined(JSON_API)
-#define JSON_API
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER < 1800
-#error                                                                         \
-    "ERROR:  Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER < 1900
-// As recommended at
-// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
-extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
-                                              const char* format, ...);
-#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
-#else
-#define jsoncpp_snprintf std::snprintf
-#endif
-
-// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
-// integer
-// Storages, and 64 bits integer support is disabled.
-// #define JSON_NO_INT64 1
-
-// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
-// C++11 should be used directly in JSONCPP.
-#define JSONCPP_OVERRIDE override
-
-#ifdef __clang__
-#if __has_extension(attribute_deprecated_with_message)
-#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
-#endif
-#elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
-#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
-#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
-#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
-#endif                  // GNUC version
-#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
-                        // MSVC)
-#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
-#endif // __clang__ || __GNUC__ || _MSC_VER
-
-#if !defined(JSONCPP_DEPRECATED)
-#define JSONCPP_DEPRECATED(message)
-#endif // if !defined(JSONCPP_DEPRECATED)
-
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
-#define JSON_USE_INT64_DOUBLE_CONVERSION 1
-#endif
-
-#if !defined(JSON_IS_AMALGAMATION)
-
-#include "allocator.h"
-#include "version.h"
-
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-namespace Json {
-using Int = int;
-using UInt = unsigned int;
-#if defined(JSON_NO_INT64)
-using LargestInt = int;
-using LargestUInt = unsigned int;
-#undef JSON_HAS_INT64
-#else                 // if defined(JSON_NO_INT64)
-// For Microsoft Visual use specific types as long long is not supported
-#if defined(_MSC_VER) // Microsoft Visual Studio
-using Int64 = __int64;
-using UInt64 = unsigned __int64;
-#else                 // if defined(_MSC_VER) // Other platforms, use long long
-using Int64 = int64_t;
-using UInt64 = uint64_t;
-#endif                // if defined(_MSC_VER)
-using LargestInt = Int64;
-using LargestUInt = UInt64;
-#define JSON_HAS_INT64
-#endif // if defined(JSON_NO_INT64)
-
-template <typename T>
-using Allocator =
-    typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
-                              std::allocator<T>>::type;
-using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
-using IStringStream =
-    std::basic_istringstream<String::value_type, String::traits_type,
-                             String::allocator_type>;
-using OStringStream =
-    std::basic_ostringstream<String::value_type, String::traits_type,
-                             String::allocator_type>;
-using IStream = std::istream;
-using OStream = std::ostream;
-} // namespace Json
-
-// Legacy names (formerly macros).
-using JSONCPP_STRING = Json::String;
-using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
-using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
-using JSONCPP_ISTREAM = Json::IStream;
-using JSONCPP_OSTREAM = Json::OStream;
-
-#endif // JSON_CONFIG_H_INCLUDED

+ 0 - 43
include/json/forwards.h

@@ -1,43 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_FORWARDS_H_INCLUDED
-#define JSON_FORWARDS_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "config.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-namespace Json {
-
-// writer.h
-class StreamWriter;
-class StreamWriterBuilder;
-class Writer;
-class FastWriter;
-class StyledWriter;
-class StyledStreamWriter;
-
-// reader.h
-class Reader;
-class CharReader;
-class CharReaderBuilder;
-
-// json_features.h
-class Features;
-
-// value.h
-using ArrayIndex = unsigned int;
-class StaticString;
-class Path;
-class PathArgument;
-class Value;
-class ValueIteratorBase;
-class ValueIterator;
-class ValueConstIterator;
-
-} // namespace Json
-
-#endif // JSON_FORWARDS_H_INCLUDED

+ 0 - 16
include/json/json.h

@@ -1,16 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_JSON_H_INCLUDED
-#define JSON_JSON_H_INCLUDED
-
-#include "config.h"
-#include "json_features.h"
-#include "reader.h"
-#include "value.h"
-#include "writer.h"
-#include "json_file.hpp"
-
-#endif // JSON_JSON_H_INCLUDED

+ 0 - 62
include/json/json_features.h

@@ -1,62 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_FEATURES_H_INCLUDED
-#define JSON_FEATURES_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "forwards.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-#pragma pack(push)
-#pragma pack()
-
-namespace Json {
-
-/** \brief Configuration passed to reader and writer.
- * This configuration object can be used to force the Reader or Writer
- * to behave in a standard conforming way.
- */
-class JSON_API Features {
-public:
-  /** \brief A configuration that allows all features and assumes all strings
-   * are UTF-8.
-   * - C & C++ comments are allowed
-   * - Root object can be any JSON value
-   * - Assumes Value strings are encoded in UTF-8
-   */
-  static Features all();
-
-  /** \brief A configuration that is strictly compatible with the JSON
-   * specification.
-   * - Comments are forbidden.
-   * - Root object must be either an array or an object value.
-   * - Assumes Value strings are encoded in UTF-8
-   */
-  static Features strictMode();
-
-  /** \brief Initialize the configuration like JsonConfig::allFeatures;
-   */
-  Features();
-
-  /// \c true if comments are allowed. Default: \c true.
-  bool allowComments_{true};
-
-  /// \c true if root must be either an array or an object value. Default: \c
-  /// false.
-  bool strictRoot_{false};
-
-  /// \c true if dropped null placeholders are allowed. Default: \c false.
-  bool allowDroppedNullPlaceholders_{false};
-
-  /// \c true if numeric object key are allowed. Default: \c false.
-  bool allowNumericKeys_{false};
-};
-
-} // namespace Json
-
-#pragma pack(pop)
-
-#endif // JSON_FEATURES_H_INCLUDED

+ 0 - 48
include/json/json_file.hpp

@@ -1,48 +0,0 @@
-#ifndef JSON_FILE_H_
-#define JSON_FILE_H_
-
-#include "reader.h"
-#include <fstream>
-
-#define JV_STRING(_json_, _key_, _value_, _default_) (_json_.isMember(_key_) && _json_[_key_].isString()) ? _value_ = _json_[_key_].asString() : _value_ = _default_;
-#define JV_INT(_json_, _key_, _value_, _default_) (_json_.isMember(_key_) && _json_[_key_].isInt()) ? _value_ = _json_[_key_].asInt() : _value_ = _default_;
-#define JV_INT64(_json_, _key_, _value_, _default_) (_json_.isMember(_key_) && _json_[_key_].isInt64()) ? _value_ = _json_[_key_].asInt64() : _value_ = _default_;
-#define JV_UINT(_json_, _key_, _value_, _default_) (_json_.isMember(_key_) && _json_[_key_].isUInt()) ? _value_ = _json_[_key_].asUInt() : _value_ = _default_;
-#define JV_UINT64(_json_, _key_, _value_, _default_) (_json_.isMember(_key_) && _json_[_key_].isUInt64()) ? _value_ = _json_[_key_].asUInt64() : _value_ = _default_;
-#define JV_BOOL(_json_, _key_, _value_, _default_) (_json_.isMember(_key_) && _json_[_key_].isBool()) ? _value_ = _json_[_key_].asBool() : _value_ = _default_;
-#define JV_DOUBLE(_json_, _key_, _value_, _default_) (_json_.isMember(_key_) && _json_[_key_].isDouble()) ? _value_ = _json_[_key_].asDouble() : _value_ = _default_;
-
-const std::string DEFAULT_STRING = "";
-const int DEFAULT_INT = 0;
-const bool DEFAULT_BOOL = false;
-const double DEFAULT_DOUBLE = 0;
-
-static bool ReadJsonFile(std::string file, Json::Value &json_data, std::ios_base::openmode mode = std::ios::in | std::ios::binary) {
-    std::fstream json_file;
-    json_file.open(file.c_str(), mode);
-
-    if(false == json_file.is_open()) {
-        return false;
-    }
-
-    bool ret = false;
-    Json::Reader json_reader;
-    ret = json_reader.parse(json_file, json_data);
-    json_file.close();
-
-    return ret;
-}
-
-static bool WriteJsonFile(std::string file, Json::Value &json_data, std::ios_base::openmode mode = std::ios::out | std::ios::trunc) {
-    std::fstream json_file;
-    json_file.open(file.c_str(), mode);
-
-    if(false == json_file.is_open()) {
-        return false;
-    }
-
-    json_file << json_data;
-    json_file.close();
-    return true;
-}
-#endif

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 2004
include/json/json_reader.cpp


+ 0 - 138
include/json/json_tool.h

@@ -1,138 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include <json/config.h>
-#endif
-
-// Also support old flag NO_LOCALE_SUPPORT
-#ifdef NO_LOCALE_SUPPORT
-#define JSONCPP_NO_LOCALE_SUPPORT
-#endif
-
-#ifndef JSONCPP_NO_LOCALE_SUPPORT
-#include <clocale>
-#endif
-
-/* This header provides common string manipulation support, such as UTF-8,
- * portable conversion from/to string...
- *
- * It is an internal header that must not be exposed.
- */
-
-namespace Json {
-static inline char getDecimalPoint() {
-#ifdef JSONCPP_NO_LOCALE_SUPPORT
-  return '\0';
-#else
-  struct lconv* lc = localeconv();
-  return lc ? *(lc->decimal_point) : '\0';
-#endif
-}
-
-/// Converts a unicode code-point to UTF-8.
-static inline String codePointToUTF8(unsigned int cp) {
-  String result;
-
-  // based on description from http://en.wikipedia.org/wiki/UTF-8
-
-  if (cp <= 0x7f) {
-    result.resize(1);
-    result[0] = static_cast<char>(cp);
-  } else if (cp <= 0x7FF) {
-    result.resize(2);
-    result[1] = static_cast<char>(0x80 | (0x3f & cp));
-    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
-  } else if (cp <= 0xFFFF) {
-    result.resize(3);
-    result[2] = static_cast<char>(0x80 | (0x3f & cp));
-    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
-    result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
-  } else if (cp <= 0x10FFFF) {
-    result.resize(4);
-    result[3] = static_cast<char>(0x80 | (0x3f & cp));
-    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
-    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
-    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
-  }
-
-  return result;
-}
-
-enum {
-  /// Constant that specify the size of the buffer that must be passed to
-  /// uintToString.
-  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1
-};
-
-// Defines a char buffer for use with uintToString().
-using UIntToStringBuffer = char[uintToStringBufferSize];
-
-/** Converts an unsigned integer to string.
- * @param value Unsigned integer to convert to string
- * @param current Input/Output string buffer.
- *        Must have at least uintToStringBufferSize chars free.
- */
-static inline void uintToString(LargestUInt value, char*& current) {
-  *--current = 0;
-  do {
-    *--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
-    value /= 10;
-  } while (value != 0);
-}
-
-/** Change ',' to '.' everywhere in buffer.
- *
- * We had a sophisticated way, but it did not work in WinCE.
- * @see https://github.com/open-source-parsers/jsoncpp/pull/9
- */
-template <typename Iter> Iter fixNumericLocale(Iter begin, Iter end) {
-  for (; begin != end; ++begin) {
-    if (*begin == ',') {
-      *begin = '.';
-    }
-  }
-  return begin;
-}
-
-template <typename Iter> void fixNumericLocaleInput(Iter begin, Iter end) {
-  char decimalPoint = getDecimalPoint();
-  if (decimalPoint == '\0' || decimalPoint == '.') {
-    return;
-  }
-  for (; begin != end; ++begin) {
-    if (*begin == '.') {
-      *begin = decimalPoint;
-    }
-  }
-}
-
-/**
- * Return iterator that would be the new end of the range [begin,end), if we
- * were to delete zeros in the end of string, but not the last zero before '.'.
- */
-template <typename Iter>
-Iter fixZerosInTheEnd(Iter begin, Iter end, unsigned int precision) {
-  for (; begin != end; --end) {
-    if (*(end - 1) != '0') {
-      return end;
-    }
-    // Don't delete the last zero before the decimal point.
-    if (begin != (end - 1) && begin != (end - 2) && *(end - 2) == '.') {
-      if (precision) {
-        return end;
-      }
-      return end - 2;
-    }
-  }
-  return end;
-}
-
-} // namespace Json
-
-#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 1634
include/json/json_value.cpp


+ 0 - 156
include/json/json_valueiterator.inl

@@ -1,156 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-// included by json_value.cpp
-
-namespace Json {
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIteratorBase
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIteratorBase::ValueIteratorBase() : current_() {}
-
-ValueIteratorBase::ValueIteratorBase(
-    const Value::ObjectValues::iterator& current)
-    : current_(current), isNull_(false) {}
-
-Value& ValueIteratorBase::deref() { return current_->second; }
-const Value& ValueIteratorBase::deref() const { return current_->second; }
-
-void ValueIteratorBase::increment() { ++current_; }
-
-void ValueIteratorBase::decrement() { --current_; }
-
-ValueIteratorBase::difference_type
-ValueIteratorBase::computeDistance(const SelfType& other) const {
-  // Iterator for null value are initialized using the default
-  // constructor, which initialize current_ to the default
-  // std::map::iterator. As begin() and end() are two instance
-  // of the default std::map::iterator, they can not be compared.
-  // To allow this, we handle this comparison specifically.
-  if (isNull_ && other.isNull_) {
-    return 0;
-  }
-
-  // Usage of std::distance is not portable (does not compile with Sun Studio 12
-  // RogueWave STL,
-  // which is the one used by default).
-  // Using a portable hand-made version for non random iterator instead:
-  //   return difference_type( std::distance( current_, other.current_ ) );
-  difference_type myDistance = 0;
-  for (Value::ObjectValues::iterator it = current_; it != other.current_;
-       ++it) {
-    ++myDistance;
-  }
-  return myDistance;
-}
-
-bool ValueIteratorBase::isEqual(const SelfType& other) const {
-  if (isNull_) {
-    return other.isNull_;
-  }
-  return current_ == other.current_;
-}
-
-void ValueIteratorBase::copy(const SelfType& other) {
-  current_ = other.current_;
-  isNull_ = other.isNull_;
-}
-
-Value ValueIteratorBase::key() const {
-  const Value::CZString czstring = (*current_).first;
-  if (czstring.data()) {
-    if (czstring.isStaticString())
-      return Value(StaticString(czstring.data()));
-    return Value(czstring.data(), czstring.data() + czstring.length());
-  }
-  return Value(czstring.index());
-}
-
-UInt ValueIteratorBase::index() const {
-  const Value::CZString czstring = (*current_).first;
-  if (!czstring.data())
-    return czstring.index();
-  return Value::UInt(-1);
-}
-
-String ValueIteratorBase::name() const {
-  char const* keey;
-  char const* end;
-  keey = memberName(&end);
-  if (!keey)
-    return String();
-  return String(keey, end);
-}
-
-char const* ValueIteratorBase::memberName() const {
-  const char* cname = (*current_).first.data();
-  return cname ? cname : "";
-}
-
-char const* ValueIteratorBase::memberName(char const** end) const {
-  const char* cname = (*current_).first.data();
-  if (!cname) {
-    *end = nullptr;
-    return nullptr;
-  }
-  *end = cname + (*current_).first.length();
-  return cname;
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueConstIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueConstIterator::ValueConstIterator() = default;
-
-ValueConstIterator::ValueConstIterator(
-    const Value::ObjectValues::iterator& current)
-    : ValueIteratorBase(current) {}
-
-ValueConstIterator::ValueConstIterator(ValueIterator const& other)
-    : ValueIteratorBase(other) {}
-
-ValueConstIterator& ValueConstIterator::
-operator=(const ValueIteratorBase& other) {
-  copy(other);
-  return *this;
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIterator::ValueIterator() = default;
-
-ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
-    : ValueIteratorBase(current) {}
-
-ValueIterator::ValueIterator(const ValueConstIterator& other)
-    : ValueIteratorBase(other) {
-  throwRuntimeError("ConstIterator to Iterator should never be allowed.");
-}
-
-ValueIterator::ValueIterator(const ValueIterator& other) = default;
-
-ValueIterator& ValueIterator::operator=(const SelfType& other) {
-  copy(other);
-  return *this;
-}
-
-} // namespace Json

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 1259
include/json/json_writer.cpp


+ 0 - 406
include/json/reader.h

@@ -1,406 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_READER_H_INCLUDED
-#define JSON_READER_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "json_features.h"
-#include "value.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <deque>
-#include <iosfwd>
-#include <istream>
-#include <stack>
-#include <string>
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#pragma pack(push)
-#pragma pack()
-
-namespace Json {
-
-/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
- * Value.
- *
- * \deprecated Use CharReader and CharReaderBuilder.
- */
-
-class JSON_API Reader {
-public:
-  using Char = char;
-  using Location = const Char*;
-
-  /** \brief An error tagged with where in the JSON text it was encountered.
-   *
-   * The offsets give the [start, limit) range of bytes within the text. Note
-   * that this is bytes, not codepoints.
-   */
-  struct StructuredError {
-    ptrdiff_t offset_start;
-    ptrdiff_t offset_limit;
-    String message;
-  };
-
-  /** \brief Constructs a Reader allowing all features for parsing.
-    * \deprecated Use CharReader and CharReaderBuilder.
-   */
-  Reader();
-
-  /** \brief Constructs a Reader allowing the specified feature set for parsing.
-    * \deprecated Use CharReader and CharReaderBuilder.
-   */
-  Reader(const Features& features);
-
-  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
-   * document.
-   *
-   * \param      document        UTF-8 encoded string containing the document
-   *                             to read.
-   * \param[out] root            Contains the root value of the document if it
-   *                             was successfully parsed.
-   * \param      collectComments \c true to collect comment and allow writing
-   *                             them back during serialization, \c false to
-   *                             discard comments.  This parameter is ignored
-   *                             if Features::allowComments_ is \c false.
-   * \return \c true if the document was successfully parsed, \c false if an
-   * error occurred.
-   */
-  bool parse(const std::string& document, Value& root,
-             bool collectComments = true);
-
-  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
-   * document.
-   *
-   * \param      beginDoc        Pointer on the beginning of the UTF-8 encoded
-   *                             string of the document to read.
-   * \param      endDoc          Pointer on the end of the UTF-8 encoded string
-   *                             of the document to read.  Must be >= beginDoc.
-   * \param[out] root            Contains the root value of the document if it
-   *                             was successfully parsed.
-   * \param      collectComments \c true to collect comment and allow writing
-   *                             them back during serialization, \c false to
-   *                             discard comments.  This parameter is ignored
-   *                             if Features::allowComments_ is \c false.
-   * \return \c true if the document was successfully parsed, \c false if an
-   * error occurred.
-   */
-  bool parse(const char* beginDoc, const char* endDoc, Value& root,
-             bool collectComments = true);
-
-  /// \brief Parse from input stream.
-  /// \see Json::operator>>(std::istream&, Json::Value&).
-  bool parse(IStream& is, Value& root, bool collectComments = true);
-
-  /** \brief Returns a user friendly string that list errors in the parsed
-   * document.
-   *
-   * \return Formatted error message with the list of errors with their
-   * location in the parsed document. An empty string is returned if no error
-   * occurred during parsing.
-   * \deprecated Use getFormattedErrorMessages() instead (typo fix).
-   */
-  JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
-  String getFormatedErrorMessages() const;
-
-  /** \brief Returns a user friendly string that list errors in the parsed
-   * document.
-   *
-   * \return Formatted error message with the list of errors with their
-   * location in the parsed document. An empty string is returned if no error
-   * occurred during parsing.
-   */
-  String getFormattedErrorMessages() const;
-
-  /** \brief Returns a vector of structured errors encountered while parsing.
-   *
-   * \return A (possibly empty) vector of StructuredError objects. Currently
-   * only one error can be returned, but the caller should tolerate multiple
-   * errors.  This can occur if the parser recovers from a non-fatal parse
-   * error and then encounters additional errors.
-   */
-  std::vector<StructuredError> getStructuredErrors() const;
-
-  /** \brief Add a semantic error message.
-   *
-   * \param value   JSON Value location associated with the error
-   * \param message The error message.
-   * \return \c true if the error was successfully added, \c false if the Value
-   * offset exceeds the document size.
-   */
-  bool pushError(const Value& value, const String& message);
-
-  /** \brief Add a semantic error message with extra context.
-   *
-   * \param value   JSON Value location associated with the error
-   * \param message The error message.
-   * \param extra   Additional JSON Value location to contextualize the error
-   * \return \c true if the error was successfully added, \c false if either
-   * Value offset exceeds the document size.
-   */
-  bool pushError(const Value& value, const String& message, const Value& extra);
-
-  /** \brief Return whether there are any errors.
-   *
-   * \return \c true if there are no errors to report \c false if errors have
-   * occurred.
-   */
-  bool good() const;
-
-private:
-  enum TokenType {
-    tokenEndOfStream = 0,
-    tokenObjectBegin,
-    tokenObjectEnd,
-    tokenArrayBegin,
-    tokenArrayEnd,
-    tokenString,
-    tokenNumber,
-    tokenTrue,
-    tokenFalse,
-    tokenNull,
-    tokenArraySeparator,
-    tokenMemberSeparator,
-    tokenComment,
-    tokenError
-  };
-
-  class Token {
-  public:
-    TokenType type_;
-    Location start_;
-    Location end_;
-  };
-
-  class ErrorInfo {
-  public:
-    Token token_;
-    String message_;
-    Location extra_;
-  };
-
-  using Errors = std::deque<ErrorInfo>;
-
-  bool readToken(Token& token);
-  void skipSpaces();
-  bool match(const Char* pattern, int patternLength);
-  bool readComment();
-  bool readCStyleComment();
-  bool readCppStyleComment();
-  bool readString();
-  void readNumber();
-  bool readValue();
-  bool readObject(Token& token);
-  bool readArray(Token& token);
-  bool decodeNumber(Token& token);
-  bool decodeNumber(Token& token, Value& decoded);
-  bool decodeString(Token& token);
-  bool decodeString(Token& token, String& decoded);
-  bool decodeDouble(Token& token);
-  bool decodeDouble(Token& token, Value& decoded);
-  bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
-                              unsigned int& unicode);
-  bool decodeUnicodeEscapeSequence(Token& token, Location& current,
-                                   Location end, unsigned int& unicode);
-  bool addError(const String& message, Token& token, Location extra = nullptr);
-  bool recoverFromError(TokenType skipUntilToken);
-  bool addErrorAndRecover(const String& message, Token& token,
-                          TokenType skipUntilToken);
-  void skipUntilSpace();
-  Value& currentValue();
-  Char getNextChar();
-  void getLocationLineAndColumn(Location location, int& line,
-                                int& column) const;
-  String getLocationLineAndColumn(Location location) const;
-  void addComment(Location begin, Location end, CommentPlacement placement);
-  void skipCommentTokens(Token& token);
-
-  static bool containsNewLine(Location begin, Location end);
-  static String normalizeEOL(Location begin, Location end);
-
-  using Nodes = std::stack<Value*>;
-  Nodes nodes_;
-  Errors errors_;
-  String document_;
-  Location begin_{};
-  Location end_{};
-  Location current_{};
-  Location lastValueEnd_{};
-  Value* lastValue_{};
-  String commentsBefore_;
-  Features features_;
-  bool collectComments_{};
-}; // Reader
-
-/** Interface for reading JSON from a char array.
- */
-class JSON_API CharReader {
-public:
-  virtual ~CharReader() = default;
-  /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
-   * document. The document must be a UTF-8 encoded string containing the
-   * document to read.
-   *
-   * \param      beginDoc Pointer on the beginning of the UTF-8 encoded string
-   *                      of the document to read.
-   * \param      endDoc   Pointer on the end of the UTF-8 encoded string of the
-   *                      document to read. Must be >= beginDoc.
-   * \param[out] root     Contains the root value of the document if it was
-   *                      successfully parsed.
-   * \param[out] errs     Formatted error messages (if not NULL) a user
-   *                      friendly string that lists errors in the parsed
-   *                      document.
-   * \return \c true if the document was successfully parsed, \c false if an
-   * error occurred.
-   */
-  virtual bool parse(char const* beginDoc, char const* endDoc, Value* root,
-                     String* errs) = 0;
-
-  class JSON_API Factory {
-  public:
-    virtual ~Factory() = default;
-    /** \brief Allocate a CharReader via operator new().
-     * \throw std::exception if something goes wrong (e.g. invalid settings)
-     */
-    virtual CharReader* newCharReader() const = 0;
-  }; // Factory
-};   // CharReader
-
-/** \brief Build a CharReader implementation.
- *
- * Usage:
- *   \code
- *   using namespace Json;
- *   CharReaderBuilder builder;
- *   builder["collectComments"] = false;
- *   Value value;
- *   String errs;
- *   bool ok = parseFromStream(builder, std::cin, &value, &errs);
- *   \endcode
- */
-class JSON_API CharReaderBuilder : public CharReader::Factory {
-public:
-  // Note: We use a Json::Value so that we can add data-members to this class
-  // without a major version bump.
-  /** Configuration of this builder.
-   * These are case-sensitive.
-   * Available settings (case-sensitive):
-   * - `"collectComments": false or true`
-   *   - true to collect comment and allow writing them back during
-   *     serialization, false to discard comments.  This parameter is ignored
-   *     if allowComments is false.
-   * - `"allowComments": false or true`
-   *   - true if comments are allowed.
-   * - `"allowTrailingCommas": false or true`
-   *   - true if trailing commas in objects and arrays are allowed.
-   * - `"strictRoot": false or true`
-   *   - true if root must be either an array or an object value
-   * - `"allowDroppedNullPlaceholders": false or true`
-   *   - true if dropped null placeholders are allowed. (See
-   *     StreamWriterBuilder.)
-   * - `"allowNumericKeys": false or true`
-   *   - true if numeric object keys are allowed.
-   * - `"allowSingleQuotes": false or true`
-   *   - true if '' are allowed for strings (both keys and values)
-   * - `"stackLimit": integer`
-   *   - Exceeding stackLimit (recursive depth of `readValue()`) will cause an
-   *     exception.
-   *   - This is a security issue (seg-faults caused by deeply nested JSON), so
-   *     the default is low.
-   * - `"failIfExtra": false or true`
-   *   - If true, `parse()` returns false when extra non-whitespace trails the
-   *     JSON value in the input string.
-   * - `"rejectDupKeys": false or true`
-   *   - If true, `parse()` returns false when a key is duplicated within an
-   *     object.
-   * - `"allowSpecialFloats": false or true`
-   *   - If true, special float values (NaNs and infinities) are allowed and
-   *     their values are lossfree restorable.
-   * - `"skipBom": false or true`
-   *   - If true, if the input starts with the Unicode byte order mark (BOM),
-   *     it is skipped.
-   *
-   * You can examine 'settings_` yourself to see the defaults. You can also
-   * write and read them just like any JSON Value.
-   * \sa setDefaults()
-   */
-  Json::Value settings_;
-
-  CharReaderBuilder();
-  ~CharReaderBuilder() override;
-
-  CharReader* newCharReader() const override;
-
-  /** \return true if 'settings' are legal and consistent;
-   *   otherwise, indicate bad settings via 'invalid'.
-   */
-  bool validate(Json::Value* invalid) const;
-
-  /** A simple way to update a specific setting.
-   */
-  Value& operator[](const String& key);
-
-  /** Called by ctor, but you can use this to reset settings_.
-   * \pre 'settings' != NULL (but Json::null is fine)
-   * \remark Defaults:
-   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
-   */
-  static void setDefaults(Json::Value* settings);
-  /** Same as old Features::strictMode().
-   * \pre 'settings' != NULL (but Json::null is fine)
-   * \remark Defaults:
-   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
-   */
-  static void strictMode(Json::Value* settings);
-};
-
-/** Consume entire stream and use its begin/end.
- * Someday we might have a real StreamReader, but for now this
- * is convenient.
- */
-bool JSON_API parseFromStream(CharReader::Factory const&, IStream&, Value* root,
-                              String* errs);
-
-/** \brief Read from 'sin' into 'root'.
- *
- * Always keep comments from the input JSON.
- *
- * This can be used to read a file into a particular sub-object.
- * For example:
- *   \code
- *   Json::Value root;
- *   cin >> root["dir"]["file"];
- *   cout << root;
- *   \endcode
- * Result:
- * \verbatim
- * {
- * "dir": {
- *    "file": {
- *    // The input stream JSON would be nested here.
- *    }
- * }
- * }
- * \endverbatim
- * \throw std::exception on parse error.
- * \see Json::operator<<()
- */
-JSON_API IStream& operator>>(IStream&, Value&);
-
-} // namespace Json
-
-#pragma pack(pop)
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // JSON_READER_H_INCLUDED

+ 0 - 5
include/json/test.cpp

@@ -1,5 +0,0 @@
-#include "test.h"
-
-int main(int argc, char** argv) {
-    return EXIT_SUCCESS;
-}

+ 0 - 3
include/json/test.h

@@ -1,3 +0,0 @@
-#pragma once
-
-#include <iostream>

+ 0 - 936
include/json/value.h

@@ -1,936 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_H_INCLUDED
-#define JSON_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "forwards.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-// Conditional NORETURN attribute on the throw functions would:
-// a) suppress false positives from static code analysis
-// b) possibly improve optimization opportunities.
-#if !defined(JSONCPP_NORETURN)
-#if defined(_MSC_VER) && _MSC_VER == 1800
-#define JSONCPP_NORETURN __declspec(noreturn)
-#else
-#define JSONCPP_NORETURN [[noreturn]]
-#endif
-#endif
-
-// Support for '= delete' with template declarations was a late addition
-// to the c++11 standard and is rejected by clang 3.8 and Apple clang 8.2
-// even though these declare themselves to be c++11 compilers.
-#if !defined(JSONCPP_TEMPLATE_DELETE)
-#if defined(__clang__) && defined(__apple_build_version__)
-#if __apple_build_version__ <= 8000042
-#define JSONCPP_TEMPLATE_DELETE
-#endif
-#elif defined(__clang__)
-#if __clang_major__ == 3 && __clang_minor__ <= 8
-#define JSONCPP_TEMPLATE_DELETE
-#endif
-#endif
-#if !defined(JSONCPP_TEMPLATE_DELETE)
-#define JSONCPP_TEMPLATE_DELETE = delete
-#endif
-#endif
-
-#include <array>
-#include <exception>
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251 4275)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#pragma pack(push)
-#pragma pack()
-
-/** \brief JSON (JavaScript Object Notation).
- */
-namespace Json {
-
-#if JSON_USE_EXCEPTION
-/** Base class for all exceptions we throw.
- *
- * We use nothing but these internally. Of course, STL can throw others.
- */
-class JSON_API Exception : public std::exception {
-public:
-  Exception(String msg);
-  ~Exception() noexcept override;
-  char const* what() const noexcept override;
-
-protected:
-  String msg_;
-};
-
-/** Exceptions which the user cannot easily avoid.
- *
- * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
- *
- * \remark derived from Json::Exception
- */
-class JSON_API RuntimeError : public Exception {
-public:
-  RuntimeError(String const& msg);
-};
-
-/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
- *
- * These are precondition-violations (user bugs) and internal errors (our bugs).
- *
- * \remark derived from Json::Exception
- */
-class JSON_API LogicError : public Exception {
-public:
-  LogicError(String const& msg);
-};
-#endif
-
-/// used internally
-JSONCPP_NORETURN void throwRuntimeError(String const& msg);
-/// used internally
-JSONCPP_NORETURN void throwLogicError(String const& msg);
-
-/** \brief Type of the value held by a Value object.
- */
-enum ValueType {
-  nullValue = 0, ///< 'null' value
-  intValue,      ///< signed integer value
-  uintValue,     ///< unsigned integer value
-  realValue,     ///< double value
-  stringValue,   ///< UTF-8 string value
-  booleanValue,  ///< bool value
-  arrayValue,    ///< array value (ordered list)
-  objectValue    ///< object value (collection of name/value pairs).
-};
-
-enum CommentPlacement {
-  commentBefore = 0,      ///< a comment placed on the line before a value
-  commentAfterOnSameLine, ///< a comment just after a value on the same line
-  commentAfter, ///< a comment on the line after a value (only make sense for
-  /// root value)
-  numberOfCommentPlacement
-};
-
-/** \brief Type of precision for formatting of real values.
- */
-enum PrecisionType {
-  significantDigits = 0, ///< we set max number of significant digits in string
-  decimalPlaces          ///< we set max number of digits after "." in string
-};
-
-/** \brief Lightweight wrapper to tag static string.
- *
- * Value constructor and objectValue member assignment takes advantage of the
- * StaticString and avoid the cost of string duplication when storing the
- * string or the member name.
- *
- * Example of usage:
- * \code
- * Json::Value aValue( StaticString("some text") );
- * Json::Value object;
- * static const StaticString code("code");
- * object[code] = 1234;
- * \endcode
- */
-class JSON_API StaticString {
-public:
-  explicit StaticString(const char* czstring) : c_str_(czstring) {}
-
-  operator const char*() const { return c_str_; }
-
-  const char* c_str() const { return c_str_; }
-
-private:
-  const char* c_str_;
-};
-
-/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
- *
- * This class is a discriminated union wrapper that can represents a:
- * - signed integer [range: Value::minInt - Value::maxInt]
- * - unsigned integer (range: 0 - Value::maxUInt)
- * - double
- * - UTF-8 string
- * - boolean
- * - 'null'
- * - an ordered list of Value
- * - collection of name/value pairs (javascript object)
- *
- * The type of the held value is represented by a #ValueType and
- * can be obtained using type().
- *
- * Values of an #objectValue or #arrayValue can be accessed using operator[]()
- * methods.
- * Non-const methods will automatically create the a #nullValue element
- * if it does not exist.
- * The sequence of an #arrayValue will be automatically resized and initialized
- * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
- *
- * The get() methods can be used to obtain default value in the case the
- * required element does not exist.
- *
- * It is possible to iterate over the list of member keys of an object using
- * the getMemberNames() method.
- *
- * \note #Value string-length fit in size_t, but keys must be < 2^30.
- * (The reason is an implementation detail.) A #CharReader will raise an
- * exception if a bound is exceeded to avoid security holes in your app,
- * but the Value API does *not* check bounds. That is the responsibility
- * of the caller.
- */
-class JSON_API Value {
-  friend class ValueIteratorBase;
-
-public:
-  using Members = std::vector<String>;
-  using iterator = ValueIterator;
-  using const_iterator = ValueConstIterator;
-  using UInt = Json::UInt;
-  using Int = Json::Int;
-#if defined(JSON_HAS_INT64)
-  using UInt64 = Json::UInt64;
-  using Int64 = Json::Int64;
-#endif // defined(JSON_HAS_INT64)
-  using LargestInt = Json::LargestInt;
-  using LargestUInt = Json::LargestUInt;
-  using ArrayIndex = Json::ArrayIndex;
-
-  // Required for boost integration, e. g. BOOST_TEST
-  using value_type = std::string;
-
-#if JSON_USE_NULLREF
-  // Binary compatibility kludges, do not use.
-  static const Value& null;
-  static const Value& nullRef;
-#endif
-
-  // null and nullRef are deprecated, use this instead.
-  static Value const& nullSingleton();
-
-  /// Minimum signed integer value that can be stored in a Json::Value.
-  static constexpr LargestInt minLargestInt =
-      LargestInt(~(LargestUInt(-1) / 2));
-  /// Maximum signed integer value that can be stored in a Json::Value.
-  static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
-  /// Maximum unsigned integer value that can be stored in a Json::Value.
-  static constexpr LargestUInt maxLargestUInt = LargestUInt(-1);
-
-  /// Minimum signed int value that can be stored in a Json::Value.
-  static constexpr Int minInt = Int(~(UInt(-1) / 2));
-  /// Maximum signed int value that can be stored in a Json::Value.
-  static constexpr Int maxInt = Int(UInt(-1) / 2);
-  /// Maximum unsigned int value that can be stored in a Json::Value.
-  static constexpr UInt maxUInt = UInt(-1);
-
-#if defined(JSON_HAS_INT64)
-  /// Minimum signed 64 bits int value that can be stored in a Json::Value.
-  static constexpr Int64 minInt64 = Int64(~(UInt64(-1) / 2));
-  /// Maximum signed 64 bits int value that can be stored in a Json::Value.
-  static constexpr Int64 maxInt64 = Int64(UInt64(-1) / 2);
-  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
-  static constexpr UInt64 maxUInt64 = UInt64(-1);
-#endif // defined(JSON_HAS_INT64)
-  /// Default precision for real value for string representation.
-  static constexpr UInt defaultRealPrecision = 17;
-  // The constant is hard-coded because some compiler have trouble
-  // converting Value::maxUInt64 to a double correctly (AIX/xlC).
-  // Assumes that UInt64 is a 64 bits integer.
-  static constexpr double maxUInt64AsDouble = 18446744073709551615.0;
-// Workaround for bug in the NVIDIAs CUDA 9.1 nvcc compiler
-// when using gcc and clang backend compilers.  CZString
-// cannot be defined as private.  See issue #486
-#ifdef __NVCC__
-public:
-#else
-private:
-#endif
-#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-  class CZString {
-  public:
-    enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
-    CZString(ArrayIndex index);
-    CZString(char const* str, unsigned length, DuplicationPolicy allocate);
-    CZString(CZString const& other);
-    CZString(CZString&& other) noexcept;
-    ~CZString();
-    CZString& operator=(const CZString& other);
-    CZString& operator=(CZString&& other) noexcept;
-
-    bool operator<(CZString const& other) const;
-    bool operator==(CZString const& other) const;
-    ArrayIndex index() const;
-    // const char* c_str() const; ///< \deprecated
-    char const* data() const;
-    unsigned length() const;
-    bool isStaticString() const;
-
-  private:
-    void swap(CZString& other);
-
-    struct StringStorage {
-      unsigned policy_ : 2;
-      unsigned length_ : 30; // 1GB max
-    };
-
-    char const* cstr_; // actually, a prefixed string, unless policy is noDup
-    union {
-      ArrayIndex index_;
-      StringStorage storage_;
-    };
-  };
-
-public:
-  typedef std::map<CZString, Value> ObjectValues;
-#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
-public:
-  /**
-   * \brief Create a default Value of the given type.
-   *
-   * This is a very useful constructor.
-   * To create an empty array, pass arrayValue.
-   * To create an empty object, pass objectValue.
-   * Another Value can then be set to this one by assignment.
-   * This is useful since clear() and resize() will not alter types.
-   *
-   * Examples:
-   *   \code
-   *   Json::Value null_value; // null
-   *   Json::Value arr_value(Json::arrayValue); // []
-   *   Json::Value obj_value(Json::objectValue); // {}
-   *   \endcode
-   */
-  Value(ValueType type = nullValue);
-  Value(Int value);
-  Value(UInt value);
-#if defined(JSON_HAS_INT64)
-  Value(Int64 value);
-  Value(UInt64 value);
-#endif // if defined(JSON_HAS_INT64)
-  Value(double value);
-  Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
-  Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
-  /**
-   * \brief Constructs a value from a static string.
-   *
-   * Like other value string constructor but do not duplicate the string for
-   * internal storage. The given string must remain alive after the call to
-   * this constructor.
-   *
-   * \note This works only for null-terminated strings. (We cannot change the
-   * size of this class, so we have nowhere to store the length, which might be
-   * computed later for various operations.)
-   *
-   * Example of usage:
-   *   \code
-   *   static StaticString foo("some text");
-   *   Json::Value aValue(foo);
-   *   \endcode
-   */
-  Value(const StaticString& value);
-  Value(const String& value);
-  Value(bool value);
-  Value(std::nullptr_t ptr) = delete;
-  Value(const Value& other);
-  Value(Value&& other) noexcept;
-  ~Value();
-
-  /// \note Overwrite existing comments. To preserve comments, use
-  /// #swapPayload().
-  Value& operator=(const Value& other);
-  Value& operator=(Value&& other) noexcept;
-
-  /// Swap everything.
-  void swap(Value& other);
-  /// Swap values but leave comments and source offsets in place.
-  void swapPayload(Value& other);
-
-  /// copy everything.
-  void copy(const Value& other);
-  /// copy values but leave comments and source offsets in place.
-  void copyPayload(const Value& other);
-
-  ValueType type() const;
-
-  /// Compare payload only, not comments etc.
-  bool operator<(const Value& other) const;
-  bool operator<=(const Value& other) const;
-  bool operator>=(const Value& other) const;
-  bool operator>(const Value& other) const;
-  bool operator==(const Value& other) const;
-  bool operator!=(const Value& other) const;
-  int compare(const Value& other) const;
-
-  const char* asCString() const; ///< Embedded zeroes could cause you trouble!
-#if JSONCPP_USING_SECURE_MEMORY
-  unsigned getCStringLength() const; // Allows you to understand the length of
-                                     // the CString
-#endif
-  String asString() const; ///< Embedded zeroes are possible.
-  /** Get raw char* of string-value.
-   *  \return false if !string. (Seg-fault if str or end are NULL.)
-   */
-  bool getString(char const** begin, char const** end) const;
-  Int asInt() const;
-  UInt asUInt() const;
-#if defined(JSON_HAS_INT64)
-  Int64 asInt64() const;
-  UInt64 asUInt64() const;
-#endif // if defined(JSON_HAS_INT64)
-  LargestInt asLargestInt() const;
-  LargestUInt asLargestUInt() const;
-  float asFloat() const;
-  double asDouble() const;
-  bool asBool() const;
-
-  bool isNull() const;
-  bool isBool() const;
-  bool isInt() const;
-  bool isInt64() const;
-  bool isUInt() const;
-  bool isUInt64() const;
-  bool isIntegral() const;
-  bool isDouble() const;
-  bool isNumeric() const;
-  bool isString() const;
-  bool isArray() const;
-  bool isObject() const;
-
-  /// The `as<T>` and `is<T>` member function templates and specializations.
-  template <typename T> T as() const JSONCPP_TEMPLATE_DELETE;
-  template <typename T> bool is() const JSONCPP_TEMPLATE_DELETE;
-
-  bool isConvertibleTo(ValueType other) const;
-
-  /// Number of values in array or object
-  ArrayIndex size() const;
-
-  /// \brief Return true if empty array, empty object, or null;
-  /// otherwise, false.
-  bool empty() const;
-
-  /// Return !isNull()
-  explicit operator bool() const;
-
-  /// Remove all object members and array elements.
-  /// \pre type() is arrayValue, objectValue, or nullValue
-  /// \post type() is unchanged
-  void clear();
-
-  /// Resize the array to newSize elements.
-  /// New elements are initialized to null.
-  /// May only be called on nullValue or arrayValue.
-  /// \pre type() is arrayValue or nullValue
-  /// \post type() is arrayValue
-  void resize(ArrayIndex newSize);
-
-  ///@{
-  /// Access an array element (zero based index). If the array contains less
-  /// than index element, then null value are inserted in the array so that
-  /// its size is index+1.
-  /// (You may need to say 'value[0u]' to get your compiler to distinguish
-  /// this from the operator[] which takes a string.)
-  Value& operator[](ArrayIndex index);
-  Value& operator[](int index);
-  ///@}
-
-  ///@{
-  /// Access an array element (zero based index).
-  /// (You may need to say 'value[0u]' to get your compiler to distinguish
-  /// this from the operator[] which takes a string.)
-  const Value& operator[](ArrayIndex index) const;
-  const Value& operator[](int index) const;
-  ///@}
-
-  /// If the array contains at least index+1 elements, returns the element
-  /// value, otherwise returns defaultValue.
-  Value get(ArrayIndex index, const Value& defaultValue) const;
-  /// Return true if index < size().
-  bool isValidIndex(ArrayIndex index) const;
-  /// \brief Append value to array at the end.
-  ///
-  /// Equivalent to jsonvalue[jsonvalue.size()] = value;
-  Value& append(const Value& value);
-  Value& append(Value&& value);
-
-  /// \brief Insert value in array at specific index
-  bool insert(ArrayIndex index, const Value& newValue);
-  bool insert(ArrayIndex index, Value&& newValue);
-
-  /// Access an object value by name, create a null member if it does not exist.
-  /// \note Because of our implementation, keys are limited to 2^30 -1 chars.
-  /// Exceeding that will cause an exception.
-  Value& operator[](const char* key);
-  /// Access an object value by name, returns null if there is no member with
-  /// that name.
-  const Value& operator[](const char* key) const;
-  /// Access an object value by name, create a null member if it does not exist.
-  /// \param key may contain embedded nulls.
-  Value& operator[](const String& key);
-  /// Access an object value by name, returns null if there is no member with
-  /// that name.
-  /// \param key may contain embedded nulls.
-  const Value& operator[](const String& key) const;
-  /** \brief Access an object value by name, create a null member if it does not
-   * exist.
-   *
-   * If the object has no entry for that name, then the member name used to
-   * store the new entry is not duplicated.
-   * Example of use:
-   *   \code
-   *   Json::Value object;
-   *   static const StaticString code("code");
-   *   object[code] = 1234;
-   *   \endcode
-   */
-  Value& operator[](const StaticString& key);
-  /// Return the member named key if it exist, defaultValue otherwise.
-  /// \note deep copy
-  Value get(const char* key, const Value& defaultValue) const;
-  /// Return the member named key if it exist, defaultValue otherwise.
-  /// \note deep copy
-  /// \note key may contain embedded nulls.
-  Value get(const char* begin, const char* end,
-            const Value& defaultValue) const;
-  /// Return the member named key if it exist, defaultValue otherwise.
-  /// \note deep copy
-  /// \param key may contain embedded nulls.
-  Value get(const String& key, const Value& defaultValue) const;
-  /// Most general and efficient version of isMember()const, get()const,
-  /// and operator[]const
-  /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
-  Value const* find(char const* begin, char const* end) const;
-  /// Most general and efficient version of object-mutators.
-  /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
-  /// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
-  Value* demand(char const* begin, char const* end);
-  /// \brief Remove and return the named member.
-  ///
-  /// Do nothing if it did not exist.
-  /// \pre type() is objectValue or nullValue
-  /// \post type() is unchanged
-  void removeMember(const char* key);
-  /// Same as removeMember(const char*)
-  /// \param key may contain embedded nulls.
-  void removeMember(const String& key);
-  /// Same as removeMember(const char* begin, const char* end, Value* removed),
-  /// but 'key' is null-terminated.
-  bool removeMember(const char* key, Value* removed);
-  /** \brief Remove the named map member.
-   *
-   *  Update 'removed' iff removed.
-   *  \param key may contain embedded nulls.
-   *  \return true iff removed (no exceptions)
-   */
-  bool removeMember(String const& key, Value* removed);
-  /// Same as removeMember(String const& key, Value* removed)
-  bool removeMember(const char* begin, const char* end, Value* removed);
-  /** \brief Remove the indexed array element.
-   *
-   *  O(n) expensive operations.
-   *  Update 'removed' iff removed.
-   *  \return true if removed (no exceptions)
-   */
-  bool removeIndex(ArrayIndex index, Value* removed);
-
-  /// Return true if the object has a member named key.
-  /// \note 'key' must be null-terminated.
-  bool isMember(const char* key) const;
-  /// Return true if the object has a member named key.
-  /// \param key may contain embedded nulls.
-  bool isMember(const String& key) const;
-  /// Same as isMember(String const& key)const
-  bool isMember(const char* begin, const char* end) const;
-
-  /// \brief Return a list of the member names.
-  ///
-  /// If null, return an empty list.
-  /// \pre type() is objectValue or nullValue
-  /// \post if type() was nullValue, it remains nullValue
-  Members getMemberNames() const;
-
-  /// \deprecated Always pass len.
-  JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
-  void setComment(const char* comment, CommentPlacement placement) {
-    setComment(String(comment, strlen(comment)), placement);
-  }
-  /// Comments must be //... or /* ... */
-  void setComment(const char* comment, size_t len, CommentPlacement placement) {
-    setComment(String(comment, len), placement);
-  }
-  /// Comments must be //... or /* ... */
-  void setComment(String comment, CommentPlacement placement);
-  bool hasComment(CommentPlacement placement) const;
-  /// Include delimiters and embedded newlines.
-  String getComment(CommentPlacement placement) const;
-
-  String toStyledString() const;
-
-  const_iterator begin() const;
-  const_iterator end() const;
-
-  iterator begin();
-  iterator end();
-
-  // Accessors for the [start, limit) range of bytes within the JSON text from
-  // which this value was parsed, if any.
-  void setOffsetStart(ptrdiff_t start);
-  void setOffsetLimit(ptrdiff_t limit);
-  ptrdiff_t getOffsetStart() const;
-  ptrdiff_t getOffsetLimit() const;
-
-private:
-  void setType(ValueType v) {
-    bits_.value_type_ = static_cast<unsigned char>(v);
-  }
-  bool isAllocated() const { return bits_.allocated_; }
-  void setIsAllocated(bool v) { bits_.allocated_ = v; }
-
-  void initBasic(ValueType type, bool allocated = false);
-  void dupPayload(const Value& other);
-  void releasePayload();
-  void dupMeta(const Value& other);
-
-  Value& resolveReference(const char* key);
-  Value& resolveReference(const char* key, const char* end);
-
-  // struct MemberNamesTransform
-  //{
-  //   typedef const char *result_type;
-  //   const char *operator()( const CZString &name ) const
-  //   {
-  //      return name.c_str();
-  //   }
-  //};
-
-  union ValueHolder {
-    LargestInt int_;
-    LargestUInt uint_;
-    double real_;
-    bool bool_;
-    char* string_; // if allocated_, ptr to { unsigned, char[] }.
-    ObjectValues* map_;
-  } value_;
-
-  struct {
-    // Really a ValueType, but types should agree for bitfield packing.
-    unsigned int value_type_ : 8;
-    // Unless allocated_, string_ must be null-terminated.
-    unsigned int allocated_ : 1;
-  } bits_;
-
-  class Comments {
-  public:
-    Comments() = default;
-    Comments(const Comments& that);
-    Comments(Comments&& that) noexcept;
-    Comments& operator=(const Comments& that);
-    Comments& operator=(Comments&& that) noexcept;
-    bool has(CommentPlacement slot) const;
-    String get(CommentPlacement slot) const;
-    void set(CommentPlacement slot, String comment);
-
-  private:
-    using Array = std::array<String, numberOfCommentPlacement>;
-    std::unique_ptr<Array> ptr_;
-  };
-  Comments comments_;
-
-  // [start, limit) byte offsets in the source JSON text from which this Value
-  // was extracted.
-  ptrdiff_t start_;
-  ptrdiff_t limit_;
-};
-
-template <> inline bool Value::as<bool>() const { return asBool(); }
-template <> inline bool Value::is<bool>() const { return isBool(); }
-
-template <> inline Int Value::as<Int>() const { return asInt(); }
-template <> inline bool Value::is<Int>() const { return isInt(); }
-
-template <> inline UInt Value::as<UInt>() const { return asUInt(); }
-template <> inline bool Value::is<UInt>() const { return isUInt(); }
-
-#if defined(JSON_HAS_INT64)
-template <> inline Int64 Value::as<Int64>() const { return asInt64(); }
-template <> inline bool Value::is<Int64>() const { return isInt64(); }
-
-template <> inline UInt64 Value::as<UInt64>() const { return asUInt64(); }
-template <> inline bool Value::is<UInt64>() const { return isUInt64(); }
-#endif
-
-template <> inline double Value::as<double>() const { return asDouble(); }
-template <> inline bool Value::is<double>() const { return isDouble(); }
-
-template <> inline String Value::as<String>() const { return asString(); }
-template <> inline bool Value::is<String>() const { return isString(); }
-
-/// These `as` specializations are type conversions, and do not have a
-/// corresponding `is`.
-template <> inline float Value::as<float>() const { return asFloat(); }
-template <> inline const char* Value::as<const char*>() const {
-  return asCString();
-}
-
-/** \brief Experimental and untested: represents an element of the "path" to
- * access a node.
- */
-class JSON_API PathArgument {
-public:
-  friend class Path;
-
-  PathArgument();
-  PathArgument(ArrayIndex index);
-  PathArgument(const char* key);
-  PathArgument(String key);
-
-private:
-  enum Kind { kindNone = 0, kindIndex, kindKey };
-  String key_;
-  ArrayIndex index_{};
-  Kind kind_{kindNone};
-};
-
-/** \brief Experimental and untested: represents a "path" to access a node.
- *
- * Syntax:
- * - "." => root node
- * - ".[n]" => elements at index 'n' of root node (an array value)
- * - ".name" => member named 'name' of root node (an object value)
- * - ".name1.name2.name3"
- * - ".[0][1][2].name1[3]"
- * - ".%" => member name is provided as parameter
- * - ".[%]" => index is provided as parameter
- */
-class JSON_API Path {
-public:
-  Path(const String& path, const PathArgument& a1 = PathArgument(),
-       const PathArgument& a2 = PathArgument(),
-       const PathArgument& a3 = PathArgument(),
-       const PathArgument& a4 = PathArgument(),
-       const PathArgument& a5 = PathArgument());
-
-  const Value& resolve(const Value& root) const;
-  Value resolve(const Value& root, const Value& defaultValue) const;
-  /// Creates the "path" to access the specified node and returns a reference on
-  /// the node.
-  Value& make(Value& root) const;
-
-private:
-  using InArgs = std::vector<const PathArgument*>;
-  using Args = std::vector<PathArgument>;
-
-  void makePath(const String& path, const InArgs& in);
-  void addPathInArg(const String& path, const InArgs& in,
-                    InArgs::const_iterator& itInArg, PathArgument::Kind kind);
-  static void invalidPath(const String& path, int location);
-
-  Args args_;
-};
-
-/** \brief base class for Value iterators.
- *
- */
-class JSON_API ValueIteratorBase {
-public:
-  using iterator_category = std::bidirectional_iterator_tag;
-  using size_t = unsigned int;
-  using difference_type = int;
-  using SelfType = ValueIteratorBase;
-
-  bool operator==(const SelfType& other) const { return isEqual(other); }
-
-  bool operator!=(const SelfType& other) const { return !isEqual(other); }
-
-  difference_type operator-(const SelfType& other) const {
-    return other.computeDistance(*this);
-  }
-
-  /// Return either the index or the member name of the referenced value as a
-  /// Value.
-  Value key() const;
-
-  /// Return the index of the referenced Value, or -1 if it is not an
-  /// arrayValue.
-  UInt index() const;
-
-  /// Return the member name of the referenced Value, or "" if it is not an
-  /// objectValue.
-  /// \note Avoid `c_str()` on result, as embedded zeroes are possible.
-  String name() const;
-
-  /// Return the member name of the referenced Value. "" if it is not an
-  /// objectValue.
-  /// \deprecated This cannot be used for UTF-8 strings, since there can be
-  /// embedded nulls.
-  JSONCPP_DEPRECATED("Use `key = name();` instead.")
-  char const* memberName() const;
-  /// Return the member name of the referenced Value, or NULL if it is not an
-  /// objectValue.
-  /// \note Better version than memberName(). Allows embedded nulls.
-  char const* memberName(char const** end) const;
-
-protected:
-  /*! Internal utility functions to assist with implementing
-   *   other iterator functions. The const and non-const versions
-   *   of the "deref" protected methods expose the protected
-   *   current_ member variable in a way that can often be
-   *   optimized away by the compiler.
-   */
-  const Value& deref() const;
-  Value& deref();
-
-  void increment();
-
-  void decrement();
-
-  difference_type computeDistance(const SelfType& other) const;
-
-  bool isEqual(const SelfType& other) const;
-
-  void copy(const SelfType& other);
-
-private:
-  Value::ObjectValues::iterator current_;
-  // Indicates that iterator is for a null value.
-  bool isNull_{true};
-
-public:
-  // For some reason, BORLAND needs these at the end, rather
-  // than earlier. No idea why.
-  ValueIteratorBase();
-  explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
-};
-
-/** \brief const iterator for object and array value.
- *
- */
-class JSON_API ValueConstIterator : public ValueIteratorBase {
-  friend class Value;
-
-public:
-  using value_type = const Value;
-  // typedef unsigned int size_t;
-  // typedef int difference_type;
-  using reference = const Value&;
-  using pointer = const Value*;
-  using SelfType = ValueConstIterator;
-
-  ValueConstIterator();
-  ValueConstIterator(ValueIterator const& other);
-
-private:
-  /*! \internal Use by Value to create an iterator.
-   */
-  explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
-
-public:
-  SelfType& operator=(const ValueIteratorBase& other);
-
-  SelfType operator++(int) {
-    SelfType temp(*this);
-    ++*this;
-    return temp;
-  }
-
-  SelfType operator--(int) {
-    SelfType temp(*this);
-    --*this;
-    return temp;
-  }
-
-  SelfType& operator--() {
-    decrement();
-    return *this;
-  }
-
-  SelfType& operator++() {
-    increment();
-    return *this;
-  }
-
-  reference operator*() const { return deref(); }
-
-  pointer operator->() const { return &deref(); }
-};
-
-/** \brief Iterator for object and array value.
- */
-class JSON_API ValueIterator : public ValueIteratorBase {
-  friend class Value;
-
-public:
-  using value_type = Value;
-  using size_t = unsigned int;
-  using difference_type = int;
-  using reference = Value&;
-  using pointer = Value*;
-  using SelfType = ValueIterator;
-
-  ValueIterator();
-  explicit ValueIterator(const ValueConstIterator& other);
-  ValueIterator(const ValueIterator& other);
-
-private:
-  /*! \internal Use by Value to create an iterator.
-   */
-  explicit ValueIterator(const Value::ObjectValues::iterator& current);
-
-public:
-  SelfType& operator=(const SelfType& other);
-
-  SelfType operator++(int) {
-    SelfType temp(*this);
-    ++*this;
-    return temp;
-  }
-
-  SelfType operator--(int) {
-    SelfType temp(*this);
-    --*this;
-    return temp;
-  }
-
-  SelfType& operator--() {
-    decrement();
-    return *this;
-  }
-
-  SelfType& operator++() {
-    increment();
-    return *this;
-  }
-
-  /*! The return value of non-const iterators can be
-   *  changed, so the these functions are not const
-   *  because the returned references/pointers can be used
-   *  to change state of the base class.
-   */
-  reference operator*() const { return const_cast<reference>(deref()); }
-  pointer operator->() const { return const_cast<pointer>(&deref()); }
-};
-
-inline void swap(Value& a, Value& b) { a.swap(b); }
-
-} // namespace Json
-
-#pragma pack(pop)
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // JSON_H_INCLUDED

+ 0 - 28
include/json/version.h

@@ -1,28 +0,0 @@
-#ifndef JSON_VERSION_H_INCLUDED
-#define JSON_VERSION_H_INCLUDED
-
-// Note: version must be updated in three places when doing a release. This
-// annoying process ensures that amalgamate, CMake, and meson all report the
-// correct version.
-// 1. /meson.build
-// 2. /include/json/version.h
-// 3. /CMakeLists.txt
-// IMPORTANT: also update the SOVERSION!!
-
-#define JSONCPP_VERSION_STRING "1.9.5"
-#define JSONCPP_VERSION_MAJOR 1
-#define JSONCPP_VERSION_MINOR 9
-#define JSONCPP_VERSION_PATCH 5
-#define JSONCPP_VERSION_QUALIFIER
-#define JSONCPP_VERSION_HEXA                                                   \
-  ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) |             \
-   (JSONCPP_VERSION_PATCH << 8))
-
-#ifdef JSONCPP_USING_SECURE_MEMORY
-#undef JSONCPP_USING_SECURE_MEMORY
-#endif
-#define JSONCPP_USING_SECURE_MEMORY 0
-// If non-zero, the library zeroes any memory that it has allocated before
-// it frees its memory.
-
-#endif // JSON_VERSION_H_INCLUDED

+ 0 - 370
include/json/writer.h

@@ -1,370 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_WRITER_H_INCLUDED
-#define JSON_WRITER_H_INCLUDED
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "value.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <ostream>
-#include <string>
-#include <vector>
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#pragma pack(push)
-#pragma pack()
-
-namespace Json {
-
-class Value;
-
-/**
- *
- * Usage:
- *  \code
- *  using namespace Json;
- *  void writeToStdout(StreamWriter::Factory const& factory, Value const& value)
- * { std::unique_ptr<StreamWriter> const writer( factory.newStreamWriter());
- *    writer->write(value, &std::cout);
- *    std::cout << std::endl;  // add lf and flush
- *  }
- *  \endcode
- */
-class JSON_API StreamWriter {
-protected:
-  OStream* sout_; // not owned; will not delete
-public:
-  StreamWriter();
-  virtual ~StreamWriter();
-  /** Write Value into document as configured in sub-class.
-   *   Do not take ownership of sout, but maintain a reference during function.
-   *   \pre sout != NULL
-   *   \return zero on success (For now, we always return zero, so check the
-   *   stream instead.) \throw std::exception possibly, depending on
-   * configuration
-   */
-  virtual int write(Value const& root, OStream* sout) = 0;
-
-  /** \brief A simple abstract factory.
-   */
-  class JSON_API Factory {
-  public:
-    virtual ~Factory();
-    /** \brief Allocate a CharReader via operator new().
-     * \throw std::exception if something goes wrong (e.g. invalid settings)
-     */
-    virtual StreamWriter* newStreamWriter() const = 0;
-  }; // Factory
-};   // StreamWriter
-
-/** \brief Write into stringstream, then return string, for convenience.
- * A StreamWriter will be created from the factory, used, and then deleted.
- */
-String JSON_API writeString(StreamWriter::Factory const& factory,
-                            Value const& root);
-
-/** \brief Build a StreamWriter implementation.
-
-* Usage:
-*   \code
-*   using namespace Json;
-*   Value value = ...;
-*   StreamWriterBuilder builder;
-*   builder["commentStyle"] = "None";
-*   builder["indentation"] = "   ";  // or whatever you like
-*   std::unique_ptr<Json::StreamWriter> writer(
-*      builder.newStreamWriter());
-*   writer->write(value, &std::cout);
-*   std::cout << std::endl;  // add lf and flush
-*   \endcode
-*/
-class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
-public:
-  // Note: We use a Json::Value so that we can add data-members to this class
-  // without a major version bump.
-  /** Configuration of this builder.
-   *  Available settings (case-sensitive):
-   *  - "commentStyle": "None" or "All"
-   *  - "indentation":  "<anything>".
-   *  - Setting this to an empty string also omits newline characters.
-   *  - "enableYAMLCompatibility": false or true
-   *  - slightly change the whitespace around colons
-   *  - "dropNullPlaceholders": false or true
-   *  - Drop the "null" string from the writer's output for nullValues.
-   *    Strictly speaking, this is not valid JSON. But when the output is being
-   *    fed to a browser's JavaScript, it makes for smaller output and the
-   *    browser can handle the output just fine.
-   *  - "useSpecialFloats": false or true
-   *  - If true, outputs non-finite floating point values in the following way:
-   *    NaN values as "NaN", positive infinity as "Infinity", and negative
-   *  infinity as "-Infinity".
-   *  - "precision": int
-   *  - Number of precision digits for formatting of real values.
-   *  - "precisionType": "significant"(default) or "decimal"
-   *  - Type of precision for formatting of real values.
-   *  - "emitUTF8": false or true
-   *  - If true, outputs raw UTF8 strings instead of escaping them.
-
-   *  You can examine 'settings_` yourself
-   *  to see the defaults. You can also write and read them just like any
-   *  JSON Value.
-   *  \sa setDefaults()
-   */
-  Json::Value settings_;
-
-  StreamWriterBuilder();
-  ~StreamWriterBuilder() override;
-
-  /**
-   * \throw std::exception if something goes wrong (e.g. invalid settings)
-   */
-  StreamWriter* newStreamWriter() const override;
-
-  /** \return true if 'settings' are legal and consistent;
-   *   otherwise, indicate bad settings via 'invalid'.
-   */
-  bool validate(Json::Value* invalid) const;
-  /** A simple way to update a specific setting.
-   */
-  Value& operator[](const String& key);
-
-  /** Called by ctor, but you can use this to reset settings_.
-   * \pre 'settings' != NULL (but Json::null is fine)
-   * \remark Defaults:
-   * \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
-   */
-  static void setDefaults(Json::Value* settings);
-};
-
-/** \brief Abstract class for writers.
- * \deprecated Use StreamWriter. (And really, this is an implementation detail.)
- */
-class JSON_API Writer {
-public:
-  virtual ~Writer();
-
-  virtual String write(const Value& root) = 0;
-};
-
-/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
- *without formatting (not human friendly).
- *
- * The JSON document is written in a single line. It is not intended for 'human'
- *consumption,
- * but may be useful to support feature such as RPC where bandwidth is limited.
- * \sa Reader, Value
- * \deprecated Use StreamWriterBuilder.
- */
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4996) // Deriving from deprecated class
-#endif
-class JSON_API FastWriter
-    : public Writer {
-public:
-  FastWriter();
-  ~FastWriter() override = default;
-
-  void enableYAMLCompatibility();
-
-  /** \brief Drop the "null" string from the writer's output for nullValues.
-   * Strictly speaking, this is not valid JSON. But when the output is being
-   * fed to a browser's JavaScript, it makes for smaller output and the
-   * browser can handle the output just fine.
-   */
-  void dropNullPlaceholders();
-
-  void omitEndingLineFeed();
-
-public: // overridden from Writer
-  String write(const Value& root) override;
-
-private:
-  void writeValue(const Value& value);
-
-  String document_;
-  bool yamlCompatibilityEnabled_{false};
-  bool dropNullPlaceholders_{false};
-  bool omitEndingLineFeed_{false};
-};
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
-
-/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
- *human friendly way.
- *
- * The rules for line break and indent are as follow:
- * - Object value:
- *     - if empty then print {} without indent and line break
- *     - if not empty the print '{', line break & indent, print one value per
- *line
- *       and then unindent and line break and print '}'.
- * - Array value:
- *     - if empty then print [] without indent and line break
- *     - if the array contains no object value, empty array or some other value
- *types,
- *       and all the values fit on one lines, then print the array on a single
- *line.
- *     - otherwise, it the values do not fit on one line, or the array contains
- *       object or non empty array, then print one value per line.
- *
- * If the Value have comments then they are outputted according to their
- *#CommentPlacement.
- *
- * \sa Reader, Value, Value::setComment()
- * \deprecated Use StreamWriterBuilder.
- */
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4996) // Deriving from deprecated class
-#endif
-class JSON_API
-    StyledWriter : public Writer {
-public:
-  StyledWriter();
-  ~StyledWriter() override = default;
-
-public: // overridden from Writer
-  /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
-   * \param root Value to serialize.
-   * \return String containing the JSON document that represents the root value.
-   */
-  String write(const Value& root) override;
-
-private:
-  void writeValue(const Value& value);
-  void writeArrayValue(const Value& value);
-  bool isMultilineArray(const Value& value);
-  void pushValue(const String& value);
-  void writeIndent();
-  void writeWithIndent(const String& value);
-  void indent();
-  void unindent();
-  void writeCommentBeforeValue(const Value& root);
-  void writeCommentAfterValueOnSameLine(const Value& root);
-  static bool hasCommentForValue(const Value& value);
-  static String normalizeEOL(const String& text);
-
-  using ChildValues = std::vector<String>;
-
-  ChildValues childValues_;
-  String document_;
-  String indentString_;
-  unsigned int rightMargin_{74};
-  unsigned int indentSize_{3};
-  bool addChildValues_{false};
-};
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
-
-/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
- human friendly way,
-     to a stream rather than to a string.
- *
- * The rules for line break and indent are as follow:
- * - Object value:
- *     - if empty then print {} without indent and line break
- *     - if not empty the print '{', line break & indent, print one value per
- line
- *       and then unindent and line break and print '}'.
- * - Array value:
- *     - if empty then print [] without indent and line break
- *     - if the array contains no object value, empty array or some other value
- types,
- *       and all the values fit on one lines, then print the array on a single
- line.
- *     - otherwise, it the values do not fit on one line, or the array contains
- *       object or non empty array, then print one value per line.
- *
- * If the Value have comments then they are outputted according to their
- #CommentPlacement.
- *
- * \sa Reader, Value, Value::setComment()
- * \deprecated Use StreamWriterBuilder.
- */
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4996) // Deriving from deprecated class
-#endif
-class JSON_API
-    StyledStreamWriter {
-public:
-  /**
-   * \param indentation Each level will be indented by this amount extra.
-   */
-  StyledStreamWriter(String indentation = "\t");
-  ~StyledStreamWriter() = default;
-
-public:
-  /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
-   * \param out Stream to write to. (Can be ostringstream, e.g.)
-   * \param root Value to serialize.
-   * \note There is no point in deriving from Writer, since write() should not
-   * return a value.
-   */
-  void write(OStream& out, const Value& root);
-
-private:
-  void writeValue(const Value& value);
-  void writeArrayValue(const Value& value);
-  bool isMultilineArray(const Value& value);
-  void pushValue(const String& value);
-  void writeIndent();
-  void writeWithIndent(const String& value);
-  void indent();
-  void unindent();
-  void writeCommentBeforeValue(const Value& root);
-  void writeCommentAfterValueOnSameLine(const Value& root);
-  static bool hasCommentForValue(const Value& value);
-  static String normalizeEOL(const String& text);
-
-  using ChildValues = std::vector<String>;
-
-  ChildValues childValues_;
-  OStream* document_;
-  String indentString_;
-  unsigned int rightMargin_{74};
-  String indentation_;
-  bool addChildValues_ : 1;
-  bool indented_ : 1;
-};
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
-
-#if defined(JSON_HAS_INT64)
-String JSON_API valueToString(Int value);
-String JSON_API valueToString(UInt value);
-#endif // if defined(JSON_HAS_INT64)
-String JSON_API valueToString(LargestInt value);
-String JSON_API valueToString(LargestUInt value);
-String JSON_API valueToString(
-    double value, unsigned int precision = Value::defaultRealPrecision,
-    PrecisionType precisionType = PrecisionType::significantDigits);
-String JSON_API valueToString(bool value);
-String JSON_API valueToQuotedString(const char* value);
-
-/// \brief Output using the StyledStreamWriter.
-/// \see Json::operator>>()
-JSON_API OStream& operator<<(OStream&, const Value& root);
-
-} // namespace Json
-
-#pragma pack(pop)
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // JSON_WRITER_H_INCLUDED

+ 0 - 32
include/log/CMakeLists.txt

@@ -1,32 +0,0 @@
-set(LIBRARY_NAME liblog)
-
-if (NOT ENABLE_LIBRARY_FILE)
-    message(FATAL_ERROR "Not enable ENABLE_LIBRARY_FILE")
-endif ()
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
-message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
-
-set(LIBRARY_SOURCE_LIST
-        ${CMAKE_CURRENT_LIST_DIR}/log.h
-        ${CMAKE_CURRENT_LIST_DIR}/log.cpp
-)
-
-set(LIBRARY_DEPEND_LIST
-        libfile
-        -lgflags
-        glog::glog
-)
-
-add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
-target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
-
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 0 - 5
include/log/log.cpp

@@ -1,5 +0,0 @@
-//
-// Created by zx on 2023/10/26.
-//
-
-#include "log.h"

+ 0 - 5
include/log/test.cpp

@@ -1,5 +0,0 @@
-#include "test.h"
-
-int main(int argc, char** argv) {
-    return EXIT_SUCCESS;
-}

+ 0 - 3
include/log/test.h

@@ -1,3 +0,0 @@
-#pragma once
-
-#include <iostream>

+ 1 - 14
include/message/CMakeLists.txt

@@ -1,8 +1,4 @@
-set(LIBRARY_NAME libmessage)
-
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
-message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
+set(LIBRARY_NAME zxmessage)
 
 # 获取当前目录下的所有源文件
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR} GLOB_RECURSE)
@@ -16,12 +12,3 @@ set(LIBRARY_DEPEND_LIST)
 add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
 target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
 
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 14 - 0
include/pahoc/CMakeLists.txt

@@ -0,0 +1,14 @@
+set(LIBRARY_NAME zxpahoc)
+
+# 获取当前目录下的所有源文件
+aux_source_directory(${CMAKE_CURRENT_LIST_DIR} GLOB_RECURSE)
+
+set(LIBRARY_SOURCE_LIST
+        ${GLOB_RECURSE}
+)
+
+set(LIBRARY_DEPEND_LIST paho-mqtt3a)
+
+add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
+target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
+

+ 13 - 0
include/pahoc/main.cpp

@@ -0,0 +1,13 @@
+//
+// Created by zx on 2023/12/8.
+//
+
+#include "mqtt_communication.h"
+
+int main(int argc, char** argv) {
+    Tof3DMqttAsyncClient::iter()->init("mqtt.json");
+    while (1) {
+        usleep(1000 * 1000);
+    }
+    return 1;
+}

+ 349 - 0
include/pahoc/mqtt_async.cpp

@@ -0,0 +1,349 @@
+#include "mqtt_async.h"
+
+MqttAsyncClient::MqttAsyncClient(/* args */) {
+    m_etc_ = new MqttAsyncConfig();
+    m_client_ = nullptr;
+    m_message_arrived_callback_ = nullptr;
+    m_connect_lost_callback_ = nullptr;
+    m_connect_success_ = nullptr;
+    m_disconnect_success_ = nullptr;
+    m_subscribe_success_ = nullptr;
+    m_unsubscribe_success_ = nullptr;
+    m_send_success_ = nullptr;
+    m_connect_failure_ = nullptr;
+    m_disconnect_failure_ = nullptr;
+    m_subscribe_failure_ = nullptr;
+    m_unsubscribe_failure_ = nullptr;
+    m_send_failure_ = nullptr;
+}
+
+MqttAsyncClient::~MqttAsyncClient() {
+    Disconnect();
+    MQTTAsync_destroy(&m_client_);
+}
+
+bool MqttAsyncClient::init_from_proto(const std::string &path) {
+    auto ret = loadProtobufFile(path, *m_etc_);
+    LOG(INFO) << m_etc_->DebugString();
+    if (ret != SUCCESS) {
+        LOG(ERROR) << "init config proto error from " << path;
+        return false;
+    }
+
+    m_create_opts.maxBufferedMessages = m_etc_->create_opts().maxbufferedmessages();
+
+    m_connect_ops.cleansession = m_etc_->connect_ops().cleansession();
+    m_connect_ops.keepAliveInterval = m_etc_->connect_ops().keepaliveinterval();
+    m_connect_ops.automaticReconnect = m_etc_->connect_ops().automaticreconnect();
+    m_connect_ops.minRetryInterval = m_etc_->connect_ops().minretryinterval();
+    m_connect_ops.maxRetryInterval = m_etc_->connect_ops().maxretryinterval();
+
+    if (m_etc_->client_id() == "Auto") {
+        m_etc_->set_client_id(std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
+    }
+    LOG(INFO) << m_etc_->client_id();
+    Connect(m_etc_->address(), m_etc_->client_id());
+    return true;
+}
+
+bool MqttAsyncClient::Connect(const std::string &address, const std::string &client_id) {
+    int ret = MQTTASYNC_FAILURE;
+    if ((ret = MQTTAsync_createWithOptions(&m_client_, address.c_str(), client_id.c_str(), MQTTCLIENT_PERSISTENCE_NONE,
+                                           nullptr, &m_create_opts)
+               != MQTTASYNC_SUCCESS)) {
+        LOG(ERROR) << "Failed to create client object, return code " << ret;
+        return false;
+    } else {
+        DLOG(INFO) << "Success to create client object: " << address << ", client id: " << client_id << ".";
+    }
+
+    if ((ret = MQTTAsync_setCallbacks(m_client_, this, onMessageLost, onMessageArrived, nullptr)) !=
+        MQTTASYNC_SUCCESS) {
+        LOG(ERROR) << "Failed to set callback, return code " << ret;
+        return false;
+    }
+
+    if ((ret = MQTTAsync_setConnected(m_client_, this, onConnected)) != MQTTASYNC_SUCCESS) {
+        printf("Failed to set connected callback, return code %d\n", ret);
+        return false;
+    }
+
+    if ((ret = MQTTAsync_connect(m_client_, &m_connect_ops)) != MQTTASYNC_SUCCESS) {
+        printf("Failed to start connect, return code %d\n", ret);
+        return false;
+    }
+
+    return true;
+}
+
+bool MqttAsyncClient::Disconnect() {
+    DLOG(INFO) << __func__;
+    int ret = MQTTASYNC_FAILURE;
+
+    MQTTAsync_disconnectOptions opts = MQTTAsync_disconnectOptions_initializer;
+
+    opts.timeout = 30;
+    opts.context = this;
+    opts.onSuccess = onDisconnectSuccess;
+    opts.onFailure = onDisconnectFailure;
+
+    if ((ret = MQTTAsync_disconnect(m_client_, &opts)) != MQTTASYNC_SUCCESS) {
+        printf("Failed to disconnect, return code %d\n", ret);
+        return false;
+    }
+    return true;
+}
+
+bool MqttAsyncClient::isConnected() {
+    return MQTTAsync_isConnected(m_client_);
+}
+
+bool MqttAsyncClient::SendMessage(const std::string& topic, void *message, int length, int qos) {
+    if (message == nullptr) {
+        return false;
+    }
+
+    int ret = MQTTASYNC_FAILURE;
+
+    MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+    MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+
+    opts.context = this;
+    opts.onSuccess = onSendMessageSuccess;
+    opts.onFailure = onSendMessageFailure;
+
+    pubmsg.payload = message;
+    pubmsg.payloadlen = length;
+    pubmsg.retained = 0;
+    m_etc_->sendmessage().size();
+//    if (m_etc.findsendMessageEtc(topic) != nullptr) {
+//        pubmsg.qos = m_etc.findsendMessageEtc(topic)->qos;
+//    } else {
+    pubmsg.qos = qos;
+//    }
+
+    if ((ret = MQTTAsync_sendMessage(m_client_, topic.c_str(), &pubmsg, &opts)) != MQTTASYNC_SUCCESS) {
+        printf("Failed to start sendMessage, return code %d, connect statu %d\n", ret, MQTTAsync_isConnected(m_client_));
+        return false;
+    }
+    return true;
+}
+
+void MqttAsyncClient::setCallback(MessageArrived callback) {
+    DLOG(INFO) << __func__;
+    m_message_arrived_callback_ = callback;
+}
+
+void MqttAsyncClient::setCallback(ConnectionLost callback) {
+    DLOG(INFO) << __func__;
+    m_connect_lost_callback_ = callback;
+}
+
+bool MqttAsyncClient::setCallback(OnSuccess callback, const std::string &function) {
+    DLOG(INFO) << __func__;
+    bool ret = true;
+    if (function == "subscribe") {
+        m_subscribe_success_ = callback;
+    } else if (function == "unsubscribe") {
+        m_unsubscribe_success_ = callback;
+    } else if (function == "send") {
+        m_send_success_ = callback;
+    } else if (function == "connect") {
+        m_connect_success_ = callback;
+    } else if (function == "disconnect") {
+        m_disconnect_success_ = callback;
+    } else {
+        ret = false;
+    }
+
+    return ret;
+}
+
+bool MqttAsyncClient::setCallback(OnFailure callback, const std::string &function) {
+    DLOG(INFO) << __func__ << function;
+    bool ret = true;
+    if (function == "subscribe") {
+        m_subscribe_failure_ = callback;
+    } else if (function == "unsubscribe") {
+        m_unsubscribe_failure_ = callback;
+    } else if (function == "send") {
+        m_send_failure_ = callback;
+    } else if (function == "connect") {
+        m_connect_failure_ = callback;
+    } else if (function == "disconnect") {
+        m_disconnect_failure_ = callback;
+    } else {
+        ret = false;
+    }
+
+    return ret;
+}
+
+google::protobuf::RepeatedPtrField<SubscribeEtc> MqttAsyncClient::getSubscribeEtc() {
+    return m_etc_->subscribe();
+}
+
+bool MqttAsyncClient::Subscribe(const std::string &topic, int qos) {
+    int ret = MQTTASYNC_FAILURE;
+
+    MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+
+    opts.context = this;
+    opts.onSuccess = onSubscribeSuccess;
+    opts.onFailure = onSubscribeFailure;
+
+    if ((ret = MQTTAsync_subscribe(m_client_, topic.c_str(), qos, &opts)) != MQTTASYNC_SUCCESS) {
+        DLOG(INFO) << "Failed to subscribe " << topic << ", return code " << ret;
+    } else {
+        DLOG(INFO) << "Success to subscribe " << topic;
+    }
+
+    return true;
+}
+
+bool MqttAsyncClient::unSubscribe(const std::string &topic) {
+    DLOG(INFO) << __func__;
+    int ret = MQTTASYNC_FAILURE;
+
+    MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+
+    opts.context = this;
+    opts.onSuccess = onUnSubscribeSuccess;
+    opts.onFailure = onUnSubscribeFailure;
+
+    if ((ret = MQTTAsync_unsubscribe(m_client_, topic.c_str(), &opts)) != MQTTASYNC_SUCCESS) {
+        printf("Failed to subscribe %s, return code %d\n", topic.c_str(), ret);
+        return false;
+    }
+
+    return true;
+}
+
+int MqttAsyncClient::onMessageArrived(void *context, char *topicName, int topicLen, MQTTAsync_message *message) {
+    bool ret = true;
+    auto *client = (MqttAsyncClient *) context;
+
+    if (client->m_message_arrived_callback_ != nullptr) {
+        ret = client->m_message_arrived_callback_(client, topicName, topicLen, message);
+    } else {
+    }
+
+    MQTTAsync_freeMessage(&message);
+    MQTTAsync_free(topicName);
+
+    return ret;
+}
+
+void MqttAsyncClient::onMessageLost(void *context, char *cause) {
+    if (context == nullptr || cause == nullptr) {
+        DLOG(INFO) << __func__;
+    }
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_connect_lost_callback_ != nullptr) {
+        client->m_connect_lost_callback_(client, cause);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onConnectSuccess(void *context, MQTTAsync_successData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_connect_success_ != nullptr) {
+        DLOG(INFO) << "run m_connect_success_.";
+        client->m_connect_success_(client, response);
+    }
+    DLOG(INFO) << "m_connect_success_ is nullptr.";
+}
+
+void MqttAsyncClient::onConnectFailure(void *context, MQTTAsync_failureData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_connect_failure_ != nullptr) {
+        client->m_connect_failure_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onDisconnectSuccess(void *context, MQTTAsync_successData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_disconnect_success_ != nullptr) {
+        client->m_disconnect_success_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onDisconnectFailure(void *context, MQTTAsync_failureData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_disconnect_failure_ != nullptr) {
+        client->m_disconnect_failure_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onSubscribeSuccess(void *context, MQTTAsync_successData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_subscribe_success_ != nullptr) {
+        client->m_subscribe_success_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onSubscribeFailure(void *context, MQTTAsync_failureData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_subscribe_failure_ != nullptr) {
+        client->m_subscribe_failure_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onUnSubscribeSuccess(void *context, MQTTAsync_successData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_unsubscribe_success_ != nullptr) {
+        client->m_unsubscribe_success_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onUnSubscribeFailure(void *context, MQTTAsync_failureData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_unsubscribe_failure_ != nullptr) {
+        client->m_unsubscribe_failure_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onSendMessageSuccess(void *context, MQTTAsync_successData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_send_success_ != nullptr) {
+        client->m_send_success_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onSendMessageFailure(void *context, MQTTAsync_failureData *response) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client->m_send_failure_ != nullptr) {
+        client->m_send_failure_(client, response);
+    } else {
+    }
+}
+
+void MqttAsyncClient::onConnected(void *context, char *cause) {
+    DLOG(INFO) << __func__;
+    auto *client = (MqttAsyncClient *) context;
+    if (client == nullptr || client->m_etc_->subscribe_size() == 0) {
+        return;
+    }
+
+    for (auto &sub: client->m_etc_->subscribe()) {
+        client->Subscribe(sub.topic(), sub.qos());
+    }
+}

+ 155 - 0
include/pahoc/mqtt_async.h

@@ -0,0 +1,155 @@
+#ifndef MQTT_ASYNC_CLIENT_H_
+#define MQTT_ASYNC_CLIENT_H_
+
+#include <MQTTAsync.h>
+#include <mutex>
+#include "tool/load_protobuf.hpp"
+#include "tool/log.hpp"
+#include "mqtt_async.pb.h"
+
+class MqttAsyncClient;
+
+typedef int (*MessageArrived)(MqttAsyncClient *client, char *topicName, int topicLen, MQTTAsync_message *message);
+
+typedef void (*ConnectionLost)(MqttAsyncClient *client, char *cause);
+
+typedef void (*OnSuccess)(MqttAsyncClient *client, MQTTAsync_successData *response);
+
+typedef void (*OnFailure)(MqttAsyncClient *client, MQTTAsync_failureData *response);
+
+class MqttAsyncClient {
+protected:
+    MqttAsyncClient();
+
+    virtual ~MqttAsyncClient();
+
+public:
+    /**
+      * @brief   通过json文件初始化配置,请保证配置文件路径及内容正确.
+      * @param   path json配置文件路径
+      * @return  如果获取到配置文件就会解析配置,配置文件没有则按照默认配置,找不到配置文件则会返回false.
+      */
+    bool init_from_proto(const std::string &path);
+
+    /**
+     * @brief 连接指定地址和id的EMQX服务器
+     * @param address EMQX服务器地址,不要带端口
+     * @param client_id 注册的客户端id,不同客户端id不要重复
+    **/
+    bool Connect(const std::string &address, const std::string &client_id);
+
+    /**
+     * @brief 断开当前已连接的EMQX服务器
+    **/
+    bool Disconnect();
+
+    /**
+     * @brief 当前mqtt连接状态
+    **/
+    bool isConnected();
+
+    /**
+     * @brief 添加对EMQX服务器指定topic的监听
+     * @param topic EMQX服务器topic
+     * @param qos 通信模式,默认为1
+    **/
+    bool Subscribe(const std::string &topic, int qos = 1);
+
+    /**
+     * @brief 取消对EMQX服务器指定topic的监听
+     * @param topic EMQX服务器topic
+     * @param qos 通信模式,默认为1
+    **/
+    bool unSubscribe(const std::string &topic);
+
+    /**
+     * @brief 向EMQX服务器指定的topic发布消息
+     * @param topic EMQX服务器topic
+     * @param message 发布消息的具体内容
+     * @param length 发布消息的长度
+     * @param qos 通信模式,默认为1
+    **/
+    bool SendMessage(const std::string& topic, void *message, int length, int qos = 1);
+
+    /**
+     * @brief 设置接收消息的回调函数,当本客户端收到消息时会执行该回调函数,如果未设置则按照默认回调函数执行
+     * @param callback 回调函数
+    **/
+    void setCallback(MessageArrived callback);
+
+    /**
+     * @brief 设置连接丢失的回调函数,当本客户端与EMQX服务器连接丢失时会执行该回调函数,如果未设置则按照默认回调函数执行
+     * @param callback 回调函数
+    **/
+    void setCallback(ConnectionLost callback);
+
+    /**
+     * @brief 设置指定功能执行成功的回调函数,当本客户端执行某功能成功时会执行该回调函数,如果未设置则按照默认回调函数执行
+     * @param callback 回调函数
+     * @param function 指定功能,目前有subscribe、send、connect、disconnect
+    **/
+    bool setCallback(OnSuccess callback, const std::string &function);
+
+    /**
+     * @brief 设置指定功能执行失败的回调函数,当本客户端执行某功能失败时会执行该回调函数,如果未设置则按照默认回调函数执行
+     * @param callback 回调函数
+     * @param function 指定功能,目前有subscribe、send、connect、disconnect
+    **/
+    bool setCallback(OnFailure callback, const std::string &function);
+
+    /**
+     * @brief 获取监听话题的配置
+    **/
+    google::protobuf::RepeatedPtrField<SubscribeEtc> getSubscribeEtc();
+
+private:
+    static int onMessageArrived(void *context, char *topicName, int topicLen, MQTTAsync_message *message);
+
+    static void onMessageLost(void *context, char *cause);
+
+    static void onConnected(void *context, char *cause);
+
+    static void onConnectSuccess(void *context, MQTTAsync_successData *response);
+
+    static void onConnectFailure(void *context, MQTTAsync_failureData *response);
+
+    static void onDisconnectSuccess(void *context, MQTTAsync_successData *response);
+
+    static void onDisconnectFailure(void *context, MQTTAsync_failureData *response);
+
+    static void onSubscribeSuccess(void *context, MQTTAsync_successData *response);
+
+    static void onSubscribeFailure(void *context, MQTTAsync_failureData *response);
+
+    static void onUnSubscribeSuccess(void *context, MQTTAsync_successData *response);
+
+    static void onUnSubscribeFailure(void *context, MQTTAsync_failureData *response);
+
+    static void onSendMessageSuccess(void *context, MQTTAsync_successData *response);
+
+    static void onSendMessageFailure(void *context, MQTTAsync_failureData *response);
+
+public:
+
+protected:
+    MqttAsyncConfig *m_etc_;
+    MQTTAsync m_client_;
+    MQTTAsync_createOptions m_create_opts = MQTTAsync_createOptions_initializer;
+    MQTTAsync_connectOptions m_connect_ops = MQTTAsync_connectOptions_initializer;
+
+    MessageArrived m_message_arrived_callback_;
+    ConnectionLost m_connect_lost_callback_;
+    OnSuccess m_connect_success_;
+    OnSuccess m_disconnect_success_;
+    OnSuccess m_subscribe_success_;
+    OnSuccess m_unsubscribe_success_;
+    OnSuccess m_send_success_;
+    OnFailure m_connect_failure_;
+    OnFailure m_disconnect_failure_;
+    OnFailure m_subscribe_failure_;
+    OnFailure m_unsubscribe_failure_;
+    OnFailure m_send_failure_;
+
+};
+
+#endif

+ 33 - 0
include/pahoc/mqtt_async.proto

@@ -0,0 +1,33 @@
+syntax = "proto2";
+
+message CreateOpts {
+  optional int32 maxBufferedMessages = 3 [default = 1000000];
+}
+
+message ConnectOps {
+  optional bool cleansession = 1 [default = true];
+  optional int32 keepAliveInterval = 2 [default = 30];
+  optional bool automaticReconnect = 3 [default = true];
+  optional int32 minRetryInterval = 4 [default = 3];
+  optional int32 maxRetryInterval = 5 [default = 10];
+}
+
+message SendMessageEtc {
+  required string topic = 1;
+  optional int32 qos = 2 [default = 1];
+}
+
+message SubscribeEtc {
+  required string topic = 1;
+  optional int32 qos = 2 [default = 1];
+}
+
+message MqttAsyncConfig {
+  optional string address = 1 [default = "mqtt://127.0.0.1:1883"];
+  optional string client_id = 2 [default = "Auto"];
+  optional CreateOpts create_opts = 3;
+  optional ConnectOps connect_ops = 4;
+  repeated SendMessageEtc sendMessage = 5;
+  repeated SubscribeEtc subscribe = 6;
+}
+

+ 35 - 0
include/pahoc/mqtt_communication.cpp

@@ -0,0 +1,35 @@
+#include "mqtt_communication.h"
+
+void Tof3DMqttAsyncClient::init(const std::string &file) {
+    m_message_arrived_callback_ = CloudDataArrived;
+
+    MqttAsyncClient::init_from_proto(file);
+
+//    condit = new Thread_condition();
+//
+//    t = new std::thread(&Tof3DMqttAsyncClient::run, this);
+//
+//    condit->notify_all(true);
+}
+
+// 识别结果数据包含识别结果、时间序号、具体识别信息
+int Tof3DMqttAsyncClient::CloudDataArrived(MqttAsyncClient *client, char *topicName, int topicLen,
+                                             MQTTAsync_message *message) {
+    // 1、查看识别结果
+
+    // 2、队列取数据
+//    cv::Mat merge_mat = cv::Mat::zeros(480 * 2, 640 * 2, CV_8UC1);
+//    memcpy(merge_mat.data, message->payload, message->payloadlen);
+//    cv::imshow("receive", merge_mat);
+    LOG(INFO) << topicName;
+
+    // 3、分离出四份点云
+
+    // 4、发送对应队列
+
+    return 1;
+}
+
+void Tof3DMqttAsyncClient::run() {
+
+}

+ 34 - 0
include/pahoc/mqtt_communication.h

@@ -0,0 +1,34 @@
+#pragma once
+
+#include <pcl/point_types.h>
+#include <pcl/point_cloud.h>
+
+#include "pahoc/mqtt_async.h"
+#include "tool/log.hpp"
+
+class Tof3DMqttAsyncClient : public MqttAsyncClient {
+public:
+    static Tof3DMqttAsyncClient *iter() {
+        static Tof3DMqttAsyncClient *instance = nullptr;
+        if (instance == nullptr) {
+            instance = new Tof3DMqttAsyncClient();
+        }
+        return instance;
+    }
+
+    void init(const std::string &file);
+
+protected:
+    Tof3DMqttAsyncClient() = default;
+
+private:
+    void run();
+
+    static int CloudDataArrived(MqttAsyncClient *client, char *topicName, int topicLen, MQTTAsync_message *message);
+
+public:
+
+private:
+    std::mutex m_cloud_mutex;
+
+};

+ 0 - 32
include/pcl/CMakeLists.txt

@@ -1,32 +0,0 @@
-set(LIBRARY_NAME libpcl)
-
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
-message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
-
-if (NOT ENABLE_LIBRARY_GOOGLE_LOG)
-    message(FATAL_ERROR "Not enable ENABLE_LIBRARY_GOOGLE_LOG")
-endif ()
-
-include_directories(${PCL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
-set(LIBRARY_SOURCE_LIST
-        ${CMAKE_CURRENT_LIST_DIR}/point2D_tool.h
-        ${CMAKE_CURRENT_LIST_DIR}/point2D_tool.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/point3D_tool.h
-        ${CMAKE_CURRENT_LIST_DIR}/point3D_tool.cpp
-)
-
-set(LIBRARY_DEPEND_LIST liblog ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
-
-add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
-target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
-
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 0 - 140
include/pcl/point2D_tool.cpp

@@ -1,140 +0,0 @@
-//
-// Created by huli on 2020/9/1.
-//
-
-#include "point2D_tool.h"
-
-//极坐标 -> 平面坐标
-bool Point2D_tool::Polar_coordinates_to_point2D(Point2D_tool::Polar_coordinates* p_polar_coordinates, Point2D_tool::Point2D* p_point2D)
-{
-	if ( p_polar_coordinates == NULL || p_point2D == NULL)
-	{
-		return false;
-	}
-	else
-	{
-		p_point2D->x = p_polar_coordinates->distance * cos(p_polar_coordinates->angle);
-		p_point2D->y = p_polar_coordinates->distance * sin(p_polar_coordinates->angle);
-		return true;
-	}
-	return true;
-}
-//平面坐标 -> 极坐标
-bool Point2D_tool::Point2D_to_polar_coordinates(Point2D_tool::Point2D* p_point2D, Point2D_tool::Polar_coordinates* p_polar_coordinates)
-{
-	if ( p_polar_coordinates == NULL || p_point2D == NULL)
-	{
-		return false;
-	}
-	else
-	{
-		p_polar_coordinates->distance = sqrt(p_point2D->x * p_point2D->x + p_point2D->y * p_point2D->y);
-		p_polar_coordinates->angle = atan(p_point2D->y / p_point2D->x);
-		return true;
-	}
-	return true;
-}
-
-//判断极坐标点是否在限制范围
-bool Point2D_tool::limit_with_polar_coordinates_box(float distance, float angle, Point2D_tool::Polar_coordinates_box* p_polar_coordinates_box)
-{
-	if ( p_polar_coordinates_box == NULL )
-	{
-		return false;
-	}
-	else
-	{
-		if ( angle >= p_polar_coordinates_box->angle_min &&
-			 angle <= p_polar_coordinates_box->angle_max &&
-			 distance >= p_polar_coordinates_box->distance_min &&
-			 distance <= p_polar_coordinates_box->distance_max )
-		{
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	return true;
-}
-
-//判断平面坐标点是否在限制范围
-bool Point2D_tool::limit_with_point2D_box(float x, float y, Point2D_tool::Point2D_box* p_point2D_box)
-{
-	if ( p_point2D_box == NULL )
-	{
-		return false;
-	}
-	else
-	{
-		if ( x >= p_point2D_box->x_min &&
-			 x <= p_point2D_box->x_max &&
-			 y >= p_point2D_box->y_min &&
-			 y <= p_point2D_box->y_max )
-		{
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	return true;
-}
-#ifdef OPEN_PCL_FLAG
-//平面坐标的转换, 可以进行旋转和平移, 不能缩放
-bool Point2D_tool::transform_with_translation_rotation(float* p_x_in, float* p_y_in, float* p_x_out, float* p_y_out,
-										 Point2D_tool::Point2D_transform* p_point2D_transform)
-{
-	if ( p_x_in == NULL || p_x_in == NULL || p_x_out == NULL || p_y_out == NULL || p_point2D_transform == NULL)
-	{
-		return false;
-	}
-	else
-	{
-		*p_x_out = *p_x_in * p_point2D_transform->m00 + *p_y_in * p_point2D_transform->m01 + p_point2D_transform->m02;
-		*p_y_out = *p_x_in * p_point2D_transform->m10 + *p_y_in * p_point2D_transform->m11 + p_point2D_transform->m12;
-		return true;
-	}
-	return true;
-}
-bool Point2D_tool::transform_with_translation_rotation(pcl::PointXYZ* p_point3D_in, pcl::PointXYZ* p_point3D_out,
-												Point2D_tool::Point2D_transform* p_point2D_transform)
-{
-	if (p_point3D_in == NULL || p_point3D_out == NULL || p_point2D_transform == NULL)
-	{
-		return false;
-	}
-	else
-	{
-		p_point3D_out->x = p_point3D_in->x * p_point2D_transform->m00 + p_point3D_in->y * p_point2D_transform->m01 +
-						   p_point2D_transform->m02;
-		p_point3D_out->y = p_point3D_in->x * p_point2D_transform->m10 + p_point3D_in->y * p_point2D_transform->m11 +
-						   p_point2D_transform->m12;
-		return true;
-	}
-	return true;
-}
-bool Point2D_tool::transform_with_translation_rotation(pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_in,
-												pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_out,
-												Point2D_tool::Point2D_transform* p_point2D_transform)
-{
-	if ( p_cloud_in.get() == NULL || p_cloud_out.get() == NULL || p_point2D_transform == NULL)
-	{
-	    return false;
-	}
-	else
-	{
-		pcl::PointXYZ point;
-		for (int i = 0; i < p_cloud_in->size(); ++i)
-		{
-			point.x = p_cloud_in->points[i].x * p_point2D_transform->m00 + p_cloud_in->points[i].y * p_point2D_transform->m01 + p_point2D_transform->m02;
-			point.y = p_cloud_in->points[i].x * p_point2D_transform->m10 + p_cloud_in->points[i].y * p_point2D_transform->m11 + p_point2D_transform->m12;
-			p_cloud_out->push_back(point);
-		}
-		return true;
-	}
-	return true;
-}
-#endif

+ 0 - 92
include/pcl/point2D_tool.h

@@ -1,92 +0,0 @@
-//
-// Created by huli on 2020/9/1.
-//
-
-#ifndef POINT2D_TOOL_H
-#define POINT2D_TOOL_H
-
-
-
-//#define OPEN_PCL_FLAG
-#ifdef OPEN_PCL_FLAG
-#include <pcl/point_types.h>
-#include <pcl/PCLPointCloud2.h>
-#include <pcl/conversions.h>
-#include <pcl/common/common.h>
-#endif
-
-#include <stddef.h>
-#include <math.h>
-
-class Point2D_tool
-{
-public:
-	//极坐标
-	struct Polar_coordinates
-	{
-		float angle=0;				//弧度
-		float distance=0;				//距离
-	};
-
-	//极坐标的限定范围
-	struct Polar_coordinates_box
-	{
-		float angle_min=0;			//角度最小值
-		float angle_max=0;			//角度最大值
-		float distance_min=0;			//距离最小值
-		float distance_max=0;			//距离最大值
-	};
-
-	//平面坐标
-	struct Point2D
-	{
-		float x=0;				//x轴
-		float y=0;				//y轴
-	};
-
-	//平面坐标的限定范围
-	struct Point2D_box
-	{
-		float x_min=0;				//x轴最小值
-		float x_max=0;				//x轴最大值
-		float y_min=0;				//y轴最小值
-		float y_max=0;				//y轴最大值
-	};
-
-	//平面坐标的转换矩阵, 可以进行旋转和平移, 不能缩放
-	struct Point2D_transform
-	{
-		float m00=1;
-		float m01=0;
-		float m02=0;
-		float m10=0;
-		float m11=1;
-		float m12=0;
-	};
-
-	//极坐标 -> 平面坐标
-	static bool Polar_coordinates_to_point2D(Point2D_tool::Polar_coordinates* p_polar_coordinates, Point2D_tool::Point2D* p_point2D);
-	//平面坐标 -> 极坐标
-	static bool Point2D_to_polar_coordinates(Point2D_tool::Point2D* p_point2D, Point2D_tool::Polar_coordinates* p_polar_coordinates);
-
-
-	//判断极坐标点是否在限制范围
-	static bool limit_with_polar_coordinates_box(float distance, float angle, Point2D_tool::Polar_coordinates_box* p_polar_coordinates_box);
-	//判断平面坐标点是否在限制范围
-	static bool limit_with_point2D_box(float x, float y, Point2D_tool::Point2D_box* p_point2D_box);
-
-#ifdef OPEN_PCL_FLAG
-	//平面坐标的转换, 可以进行旋转和平移, 不能缩放
-	static bool transform_with_translation_rotation(float* p_x_in, float* p_y_in, float* p_x_out, float* p_y_out,
-													Point2D_tool::Point2D_transform* p_point2D_transform);
-	static bool transform_with_translation_rotation(pcl::PointXYZ* p_point3D_in, pcl::PointXYZ* p_point3D_out,
-													Point2D_tool::Point2D_transform* p_point2D_transform);
-	static bool transform_with_translation_rotation(pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_in,
-													pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_out,
-													Point2D_tool::Point2D_transform* p_point2D_transform);
-
-#endif
-};
-
-
-#endif //POINT2D_TOOL_H

+ 0 - 130
include/pcl/point3D_tool.cpp

@@ -1,130 +0,0 @@
-//
-// Created by huli on 2021/3/24.
-//
-
-#include "point3D_tool.h"
-
-bool Point3D_tool::WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud) {
-    DLOG(INFO) << "begain push point data to " << file;
-    std::fstream fileTxtCloud;
-    fileTxtCloud.open(file, std::ios_base::trunc | std::ios::in | std::ios::out);
-    for (auto &point: *cloud) {
-        fileTxtCloud << point.x << " " << point.y << " " << point.z << std::endl;
-    }
-    fileTxtCloud.close();
-    DLOG(INFO) << "Push point complete, push point number: " << cloud->size();
-    return true;
-}
-
-bool Point3D_tool::WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud) {
-    DLOG(INFO) << "begain push point data to " << file;
-    std::fstream fileTxtCloud;
-    fileTxtCloud.open(file, std::ios_base::trunc | std::ios::in | std::ios::out);
-    for (auto &point: *cloud) {
-        fileTxtCloud << point.x << " " << point.y << " " << point.z << std::endl;
-    }
-    fileTxtCloud.close();
-    DLOG(INFO) << "Push point complete, push point number: " << cloud->size();
-    return true;
-}
-
-bool Point3D_tool::ReadTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud) {
-    DLOG(INFO) << "Load point data form file: " << file;
-    std::ifstream fin(file.c_str());
-    if (fin.bad()) {
-        LOG(WARNING) << "File " << file << " don't exist.";
-        return false;
-    }
-    const int line_length = 64;
-    char str[line_length] = {0};
-    while (fin.getline(str, line_length)) {
-        pcl::PointXYZ point{};
-        if (string2PointXYZ(str, point)) {
-            cloud->push_back(point);
-        }
-    }
-    DLOG(INFO) << "Load point complete, get point number: " << cloud->size();
-    return true;
-}
-
-template <typename PclPoint>
-int Point3D_tool::getMinRect(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds) {
-    if (clouds->points.size() < 4) {
-        DLOG(ERROR) << "points to little.";
-        return false;
-    }
-    std::vector<cv::Point2f> cv_clouds;
-    for (auto &point: clouds->points) {
-        cv_clouds.emplace_back(point.x, point.y);
-    }
-    rect = cv::minAreaRect(cv_clouds);
-    return true;
-}
-
-int Point3D_tool::getRectCloud(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value, int numbers) {
-    cv::Point2f cv_points[4];
-    rect.points(cv_points);
-    // PclPoint point;
-    pcl::PointXYZ point;
-    // 左侧点
-    double step_x = (cv_points[1].x - cv_points[0].x) / numbers;
-    double step_y = (cv_points[1].y - cv_points[0].y) / numbers;
-    for (int i = 0; i < numbers; i++) {
-        point.x = cv_points[0].x + i * step_x;
-        point.y = cv_points[0].y + i * step_y;
-        point.z = z_value;
-        points->points.emplace_back(point);
-    }
-
-    // 上侧点
-    step_x = (cv_points[2].x - cv_points[1].x) / numbers;
-    step_y = (cv_points[2].y - cv_points[1].y) / numbers;
-    for (int i = 0; i < numbers; i++) {
-        point.x = cv_points[1].x + i * step_x;
-        point.y = cv_points[1].y + i * step_y;
-        point.z = z_value;
-        points->points.emplace_back(point);
-    }
-
-    // 右侧点
-    step_x = (cv_points[3].x - cv_points[2].x) / numbers;
-    step_y = (cv_points[3].y - cv_points[2].y) / numbers;
-    for (int i = 0; i < numbers; i++) {
-        point.x = cv_points[2].x + i * step_x;
-        point.y = cv_points[2].y + i * step_y;
-        point.z = z_value;
-        points->points.emplace_back(point);
-    }
-
-
-    // 下侧点
-    step_x = (cv_points[0].x - cv_points[3].x) / numbers;
-    step_y = (cv_points[0].y - cv_points[3].y) / numbers;
-    for (int i = 0; i < numbers; i++) {
-        point.x = cv_points[3].x + i * step_x;
-        point.y = cv_points[3].y + i * step_y;
-        point.z = z_value;
-        points->points.emplace_back(point);
-    }
-
-    return points->size();
-}
-
-template <typename PclPoint>
-int Point3D_tool::getRectCloud(pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value, int numbers) {
-    cv::RotatedRect rect = getMinRect(clouds);
-    getRectCloud(rect, points, z_value, numbers);
-    return points->size();
-}
-
-void Point3D_tool::getRectWidthlength(cv::RotatedRect &rect, double &width, double &length) {
-    cv::Point2f points[4];
-    rect.points(points);
-
-    double a = sqrt((points[1].x - points[0].x) * (points[1].x - points[0].x) + (points[1].y - points[0].y) * (points[1].y - points[0].y));
-    double b = sqrt((points[2].x - points[1].x) * (points[2].x - points[1].x) + (points[2].y - points[1].y) * (points[2].y - points[1].y));
-
-    width = MIN(a, b);
-    length = MAX(a, b);
-}
-

+ 0 - 56
include/pcl/point3D_tool.h

@@ -1,56 +0,0 @@
-//
-// Created by huli on 2021/3/24.
-//
-
-#ifndef NNXX_TESTS_POINT3D_TOOL_H
-#define NNXX_TESTS_POINT3D_TOOL_H
-
-#include <pcl/point_cloud.h>
-#include <pcl/point_types.h>
-#include <vector>
-#include <opencv4/opencv2/opencv.hpp>
-#include "log/log.h"
-
-class Point3D_tool
-{
-public:
-    static bool WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud);
-
-    static bool WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud);
-
-    static bool ReadTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud);
-
-	template <typename PclPoint>
-	static int getMinRect(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds);
-
-	// template <typename PclPoint>
-	// static int getMinRect(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<PclPoint>> &points) {
-	static int getRectCloud(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value = 0, int numbers = 100);
-
-	template <typename PclPoint>
-	static int getRectCloud(pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value = 0, int numbers = 100);
-
-	static void getRectWidthlength(cv::RotatedRect &rect, double &width, double &length);
-
-private:
-    static bool string2PointXYZ(const std::string &str, pcl::PointXYZ &point) {
-        std::istringstream iss;
-        iss.str(str);
-        float value;
-        float data[3];
-        for (int i = 0; i < 3; ++i) {
-            if (iss >> value) {
-                data[i] = value;
-            } else {
-                return false;
-            }
-        }
-        point.x = data[0];
-        point.y = data[1];
-        point.z = data[2];
-        return true;
-    }
-};
-
-
-#endif //NNXX_TESTS_POINT3D_TOOL_H

+ 0 - 5
include/pcl/test.cpp

@@ -1,5 +0,0 @@
-#include "test.h"
-
-int main(int argc, char** argv) {
-    return EXIT_SUCCESS;
-}

+ 0 - 3
include/pcl/test.h

@@ -1,3 +0,0 @@
-#pragma once
-
-#include <iostream>

+ 0 - 49
include/plc/CMakeLists.txt

@@ -1,49 +0,0 @@
-set(LIBRARY_NAME libplc)
-
-if (NOT ENABLE_LIBRARY_THREAD)
-    message(FATAL_ERROR "Not enable ENABLE_LIBRARY_THREAD")
-endif ()
-if (NOT ENABLE_LIBRARY_JSON)
-    message(FATAL_ERROR "Not enable ENABLE_LIBRARY_JSON")
-endif ()
-if (NOT ENABLE_LIBRARY_GOOGLE_LOG)
-    message(FATAL_ERROR "Not enable ENABLE_LIBRARY_GOOGLE_LOG")
-endif ()
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." ON)
-message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
-
-include_directories(
-        /usr/local/include/snap7
-)
-
-set(LIBRARY_SOURCE_LIST
-        ${CMAKE_CURRENT_LIST_DIR}/plcJsonConfig.h
-        ${CMAKE_CURRENT_LIST_DIR}/plcJsonConfig.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/s7_plc.h
-        ${CMAKE_CURRENT_LIST_DIR}/s7_plc.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/snap7_buf.h
-        ${CMAKE_CURRENT_LIST_DIR}/snap7_buf.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/snap7_communication_base.h
-        ${CMAKE_CURRENT_LIST_DIR}/snap7_communication_base.cpp
-)
-
-set(LIBRARY_DEPEND_LIST
-        liblog
-        libthread
-        libjson
-        snap7
-)
-
-add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
-target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
-
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 0 - 19
include/plc/plcJsonConfig.cpp

@@ -1,19 +0,0 @@
-/**
-  * @project shutter_verify
-  * @brief   $BRIEF$
-  * @author  lz
-  * @data    2023/4/13
- **/
-#include "plcJsonConfig.h"
-#include <utility>
-
-plcJsonConfig::plcJsonConfig(std::string path) {
-    m_path = path;
-}
-
-std::string plcJsonConfig::ip() {
-    std::string ip;
-    ReadJsonFile(m_path, m_config);
-    JV_STRING(m_config, "ip", ip, DEFAULT_STRING);
-    return ip;
-}

+ 0 - 21
include/plc/plcJsonConfig.h

@@ -1,21 +0,0 @@
-/**
-  * @project shutter_verify
-  * @brief   $BRIEF$
-  * @author  lz
-  * @data    2023/4/13
- **/
-#pragma once
-
-#include "json/json.h"
-
-class plcJsonConfig {
-public:
-    explicit plcJsonConfig(std::string path);
-    ~plcJsonConfig() = default;
-
-    std::string ip();
-
-private:
-    std::string m_path;
-    Json::Value m_config;
-};

+ 0 - 78
include/plc/s7_plc.cpp

@@ -1,78 +0,0 @@
-#include "s7_plc.h"
-
-S7PLC::S7PLC() : bConnected_(false) {
-}
-
-S7PLC::~S7PLC() {
-    disconnect();
-}
-
-bool S7PLC::getConnection() {
-    return bConnected_;
-}
-
-bool S7PLC::connect(std::string ip) {
-    std::lock_guard<std::mutex> lck(mutex_);
-    int ret = client_.ConnectTo(ip.c_str(), 0, 1);
-    bConnected_ = (ret == 0);
-    return bConnected_;
-}
-
-bool S7PLC::ReadShorts(int DBNumber, int start, int size, short *pdata) {
-    short *plc_data = (short *) malloc(size * sizeof(short));
-    bool ret = read_dbs(DBNumber, start * sizeof(short), size * sizeof(short), pdata);
-    if (ret) {
-        reverse_byte(pdata, size * sizeof(short), plc_data);
-        for (int i = 0; i < size; ++i)
-            pdata[i] = plc_data[size - i - 1];
-    }
-    free(plc_data);
-    return ret;
-
-}
-
-bool S7PLC::WriteShorts(int DBNumber, int start, int size, short *pdata) {
-    short *plc_data = (short *) malloc(size * sizeof(short));
-    memcpy(plc_data, pdata, size * sizeof(short));
-    for (int i = 0; i < size; ++i)
-        plc_data[i] = HTON(plc_data[i]);
-
-    bool ret = write_dbs(DBNumber, start * sizeof(short), size * sizeof(short), plc_data);
-    free(plc_data);
-    return ret;
-}
-
-bool S7PLC::read_dbs(int DBNumber, int start, int size, void *pdata) {
-    std::lock_guard<std::mutex> lck(mutex_);
-    usleep(1000 * 50);
-    if (bConnected_ == false)
-        return false;
-
-    int ret = client_.AsDBRead(DBNumber, start, size, pdata);
-
-    return ret == 0;
-}
-
-bool S7PLC::write_dbs(int DBNumber, int start, int size, void *pdata) {
-    std::lock_guard<std::mutex> lck(mutex_);
-    usleep(1000 * 50);
-    if (bConnected_ == false)
-        return false;
-
-    int ret = client_.AsDBWrite(DBNumber, start, size, pdata);
-
-    return ret == 0;
-}
-
-void S7PLC::disconnect() {
-    std::lock_guard<std::mutex> lck(mutex_);
-    client_.Disconnect();
-}
-
-void S7PLC::reverse_byte(void *pdata, int num_byte, void *out) {
-    char *pin = (char *) pdata;
-    char *pout = (char *) out;
-    for (int i = 0; i < num_byte; ++i) {
-        pout[i] = pin[num_byte - i - 1];
-    }
-}

+ 0 - 39
include/plc/s7_plc.h

@@ -1,39 +0,0 @@
-#ifndef S7__PLC__H
-#define S7__PLC__H
-
-#include <s7_client.h>
-#include <mutex>
-#include <iostream>
-
-class S7PLC {
-public:
-#define HTON(T) ((T) << 8) | ((T) >> 8)
-protected:
-    bool bConnected_;
-    std::mutex mutex_;
-    TSnap7Client client_;
-public:
-    S7PLC();
-
-    ~S7PLC();
-
-    bool connect(std::string ip);
-
-    bool getConnection();
-
-    bool ReadShorts(int DBNumber, int start, int size, short *pdata);
-
-    bool WriteShorts(int DBNumber, int start, int size, short *pdata);
-
-    void disconnect();
-
-private:
-    bool read_dbs(int DBNumber, int start, int size, void *pdata);
-
-    bool write_dbs(int DBNumber, int start, int size, void *pdata);
-
-    void reverse_byte(void *pdata, int num_byte, void *out);
-
-};
-
-#endif // !S7__PLC__H

+ 0 - 217
include/plc/snap7_buf.cpp

@@ -1,217 +0,0 @@
-#include "snap7_buf.h"
-#include <string>
-#include <string.h>
-
-Snap7_buf::Snap7_buf() {
-    m_id = 0;
-    m_start_index = 0;
-    m_size = 0;
-    mp_buf_obverse = nullptr;
-    mp_buf_reverse = nullptr;
-    m_communication_mode = NO_COMMUNICATION;
-
-}
-
-Snap7_buf::Snap7_buf(const Snap7_buf &other) {
-    m_id = other.m_id;
-    m_start_index = other.m_start_index;
-    m_communication_mode = other.m_communication_mode;
-
-    if (other.m_size > 0 && other.mp_buf_obverse != nullptr && other.mp_buf_reverse != nullptr) {
-        mp_buf_obverse = (void *) malloc(other.m_size);
-        memcpy(mp_buf_obverse, other.mp_buf_obverse, other.m_size);
-        mp_buf_reverse = (void *) malloc(other.m_size);
-        memcpy(mp_buf_reverse, other.mp_buf_reverse, other.m_size);
-        m_size = other.m_size;
-        m_variable_information_vector = other.m_variable_information_vector;
-    }
-}
-
-Snap7_buf &Snap7_buf::operator=(const Snap7_buf &other) {
-    m_id = other.m_id;
-    m_start_index = other.m_start_index;
-    m_communication_mode = other.m_communication_mode;
-
-    if (other.m_size > 0 && other.mp_buf_obverse != nullptr && other.mp_buf_reverse != nullptr) {
-        mp_buf_obverse = (void *) malloc(other.m_size);
-        memcpy(mp_buf_obverse, other.mp_buf_obverse, other.m_size);
-        mp_buf_reverse = (void *) malloc(other.m_size);
-        memcpy(mp_buf_reverse, other.mp_buf_reverse, other.m_size);
-        m_size = other.m_size;
-        m_variable_information_vector = other.m_variable_information_vector;
-    }
-    return *this;
-}
-
-Snap7_buf::~Snap7_buf() {
-    if (mp_buf_obverse) {
-        free(mp_buf_obverse);
-        mp_buf_obverse = NULL;
-    }
-    if (mp_buf_reverse) {
-        free(mp_buf_reverse);
-        mp_buf_reverse = NULL;
-    }
-}
-
-Snap7_buf::Snap7_buf(int id, int start_index, int size,
-                     std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-                     Communication_mode communication_mode) {
-    m_id = id;
-    m_start_index = start_index;
-    m_communication_mode = communication_mode;
-
-    if (size > 0) {
-        mp_buf_obverse = (void *) malloc(size);
-        memset(mp_buf_obverse, 0, size);
-        mp_buf_reverse = (void *) malloc(size);
-        memset(mp_buf_reverse, 0, size);
-        m_size = size;
-        m_variable_information_vector = variable_information_vector;
-    }
-}
-
-Snap7_buf::Snap7_buf(int id, int start_index, int size, void *p_buf_obverse, void *p_buf_reverse,
-                     std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-                     Communication_mode communication_mode) {
-    m_id = id;
-    m_start_index = start_index;
-    m_communication_mode = communication_mode;
-
-    if (size > 0 && p_buf_obverse != nullptr && p_buf_reverse != nullptr) {
-        mp_buf_obverse = (void *) malloc(size);
-        memcpy(mp_buf_obverse, p_buf_obverse, size);
-        mp_buf_reverse = (void *) malloc(size);
-        memcpy(mp_buf_reverse, p_buf_reverse, size);
-        m_size = size;
-        m_variable_information_vector = variable_information_vector;
-    }
-}
-
-void Snap7_buf::init(int id, int start_index, int size,
-                     std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-                     Communication_mode communication_mode) {
-    m_id = id;
-    m_start_index = start_index;
-    m_communication_mode = communication_mode;
-
-    if (mp_buf_obverse) {
-        free(mp_buf_obverse);
-        mp_buf_obverse = NULL;
-    }
-    if (mp_buf_reverse) {
-        free(mp_buf_reverse);
-        mp_buf_reverse = NULL;
-    }
-
-    if (size > 0) {
-        mp_buf_obverse = (void *) malloc(size);
-        memset(mp_buf_obverse, 0, size);
-        mp_buf_reverse = (void *) malloc(size);
-        memset(mp_buf_reverse, 0, size);
-        m_size = size;
-        m_variable_information_vector = variable_information_vector;
-    }
-}
-
-void Snap7_buf::init(int id, int start_index, int size, void *p_buf_obverse, void *p_buf_reverse,
-                     std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-                     Communication_mode communication_mode) {
-    m_id = id;
-    m_start_index = start_index;
-    m_communication_mode = communication_mode;
-
-    if (mp_buf_obverse) {
-        free(mp_buf_obverse);
-        mp_buf_obverse = NULL;
-    }
-    if (mp_buf_reverse) {
-        free(mp_buf_reverse);
-        mp_buf_reverse = NULL;
-    }
-
-    if (size > 0 && p_buf_obverse != nullptr && p_buf_reverse != nullptr) {
-        mp_buf_obverse = (void *) malloc(size);
-        memcpy(mp_buf_obverse, p_buf_obverse, size);
-        mp_buf_reverse = (void *) malloc(size);
-        memcpy(mp_buf_reverse, p_buf_reverse, size);
-        m_size = size;
-        m_variable_information_vector = variable_information_vector;
-    }
-}
-
-//正序数据 转为 倒序数据
-void Snap7_buf::obverse_to_reverse() {
-    char *p_in = (char *) mp_buf_obverse;
-    char *p_out = (char *) mp_buf_reverse;
-
-    for (auto &iter: m_variable_information_vector) {
-        for (int i = 0; i < iter.m_variable_count; ++i) {
-            for (int j = 0; j < iter.m_variable_size; ++j) {
-                p_out[iter.m_variable_index + iter.m_variable_size * i + j] = p_in[iter.m_variable_index +
-                                                                                   iter.m_variable_size * (i + 1) - j -
-                                                                                   1];
-            }
-        }
-//		for (int i = 0; i < iter.m_variable_count; ++i)
-//		{
-//			for (int j = iter.m_variable_index*i; j < iter.m_variable_index*i+iter.m_variable_size ; ++j)
-//			{
-//				p_out[j] = p_in[iter.m_variable_index*i+iter.m_variable_size - j -1];
-//			}
-//		}
-    }
-}
-
-//倒序数据 转为 正序数据
-void Snap7_buf::reverse_to_obverse() {
-    char *p_in = (char *) mp_buf_reverse;
-    char *p_out = (char *) mp_buf_obverse;
-
-
-    for (auto &iter: m_variable_information_vector) {
-        for (int i = 0; i < iter.m_variable_count; ++i) {
-            for (int j = 0; j < iter.m_variable_size; ++j) {
-                p_out[iter.m_variable_index + iter.m_variable_size * i + j] = p_in[iter.m_variable_index +
-                                                                                   iter.m_variable_size * (i + 1) - j -
-                                                                                   1];
-            }
-        }
-
-//		for (int i = 0; i < iter.m_variable_count; ++i)
-//		{
-//			for (int j = iter.m_variable_index*i; j < iter.m_variable_index*i+iter.m_variable_size ; ++j)
-//			{
-//				p_out[j] = p_in[iter.m_variable_index*i+iter.m_variable_size - j -1];
-//			}
-//		}
-    }
-}
-
-int Snap7_buf::get_id() {
-    return m_id;
-}
-
-int Snap7_buf::get_start_index() {
-    return m_start_index;
-}
-
-int Snap7_buf::get_size() {
-    return m_size;
-}
-
-void *Snap7_buf::get_buf_obverse() {
-    return mp_buf_obverse;
-}
-
-void *Snap7_buf::get_buf_reverse() {
-    return mp_buf_reverse;
-}
-
-Snap7_buf::Communication_mode Snap7_buf::get_communication_mode() {
-    return m_communication_mode;
-}
-
-void Snap7_buf::set_communication_mode(Communication_mode communication_mode) {
-    m_communication_mode = communication_mode;
-}

+ 0 - 98
include/plc/snap7_buf.h

@@ -1,98 +0,0 @@
-#ifndef NNXX_TESTS_SNAP7_BUF_H
-#define NNXX_TESTS_SNAP7_BUF_H
-
-#include <string>
-#include <map>
-#include <vector>
-#include <iostream>
-
-//Snap7协议的数据结构
-class Snap7_buf {
-public:
-    //通信模式
-    enum Communication_mode {
-        NO_COMMUNICATION = 0,    //不通信
-        ONCE_COMMUNICATION = 1,    //一次通信
-        LOOP_COMMUNICATION = 2,    //循环通信
-    };
-
-    //变量信息
-    struct Variable_information {
-        std::string m_variable_name;        //变量名称
-        std::string m_variable_type;        //变量类型, 使用 typeid(a).name() 获取
-        int m_variable_index;        //变量下标, 偏移量
-        int m_variable_size;        //变量类型大小
-        int m_variable_count;        //变量个数
-    };
-public:
-    Snap7_buf();
-
-    Snap7_buf(const Snap7_buf &other);
-
-    Snap7_buf &operator=(const Snap7_buf &other);
-
-    ~Snap7_buf();
-
-public://API functions
-    Snap7_buf(int id, int start_index, int size,
-              std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-              Communication_mode communication_mode = NO_COMMUNICATION);
-
-    Snap7_buf(int id, int start_index, int size, void *p_buf_obverse, void *p_buf_reverse,
-              std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-              Communication_mode communication_mode = NO_COMMUNICATION);
-
-    void init(int id, int start_index, int size,
-              std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-              Communication_mode communication_mode = NO_COMMUNICATION);
-
-    void init(int id, int start_index, int size, void *p_buf_obverse, void *p_buf_reverse,
-              std::vector<Snap7_buf::Variable_information> &variable_information_vector,
-              Communication_mode communication_mode = NO_COMMUNICATION);
-
-
-    //正序数据 转为 倒序数据
-    void obverse_to_reverse();
-
-    //倒序数据 转为 正序数据
-    void reverse_to_obverse();
-
-public://get or set member variable
-    int get_id();
-
-    int get_start_index();
-
-    int get_size();
-
-    void *get_buf_obverse();
-
-    void *get_buf_reverse();
-
-    Communication_mode get_communication_mode();
-
-    void set_communication_mode(Communication_mode communication_mode);
-
-protected://member functions
-
-public://member variable
-
-    int m_id;                    //Snap7协议的数据块的编号
-    int m_start_index;            //Snap7协议的数据起始位下标
-    int m_size;                    //Snap7协议的数据字节大小
-    void *mp_buf_obverse;            //Snap7协议的正序数据指针, 和数据结构体进行强转, 内存由本类管理
-    void *mp_buf_reverse;            //Snap7协议的倒序数据指针, 用作s7通信, 内存由本类管理
-    //注:s7的通信的数据必须要倒序之后才能进行通信,
-
-//	std::map<std::string, Variable_information>			m_variable_information_map;
-    std::vector<Variable_information> m_variable_information_vector;
-
-    Communication_mode m_communication_mode;    //Snap7协议的通信模式
-    //注:s7协议传输很慢, 防止相同的数据重复发送...
-
-
-private:
-
-};
-
-
-#endif //NNXX_TESTS_SNAP7_BUF_H

+ 0 - 292
include/plc/snap7_communication_base.cpp

@@ -1,292 +0,0 @@
-//
-// Created by huli on 2020/9/25.
-//
-
-#include "snap7_communication_base.h"
-
-Snap7_communication_base::Snap7_communication_base() {
-    m_communication_status = SNAP7_COMMUNICATION_UNKNOWN;
-    m_communication_delay_time_ms = SNAP7_COMMUNICATION_DELAY_TIME_MS;
-    mp_communication_thread = nullptr;
-}
-
-Snap7_communication_base::~Snap7_communication_base() {
-    communication_uninit();
-}
-
-//初始化 通信 模块。如下三选一
-Error_manager Snap7_communication_base::communication_init(std::string ip) {
-    m_ip_string = ip;
-    Error_manager t_error = communication_connect(m_ip_string);
-    if (t_error != Error_code::SUCCESS) {
-        //连接失败, 不要直接返回, 而是改为断连, 后面继续启动线程, (线程内部有重连功能)
-        printf("---Debug %s %d : CONNECT ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", __func__, __LINE__);
-        m_communication_status = SNAP7_COMMUNICATION_DISCONNECT;
-    } else {
-
-        printf("---Debug %s %d : CONNECT SUCCESS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", __func__, __LINE__);
-        m_communication_status = SNAP7_COMMUNICATION_READY;
-    }
-    return communication_run();
-}
-
-//反初始化 通信 模块。
-Error_manager Snap7_communication_base::communication_uninit() {
-    //关闭线程并回收资源
-    if (mp_communication_thread) {
-        m_communication_condition.kill_all();
-    }
-    if (mp_communication_thread) {
-        mp_communication_thread->join();
-        delete mp_communication_thread;
-        mp_communication_thread = nullptr;
-    }
-
-    //清空map
-    {
-        std::unique_lock<std::mutex> t_lock(m_receive_buf_lock);
-        m_receive_buf_map.clear();
-    }
-    {
-        std::unique_lock<std::mutex> t_lock(m_send_buf_lock);
-        m_send_buf_map.clear();
-    }
-
-    communication_disconnect();
-    m_communication_status = SNAP7_COMMUNICATION_UNKNOWN;
-
-    return Error_code::SUCCESS;
-}
-
-
-//唤醒s7通信线程
-Error_manager Snap7_communication_base::communication_start() {
-    m_communication_condition.notify_all(true);
-    return Error_code::SUCCESS;
-}
-
-//停止s7通信线程
-Error_manager Snap7_communication_base::communication_stop() {
-    m_communication_condition.notify_all(false);
-    return Error_code::SUCCESS;
-}
-
-
-Snap7_communication_base::Snap7_communication_statu Snap7_communication_base::get_status() {
-    return m_communication_status;
-}
-
-//通信连接
-Error_manager Snap7_communication_base::communication_connect(std::string ip_string) {
-    std::unique_lock<std::mutex> t_lock(m_communication_lock);
-    int result = m_snap7_client.ConnectTo(ip_string.c_str(), 0, 1);
-    std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-    printf("---Debug %s %d : connect %s result is %d \n", __func__, __LINE__, ip_string.c_str(), result);
-    if (result == 0) {
-        return Error_code::SUCCESS;
-    } else {
-        return {Error_code::SNAP7_CONNECT_ERROR, Error_level::MINOR_ERROR,
-                             " Snap7_communication_base::communication_connect error "};
-    }
-}
-
-//启动通信, run thread
-Error_manager Snap7_communication_base::communication_run() {
-    //启动4个线程。
-    //接受线程默认循环, 内部的nn_recv进行等待, 超时1ms
-    m_communication_condition.reset(false, false, false);
-    mp_communication_thread = new std::thread(&Snap7_communication_base::communication_thread, this);
-
-    return Error_code::SUCCESS;
-}
-
-//通信断连
-Error_manager Snap7_communication_base::communication_disconnect() {
-    std::unique_lock<std::mutex> t_lock(m_communication_lock);
-    int result = m_snap7_client.Disconnect();
-    std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-    if (result == 0) {
-        return Error_code::SUCCESS;
-    } else {
-        return {Error_code::SNAP7_DISCONNECT_ERROR, Error_level::MINOR_ERROR,
-                             " Snap7_communication_base::communication_disconnect error "};
-    }
-    return Error_code::SUCCESS;
-}
-
-//mp_communication_thread线程的执行函数, 负责进行s7的通信
-void Snap7_communication_base::communication_thread() {
-    //LOG(INFO) << " ---Snap7_communication_base::communication_thread()--- "<< this;
-    Error_manager t_error;
-    while (m_communication_condition.is_alive()) {
-        m_communication_condition.wait_for_millisecond(1);
-
-        //s7的通信时间较长, 所以将发送和接受分开
-        //发送多个时, 必须加锁后一起发送, 不允许分段写入, 防止数据错误
-        if (m_communication_condition.is_alive()) {
-            std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-            std::this_thread::yield();
-            switch (m_communication_status) {
-                case SNAP7_COMMUNICATION_READY:
-                case SNAP7_COMMUNICATION_RECEIVE: {
-                    {
-                        std::unique_lock<std::mutex> t_lock(m_receive_buf_lock);
-                        auto iter = m_receive_buf_map.begin();
-                        for (; iter != m_receive_buf_map.end(); ++iter) {
-                            //接受数据, 读取DB块,
-                            t_error = read_data_buf(iter->second);
-                            if (t_error == Error_code::SNAP7_READ_ERROR) {
-                                m_communication_status = SNAP7_COMMUNICATION_DISCONNECT;
-                                printf("---Debug %s %d : t_error = %s \n", __func__, __LINE__, t_error.to_string().c_str());
-                                break;
-                            }
-                        }
-                        if (iter != m_receive_buf_map.end()) {
-                            break;
-                        }
-                    }
-                    //注:数据更新放在锁的外面, 防止重复加锁....
-                    if(updata_receive_buf() != Error_code::SUCCESS) {
-                        m_communication_status = SNAP7_COMMUNICATION_DISCONNECT;
-                    }
-                    else {
-                        m_communication_status = SNAP7_COMMUNICATION_SEND;
-                    }
-                    break;
-                }
-                case SNAP7_COMMUNICATION_SEND: {
-                    //注:数据更新放在锁的外面, 防止重复加锁....
-                    updata_send_buf();
-                    {
-                        std::unique_lock<std::mutex> t_lock(m_send_buf_lock);
-                        auto iter = m_send_buf_map.begin();
-                        for (; iter != m_send_buf_map.end(); ++iter) {
-                            //发送数据, 写入DB块,
-                            t_error = write_data_buf(iter->second);
-                            if (t_error == Error_code::SNAP7_WRITE_ERROR) {
-                                m_communication_status = SNAP7_COMMUNICATION_DISCONNECT;
-                                printf("---Debug %s %d : t_error = %s \n", __func__, __LINE__, t_error.to_string().c_str());
-                                break;
-                            }
-                        }
-                        if (iter != m_send_buf_map.end()) {
-                            break;
-                        }
-                    }
-                    m_communication_status = SNAP7_COMMUNICATION_RECEIVE;
-                    break;
-                }
-                case SNAP7_COMMUNICATION_DISCONNECT: {
-                    //重连
-                    printf("---Debug %s %d : find plc connection error, trying to reconnect.\n", __func__, __LINE__);
-                    communication_disconnect();
-                    std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-                    t_error = communication_connect(m_ip_string);
-                    if (t_error != Error_code::SUCCESS) {
-                        //连接失败, 不要直接返回, 而是改为断连, 后面继续启动线程, (线程内部有重连功能)
-                        m_communication_status = SNAP7_COMMUNICATION_DISCONNECT;
-                    } else {
-                        m_communication_status = SNAP7_COMMUNICATION_READY;
-                    }
-                    std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-
-                    break;
-                }
-                default: {
-
-                    break;
-                }
-            }
-        }
-    }
-    //LOG(INFO) << " Communication_socket_base::send_data_thread end "<< this;
-}
-
-//接受数据, 读取DB块,
-Error_manager Snap7_communication_base::read_data_buf(Snap7_buf &snap7_buf) {
-    Error_manager t_error;
-    if (snap7_buf.m_communication_mode != Snap7_buf::NO_COMMUNICATION) {
-        if (snap7_buf.m_communication_mode == Snap7_buf::ONCE_COMMUNICATION) {
-            snap7_buf.m_communication_mode = Snap7_buf::NO_COMMUNICATION;
-        }
-
-        std::unique_lock<std::mutex> lck(m_communication_lock);
-//        printf("---Debug %s %d : snap7_buf,m_id %d \n", __func__, __LINE__, snap7_buf.m_id);
-//        printf("---Debug %s %d : snap7_buf,m_start_index %d\n", __func__, __LINE__, snap7_buf.m_start_index);
-//        printf("---Debug %s %d : snap7_buf,m_size %d\n", __func__, __LINE__, snap7_buf.m_size);
-        int result = m_snap7_client.AsDBRead(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size,
-                                             snap7_buf.mp_buf_reverse);
-
-//		std::this_thread::sleep_for(std::chrono::milliseconds(10));
-        if (result == 0) {
-            m_snap7_client.WaitAsCompletion(100);
-            //倒序数据 转为 正序数据
-            snap7_buf.reverse_to_obverse();
-        } else {
-            std::cout << " huli test :::: " << " result = " << result << std::endl;
-            return {Error_code::SNAP7_READ_ERROR, Error_level::MINOR_ERROR,
-                                 " Snap7_communication_base::read_data_buf error "};
-        }
-    }
-
-    return Error_code::SUCCESS;
-}
-
-//发送数据, 写入DB块,
-Error_manager Snap7_communication_base::write_data_buf(Snap7_buf &snap7_buf) {
-    Error_manager t_error;
-    if (snap7_buf.m_communication_mode != Snap7_buf::NO_COMMUNICATION) {
-        if (snap7_buf.m_communication_mode == Snap7_buf::ONCE_COMMUNICATION) {
-            snap7_buf.m_communication_mode = Snap7_buf::NO_COMMUNICATION;
-        }
-
-        //正序数据 转为 倒序数据
-        snap7_buf.obverse_to_reverse();
-        std::unique_lock<std::mutex> lck(m_communication_lock);
-        unsigned short a = 0;
-        memcpy(&a, snap7_buf.mp_buf_reverse, 2);
-        //printf("id %d  start %d  size :%d   value :%d\n",snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size,a);
-        int result = m_snap7_client.AsDBWrite(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size,
-                                              snap7_buf.mp_buf_reverse);
-
-        if (result == 0) {
-            if (0 != m_snap7_client.WaitAsCompletion(1000)) {
-            }
-        } else {
-            printf("---Debug %s %d : snap7_buf,m_id %d \n", __func__, __LINE__, snap7_buf.m_id);
-            printf("---Debug %s %d : snap7_buf,m_start_index %d\n", __func__, __LINE__, snap7_buf.m_start_index);
-            printf("---Debug %s %d : snap7_buf,m_size %d\n", __func__, __LINE__, snap7_buf.m_size);
-            return {Error_code::SNAP7_WRITE_ERROR, Error_level::MINOR_ERROR,
-                                 " Snap7_communication_base::write_data_buf error "};
-        }
-    }
-    return Error_code::SUCCESS;
-}
-
-//数据颠倒
-Error_manager Snap7_communication_base::reverse_byte(void *p_buf_in, void *p_buf_out, int size) {
-    if (p_buf_in == nullptr || p_buf_out == nullptr) {
-        return {Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
-                             "  POINTER IS NULL "};
-    }
-    char *tp_in = (char *) p_buf_in;
-    char *tp_out = (char *) p_buf_out;
-
-    for (int i = 0; i < size; ++i) {
-        tp_out[i] = tp_in[i];
-    }
-    return Error_code::SUCCESS;
-}
-
-//更新数据
-Error_manager Snap7_communication_base::updata_receive_buf() {
-    return Error_code::SUCCESS;
-}
-
-Error_manager Snap7_communication_base::updata_send_buf() {
-
-    return Error_code::SUCCESS;
-}
-
-
-

+ 0 - 115
include/plc/snap7_communication_base.h

@@ -1,115 +0,0 @@
-//
-// Created by huli on 2020/9/25.
-//
-
-#ifndef NNXX_TESTS_SNAP7_E_BASE_H
-#define NNXX_TESTS_SNAP7_E_BASE_H
-
-#include <s7_client.h>
-#include <mutex>
-#include <map>
-
-#include "error_code/error_code.hpp"
-#include "thread/thread_condition.h"
-#include "snap7_buf.h"
-#include "s7_plc.h"
-#include "plcJsonConfig.h"
-
-class Snap7_communication_base {
-public:
-    //snap7的通信延时, 默认50ms
-#define SNAP7_COMMUNICATION_DELAY_TIME_MS    10
-//snap7的通信参数路径
-#define SNAP7_COMMUNICATION_PARAMETER_PATH    "../etc/snap7_communication.prototxt"
-    //通信状态
-    enum Snap7_communication_statu {
-        SNAP7_COMMUNICATION_UNKNOWN = 0,            //通信状态 未知
-        SNAP7_COMMUNICATION_READY = 1,            //通信状态 正常
-        SNAP7_COMMUNICATION_RECEIVE = 2,        //接受
-        SNAP7_COMMUNICATION_SEND = 3,        //发送
-        SNAP7_COMMUNICATION_DISCONNECT = 4,        //断连
-        SNAP7_COMMUNICATION_FAULT = 10,         //通信状态 错误
-    };
-protected:
-    Snap7_communication_base();
-
-    Snap7_communication_base(const Snap7_communication_base &other) = default;
-
-    Snap7_communication_base &operator=(const Snap7_communication_base &other) = default;
-
-    ~Snap7_communication_base();
-
-public://API functions
-    //初始化 通信 模块。如下二选一
-    virtual Error_manager communication_init(std::string ip);
-
-    //反初始化 通信 模块。
-    virtual Error_manager communication_uninit();
-
-    //唤醒s7通信线程
-    virtual Error_manager communication_start();
-
-    //停止s7通信线程
-    virtual Error_manager communication_stop();
-
-    //更新数据
-    virtual Error_manager updata_receive_buf();
-
-    virtual Error_manager updata_send_buf();
-
-public://get or set member variable
-    Snap7_communication_statu get_status();
-
-protected://member functions
-    //接受数据, 读取DB块,
-    Error_manager read_data_buf(Snap7_buf &snap7_buf);
-
-    //发送数据, 写入DB块,
-    Error_manager write_data_buf(Snap7_buf &snap7_buf);
-
-    //通信连接
-    Error_manager communication_connect(std::string ip_string);
-
-    //启动通信, run thread
-    Error_manager communication_run();
-
-    //通信断连
-    Error_manager communication_disconnect();
-
-    //mp_communication_thread线程的执行函数, 负责进行s7的通信
-    void communication_thread();
-
-
-    //数据颠倒
-    Error_manager reverse_byte(void *p_buf_in, void *p_buf_out, int size);
-
-
-protected://member variable
-public:
-    //状态
-    Snap7_communication_statu m_communication_status;    //通信状态
-    std::string m_ip_string;            //通信ip
-
-    //通信模块
-    std::mutex m_communication_lock;    //通信锁
-    TSnap7Client m_snap7_client;            //通信的客户端
-    int m_communication_delay_time_ms;//通信延时, 单位ms
-    //注:s7协议通信很不稳定, 在每次使用 TSnap7Client 之后, 都需要加延时
-
-    //数据
-    std::mutex m_receive_buf_lock;        //接受的锁
-    std::map<int, Snap7_buf> m_receive_buf_map;        //接受的map容器
-    std::mutex m_send_buf_lock;        //发送的锁
-    std::map<int, Snap7_buf> m_send_buf_map;        //发送的map容器
-
-    //线程, snap7的通信核心就是对 发送和接受内存的 周期性读写, 所以使用一个线程即可.
-    std::thread *mp_communication_thread;            //通信的线程指针
-    Thread_condition m_communication_condition;            //通信的条件变量
-
-
-private:
-
-};
-
-
-#endif //NNXX_TESTS_SNAP7_E_BASE_H

+ 0 - 8
include/plc/test.cpp

@@ -1,8 +0,0 @@
-#include "test.h"
-
-int main(int argc, char** argv) {
-    S7Test s7;
-    s7.communication_init("");
-
-    return EXIT_SUCCESS;
-}

+ 0 - 8
include/plc/test.h

@@ -1,8 +0,0 @@
-#pragma once
-
-#include <iostream>
-#include "snap7_communication_base.h"
-
-class S7Test:public Snap7_communication_base {
-
-};

+ 3 - 15
include/rabbitmq/CMakeLists.txt

@@ -1,8 +1,4 @@
-set(LIBRARY_NAME librabbitmq)
-
-unset(OPTION_ENABLE_TEST_CODE CACHE)
-option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
-message("<=${LIBRARY_NAME}=> test: " ${OPTION_ENABLE_TEST_CODE})
+set(LIBRARY_NAME zxrabbitmq)
 
 set(LIBRARY_SOURCE_LIST
     ${CMAKE_CURRENT_LIST_DIR}/rabbitmq_base.h
@@ -24,7 +20,8 @@ else()
 endif()
 
 set(LIBRARY_DEPEND_LIST
-    libthread
+    zxthread
+        zxmessage
     ${Rabbitmq}
     ${PROTOBUF_LIBRARIES}
 )
@@ -32,12 +29,3 @@ set(LIBRARY_DEPEND_LIST
 add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
 target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
 
-if (OPTION_ENABLE_TEST_CODE)
-    set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
-    set(LIBRARY_TEST_SOURCE_LIST
-            ${CMAKE_CURRENT_LIST_DIR}/test.h
-            ${CMAKE_CURRENT_LIST_DIR}/test.cpp
-    )
-    add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
-    target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
-endif ()

+ 3 - 3
include/rabbitmq/rabbitmq_base.h

@@ -22,16 +22,16 @@
 #include <cstring>
 #include <ctime>
 #include <map>
-#include "protobuf/load_protobuf.hpp"
+#include "tool/load_protobuf.hpp"
 
 #include <rabbitmq-c/amqp.h>
 #include <rabbitmq-c/tcp_socket.h>
 #include <cassert>
 
 #include <glog/logging.h>
-#include "error_code/error_code.hpp"
+#include "tool/error_code.hpp"
 #include "thread/binary_buf.h"
-#include "thread/thread_safe_list.hpp"
+#include "tool/thread_safe_list.hpp"
 #include "thread/thread_condition.h"
 
 #include "rabbitmq/rabbitmq.pb.h"

+ 1 - 1
include/rabbitmq/rabbitmq_message.h

@@ -5,7 +5,7 @@
 #ifndef __RABBITMQ_MESSAGE_H
 #define __RABBITMQ_MESSAGE_H
 
-#include "error_code/error_code.hpp"
+#include "tool/error_code.hpp"
 
 #include <time.h>
 #include <sys/time.h>

+ 0 - 5
include/rabbitmq/test.cpp

@@ -1,5 +0,0 @@
-#include "test.h"
-
-int main(int argc, char** argv) {
-    return EXIT_SUCCESS;
-}

+ 0 - 3
include/rabbitmq/test.h

@@ -1,3 +0,0 @@
-#pragma once
-
-#include <iostream>

+ 1 - 6
include/thread/CMakeLists.txt

@@ -1,4 +1,4 @@
-set(LIBRARY_NAME libthread)
+set(LIBRARY_NAME zxthread)
 
 unset(OPTION_ENABLE_TEST_CODE CACHE)
 option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
@@ -7,13 +7,8 @@ message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_COD
 set(LIBRARY_SOURCE_LIST
         ${CMAKE_CURRENT_LIST_DIR}/thread_condition.h
         ${CMAKE_CURRENT_LIST_DIR}/thread_condition.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/thread_pool.h
-        ${CMAKE_CURRENT_LIST_DIR}/thread_safe_list.hpp
-        ${CMAKE_CURRENT_LIST_DIR}/thread_safe_queue.hpp
         ${CMAKE_CURRENT_LIST_DIR}/time_tool.h
         ${CMAKE_CURRENT_LIST_DIR}/time_tool.cpp
-        ${CMAKE_CURRENT_LIST_DIR}/singleton.h
-        ${CMAKE_CURRENT_LIST_DIR}/singleton.cpp
         ${CMAKE_CURRENT_LIST_DIR}/binary_buf.h
         ${CMAKE_CURRENT_LIST_DIR}/binary_buf.cpp
 )

+ 0 - 4
include/thread/singleton.cpp

@@ -1,4 +0,0 @@
-
-#include "singleton.h"
-
-

+ 0 - 5
include/thread/test.cpp

@@ -1,5 +0,0 @@
-#include "test.h"
-
-int main(int argc, char** argv) {
-    return EXIT_SUCCESS;
-}

+ 0 - 3
include/thread/test.h

@@ -1,3 +0,0 @@
-#pragma once
-
-#include <iostream>

+ 1 - 1
include/thread/time_tool.h

@@ -10,7 +10,7 @@
 #include <iostream>
 #include<time.h>
 #include <queue>
-#include "./singleton.h"
+#include "tool/singleton.hpp"
 
 class Time_tool:public Singleton<Time_tool>
 {

include/error_code/error_code.hpp → include/tool/error_code.hpp


+ 1 - 1
include/protobuf/load_protobuf.hpp

@@ -8,7 +8,7 @@
 #include <google/protobuf/text_format.h>
 #include "google/protobuf/util/json_util.h"
 
-#include "error_code/error_code.hpp"
+#include "tool/error_code.hpp"
 
 using google::protobuf::io::FileInputStream;
 using google::protobuf::io::FileOutputStream;

+ 1 - 1
include/log/log.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include <glog/logging.h>
-#include "file/pathcreator.h"
+#include "tool/pathcreator.hpp"
 
 namespace ZX{
     static void shut_down_logging(const char *data, size_t size) {

+ 118 - 0
include/tool/pathcreator.hpp

@@ -0,0 +1,118 @@
+#pragma once
+
+#include <string>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fstream>
+#include <stdint.h>
+#include <stdio.h>
+#include <time.h>
+
+class PathCreator
+{
+public:
+    PathCreator() = default;
+    ~PathCreator() = default;
+
+    std::string GetCurPath() {
+        return m_current_path;
+    }
+
+    bool Mkdir(std::string dirName) {
+        uint32_t beginCmpPath = 0;
+        uint32_t endCmpPath = 0;
+        std::string fullPath = "";
+
+        if('/' != dirName[0])
+        {
+            fullPath = getcwd(nullptr, 0);
+            beginCmpPath = fullPath.size();
+            fullPath = fullPath + "/" + dirName;
+        }
+        else
+        {
+            //Absolute path
+            fullPath = dirName;
+            beginCmpPath = 1;
+        }
+        if (fullPath[fullPath.size() - 1] != '/')
+        {
+            fullPath += "/";
+        }
+        endCmpPath = fullPath.size();
+
+        //create dirs;
+        for(uint32_t i = beginCmpPath; i < endCmpPath ; i++ )
+        {
+            if('/' == fullPath[i])
+            {
+                std::string curPath = fullPath.substr(0, i);
+                if(access(curPath.c_str(), F_OK) != 0)
+                {
+                    if(mkdir(curPath.c_str(), /*S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH*/0777) == -1)
+                    {
+                        printf("mkdir(%s) failed\n", curPath.c_str());
+                        return false;
+                    }
+                }
+            }
+        }
+        m_current_path=fullPath;
+        return true;
+
+    }
+
+    bool CreateDatePath(std::string root, bool add_time = true) {
+        time_t tt;
+        time( &tt );
+        tt = tt + 8*3600;  // transform the time zone
+        tm* t= gmtime( &tt );
+        char buf[255]={0};
+        if (add_time)
+        {
+            sprintf(buf, "%s/%d%02d%02d-%02d%02d%02d", root.c_str(),
+                    t->tm_year + 1900,
+                    t->tm_mon + 1,
+                    t->tm_mday,
+                    t->tm_hour,
+                    t->tm_min,
+                    t->tm_sec);
+        }
+        else
+        {
+            sprintf(buf, "%s/%d%02d%02d", root.c_str(),
+                    t->tm_year + 1900,
+                    t->tm_mon + 1,
+                    t->tm_mday);
+        }
+        return Mkdir(buf);
+    }
+
+    static bool IsPathExist(const std::string& path) {
+        if (access(path.c_str(), 0) == F_OK) {
+            return true;
+        }
+        return false;
+    }
+
+    static bool IsFile(const std::string& path) {
+        if (!IsPathExist(path)) {
+            printf("%s:%d %s not exist\n", __FILE__, __LINE__, path.c_str());
+            return false;
+        }
+        struct stat buffer;
+        return (stat(path.c_str(), &buffer) == 0 && S_ISREG(buffer.st_mode));
+    }
+
+    static bool IsFolder(const std::string& path) {
+        if (!IsPathExist(path)) {
+            return false;
+        }
+        struct stat buffer;
+        return (stat(path.c_str(), &buffer) == 0 && S_ISDIR(buffer.st_mode));
+    }
+
+protected:
+    std::string m_current_path;
+};

+ 227 - 0
include/tool/point2D_tool.hpp

@@ -0,0 +1,227 @@
+//
+// Created by huli on 2020/9/1.
+//
+
+#ifndef POINT2D_TOOL_H
+#define POINT2D_TOOL_H
+
+
+
+//#define OPEN_PCL_FLAG
+#ifdef OPEN_PCL_FLAG
+#include <pcl/point_types.h>
+#include <pcl/PCLPointCloud2.h>
+#include <pcl/conversions.h>
+#include <pcl/common/common.h>
+#endif
+
+#include <stddef.h>
+#include <math.h>
+
+class Point2D_tool
+{
+public:
+	//极坐标
+	struct Polar_coordinates
+	{
+		float angle=0;				//弧度
+		float distance=0;				//距离
+	};
+
+	//极坐标的限定范围
+	struct Polar_coordinates_box
+	{
+		float angle_min=0;			//角度最小值
+		float angle_max=0;			//角度最大值
+		float distance_min=0;			//距离最小值
+		float distance_max=0;			//距离最大值
+	};
+
+	//平面坐标
+	struct Point2D
+	{
+		float x=0;				//x轴
+		float y=0;				//y轴
+	};
+
+	//平面坐标的限定范围
+	struct Point2D_box
+	{
+		float x_min=0;				//x轴最小值
+		float x_max=0;				//x轴最大值
+		float y_min=0;				//y轴最小值
+		float y_max=0;				//y轴最大值
+	};
+
+	//平面坐标的转换矩阵, 可以进行旋转和平移, 不能缩放
+	struct Point2D_transform
+	{
+		float m00=1;
+		float m01=0;
+		float m02=0;
+		float m10=0;
+		float m11=1;
+		float m12=0;
+	};
+
+	//极坐标 -> 平面坐标
+	static bool Polar_coordinates_to_point2D(Point2D_tool::Polar_coordinates* p_polar_coordinates, Point2D_tool::Point2D* p_point2D);
+	//平面坐标 -> 极坐标
+	static bool Point2D_to_polar_coordinates(Point2D_tool::Point2D* p_point2D, Point2D_tool::Polar_coordinates* p_polar_coordinates);
+
+
+	//判断极坐标点是否在限制范围
+	static bool limit_with_polar_coordinates_box(float distance, float angle, Point2D_tool::Polar_coordinates_box* p_polar_coordinates_box);
+	//判断平面坐标点是否在限制范围
+	static bool limit_with_point2D_box(float x, float y, Point2D_tool::Point2D_box* p_point2D_box);
+
+#ifdef OPEN_PCL_FLAG
+	//平面坐标的转换, 可以进行旋转和平移, 不能缩放
+	static bool transform_with_translation_rotation(float* p_x_in, float* p_y_in, float* p_x_out, float* p_y_out,
+													Point2D_tool::Point2D_transform* p_point2D_transform);
+	static bool transform_with_translation_rotation(pcl::PointXYZ* p_point3D_in, pcl::PointXYZ* p_point3D_out,
+													Point2D_tool::Point2D_transform* p_point2D_transform);
+	static bool transform_with_translation_rotation(pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_in,
+													pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_out,
+													Point2D_tool::Point2D_transform* p_point2D_transform);
+
+#endif
+};
+
+//极坐标 -> 平面坐标
+bool Point2D_tool::Polar_coordinates_to_point2D(Point2D_tool::Polar_coordinates* p_polar_coordinates, Point2D_tool::Point2D* p_point2D)
+{
+    if ( p_polar_coordinates == NULL || p_point2D == NULL)
+    {
+        return false;
+    }
+    else
+    {
+        p_point2D->x = p_polar_coordinates->distance * cos(p_polar_coordinates->angle);
+        p_point2D->y = p_polar_coordinates->distance * sin(p_polar_coordinates->angle);
+        return true;
+    }
+    return true;
+}
+//平面坐标 -> 极坐标
+bool Point2D_tool::Point2D_to_polar_coordinates(Point2D_tool::Point2D* p_point2D, Point2D_tool::Polar_coordinates* p_polar_coordinates)
+{
+    if ( p_polar_coordinates == NULL || p_point2D == NULL)
+    {
+        return false;
+    }
+    else
+    {
+        p_polar_coordinates->distance = sqrt(p_point2D->x * p_point2D->x + p_point2D->y * p_point2D->y);
+        p_polar_coordinates->angle = atan(p_point2D->y / p_point2D->x);
+        return true;
+    }
+    return true;
+}
+
+//判断极坐标点是否在限制范围
+bool Point2D_tool::limit_with_polar_coordinates_box(float distance, float angle, Point2D_tool::Polar_coordinates_box* p_polar_coordinates_box)
+{
+    if ( p_polar_coordinates_box == NULL )
+    {
+        return false;
+    }
+    else
+    {
+        if ( angle >= p_polar_coordinates_box->angle_min &&
+             angle <= p_polar_coordinates_box->angle_max &&
+             distance >= p_polar_coordinates_box->distance_min &&
+             distance <= p_polar_coordinates_box->distance_max )
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+//判断平面坐标点是否在限制范围
+bool Point2D_tool::limit_with_point2D_box(float x, float y, Point2D_tool::Point2D_box* p_point2D_box)
+{
+    if ( p_point2D_box == NULL )
+    {
+        return false;
+    }
+    else
+    {
+        if ( x >= p_point2D_box->x_min &&
+             x <= p_point2D_box->x_max &&
+             y >= p_point2D_box->y_min &&
+             y <= p_point2D_box->y_max )
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+#ifdef OPEN_PCL_FLAG
+//平面坐标的转换, 可以进行旋转和平移, 不能缩放
+bool Point2D_tool::transform_with_translation_rotation(float* p_x_in, float* p_y_in, float* p_x_out, float* p_y_out,
+										 Point2D_tool::Point2D_transform* p_point2D_transform)
+{
+	if ( p_x_in == NULL || p_x_in == NULL || p_x_out == NULL || p_y_out == NULL || p_point2D_transform == NULL)
+	{
+		return false;
+	}
+	else
+	{
+		*p_x_out = *p_x_in * p_point2D_transform->m00 + *p_y_in * p_point2D_transform->m01 + p_point2D_transform->m02;
+		*p_y_out = *p_x_in * p_point2D_transform->m10 + *p_y_in * p_point2D_transform->m11 + p_point2D_transform->m12;
+		return true;
+	}
+	return true;
+}
+bool Point2D_tool::transform_with_translation_rotation(pcl::PointXYZ* p_point3D_in, pcl::PointXYZ* p_point3D_out,
+												Point2D_tool::Point2D_transform* p_point2D_transform)
+{
+	if (p_point3D_in == NULL || p_point3D_out == NULL || p_point2D_transform == NULL)
+	{
+		return false;
+	}
+	else
+	{
+		p_point3D_out->x = p_point3D_in->x * p_point2D_transform->m00 + p_point3D_in->y * p_point2D_transform->m01 +
+						   p_point2D_transform->m02;
+		p_point3D_out->y = p_point3D_in->x * p_point2D_transform->m10 + p_point3D_in->y * p_point2D_transform->m11 +
+						   p_point2D_transform->m12;
+		return true;
+	}
+	return true;
+}
+bool Point2D_tool::transform_with_translation_rotation(pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_in,
+												pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_out,
+												Point2D_tool::Point2D_transform* p_point2D_transform)
+{
+	if ( p_cloud_in.get() == NULL || p_cloud_out.get() == NULL || p_point2D_transform == NULL)
+	{
+	    return false;
+	}
+	else
+	{
+		pcl::PointXYZ point;
+		for (int i = 0; i < p_cloud_in->size(); ++i)
+		{
+			point.x = p_cloud_in->points[i].x * p_point2D_transform->m00 + p_cloud_in->points[i].y * p_point2D_transform->m01 + p_point2D_transform->m02;
+			point.y = p_cloud_in->points[i].x * p_point2D_transform->m10 + p_cloud_in->points[i].y * p_point2D_transform->m11 + p_point2D_transform->m12;
+			p_cloud_out->push_back(point);
+		}
+		return true;
+	}
+	return true;
+}
+#endif
+
+#endif //POINT2D_TOOL_H

+ 155 - 0
include/tool/point3D_tool.hpp

@@ -0,0 +1,155 @@
+#pragma once
+
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+#include <vector>
+#include <opencv4/opencv2/opencv.hpp>
+#include "tool/log.hpp"
+
+class Point3D_tool
+{
+public:
+    static bool WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud) {
+        DLOG(INFO) << "begain push point data to " << file;
+        std::fstream fileTxtCloud;
+        fileTxtCloud.open(file, std::ios_base::trunc | std::ios::in | std::ios::out);
+        for (auto &point: *cloud) {
+            fileTxtCloud << point.x << " " << point.y << " " << point.z << std::endl;
+        }
+        fileTxtCloud.close();
+        DLOG(INFO) << "Push point complete, push point number: " << cloud->size();
+        return true;
+    }
+
+    static bool WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud) {
+        DLOG(INFO) << "begain push point data to " << file;
+        std::fstream fileTxtCloud;
+        fileTxtCloud.open(file, std::ios_base::trunc | std::ios::in | std::ios::out);
+        for (auto &point: *cloud) {
+            fileTxtCloud << point.x << " " << point.y << " " << point.z << std::endl;
+        }
+        fileTxtCloud.close();
+        DLOG(INFO) << "Push point complete, push point number: " << cloud->size();
+        return true;
+    }
+
+    static bool ReadTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud) {
+        DLOG(INFO) << "Load point data form file: " << file;
+        std::ifstream fin(file.c_str());
+        if (fin.bad()) {
+            LOG(WARNING) << "File " << file << " don't exist.";
+            return false;
+        }
+        const int line_length = 64;
+        char str[line_length] = {0};
+        while (fin.getline(str, line_length)) {
+            pcl::PointXYZ point{};
+            if (string2PointXYZ(str, point)) {
+                cloud->push_back(point);
+            }
+        }
+        DLOG(INFO) << "Load point complete, get point number: " << cloud->size();
+        return true;
+    }
+
+	template <typename PclPoint>
+	static int getMinRect(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds) {
+        if (clouds->points.size() < 4) {
+            DLOG(ERROR) << "points to little.";
+            return false;
+        }
+        std::vector<cv::Point2f> cv_clouds;
+        for (auto &point: clouds->points) {
+            cv_clouds.emplace_back(point.x, point.y);
+        }
+        rect = cv::minAreaRect(cv_clouds);
+        return true;
+    }
+
+	// template <typename PclPoint>
+	static int getRectCloud(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value = 0, int numbers = 100) {
+        cv::Point2f cv_points[4];
+        rect.points(cv_points);
+        // PclPoint point;
+        pcl::PointXYZ point;
+        // 左侧点
+        double step_x = (cv_points[1].x - cv_points[0].x) / numbers;
+        double step_y = (cv_points[1].y - cv_points[0].y) / numbers;
+        for (int i = 0; i < numbers; i++) {
+            point.x = cv_points[0].x + i * step_x;
+            point.y = cv_points[0].y + i * step_y;
+            point.z = z_value;
+            points->points.emplace_back(point);
+        }
+
+        // 上侧点
+        step_x = (cv_points[2].x - cv_points[1].x) / numbers;
+        step_y = (cv_points[2].y - cv_points[1].y) / numbers;
+        for (int i = 0; i < numbers; i++) {
+            point.x = cv_points[1].x + i * step_x;
+            point.y = cv_points[1].y + i * step_y;
+            point.z = z_value;
+            points->points.emplace_back(point);
+        }
+
+        // 右侧点
+        step_x = (cv_points[3].x - cv_points[2].x) / numbers;
+        step_y = (cv_points[3].y - cv_points[2].y) / numbers;
+        for (int i = 0; i < numbers; i++) {
+            point.x = cv_points[2].x + i * step_x;
+            point.y = cv_points[2].y + i * step_y;
+            point.z = z_value;
+            points->points.emplace_back(point);
+        }
+
+
+        // 下侧点
+        step_x = (cv_points[0].x - cv_points[3].x) / numbers;
+        step_y = (cv_points[0].y - cv_points[3].y) / numbers;
+        for (int i = 0; i < numbers; i++) {
+            point.x = cv_points[3].x + i * step_x;
+            point.y = cv_points[3].y + i * step_y;
+            point.z = z_value;
+            points->points.emplace_back(point);
+        }
+
+        return points->size();
+    }
+
+	template <typename PclPoint>
+	static int getRectCloud(pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value = 0, int numbers = 100) {
+        cv::RotatedRect rect = getMinRect(clouds);
+        getRectCloud(rect, points, z_value, numbers);
+        return points->size();
+    }
+
+	static void getRectWidthlength(cv::RotatedRect &rect, double &width, double &length) {
+        cv::Point2f points[4];
+        rect.points(points);
+
+        double a = sqrt((points[1].x - points[0].x) * (points[1].x - points[0].x) + (points[1].y - points[0].y) * (points[1].y - points[0].y));
+        double b = sqrt((points[2].x - points[1].x) * (points[2].x - points[1].x) + (points[2].y - points[1].y) * (points[2].y - points[1].y));
+
+        width = MIN(a, b);
+        length = MAX(a, b);
+    }
+
+private:
+    static bool string2PointXYZ(const std::string &str, pcl::PointXYZ &point) {
+        std::istringstream iss;
+        iss.str(str);
+        float value;
+        float data[3];
+        for (int i = 0; i < 3; ++i) {
+            if (iss >> value) {
+                data[i] = value;
+            } else {
+                return false;
+            }
+        }
+        point.x = data[0];
+        point.y = data[1];
+        point.z = data[2];
+        return true;
+    }
+};

include/thread/singleton.h → include/tool/singleton.hpp


include/thread/thread_pool.h → include/tool/thread_pool.hpp


include/thread/thread_safe_list.hpp → include/tool/thread_safe_list.hpp


include/thread/thread_safe_queue.hpp → include/tool/thread_safe_queue.hpp


include/pcl/trans_coor.hpp → include/tool/trans_coor.hpp


+ 1 - 1
project/clamp_lidar

@@ -1 +1 @@
-Subproject commit f1463f303b96e577eb66749efba4fbbc23f69435
+Subproject commit 28237c6a24b8df4093998e7b57955e9b09587183