File size: 1,607 Bytes
7fc5a59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef OPENPOSE_FILESTREAM_JSON_OFSTREAM_HPP
#define OPENPOSE_FILESTREAM_JSON_OFSTREAM_HPP

#include <fstream> // std::ofstream
#include <openpose/core/common.hpp>

namespace op
{
    class OP_API JsonOfstream
    {
    public:
        explicit JsonOfstream(const std::string& filePath, const bool humanReadable = true);

        /**
         * Move constructor.
         * It destroys the original JsonOfstream to be moved.
         * @param array JsonOfstream to be moved.
         */
        JsonOfstream(JsonOfstream&& jsonOfstream);

        /**
         * Move assignment.
         * Similar to JsonOfstream(JsonOfstream&& jsonOfstream).
         * @param array JsonOfstream to be moved.
         * @return The resulting JsonOfstream.
         */
        JsonOfstream& operator=(JsonOfstream&& jsonOfstream);

        virtual ~JsonOfstream();

        void objectOpen();

        void objectClose();

        void arrayOpen();

        void arrayClose();

        void version(const std::string& version);

        void key(const std::string& string);

        template <typename T>
        inline void plainText(const T& value)
        {
            *upOfstream << value;
        }

        inline void comma()
        {
            *upOfstream << ",";
        }

        void enter();

    private:
        bool mHumanReadable;
        long long mBracesCounter;
        long long mBracketsCounter;
        std::unique_ptr<std::ofstream> upOfstream; // std::unique_ptr to solve std::move issue in GCC < 5

        DELETE_COPY(JsonOfstream);
    };
}

#endif // OPENPOSE_FILESTREAM_JSON_OFSTREAM_HPP