├── README.md
├── global.cpp
├── global.h
├── json
├── json-forwards.h
└── json.h
├── jsoncpp.cpp
├── main.cpp
├── makefile
├── spider.cpp
└── spider.h
/README.md:
--------------------------------------------------------------------------------
1 | ##某个社交app爬虫
2 |
3 | 主要用libcurl实现的一个爬虫,写这个主要因为好玩,绝不是程序员的闷骚。。哈哈哈
4 |
5 | 抓取某个社交app用户(只抓取女性用户。。。)的头像图片、基本信息、相册、动态(包括动态文本和图片)。
6 |
7 | 多线程,线程之间无锁(只在获取id的时候使用了__sync_fetch_and_add),抓取速度快,基本满带宽下载
8 |
9 |
10 | ##INSTALL:
11 | ```Bash
12 | ./makefile
13 | ```
14 |
15 | ##Usage:
16 | ```Bash
17 | spider -t thread_count -p save path -i start_id
18 | ```
19 |
20 |
thread_count:线程数,可以看情况多开点
21 | save:保存的路径
22 | start_id:抓取的用户起始id,不会重复抓取已经抓取的用户
23 |
24 | 注:我已经很久没更新,这个目标app的有些api可能已经更改,所以可能会失效。但是代码可以参考。
25 |
26 |
27 | ##我的邮箱:
28 |
29 | 646452100@qq.com
30 |
--------------------------------------------------------------------------------
/global.cpp:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 | #include "curl/curl.h"
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | Global* Global::m_instance = NULL;
13 | __thread char Global::m_log_buff[MSG_BUFF] = {};
14 |
15 | Global::Global()
16 | {
17 | m_init = false;
18 | m_path[0] = '\0';
19 | m_pic_path[0] = '\0';
20 | m_json_path[0] = '\0';
21 | m_terminated = false;
22 | m_spider_cnt = 0;
23 | }
24 |
25 | Global::~Global()
26 | {
27 | if (m_init)
28 | {
29 | curl_global_cleanup();
30 | }
31 |
32 | on_end();
33 | }
34 |
35 | bool Global::check_path(const char* path)
36 | {
37 | if (!opendir(path))
38 | {
39 | if (errno != ENOENT)
40 | {
41 | fprintf(stderr, "open path %s error.%s. \n", path, strerror(errno));
42 | return false;
43 | }
44 |
45 | if (mkdir(path, 0777) != 0)
46 | {
47 | fprintf(stderr, "create path %s error.%s. \n", path, strerror(errno));
48 | return false;
49 | }
50 | }
51 |
52 | return true;
53 | }
54 |
55 | bool Global::set_path(const char* path)
56 | {
57 | if (!path || path[0] == '\0') return false;
58 |
59 | strncpy(m_path, path, MAX_PATH);
60 |
61 | int len = strlen(m_path);
62 | if (m_path[len - 1] == '/')
63 | {
64 | m_path[len - 1] = '\0';
65 | }
66 |
67 | strncpy(m_pic_path, path, MAX_PATH);
68 | strcat(m_pic_path, "/pics");
69 | strncpy(m_json_path, path, MAX_PATH);
70 | strcat(m_json_path, "/jsons");
71 |
72 | if (!check_path(path)) return false;
73 | if (!check_path(m_pic_path)) return false;
74 | if (!check_path(m_json_path)) return false;
75 |
76 | return true;
77 | }
78 |
79 | Global* Global::get_instance()
80 | {
81 | if (!m_instance)
82 | m_instance = new Global();
83 |
84 | return m_instance;
85 | }
86 |
87 | bool Global::init_global_env()
88 | {
89 | if (m_init) return false;
90 |
91 | CURLcode ret = curl_global_init(CURL_GLOBAL_ALL);
92 | if (CURLE_OK != ret)
93 | {
94 | return false;
95 | }
96 |
97 | m_init = true;
98 | return true;
99 | }
100 |
101 | void Global::out_log(const char* sFormat, ...)
102 | {
103 | time_t tNow = time(NULL);
104 | struct tm ptm = {};
105 | localtime_r(&tNow, &ptm);
106 | strftime(m_log_buff, MSG_BUFF, "[%Y-%m-%d %H:%M:%S]", &ptm);
107 |
108 | int len = strlen(m_log_buff);
109 | sprintf(m_log_buff + len, "Thread[%lu]->", pthread_self());
110 | len = strlen(m_log_buff);
111 |
112 | va_list ap;
113 | va_start(ap, sFormat);
114 | vsnprintf(m_log_buff + len, MSG_BUFF - len, sFormat, ap);
115 | va_end(ap);
116 | m_log_buff[MSG_BUFF - 1] = '\0';
117 |
118 | fprintf(stderr, m_log_buff);
119 | }
120 |
121 | void Global::on_end()
122 | {
123 | char path[MAX_PATH];
124 | strcpy(path, m_path);
125 | strcat(path, "/spider_log.txt");
126 |
127 | FILE *fptr = fopen(path, "a");
128 | if (!fptr) return;
129 |
130 | time_t tNow = time(NULL);
131 | struct tm ptm = {};
132 | localtime_r(&tNow, &ptm);
133 | strftime(m_log_buff, MSG_BUFF, "[%Y-%m-%d %H:%M:%S]", &ptm);
134 | int len = strlen(m_log_buff);
135 |
136 | sprintf(m_log_buff + len, "Start-->[%d], End-->[%d], Available-->[%d].\r\n", m_log_start, m_target_start - 1, m_spider_cnt);
137 |
138 | fprintf(fptr, m_log_buff);
139 |
140 | fclose(fptr);
141 | fprintf(stderr, m_log_buff);
142 | }
143 |
--------------------------------------------------------------------------------
/global.h:
--------------------------------------------------------------------------------
1 | #ifndef __GLOBAL_H__
2 | #define __GLOBAL_H__
3 |
4 | #include
5 |
6 | #define MAX_PATH 256
7 |
8 | class Global
9 | {
10 | public:
11 | static const int MSG_BUFF = 256;
12 |
13 | virtual ~Global();
14 |
15 | static Global* get_instance();
16 |
17 | bool set_path(const char* path);
18 |
19 | const char* get_path()
20 | {
21 | return m_path;
22 | }
23 |
24 | const char* get_pic_path()
25 | {
26 | return m_pic_path;
27 | }
28 |
29 | const char* get_json_path()
30 | {
31 | return m_json_path;
32 | }
33 |
34 | bool init_global_env();
35 |
36 | void set_target_start(int target_id)
37 | {
38 | m_target_start = target_id;
39 | m_log_start = target_id;
40 | }
41 |
42 | int get_target_id()
43 | {
44 | return __sync_fetch_and_add(&m_target_start, 1);
45 | }
46 |
47 | void add_spider_cnt()
48 | {
49 | __sync_fetch_and_add(&m_spider_cnt, 1);
50 | }
51 |
52 | bool is_terminated()
53 | {
54 | return m_terminated;
55 | }
56 |
57 | void set_terminated()
58 | {
59 | m_terminated = true;
60 | }
61 |
62 | void out_log(const char* sFormat, ...);
63 |
64 | void on_end();
65 |
66 | private:
67 | Global();
68 | bool check_path(const char* path);
69 |
70 | private:
71 | char m_path[MAX_PATH];
72 | char m_pic_path[MAX_PATH];
73 | char m_json_path[MAX_PATH];
74 |
75 | bool m_init;
76 | static Global* m_instance;
77 | int m_target_start;
78 | int m_log_start;
79 | int m_spider_cnt; //爬下来的id个数
80 | bool m_terminated;
81 |
82 | static __thread char m_log_buff[MSG_BUFF];
83 | };
84 |
85 |
86 | #endif
87 |
--------------------------------------------------------------------------------
/json/json-forwards.h:
--------------------------------------------------------------------------------
1 | /// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
2 | /// It is intended to be used with #include "json/json-forwards.h"
3 | /// This header provides forward declaration for all JsonCpp types.
4 |
5 | // //////////////////////////////////////////////////////////////////////
6 | // Beginning of content of file: LICENSE
7 | // //////////////////////////////////////////////////////////////////////
8 |
9 | /*
10 | The JsonCpp library's source code, including accompanying documentation,
11 | tests and demonstration applications, are licensed under the following
12 | conditions...
13 |
14 | The author (Baptiste Lepilleur) explicitly disclaims copyright in all
15 | jurisdictions which recognize such a disclaimer. In such jurisdictions,
16 | this software is released into the Public Domain.
17 |
18 | In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
19 | 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
20 | released under the terms of the MIT License (see below).
21 |
22 | In jurisdictions which recognize Public Domain property, the user of this
23 | software may choose to accept it either as 1) Public Domain, 2) under the
24 | conditions of the MIT License (see below), or 3) under the terms of dual
25 | Public Domain/MIT License conditions described here, as they choose.
26 |
27 | The MIT License is about as close to Public Domain as a license can get, and is
28 | described in clear, concise terms at:
29 |
30 | http://en.wikipedia.org/wiki/MIT_License
31 |
32 | The full text of the MIT License follows:
33 |
34 | ========================================================================
35 | Copyright (c) 2007-2010 Baptiste Lepilleur
36 |
37 | Permission is hereby granted, free of charge, to any person
38 | obtaining a copy of this software and associated documentation
39 | files (the "Software"), to deal in the Software without
40 | restriction, including without limitation the rights to use, copy,
41 | modify, merge, publish, distribute, sublicense, and/or sell copies
42 | of the Software, and to permit persons to whom the Software is
43 | furnished to do so, subject to the following conditions:
44 |
45 | The above copyright notice and this permission notice shall be
46 | included in all copies or substantial portions of the Software.
47 |
48 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
49 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
51 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
52 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
53 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
54 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55 | SOFTWARE.
56 | ========================================================================
57 | (END LICENSE TEXT)
58 |
59 | The MIT license is compatible with both the GPL and commercial
60 | software, affording one all of the rights of Public Domain with the
61 | minor nuisance of being required to keep the above copyright notice
62 | and license text in the source code. Note also that by accepting the
63 | Public Domain "license" you can re-license your copy using whatever
64 | license you like.
65 |
66 | */
67 |
68 | // //////////////////////////////////////////////////////////////////////
69 | // End of content of file: LICENSE
70 | // //////////////////////////////////////////////////////////////////////
71 |
72 |
73 |
74 |
75 |
76 | #ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
77 | # define JSON_FORWARD_AMALGATED_H_INCLUDED
78 | /// If defined, indicates that the source file is amalgated
79 | /// to prevent private header inclusion.
80 | #define JSON_IS_AMALGAMATION
81 |
82 | // //////////////////////////////////////////////////////////////////////
83 | // Beginning of content of file: include/json/config.h
84 | // //////////////////////////////////////////////////////////////////////
85 |
86 | // Copyright 2007-2010 Baptiste Lepilleur
87 | // Distributed under MIT license, or public domain if desired and
88 | // recognized in your jurisdiction.
89 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
90 |
91 | #ifndef JSON_CONFIG_H_INCLUDED
92 | #define JSON_CONFIG_H_INCLUDED
93 |
94 | /// If defined, indicates that json library is embedded in CppTL library.
95 | //# define JSON_IN_CPPTL 1
96 |
97 | /// If defined, indicates that json may leverage CppTL library
98 | //# define JSON_USE_CPPTL 1
99 | /// If defined, indicates that cpptl vector based map should be used instead of
100 | /// std::map
101 | /// as Value container.
102 | //# define JSON_USE_CPPTL_SMALLMAP 1
103 |
104 | // If non-zero, the library uses exceptions to report bad input instead of C
105 | // assertion macros. The default is to use exceptions.
106 | #ifndef JSON_USE_EXCEPTION
107 | #define JSON_USE_EXCEPTION 1
108 | #endif
109 |
110 | /// If defined, indicates that the source file is amalgated
111 | /// to prevent private header inclusion.
112 | /// Remarks: it is automatically defined in the generated amalgated header.
113 | // #define JSON_IS_AMALGAMATION
114 |
115 | #ifdef JSON_IN_CPPTL
116 | #include
117 | #ifndef JSON_USE_CPPTL
118 | #define JSON_USE_CPPTL 1
119 | #endif
120 | #endif
121 |
122 | #ifdef JSON_IN_CPPTL
123 | #define JSON_API CPPTL_API
124 | #elif defined(JSON_DLL_BUILD)
125 | #if defined(_MSC_VER)
126 | #define JSON_API __declspec(dllexport)
127 | #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
128 | #endif // if defined(_MSC_VER)
129 | #elif defined(JSON_DLL)
130 | #if defined(_MSC_VER)
131 | #define JSON_API __declspec(dllimport)
132 | #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
133 | #endif // if defined(_MSC_VER)
134 | #endif // ifdef JSON_IN_CPPTL
135 | #if !defined(JSON_API)
136 | #define JSON_API
137 | #endif
138 |
139 | // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
140 | // integer
141 | // Storages, and 64 bits integer support is disabled.
142 | // #define JSON_NO_INT64 1
143 |
144 | #if defined(_MSC_VER) // MSVC
145 | # if _MSC_VER <= 1200 // MSVC 6
146 | // Microsoft Visual Studio 6 only support conversion from __int64 to double
147 | // (no conversion from unsigned __int64).
148 | # define JSON_USE_INT64_DOUBLE_CONVERSION 1
149 | // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
150 | // characters in the debug information)
151 | // All projects I've ever seen with VS6 were using this globally (not bothering
152 | // with pragma push/pop).
153 | # pragma warning(disable : 4786)
154 | # endif // MSVC 6
155 |
156 | # if _MSC_VER >= 1500 // MSVC 2008
157 | /// Indicates that the following function is deprecated.
158 | # define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
159 | # endif
160 |
161 | #endif // defined(_MSC_VER)
162 |
163 |
164 | #ifndef JSON_HAS_RVALUE_REFERENCES
165 |
166 | #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
167 | #define JSON_HAS_RVALUE_REFERENCES 1
168 | #endif // MSVC >= 2010
169 |
170 | #ifdef __clang__
171 | #if __has_feature(cxx_rvalue_references)
172 | #define JSON_HAS_RVALUE_REFERENCES 1
173 | #endif // has_feature
174 |
175 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
176 | #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
177 | #define JSON_HAS_RVALUE_REFERENCES 1
178 | #endif // GXX_EXPERIMENTAL
179 |
180 | #endif // __clang__ || __GNUC__
181 |
182 | #endif // not defined JSON_HAS_RVALUE_REFERENCES
183 |
184 | #ifndef JSON_HAS_RVALUE_REFERENCES
185 | #define JSON_HAS_RVALUE_REFERENCES 0
186 | #endif
187 |
188 | #ifdef __clang__
189 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
190 | # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
191 | # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
192 | # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
193 | # define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
194 | # endif // GNUC version
195 | #endif // __clang__ || __GNUC__
196 |
197 | #if !defined(JSONCPP_DEPRECATED)
198 | #define JSONCPP_DEPRECATED(message)
199 | #endif // if !defined(JSONCPP_DEPRECATED)
200 |
201 | namespace Json {
202 | typedef int Int;
203 | typedef unsigned int UInt;
204 | #if defined(JSON_NO_INT64)
205 | typedef int LargestInt;
206 | typedef unsigned int LargestUInt;
207 | #undef JSON_HAS_INT64
208 | #else // if defined(JSON_NO_INT64)
209 | // For Microsoft Visual use specific types as long long is not supported
210 | #if defined(_MSC_VER) // Microsoft Visual Studio
211 | typedef __int64 Int64;
212 | typedef unsigned __int64 UInt64;
213 | #else // if defined(_MSC_VER) // Other platforms, use long long
214 | typedef long long int Int64;
215 | typedef unsigned long long int UInt64;
216 | #endif // if defined(_MSC_VER)
217 | typedef Int64 LargestInt;
218 | typedef UInt64 LargestUInt;
219 | #define JSON_HAS_INT64
220 | #endif // if defined(JSON_NO_INT64)
221 | } // end namespace Json
222 |
223 | #endif // JSON_CONFIG_H_INCLUDED
224 |
225 | // //////////////////////////////////////////////////////////////////////
226 | // End of content of file: include/json/config.h
227 | // //////////////////////////////////////////////////////////////////////
228 |
229 |
230 |
231 |
232 |
233 |
234 | // //////////////////////////////////////////////////////////////////////
235 | // Beginning of content of file: include/json/forwards.h
236 | // //////////////////////////////////////////////////////////////////////
237 |
238 | // Copyright 2007-2010 Baptiste Lepilleur
239 | // Distributed under MIT license, or public domain if desired and
240 | // recognized in your jurisdiction.
241 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
242 |
243 | #ifndef JSON_FORWARDS_H_INCLUDED
244 | #define JSON_FORWARDS_H_INCLUDED
245 |
246 | #if !defined(JSON_IS_AMALGAMATION)
247 | #include "config.h"
248 | #endif // if !defined(JSON_IS_AMALGAMATION)
249 |
250 | namespace Json {
251 |
252 | // writer.h
253 | class FastWriter;
254 | class StyledWriter;
255 |
256 | // reader.h
257 | class Reader;
258 |
259 | // features.h
260 | class Features;
261 |
262 | // value.h
263 | typedef unsigned int ArrayIndex;
264 | class StaticString;
265 | class Path;
266 | class PathArgument;
267 | class Value;
268 | class ValueIteratorBase;
269 | class ValueIterator;
270 | class ValueConstIterator;
271 |
272 | } // namespace Json
273 |
274 | #endif // JSON_FORWARDS_H_INCLUDED
275 |
276 | // //////////////////////////////////////////////////////////////////////
277 | // End of content of file: include/json/forwards.h
278 | // //////////////////////////////////////////////////////////////////////
279 |
280 |
281 |
282 |
283 |
284 | #endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
285 |
--------------------------------------------------------------------------------
/json/json.h:
--------------------------------------------------------------------------------
1 | /// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).
2 | /// It is intended to be used with #include "json/json.h"
3 |
4 | // //////////////////////////////////////////////////////////////////////
5 | // Beginning of content of file: LICENSE
6 | // //////////////////////////////////////////////////////////////////////
7 |
8 | /*
9 | The JsonCpp library's source code, including accompanying documentation,
10 | tests and demonstration applications, are licensed under the following
11 | conditions...
12 |
13 | The author (Baptiste Lepilleur) explicitly disclaims copyright in all
14 | jurisdictions which recognize such a disclaimer. In such jurisdictions,
15 | this software is released into the Public Domain.
16 |
17 | In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
18 | 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
19 | released under the terms of the MIT License (see below).
20 |
21 | In jurisdictions which recognize Public Domain property, the user of this
22 | software may choose to accept it either as 1) Public Domain, 2) under the
23 | conditions of the MIT License (see below), or 3) under the terms of dual
24 | Public Domain/MIT License conditions described here, as they choose.
25 |
26 | The MIT License is about as close to Public Domain as a license can get, and is
27 | described in clear, concise terms at:
28 |
29 | http://en.wikipedia.org/wiki/MIT_License
30 |
31 | The full text of the MIT License follows:
32 |
33 | ========================================================================
34 | Copyright (c) 2007-2010 Baptiste Lepilleur
35 |
36 | Permission is hereby granted, free of charge, to any person
37 | obtaining a copy of this software and associated documentation
38 | files (the "Software"), to deal in the Software without
39 | restriction, including without limitation the rights to use, copy,
40 | modify, merge, publish, distribute, sublicense, and/or sell copies
41 | of the Software, and to permit persons to whom the Software is
42 | furnished to do so, subject to the following conditions:
43 |
44 | The above copyright notice and this permission notice shall be
45 | included in all copies or substantial portions of the Software.
46 |
47 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
50 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
51 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
52 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
53 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54 | SOFTWARE.
55 | ========================================================================
56 | (END LICENSE TEXT)
57 |
58 | The MIT license is compatible with both the GPL and commercial
59 | software, affording one all of the rights of Public Domain with the
60 | minor nuisance of being required to keep the above copyright notice
61 | and license text in the source code. Note also that by accepting the
62 | Public Domain "license" you can re-license your copy using whatever
63 | license you like.
64 |
65 | */
66 |
67 | // //////////////////////////////////////////////////////////////////////
68 | // End of content of file: LICENSE
69 | // //////////////////////////////////////////////////////////////////////
70 |
71 |
72 |
73 |
74 |
75 | #ifndef JSON_AMALGATED_H_INCLUDED
76 | # define JSON_AMALGATED_H_INCLUDED
77 | /// If defined, indicates that the source file is amalgated
78 | /// to prevent private header inclusion.
79 | #define JSON_IS_AMALGAMATION
80 |
81 | // //////////////////////////////////////////////////////////////////////
82 | // Beginning of content of file: include/json/version.h
83 | // //////////////////////////////////////////////////////////////////////
84 |
85 | // DO NOT EDIT. This file (and "version") is generated by CMake.
86 | // Run CMake configure step to update it.
87 | #ifndef JSON_VERSION_H_INCLUDED
88 | # define JSON_VERSION_H_INCLUDED
89 |
90 | # define JSONCPP_VERSION_STRING "1.6.5"
91 | # define JSONCPP_VERSION_MAJOR 1
92 | # define JSONCPP_VERSION_MINOR 6
93 | # define JSONCPP_VERSION_PATCH 5
94 | # define JSONCPP_VERSION_QUALIFIER
95 | # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
96 |
97 | #endif // JSON_VERSION_H_INCLUDED
98 |
99 | // //////////////////////////////////////////////////////////////////////
100 | // End of content of file: include/json/version.h
101 | // //////////////////////////////////////////////////////////////////////
102 |
103 |
104 |
105 |
106 |
107 |
108 | // //////////////////////////////////////////////////////////////////////
109 | // Beginning of content of file: include/json/config.h
110 | // //////////////////////////////////////////////////////////////////////
111 |
112 | // Copyright 2007-2010 Baptiste Lepilleur
113 | // Distributed under MIT license, or public domain if desired and
114 | // recognized in your jurisdiction.
115 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
116 |
117 | #ifndef JSON_CONFIG_H_INCLUDED
118 | #define JSON_CONFIG_H_INCLUDED
119 |
120 | /// If defined, indicates that json library is embedded in CppTL library.
121 | //# define JSON_IN_CPPTL 1
122 |
123 | /// If defined, indicates that json may leverage CppTL library
124 | //# define JSON_USE_CPPTL 1
125 | /// If defined, indicates that cpptl vector based map should be used instead of
126 | /// std::map
127 | /// as Value container.
128 | //# define JSON_USE_CPPTL_SMALLMAP 1
129 |
130 | // If non-zero, the library uses exceptions to report bad input instead of C
131 | // assertion macros. The default is to use exceptions.
132 | #ifndef JSON_USE_EXCEPTION
133 | #define JSON_USE_EXCEPTION 1
134 | #endif
135 |
136 | /// If defined, indicates that the source file is amalgated
137 | /// to prevent private header inclusion.
138 | /// Remarks: it is automatically defined in the generated amalgated header.
139 | // #define JSON_IS_AMALGAMATION
140 |
141 | #ifdef JSON_IN_CPPTL
142 | #include
143 | #ifndef JSON_USE_CPPTL
144 | #define JSON_USE_CPPTL 1
145 | #endif
146 | #endif
147 |
148 | #ifdef JSON_IN_CPPTL
149 | #define JSON_API CPPTL_API
150 | #elif defined(JSON_DLL_BUILD)
151 | #if defined(_MSC_VER)
152 | #define JSON_API __declspec(dllexport)
153 | #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
154 | #endif // if defined(_MSC_VER)
155 | #elif defined(JSON_DLL)
156 | #if defined(_MSC_VER)
157 | #define JSON_API __declspec(dllimport)
158 | #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
159 | #endif // if defined(_MSC_VER)
160 | #endif // ifdef JSON_IN_CPPTL
161 | #if !defined(JSON_API)
162 | #define JSON_API
163 | #endif
164 |
165 | // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
166 | // integer
167 | // Storages, and 64 bits integer support is disabled.
168 | // #define JSON_NO_INT64 1
169 |
170 | #if defined(_MSC_VER) // MSVC
171 | # if _MSC_VER <= 1200 // MSVC 6
172 | // Microsoft Visual Studio 6 only support conversion from __int64 to double
173 | // (no conversion from unsigned __int64).
174 | # define JSON_USE_INT64_DOUBLE_CONVERSION 1
175 | // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
176 | // characters in the debug information)
177 | // All projects I've ever seen with VS6 were using this globally (not bothering
178 | // with pragma push/pop).
179 | # pragma warning(disable : 4786)
180 | # endif // MSVC 6
181 |
182 | # if _MSC_VER >= 1500 // MSVC 2008
183 | /// Indicates that the following function is deprecated.
184 | # define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
185 | # endif
186 |
187 | #endif // defined(_MSC_VER)
188 |
189 |
190 | #ifndef JSON_HAS_RVALUE_REFERENCES
191 |
192 | #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
193 | #define JSON_HAS_RVALUE_REFERENCES 1
194 | #endif // MSVC >= 2010
195 |
196 | #ifdef __clang__
197 | #if __has_feature(cxx_rvalue_references)
198 | #define JSON_HAS_RVALUE_REFERENCES 1
199 | #endif // has_feature
200 |
201 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
202 | #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
203 | #define JSON_HAS_RVALUE_REFERENCES 1
204 | #endif // GXX_EXPERIMENTAL
205 |
206 | #endif // __clang__ || __GNUC__
207 |
208 | #endif // not defined JSON_HAS_RVALUE_REFERENCES
209 |
210 | #ifndef JSON_HAS_RVALUE_REFERENCES
211 | #define JSON_HAS_RVALUE_REFERENCES 0
212 | #endif
213 |
214 | #ifdef __clang__
215 | #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
216 | # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
217 | # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
218 | # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
219 | # define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
220 | # endif // GNUC version
221 | #endif // __clang__ || __GNUC__
222 |
223 | #if !defined(JSONCPP_DEPRECATED)
224 | #define JSONCPP_DEPRECATED(message)
225 | #endif // if !defined(JSONCPP_DEPRECATED)
226 |
227 | namespace Json {
228 | typedef int Int;
229 | typedef unsigned int UInt;
230 | #if defined(JSON_NO_INT64)
231 | typedef int LargestInt;
232 | typedef unsigned int LargestUInt;
233 | #undef JSON_HAS_INT64
234 | #else // if defined(JSON_NO_INT64)
235 | // For Microsoft Visual use specific types as long long is not supported
236 | #if defined(_MSC_VER) // Microsoft Visual Studio
237 | typedef __int64 Int64;
238 | typedef unsigned __int64 UInt64;
239 | #else // if defined(_MSC_VER) // Other platforms, use long long
240 | typedef long long int Int64;
241 | typedef unsigned long long int UInt64;
242 | #endif // if defined(_MSC_VER)
243 | typedef Int64 LargestInt;
244 | typedef UInt64 LargestUInt;
245 | #define JSON_HAS_INT64
246 | #endif // if defined(JSON_NO_INT64)
247 | } // end namespace Json
248 |
249 | #endif // JSON_CONFIG_H_INCLUDED
250 |
251 | // //////////////////////////////////////////////////////////////////////
252 | // End of content of file: include/json/config.h
253 | // //////////////////////////////////////////////////////////////////////
254 |
255 |
256 |
257 |
258 |
259 |
260 | // //////////////////////////////////////////////////////////////////////
261 | // Beginning of content of file: include/json/forwards.h
262 | // //////////////////////////////////////////////////////////////////////
263 |
264 | // Copyright 2007-2010 Baptiste Lepilleur
265 | // Distributed under MIT license, or public domain if desired and
266 | // recognized in your jurisdiction.
267 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
268 |
269 | #ifndef JSON_FORWARDS_H_INCLUDED
270 | #define JSON_FORWARDS_H_INCLUDED
271 |
272 | #if !defined(JSON_IS_AMALGAMATION)
273 | #include "config.h"
274 | #endif // if !defined(JSON_IS_AMALGAMATION)
275 |
276 | namespace Json {
277 |
278 | // writer.h
279 | class FastWriter;
280 | class StyledWriter;
281 |
282 | // reader.h
283 | class Reader;
284 |
285 | // features.h
286 | class Features;
287 |
288 | // value.h
289 | typedef unsigned int ArrayIndex;
290 | class StaticString;
291 | class Path;
292 | class PathArgument;
293 | class Value;
294 | class ValueIteratorBase;
295 | class ValueIterator;
296 | class ValueConstIterator;
297 |
298 | } // namespace Json
299 |
300 | #endif // JSON_FORWARDS_H_INCLUDED
301 |
302 | // //////////////////////////////////////////////////////////////////////
303 | // End of content of file: include/json/forwards.h
304 | // //////////////////////////////////////////////////////////////////////
305 |
306 |
307 |
308 |
309 |
310 |
311 | // //////////////////////////////////////////////////////////////////////
312 | // Beginning of content of file: include/json/features.h
313 | // //////////////////////////////////////////////////////////////////////
314 |
315 | // Copyright 2007-2010 Baptiste Lepilleur
316 | // Distributed under MIT license, or public domain if desired and
317 | // recognized in your jurisdiction.
318 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
319 |
320 | #ifndef CPPTL_JSON_FEATURES_H_INCLUDED
321 | #define CPPTL_JSON_FEATURES_H_INCLUDED
322 |
323 | #if !defined(JSON_IS_AMALGAMATION)
324 | #include "forwards.h"
325 | #endif // if !defined(JSON_IS_AMALGAMATION)
326 |
327 | namespace Json {
328 |
329 | /** \brief Configuration passed to reader and writer.
330 | * This configuration object can be used to force the Reader or Writer
331 | * to behave in a standard conforming way.
332 | */
333 | class JSON_API Features {
334 | public:
335 | /** \brief A configuration that allows all features and assumes all strings
336 | * are UTF-8.
337 | * - C & C++ comments are allowed
338 | * - Root object can be any JSON value
339 | * - Assumes Value strings are encoded in UTF-8
340 | */
341 | static Features all();
342 |
343 | /** \brief A configuration that is strictly compatible with the JSON
344 | * specification.
345 | * - Comments are forbidden.
346 | * - Root object must be either an array or an object value.
347 | * - Assumes Value strings are encoded in UTF-8
348 | */
349 | static Features strictMode();
350 |
351 | /** \brief Initialize the configuration like JsonConfig::allFeatures;
352 | */
353 | Features();
354 |
355 | /// \c true if comments are allowed. Default: \c true.
356 | bool allowComments_;
357 |
358 | /// \c true if root must be either an array or an object value. Default: \c
359 | /// false.
360 | bool strictRoot_;
361 |
362 | /// \c true if dropped null placeholders are allowed. Default: \c false.
363 | bool allowDroppedNullPlaceholders_;
364 |
365 | /// \c true if numeric object key are allowed. Default: \c false.
366 | bool allowNumericKeys_;
367 | };
368 |
369 | } // namespace Json
370 |
371 | #endif // CPPTL_JSON_FEATURES_H_INCLUDED
372 |
373 | // //////////////////////////////////////////////////////////////////////
374 | // End of content of file: include/json/features.h
375 | // //////////////////////////////////////////////////////////////////////
376 |
377 |
378 |
379 |
380 |
381 |
382 | // //////////////////////////////////////////////////////////////////////
383 | // Beginning of content of file: include/json/value.h
384 | // //////////////////////////////////////////////////////////////////////
385 |
386 | // Copyright 2007-2010 Baptiste Lepilleur
387 | // Distributed under MIT license, or public domain if desired and
388 | // recognized in your jurisdiction.
389 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
390 |
391 | #ifndef CPPTL_JSON_H_INCLUDED
392 | #define CPPTL_JSON_H_INCLUDED
393 |
394 | #if !defined(JSON_IS_AMALGAMATION)
395 | #include "forwards.h"
396 | #endif // if !defined(JSON_IS_AMALGAMATION)
397 | #include
398 | #include
399 | #include
400 |
401 | #ifndef JSON_USE_CPPTL_SMALLMAP
402 | #include