mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-01-14 01:47:54 +08:00
JsonCpp is now licensed under MIT license, or public domain if desired and recognized in your jurisdiction.
This commit is contained in:
parent
201fb2cf0d
commit
7469f1d014
58
LICENSE
58
LICENSE
@ -1 +1,57 @@
|
|||||||
The json-cpp library and this documentation are in Public Domain.
|
This is the LICENSE file for JsonCpp, a C++ library implementing a
|
||||||
|
JSON format reader and writer.
|
||||||
|
|
||||||
|
Author: Baptiste Lepilleur
|
||||||
|
|
||||||
|
The license for this library's code is as follows:
|
||||||
|
|
||||||
|
- If the code is used in a jurisdiction where Public Domain
|
||||||
|
property is regonized, then this code may be considered to be
|
||||||
|
in the Public Domain. Its author expressly disclaims copyright
|
||||||
|
in jurisdictions where such a disclaimer is allowed.
|
||||||
|
|
||||||
|
- If the code is used in a jurisdiction which does not recognize
|
||||||
|
Public Domain, the code must be used in terms with the MIT license,
|
||||||
|
as described clearly and concisely at:
|
||||||
|
|
||||||
|
http://en.wikipedia.org/wiki/MIT_License
|
||||||
|
|
||||||
|
and reproduced in full below.
|
||||||
|
|
||||||
|
- If the code is used in a jurisdiction which recognizes Public
|
||||||
|
Domain, the user may instead use the code under the terms of the
|
||||||
|
MIT license.
|
||||||
|
|
||||||
|
The MIT licensing terms follow:
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Copyright (c) 2007-2010 Baptiste Lepilleur
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
========================================================================
|
||||||
|
(END LICENSE TEXT)
|
||||||
|
|
||||||
|
The MIT license is compatible with both the GPL and commercial
|
||||||
|
software, affording one all of the rights of Public Domain with the
|
||||||
|
minor nuisance of being required to keep the above copyright notice
|
||||||
|
and license text in the source code. Note also that by accepting the
|
||||||
|
Public Domain "license" you can re-license your copy using whatever
|
||||||
|
license you like.
|
||||||
|
5
NEWS.txt
5
NEWS.txt
@ -32,3 +32,8 @@
|
|||||||
|
|
||||||
- The type Json::ArrayIndex is used for indexes of a JSON value array. It
|
- The type Json::ArrayIndex is used for indexes of a JSON value array. It
|
||||||
is an unsigned int (typically 32 bits).
|
is an unsigned int (typically 32 bits).
|
||||||
|
|
||||||
|
* License
|
||||||
|
|
||||||
|
- See file LICENSE for details. Basically JsonCpp is now licensed under
|
||||||
|
MIT license, or public domain if desired and recognized in your jurisdiction.
|
||||||
|
@ -120,3 +120,9 @@ Below is a short description of the content of each file:
|
|||||||
jsontest.exe from reading test_complex_01.rewrite.
|
jsontest.exe from reading test_complex_01.rewrite.
|
||||||
test_complex_01.process-output: jsontest.exe output, typically useful to
|
test_complex_01.process-output: jsontest.exe output, typically useful to
|
||||||
understand parsing error.
|
understand parsing error.
|
||||||
|
|
||||||
|
* License
|
||||||
|
=======
|
||||||
|
|
||||||
|
See file LICENSE for details. Basically JsonCpp is licensed under
|
||||||
|
MIT license, or public domain if desired and recognized in your jurisdiction.
|
||||||
|
93
devtools/licenseupdater.py
Normal file
93
devtools/licenseupdater.py
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
"""Updates the license text in source file.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# An existing license is found if the file starts with the string below,
|
||||||
|
# and ends with the first blank line.
|
||||||
|
LICENSE_BEGIN = "// Copyright "
|
||||||
|
|
||||||
|
BRIEF_LICENSE = LICENSE_BEGIN + """2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
||||||
|
|
||||||
|
""".replace('\r\n','\n')
|
||||||
|
|
||||||
|
def update_license( path, dry_run, show_diff ):
|
||||||
|
"""Update the license statement in the specified file.
|
||||||
|
Parameters:
|
||||||
|
path: path of the C++ source file to update.
|
||||||
|
dry_run: if True, just print the path of the file that would be updated,
|
||||||
|
but don't change it.
|
||||||
|
show_diff: if True, print the path of the file that would be modified,
|
||||||
|
as well as the change made to the file.
|
||||||
|
"""
|
||||||
|
with open( path, 'rt' ) as fin:
|
||||||
|
original_text = fin.read().replace('\r\n','\n')
|
||||||
|
newline = fin.newlines and fin.newlines[0] or '\n'
|
||||||
|
if not original_text.startswith( LICENSE_BEGIN ):
|
||||||
|
# No existing license found => prepend it
|
||||||
|
new_text = BRIEF_LICENSE + original_text
|
||||||
|
else:
|
||||||
|
license_end_index = original_text.index( '\n\n' ) # search first blank line
|
||||||
|
new_text = BRIEF_LICENSE + original_text[license_end_index+2:]
|
||||||
|
if original_text != new_text:
|
||||||
|
if not dry_run:
|
||||||
|
with open( path, 'wb' ) as fout:
|
||||||
|
fout.write( new_text.replace('\n', newline ) )
|
||||||
|
print 'Updated', path
|
||||||
|
if show_diff:
|
||||||
|
import difflib
|
||||||
|
print '\n'.join( difflib.unified_diff( original_text.split('\n'),
|
||||||
|
new_text.split('\n') ) )
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def update_license_in_source_directories( source_dirs, dry_run, show_diff ):
|
||||||
|
"""Updates license text in C++ source files found in directory source_dirs.
|
||||||
|
Parameters:
|
||||||
|
source_dirs: list of directory to scan for C++ sources. Directories are
|
||||||
|
scanned recursively.
|
||||||
|
dry_run: if True, just print the path of the file that would be updated,
|
||||||
|
but don't change it.
|
||||||
|
show_diff: if True, print the path of the file that would be modified,
|
||||||
|
as well as the change made to the file.
|
||||||
|
"""
|
||||||
|
from devtools import antglob
|
||||||
|
prune_dirs = antglob.prune_dirs + 'scons-local* ./build* ./libs ./dist'
|
||||||
|
for source_dir in source_dirs:
|
||||||
|
cpp_sources = antglob.glob( source_dir,
|
||||||
|
includes = '''**/*.h **/*.cpp **/*.inl''',
|
||||||
|
prune_dirs = prune_dirs )
|
||||||
|
for source in cpp_sources:
|
||||||
|
update_license( source, dry_run, show_diff )
|
||||||
|
|
||||||
|
def main():
|
||||||
|
usage = """%prog DIR [DIR2...]
|
||||||
|
Updates license text in sources of the project in source files found
|
||||||
|
in the directory specified on the command-line.
|
||||||
|
|
||||||
|
Example of call:
|
||||||
|
python devtools\licenseupdater.py include src -n --diff
|
||||||
|
=> Show change that would be made to the sources.
|
||||||
|
|
||||||
|
python devtools\licenseupdater.py include src
|
||||||
|
=> Update license statement on all sources in directories include/ and src/.
|
||||||
|
"""
|
||||||
|
from optparse import OptionParser
|
||||||
|
parser = OptionParser(usage=usage)
|
||||||
|
parser.allow_interspersed_args = False
|
||||||
|
parser.add_option('-n', '--dry-run', dest="dry_run", action='store_true', default=False,
|
||||||
|
help="""Only show what files are updated, do not update the files""")
|
||||||
|
parser.add_option('--diff', dest="show_diff", action='store_true', default=False,
|
||||||
|
help="""On update, show change made to the file.""")
|
||||||
|
parser.enable_interspersed_args()
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
update_license_in_source_directories( args, options.dry_run, options.show_diff )
|
||||||
|
print 'Done'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
import os.path
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
main()
|
||||||
|
|
@ -117,7 +117,10 @@ Permanent link to the latest revision of the file in subversion:
|
|||||||
- <a HREF="http://www.cl.cam.ac.uk/~mgk25/unicode.html">UTF-8 and Unicode FAQ</a>.
|
- <a HREF="http://www.cl.cam.ac.uk/~mgk25/unicode.html">UTF-8 and Unicode FAQ</a>.
|
||||||
|
|
||||||
\section _license License
|
\section _license License
|
||||||
The json-cpp library and this documentation are in Public Domain.
|
See file <a HREF="LICENSE">LICENSE</a> in the top-directory of the project.
|
||||||
|
|
||||||
|
Basically JsonCpp is licensed under MIT license, or public domain if desired
|
||||||
|
and recognized in your jurisdiction.
|
||||||
|
|
||||||
\author Baptiste Lepilleur <blep@users.sourceforge.net>
|
\author Baptiste Lepilleur <blep@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
@ -127,6 +127,7 @@ def build_doc( options, make_release=False ):
|
|||||||
tarball_sources = [
|
tarball_sources = [
|
||||||
output_dir,
|
output_dir,
|
||||||
'README.txt',
|
'README.txt',
|
||||||
|
'LICENSE',
|
||||||
'NEWS.txt',
|
'NEWS.txt',
|
||||||
'version'
|
'version'
|
||||||
]
|
]
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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_AUTOLINK_H_INCLUDED
|
#ifndef JSON_AUTOLINK_H_INCLUDED
|
||||||
# define JSON_AUTOLINK_H_INCLUDED
|
# define JSON_AUTOLINK_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
#ifndef JSON_CONFIG_H_INCLUDED
|
||||||
# define JSON_CONFIG_H_INCLUDED
|
# define JSON_CONFIG_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,42 +1,47 @@
|
|||||||
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
# define CPPTL_JSON_FEATURES_H_INCLUDED
|
// Distributed under MIT license, or public domain if desired and
|
||||||
|
// recognized in your jurisdiction.
|
||||||
# include "forwards.h"
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
|
||||||
namespace Json {
|
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
|
||||||
|
# define CPPTL_JSON_FEATURES_H_INCLUDED
|
||||||
/** \brief Configuration passed to reader and writer.
|
|
||||||
* This configuration object can be used to force the Reader or Writer
|
# include "forwards.h"
|
||||||
* to behave in a standard conforming way.
|
|
||||||
*/
|
namespace Json {
|
||||||
class JSON_API Features
|
|
||||||
{
|
/** \brief Configuration passed to reader and writer.
|
||||||
public:
|
* This configuration object can be used to force the Reader or Writer
|
||||||
/** \brief A configuration that allows all features and assumes all strings are UTF-8.
|
* to behave in a standard conforming way.
|
||||||
* - C & C++ comments are allowed
|
*/
|
||||||
* - Root object can be any JSON value
|
class JSON_API Features
|
||||||
* - Assumes Value strings are encoded in UTF-8
|
{
|
||||||
*/
|
public:
|
||||||
static Features all();
|
/** \brief A configuration that allows all features and assumes all strings are UTF-8.
|
||||||
|
* - C & C++ comments are allowed
|
||||||
/** \brief A configuration that is strictly compatible with the JSON specification.
|
* - Root object can be any JSON value
|
||||||
* - Comments are forbidden.
|
* - Assumes Value strings are encoded in UTF-8
|
||||||
* - Root object must be either an array or an object value.
|
*/
|
||||||
* - Assumes Value strings are encoded in UTF-8
|
static Features all();
|
||||||
*/
|
|
||||||
static Features strictMode();
|
/** \brief A configuration that is strictly compatible with the JSON specification.
|
||||||
|
* - Comments are forbidden.
|
||||||
/** \brief Initialize the configuration like JsonConfig::allFeatures;
|
* - Root object must be either an array or an object value.
|
||||||
*/
|
* - Assumes Value strings are encoded in UTF-8
|
||||||
Features();
|
*/
|
||||||
|
static Features strictMode();
|
||||||
/// \c true if comments are allowed. Default: \c true.
|
|
||||||
bool allowComments_;
|
/** \brief Initialize the configuration like JsonConfig::allFeatures;
|
||||||
|
*/
|
||||||
/// \c true if root must be either an array or an object value. Default: \c false.
|
Features();
|
||||||
bool strictRoot_;
|
|
||||||
};
|
/// \c true if comments are allowed. Default: \c true.
|
||||||
|
bool allowComments_;
|
||||||
} // namespace Json
|
|
||||||
|
/// \c true if root must be either an array or an object value. Default: \c false.
|
||||||
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
bool strictRoot_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Json
|
||||||
|
|
||||||
|
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||||
# define JSON_FORWARDS_H_INCLUDED
|
# define JSON_FORWARDS_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
#ifndef JSON_JSON_H_INCLUDED
|
||||||
# define JSON_JSON_H_INCLUDED
|
# define JSON_JSON_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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 CPPTL_JSON_READER_H_INCLUDED
|
#ifndef CPPTL_JSON_READER_H_INCLUDED
|
||||||
# define CPPTL_JSON_READER_H_INCLUDED
|
# define CPPTL_JSON_READER_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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 CPPTL_JSON_H_INCLUDED
|
#ifndef CPPTL_JSON_H_INCLUDED
|
||||||
# define CPPTL_JSON_H_INCLUDED
|
# define CPPTL_JSON_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
#ifndef JSON_WRITER_H_INCLUDED
|
||||||
# define JSON_WRITER_H_INCLUDED
|
# define JSON_WRITER_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
||||||
|
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
#include <algorithm> // sort
|
#include <algorithm> // sort
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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 JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
||||||
# define JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
# define JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
// included by json_value.cpp
|
||||||
// everything is within Json namespace
|
// everything is within Json namespace
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
// included by json_value.cpp
|
||||||
// everything is within Json namespace
|
// everything is within Json namespace
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
||||||
|
|
||||||
#include <json/reader.h>
|
#include <json/reader.h>
|
||||||
#include <json/value.h>
|
#include <json/value.h>
|
||||||
#include "json_tool.h"
|
#include "json_tool.h"
|
||||||
|
@ -1,88 +1,93 @@
|
|||||||
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
# define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
// Distributed under MIT license, or public domain if desired and
|
||||||
|
// recognized in your jurisdiction.
|
||||||
/* This header provides common string manipulation support, such as UTF-8,
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
* portable conversion from/to string...
|
|
||||||
*
|
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
* It is an internal header that must not be exposed.
|
# define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
*/
|
|
||||||
|
/* This header provides common string manipulation support, such as UTF-8,
|
||||||
namespace Json {
|
* portable conversion from/to string...
|
||||||
|
*
|
||||||
/// Converts a unicode code-point to UTF-8.
|
* It is an internal header that must not be exposed.
|
||||||
static inline std::string
|
*/
|
||||||
codePointToUTF8(unsigned int cp)
|
|
||||||
{
|
namespace Json {
|
||||||
std::string result;
|
|
||||||
|
/// Converts a unicode code-point to UTF-8.
|
||||||
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
static inline std::string
|
||||||
|
codePointToUTF8(unsigned int cp)
|
||||||
if (cp <= 0x7f)
|
{
|
||||||
{
|
std::string result;
|
||||||
result.resize(1);
|
|
||||||
result[0] = static_cast<char>(cp);
|
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
||||||
}
|
|
||||||
else if (cp <= 0x7FF)
|
if (cp <= 0x7f)
|
||||||
{
|
{
|
||||||
result.resize(2);
|
result.resize(1);
|
||||||
result[1] = static_cast<char>(0x80 | (0x3f & cp));
|
result[0] = static_cast<char>(cp);
|
||||||
result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
|
}
|
||||||
}
|
else if (cp <= 0x7FF)
|
||||||
else if (cp <= 0xFFFF)
|
{
|
||||||
{
|
result.resize(2);
|
||||||
result.resize(3);
|
result[1] = static_cast<char>(0x80 | (0x3f & cp));
|
||||||
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
|
||||||
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
|
}
|
||||||
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
|
else if (cp <= 0xFFFF)
|
||||||
}
|
{
|
||||||
else if (cp <= 0x10FFFF)
|
result.resize(3);
|
||||||
{
|
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
||||||
result.resize(4);
|
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
|
||||||
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
|
||||||
result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
|
}
|
||||||
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
|
else if (cp <= 0x10FFFF)
|
||||||
result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
|
{
|
||||||
}
|
result.resize(4);
|
||||||
|
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
||||||
return result;
|
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)));
|
||||||
|
}
|
||||||
/// Returns true if ch is a control character (in range [0,32[).
|
|
||||||
static inline bool
|
return result;
|
||||||
isControlCharacter(char ch)
|
}
|
||||||
{
|
|
||||||
return ch > 0 && ch <= 0x1F;
|
|
||||||
}
|
/// Returns true if ch is a control character (in range [0,32[).
|
||||||
|
static inline bool
|
||||||
|
isControlCharacter(char ch)
|
||||||
enum {
|
{
|
||||||
/// Constant that specify the size of the buffer that must be passed to uintToString.
|
return ch > 0 && ch <= 0x1F;
|
||||||
uintToStringBufferSize = 3*sizeof(UInt)+1
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// Defines a char buffer for use with uintToString().
|
enum {
|
||||||
typedef char UIntToStringBuffer[uintToStringBufferSize];
|
/// Constant that specify the size of the buffer that must be passed to uintToString.
|
||||||
|
uintToStringBufferSize = 3*sizeof(UInt)+1
|
||||||
|
};
|
||||||
/** Converts an unsigned integer to string.
|
|
||||||
* @param value Unsigned interger to convert to string
|
// Defines a char buffer for use with uintToString().
|
||||||
* @param current Input/Output string buffer.
|
typedef char UIntToStringBuffer[uintToStringBufferSize];
|
||||||
* Must have at least uintToStringBufferSize chars free.
|
|
||||||
*/
|
|
||||||
static inline void
|
/** Converts an unsigned integer to string.
|
||||||
uintToString( UInt value,
|
* @param value Unsigned interger to convert to string
|
||||||
char *¤t )
|
* @param current Input/Output string buffer.
|
||||||
{
|
* Must have at least uintToStringBufferSize chars free.
|
||||||
*--current = 0;
|
*/
|
||||||
do
|
static inline void
|
||||||
{
|
uintToString( UInt value,
|
||||||
*--current = char(value % 10) + '0';
|
char *¤t )
|
||||||
value /= 10;
|
{
|
||||||
}
|
*--current = 0;
|
||||||
while ( value != 0 );
|
do
|
||||||
}
|
{
|
||||||
|
*--current = char(value % 10) + '0';
|
||||||
} // namespace Json {
|
value /= 10;
|
||||||
|
}
|
||||||
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
while ( value != 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Json {
|
||||||
|
|
||||||
|
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <json/value.h>
|
#include <json/value.h>
|
||||||
#include <json/writer.h>
|
#include <json/writer.h>
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
// included by json_value.cpp
|
||||||
// everything is within Json namespace
|
// everything is within Json namespace
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
||||||
|
|
||||||
#include <json/writer.h>
|
#include <json/writer.h>
|
||||||
#include "json_tool.h"
|
#include "json_tool.h"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS 1 // Prevents deprecation warning with MSVC
|
#define _CRT_SECURE_NO_WARNINGS 1 // Prevents deprecation warning with MSVC
|
||||||
#include "jsontest.h"
|
#include "jsontest.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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 JSONTEST_H_INCLUDED
|
#ifndef JSONTEST_H_INCLUDED
|
||||||
# define JSONTEST_H_INCLUDED
|
# define JSONTEST_H_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
|
// 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
|
||||||
|
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
#include "jsontest.h"
|
#include "jsontest.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user