Commit fb9deba6 authored by Tomáš Jakubec's avatar Tomáš Jakubec
Browse files

add cmake list, use std::quote in JSON

parent fc79208b
Loading
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#include <fstream>
#include "VariableExport.h"
#include <iostream>
#include <iomanip>
/**
 * @brief The JSONLogger class
 * has opened file to write log
@@ -84,7 +85,7 @@ public:
            firstWrite = false;
        }

        (*logFile) << "\t{\n\t\t\"expr\" : \""<< escapeQuotationMarks( name ) <<
        (*logFile) << "\t{\n\t\t\"expr\" : \""<< std::quoted( name ) <<
                      "\",\n\t\t\"data\" : " ;
        VariableExport<>::exportVariable(*logFile, value);
        (*logFile) << "\n}";
@@ -108,7 +109,7 @@ public:
                      "\n\t\t\"gInd\" : " << groupIndex << "," <<
                      "\n\t\t\"file\" : \"" << cppFile << "\"," <<
                      "\n\t\t\"line\" : " << line << "," <<
                      "\n\t\t\"expr\" : \""<< escapeQuotationMarks( name ) << "\"," <<
                      "\n\t\t\"expr\" : \""<< std::quoted( name ) << "\"," <<
                      "\n\t\t\"data\" : ";
        VariableExport<>::exportVariable(*logFile, value);
        (*logFile) << "\n\t}";
@@ -132,7 +133,7 @@ public:
                      "\n\t\t\"gInd\" : " << groupIndex << "," <<
                      "\n\t\t\"file\" : \"" << cppFile << "\"," <<
                      "\n\t\t\"line\" : " << line << "," <<
                      "\n\t\t\"expr\" : \""<< escapeQuotationMarks( name ) << "\"," <<
                      "\n\t\t\"expr\" : \""<< std::quoted( name ) << "\"," <<
                      "\n\t\t\"data\" : ";
        VariableExport<>::exportVariable(*logFile, value);

@@ -157,16 +158,6 @@ public:
        }
        return res;
    }

    std::string escapeQuotationMarks(const char * str){
        std::string res = str;
        size_t pos = 0;
        while((pos = res.find("\"", pos + 2)) != res.npos){
            res.replace(pos, 1, "\\\"");
        }
        return res;
    }

};

#endif // JSONLOGGER_H
+9 −0
Original line number Diff line number Diff line

## below are targets for each test
add_executable( BinarySerializerTest BinarySerializerTest.cpp )
target_compile_options( BinarySerializerTest PRIVATE ${CXX_TESTS_FLAGS} )
target_link_libraries( BinarySerializerTest ${GTEST_BOTH_LIBRARIES} )


## add all targets to the CMake's "test" target (i.e. `make test` runs all tests)
add_test( BinarySerializerTest ${EXECUTABLE_OUTPUT_PATH}/BinarySerializerTest${CMAKE_EXECUTABLE_SUFFIX} )