mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 07:30:54 +00:00
a0e9ee5965
Summary: This diff adds rapidjson (https://code.google.com/p/rapidjson/) to RocksDB repository. First step to adding JSON is to add a JSON parser :) I'm not sure if rapidjson is the right choice. I only considered folly as an alternative. Using folly JSON parser has serious downsides. I tried extracting folly::json from the folly library. However, it depends on folly::dynamic, which basically depends on everything else. I would prefer to avoid adding complete folly library as RocksDB dependency. Folly has a lot of its own dependencies (https://github.com/facebook/folly) and also looks like open source world has some trouble installing it (https://groups.google.com/forum/#!forum/facebook-folly -- 60% of the posts are compile errors). We can discuss this if you think otherwise. RapidJSON does not have any dependencies whatsoever. No boost, no STL. We don't need to compile it since it's all header files. The performance results are also impressive: https://code.google.com/p/rapidjson/wiki/Performance. However, I'll make sure to write code in a way that we can easily switch JSON implementations going forward. Quora thread has some alternatives: http://www.quora.com/What-is-the-best-C-JSON-library Test Plan: none Reviewers: dhruba, haobo, yhchiang, sdong, jamesgpearce Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D18729
25 lines
656 B
C++
25 lines
656 B
C++
#ifndef RAPIDJSON_INTERNAL_STRFUNC_H_
|
|
#define RAPIDJSON_INTERNAL_STRFUNC_H_
|
|
|
|
namespace rapidjson {
|
|
namespace internal {
|
|
|
|
//! Custom strlen() which works on different character types.
|
|
/*! \tparam Ch Character type (e.g. char, wchar_t, short)
|
|
\param s Null-terminated input string.
|
|
\return Number of characters in the string.
|
|
\note This has the same semantics as strlen(), the return value is not number of Unicode codepoints.
|
|
*/
|
|
template <typename Ch>
|
|
inline SizeType StrLen(const Ch* s) {
|
|
const Ch* p = s;
|
|
while (*p != '\0')
|
|
++p;
|
|
return SizeType(p - s);
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace rapidjson
|
|
|
|
#endif // RAPIDJSON_INTERNAL_STRFUNC_H_
|