├── src
├── plugin.def
├── libjson
│ ├── ._JSONOptions.h
│ ├── Documentation.pdf
│ ├── _internal
│ │ ├── Source
│ │ │ ├── ._JSONDefs
│ │ │ ├── ._JSONDebug.h
│ │ │ ├── ._JSONDefs.h
│ │ │ ├── ._JSONNode.h
│ │ │ ├── ._JSONStats.h
│ │ │ ├── ._libjson.cpp
│ │ │ ├── ._JSONChildren.h
│ │ │ ├── ._JSONDebug.cpp
│ │ │ ├── ._JSONGlobals.h
│ │ │ ├── ._JSONMemory.cpp
│ │ │ ├── ._JSONMemory.h
│ │ │ ├── ._JSONNode.cpp
│ │ │ ├── ._JSONPreparse.h
│ │ │ ├── ._JSONStream.cpp
│ │ │ ├── ._JSONStream.h
│ │ │ ├── ._JSONWorker.cpp
│ │ │ ├── ._JSONWorker.h
│ │ │ ├── ._JSONWriter.cpp
│ │ │ ├── ._JSON_Base64.h
│ │ │ ├── ._JSONAllocator.h
│ │ │ ├── ._JSONChildren.cpp
│ │ │ ├── ._JSONMemoryPool.h
│ │ │ ├── ._JSONPreparse.cpp
│ │ │ ├── ._JSONSingleton.h
│ │ │ ├── ._JSONValidator.h
│ │ │ ├── ._NumberToString.h
│ │ │ ├── JSONDefs
│ │ │ │ ├── ._GNU_C.h
│ │ │ │ ├── ._Visual_C.h
│ │ │ │ ├── ._Unknown_C.h
│ │ │ │ ├── ._Strings_Defs.h
│ │ │ │ ├── Unknown_C.h
│ │ │ │ ├── Visual_C.h
│ │ │ │ ├── Strings_Defs.h
│ │ │ │ └── GNU_C.h
│ │ │ ├── ._JSONAllocator.cpp
│ │ │ ├── ._JSONIterators.cpp
│ │ │ ├── ._JSONNode_Mutex.cpp
│ │ │ ├── ._JSONSharedString.h
│ │ │ ├── ._internalJSONNode.h
│ │ │ ├── ._internalJSONNode.cpp
│ │ │ ├── JSONAllocator.cpp
│ │ │ ├── JSONSingleton.h
│ │ │ ├── JSONPreparse.h
│ │ │ ├── JSON_Base64.h
│ │ │ ├── JSONDebug.cpp
│ │ │ ├── JSONMemoryPool.h
│ │ │ ├── JSONValidator.h
│ │ │ ├── JSONDebug.h
│ │ │ ├── JSONAllocator.h
│ │ │ ├── JSONStream.h
│ │ │ ├── JSONWorker.h
│ │ │ ├── JSONStats.h
│ │ │ ├── JSONGlobals.h
│ │ │ ├── JSONChildren.cpp
│ │ │ ├── JSONStream.cpp
│ │ │ ├── JSONDefs.h
│ │ │ └── JSONDefs.h~
│ │ ├── Dependencies
│ │ │ ├── ._mempool++
│ │ │ ├── ._libbase64++
│ │ │ ├── mempool++
│ │ │ │ └── ._mempool.h
│ │ │ └── libbase64++
│ │ │ │ └── ._libbase64++.h
│ │ ├── TestSuite
│ │ │ ├── TestSuite.xcodeproj
│ │ │ │ ├── ._xcuserdata
│ │ │ │ ├── ._wallace.mode1v3
│ │ │ │ ├── ._wallace.pbxuser
│ │ │ │ ├── ._project.xcworkspace
│ │ │ │ ├── project.xcworkspace
│ │ │ │ │ ├── ._xcuserdata
│ │ │ │ │ ├── xcuserdata
│ │ │ │ │ │ ├── ._wallace.xcuserdatad
│ │ │ │ │ │ └── wallace.xcuserdatad
│ │ │ │ │ │ │ └── WorkspaceSettings.xcsettings
│ │ │ │ │ └── contents.xcworkspacedata
│ │ │ │ └── xcuserdata
│ │ │ │ │ ├── ._wallace.xcuserdatad
│ │ │ │ │ └── wallace.xcuserdatad
│ │ │ │ │ ├── ._xcdebugger
│ │ │ │ │ ├── ._xcschemes
│ │ │ │ │ ├── xcschemes
│ │ │ │ │ ├── ._TestSuite.xcscheme
│ │ │ │ │ ├── ._xcschememanagement.plist
│ │ │ │ │ ├── xcschememanagement.plist
│ │ │ │ │ └── TestSuite.xcscheme
│ │ │ │ │ └── xcdebugger
│ │ │ │ │ └── Breakpoints.xcbkptlist
│ │ │ ├── RunTestSuite2.h
│ │ │ ├── Checklist.txt
│ │ │ ├── TestBinary.cpp
│ │ │ ├── Benchmark
│ │ │ │ └── makefile
│ │ │ ├── TestSuite2Creator.php
│ │ │ ├── TestInequality.cpp
│ │ │ ├── TestSuite.cpp
│ │ │ ├── TestEquality.cpp
│ │ │ ├── TestSuite.1
│ │ │ ├── TestSuite.h~
│ │ │ ├── TestSuite.h
│ │ │ ├── TestCtors.cpp
│ │ │ ├── TestRefCounting.cpp
│ │ │ ├── main.cpp~
│ │ │ ├── main.cpp
│ │ │ ├── TestAssign.cpp
│ │ │ ├── TestString.cpp
│ │ │ └── TestString.cpp~
│ │ └── TestSuite2
│ │ │ ├── JSONValidator
│ │ │ ├── isValidArray.h
│ │ │ ├── isValidObject.h
│ │ │ ├── isValidNamedObject.h
│ │ │ ├── isValidPartialRoot.h
│ │ │ ├── isValidArray.cpp
│ │ │ ├── isValidObject.cpp
│ │ │ ├── isValidNamedObject.cpp
│ │ │ ├── isValidPartialRoot.cpp
│ │ │ ├── securityTest.h
│ │ │ ├── isValidRoot.h
│ │ │ ├── isValidMember.h
│ │ │ ├── isValidString.h
│ │ │ ├── isValidNumber.h
│ │ │ ├── securityTest.cpp
│ │ │ ├── Resources
│ │ │ │ ├── validyMacros.h~
│ │ │ │ └── validyMacros.h
│ │ │ ├── isValidRoot.cpp
│ │ │ ├── isValidString.cpp
│ │ │ └── isValidMember.cpp
│ │ │ ├── JSON_Base64
│ │ │ ├── json_decode64.h
│ │ │ ├── json_encode64.h
│ │ │ ├── json_decode64.cpp
│ │ │ └── json_encode64.cpp
│ │ │ ├── NumberToString
│ │ │ ├── getLenSize.h
│ │ │ ├── _ftoa.h
│ │ │ ├── _itoa.h
│ │ │ ├── _areFloatsEqual.h
│ │ │ ├── _uitoa.h
│ │ │ ├── getLenSize.cpp
│ │ │ ├── _atof.h
│ │ │ ├── isNumeric.h
│ │ │ ├── _areFloatsEqual.cpp
│ │ │ ├── _ftoa.cpp
│ │ │ ├── _uitoa.cpp
│ │ │ └── _itoa.cpp
│ │ │ ├── JSONGlobals
│ │ │ ├── jsonSingleton.h
│ │ │ └── jsonSingleton.cpp
│ │ │ ├── JSONDebug
│ │ │ ├── JSON_FAIL.h
│ │ │ ├── JSON_FAIL_SAFE.h
│ │ │ ├── JSON_ASSERT.h
│ │ │ ├── JSON_ASSERT_SAFE.h
│ │ │ ├── JSON_FAIL.cpp
│ │ │ ├── JSON_FAIL_SAFE.cpp
│ │ │ ├── JSON_ASSERT.cpp
│ │ │ └── JSON_ASSERT_SAFE.cpp
│ │ │ └── BaseTest.h
│ ├── libjson.vcxproj.user
│ ├── JSONOptions.h
│ └── License.txt
├── Util.h
├── Server.h
├── Server.cpp
├── Platform.cpp
├── AMXUtil.h
├── Platform.h
├── SDK
│ ├── amx
│ │ └── sclinux.h
│ └── plugincommon.h
├── Util.cpp
├── JSONParser.h
├── Makefile
├── plugin.cpp
├── SAMPSON.sln
├── SAMPSON.vcxproj.filters
└── AMXUtil.cpp
├── pawn.json
├── test.pwn
├── .gitignore
├── LICENSE
├── pawno
└── include
│ └── a_json.inc
└── README.md
/src/plugin.def:
--------------------------------------------------------------------------------
1 | EXPORTS
2 | Supports
3 | Load
4 | Unload
5 | AmxLoad
6 | AmxUnload
7 |
--------------------------------------------------------------------------------
/src/libjson/._JSONOptions.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/._JSONOptions.h
--------------------------------------------------------------------------------
/src/libjson/Documentation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/Documentation.pdf
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONDefs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONDefs
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONDebug.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONDebug.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONDefs.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONDefs.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONNode.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONNode.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONStats.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONStats.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._libjson.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._libjson.cpp
--------------------------------------------------------------------------------
/src/Util.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | class Util
4 | {
5 | public:
6 | static char* ReadFile(const char szPath[]);
7 |
8 | };
9 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONChildren.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONChildren.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONDebug.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONDebug.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONGlobals.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONGlobals.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONMemory.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONMemory.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONMemory.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONMemory.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONNode.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONNode.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONPreparse.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONPreparse.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONStream.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONStream.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONStream.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONStream.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONWorker.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONWorker.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONWorker.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONWorker.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONWriter.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONWriter.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSON_Base64.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSON_Base64.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Dependencies/._mempool++:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Dependencies/._mempool++
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONAllocator.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONAllocator.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONChildren.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONChildren.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONMemoryPool.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONMemoryPool.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONPreparse.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONPreparse.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONSingleton.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONSingleton.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONValidator.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONValidator.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._NumberToString.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._NumberToString.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/._GNU_C.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/JSONDefs/._GNU_C.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Dependencies/._libbase64++:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Dependencies/._libbase64++
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONAllocator.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONAllocator.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONIterators.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONIterators.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONNode_Mutex.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONNode_Mutex.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._JSONSharedString.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._JSONSharedString.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._internalJSONNode.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._internalJSONNode.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/._Visual_C.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/JSONDefs/._Visual_C.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/._internalJSONNode.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/._internalJSONNode.cpp
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/._Unknown_C.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/JSONDefs/._Unknown_C.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/._Strings_Defs.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Source/JSONDefs/._Strings_Defs.h
--------------------------------------------------------------------------------
/src/libjson/_internal/Dependencies/mempool++/._mempool.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Dependencies/mempool++/._mempool.h
--------------------------------------------------------------------------------
/src/Server.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | class Server
4 | {
5 | public:
6 | static bool GetScriptfilesPath(char pBuf[], const char szAppend[] = nullptr);
7 | };
8 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Dependencies/libbase64++/._libbase64++.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/Dependencies/libbase64++/._libbase64++.h
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._xcuserdata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._xcuserdata
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._wallace.mode1v3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._wallace.mode1v3
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._wallace.pbxuser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._wallace.pbxuser
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._project.xcworkspace:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/._project.xcworkspace
--------------------------------------------------------------------------------
/src/libjson/libjson.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/RunTestSuite2.h:
--------------------------------------------------------------------------------
1 | #ifndef RUN_TEST_SUITE2_H
2 | #define RUN_TEST_SUITE2_H
3 |
4 | class RunTestSuite2 {
5 | public:
6 | static void RunTests(void);
7 | };
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/project.xcworkspace/._xcuserdata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/project.xcworkspace/._xcuserdata
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/._wallace.xcuserdatad:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/._wallace.xcuserdatad
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/._xcdebugger:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/._xcdebugger
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/._xcschemes:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/._xcschemes
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidArray.h:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidArray.h
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidObject.h:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidObject.h
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/project.xcworkspace/xcuserdata/._wallace.xcuserdatad:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/project.xcworkspace/xcuserdata/._wallace.xcuserdatad
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidNamedObject.h:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidNamedObject.h
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidPartialRoot.h:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidPartialRoot.h
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/xcschemes/._TestSuite.xcscheme:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/xcschemes/._TestSuite.xcscheme
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/xcschemes/._xcschememanagement.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hual/SAMPSON/HEAD/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/xcschemes/._xcschememanagement.plist
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidArray.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidArray.cpp
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 | #include "isValidArray.h"
11 |
12 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidObject.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidObject.cpp
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 | #include "isValidObject.h"
11 |
12 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidNamedObject.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidNamedObject.cpp
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 | #include "isValidNamedObject.h"
11 |
12 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidPartialRoot.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * isValidPartialRoot.cpp
3 | * TestSuite
4 | *
5 | * Created by Jonathan Wallace on 11/13/11.
6 | * Copyright 2011 StreamWIDE. All rights reserved.
7 | *
8 | */
9 |
10 | #include "isValidPartialRoot.h"
11 |
12 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSON_Base64/json_decode64.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_BASE64__JSON_DECODE64_H
2 | #define JSON_TESTSUITE_JSON_BASE64__JSON_DECODE64_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSON_Base64__json_decode64 : public BaseTest {
7 | public:
8 | testJSON_Base64__json_decode64(const std::string & name) : BaseTest(name){}
9 | void testNotBase64(void);
10 | };
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONAllocator.cpp:
--------------------------------------------------------------------------------
1 | #include "JSONAllocator.h"
2 |
3 | #if defined(JSON_MEMORY_CALLBACKS) || defined(JSON_MEMORY_POOL)
4 | #include "JSONMemory.h"
5 |
6 | void * JSONAllocatorRelayer::alloc(size_t bytes) json_nothrow {
7 | return JSONMemory::json_malloc(bytes);
8 | }
9 |
10 | void JSONAllocatorRelayer::dealloc(void * ptr) json_nothrow {
11 | JSONMemory::json_free(ptr);
12 | }
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/getLenSize.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_NUMBER_TO_STRING__GET_LEN_SIZE_H
2 | #define JSON_TESTSUITE_NUMBER_TO_STRING__GET_LEN_SIZE_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testNumberToString__getLenSize : public BaseTest {
7 | public:
8 | testNumberToString__getLenSize(const std::string & name) : BaseTest(name){}
9 | void testStruct(void);
10 | };
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/securityTest.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_VALIDATOR__SECURITY_TEST_H
2 | #define JSON_TESTSUITE_JSON_VALIDATOR__SECURITY_TEST_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONValidator__securityTest : public BaseTest {
7 | public:
8 | testJSONValidator__securityTest(const std::string & name) : BaseTest(name){}
9 | void testsecurity(void);
10 | };
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/pawn.json:
--------------------------------------------------------------------------------
1 | {
2 | "include_path": "pawno/include",
3 | "user": "Hual",
4 | "repo": "SAMPSON",
5 | "entry": "test.pwn",
6 | "output": "test.amx",
7 | "dependencies": ["sampctl/samp-stdlib"],
8 | "resources": [
9 | {
10 | "name": "SAMPSON.dll",
11 | "platform": "windows",
12 | "archive": false
13 | },
14 | {
15 | "name": "SAMPSON.so",
16 | "platform": "linux",
17 | "archive": false
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/_ftoa.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_NUMBER_TO_STRING__FTOA_H
2 | #define JSON_TESTSUITE_NUMBER_TO_STRING__FTOA_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testNumberToString__ftoa : public BaseTest {
7 | public:
8 | testNumberToString__ftoa(const std::string & name) : BaseTest(name){}
9 | void testRandomNumbers(void);
10 | void testSpecializedInts(void);
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONGlobals/jsonSingleton.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_GLOBALS__JSON_SINGLETON_H
2 | #define JSON_TESTSUITE_JSON_GLOBALS__JSON_SINGLETON_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONGlobals__jsonSingleton : public BaseTest {
7 | public:
8 | testJSONGlobals__jsonSingleton(const std::string & name) : BaseTest(name){}
9 | void testValue(void);
10 | void testNoValue(void);
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSON_Base64/json_encode64.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_BASE64__JSON_ENCODE64_H
2 | #define JSON_TESTSUITE_JSON_BASE64__JSON_ENCODE64_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSON_Base64__json_encode64 : public BaseTest {
7 | public:
8 | testJSON_Base64__json_encode64(const std::string & name) : BaseTest(name){}
9 | void testReverseEachOther(void);
10 | void testAllChars(void);
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/Checklist.txt:
--------------------------------------------------------------------------------
1 | Update LIBJSON_VERSION values and values in makefile too
2 | Strip all trailing white space
3 | Run test in XCode using all options on
4 | Export Documentation to PDF
5 | Delete build folders
6 | Run all tests on Mac
7 | Run all tests on Linux
8 | Run test in VC++ using all options on (if possible)
9 | Run benchmark to assert options are all the default
10 | Remove Hidden Finder files
11 | Zip TestSuite
12 | Zip on Linux
13 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_FAIL.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_DEBUG__JSON_FAIL_H
2 | #define JSON_TESTSUITE_JSON_DEBUG__JSON_FAIL_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONDebug_JSON_FAIL : public BaseTest {
7 | public:
8 | testJSONDebug_JSON_FAIL(const std::string & name) : BaseTest(name){}
9 | virtual void setUp(const std::string & methodName);
10 | virtual void tearDown(void);
11 | void testFail(void);
12 | };
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidRoot.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_ROOT_H
2 | #define JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_ROOT_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONValidator__isValidRoot : public BaseTest {
7 | public:
8 | testJSONValidator__isValidRoot(const std::string & name) : BaseTest(name){}
9 | void testRoots(void);
10 | void testNotRoots(void);
11 | void testSuddenEnd(void);
12 | };
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_FAIL_SAFE.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_DEBUG__JSON_FAIL_SAFE_H
2 | #define JSON_TESTSUITE_JSON_DEBUG__JSON_FAIL_SAFE_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONDebug_JSON_FAIL_SAFE : public BaseTest {
7 | public:
8 | testJSONDebug_JSON_FAIL_SAFE(const std::string & name) : BaseTest(name){}
9 | virtual void setUp(const std::string & methodName);
10 | virtual void tearDown(void);
11 | void testFail(void);
12 | };
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/_itoa.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_NUMBER_TO_STRING__ITOA_H
2 | #define JSON_TESTSUITE_NUMBER_TO_STRING__ITOA_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testNumberToString__itoa : public BaseTest {
7 | public:
8 | testNumberToString__itoa(const std::string & name) : BaseTest(name){}
9 | void testChar(void);
10 | void testShort(void);
11 | void testInt(void);
12 | void testLong(void);
13 | void testLongLong(void);
14 | };
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/_areFloatsEqual.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_NUMBER_TO_STRING__ARE_FLOATS_EQUAL_H
2 | #define JSON_TESTSUITE_NUMBER_TO_STRING__ARE_FLOATS_EQUAL_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testNumberToString__areFloatsEqual : public BaseTest {
7 | public:
8 | testNumberToString__areFloatsEqual(const std::string & name) : BaseTest(name){}
9 | void testEqual(void);
10 | void testNotEqual(void);
11 | void testCloseEnough(void);
12 | };
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/_uitoa.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_NUMBER_TO_STRING__UITOA_H
2 | #define JSON_TESTSUITE_NUMBER_TO_STRING__UITOA_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testNumberToString__uitoa : public BaseTest {
7 | public:
8 | testNumberToString__uitoa(const std::string & name) : BaseTest(name){}
9 | void testChar(void);
10 | void testShort(void);
11 | void testInt(void);
12 | void testLong(void);
13 | void testLongLong(void);
14 | };
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_ASSERT.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_DEBUG__JSON_ASSERT_H
2 | #define JSON_TESTSUITE_JSON_DEBUG__JSON_ASSERT_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONDebug_JSON_ASSERT : public BaseTest {
7 | public:
8 | testJSONDebug_JSON_ASSERT(const std::string & name) : BaseTest(name){}
9 | virtual void setUp(const std::string & methodName);
10 | virtual void tearDown(void);
11 | void testPass(void);
12 | void testFail(void);
13 | };
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/test.pwn:
--------------------------------------------------------------------------------
1 | // generated by "sampctl package generate"
2 |
3 | #include "pawno/include/a_json.inc"
4 |
5 |
6 |
7 | main() {
8 | new dummy_data[128], foo[8], JSONNode:response;
9 | format(dummy_data, sizeof(dummy_data), "{ \"foo\": \"bar\", \"testing\": true, \"count\": 123 }");
10 |
11 | response = json_parse_string(dummy_data);
12 |
13 | json_get_string(response, foo, sizeof(foo), "foo");
14 |
15 | printf("%s %d %i", foo, json_get_bool(response, "testing"), json_get_int(response, "count"));
16 | }
17 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_ASSERT_SAFE.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_DEBUG__JSON_ASSERT_SAFE_H
2 | #define JSON_TESTSUITE_JSON_DEBUG__JSON_ASSERT_SAFE_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONDebug_JSON_ASSERT_SAFE : public BaseTest {
7 | public:
8 | testJSONDebug_JSON_ASSERT_SAFE(const std::string & name) : BaseTest(name){}
9 | virtual void setUp(const std::string & methodName);
10 | virtual void tearDown(void);
11 | void testPass(void);
12 | void testFail(void);
13 | };
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSON_Base64/json_decode64.cpp:
--------------------------------------------------------------------------------
1 | #include "json_decode64.h"
2 | #include "../../Source/JSON_Base64.h"
3 |
4 | void testJSON_Base64__json_decode64::testNotBase64(void){
5 | #if defined(JSON_BINARY) || defined(JSON_EXPOSE_BASE64)
6 | #ifdef JSON_SAFE
7 | assertEquals(JSONBase64::json_decode64(JSON_TEXT("123!abc")), "");
8 | assertEquals(JSONBase64::json_decode64(JSON_TEXT("123=abc")), "");
9 | assertEquals(JSONBase64::json_decode64(JSON_TEXT("123abc===")), "");
10 | #endif
11 | #endif
12 | }
13 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/project.xcworkspace/xcuserdata/wallace.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/getLenSize.cpp:
--------------------------------------------------------------------------------
1 | #include "getLenSize.h"
2 | #include "../../Source/NumberToString.h"
3 |
4 |
5 | /**
6 | * Make sure the specialized template returns the right
7 | * number of bytes required
8 | */
9 | void testNumberToString__getLenSize::testStruct(void){
10 | assertEquals(getLenSize<1>::GETLEN, 5);
11 | assertEquals(getLenSize<2>::GETLEN, 7);
12 | assertEquals(getLenSize<4>::GETLEN, 12);
13 | assertEquals(getLenSize<8>::GETLEN, 22);
14 | assertEquals(getLenSize<16>::GETLEN, 41);
15 | }
16 |
--------------------------------------------------------------------------------
/src/Server.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "Server.h"
4 | #include "Platform.h"
5 | #include "AMXUtil.h"
6 |
7 | #define S_SCRIPTFILES_PATH (PATH_SEPARATOR "scriptfiles" PATH_SEPARATOR)
8 |
9 | bool Server::GetScriptfilesPath(char pBuf[], const char szAppend[])
10 | {
11 | if (Platform::GetExecutablePath(pBuf) == nullptr) {
12 | return false;
13 | }
14 |
15 | std::strcat(pBuf, S_SCRIPTFILES_PATH);
16 |
17 | if (szAppend != nullptr) {
18 | std::strcat(pBuf, szAppend);
19 | }
20 |
21 | return true;
22 | }
23 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidMember.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_MEMBER_H
2 | #define JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_MEMBER_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONValidator__isValidMember : public BaseTest {
7 | public:
8 | testJSONValidator__isValidMember(const std::string & name) : BaseTest(name){}
9 | void testMembers(void);
10 | void testStrict(void);
11 | void testNotStrict(void);
12 | void testNotMembers(void);
13 | void testSuddenEnd(void);
14 | };
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidString.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_STRING_H
2 | #define JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_STRING_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONValidator__isValidString : public BaseTest {
7 | public:
8 | testJSONValidator__isValidString(const std::string & name) : BaseTest(name){}
9 | void testNormal(void);
10 | void testUnicode(void);
11 | void testStrict(void);
12 | void testNotStrict(void);
13 | void testNotString(void);
14 | void testSuddenEnd(void);
15 | };
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Precompiled Headers
8 | *.gch
9 | *.pch
10 |
11 | # Compiled Dynamic libraries
12 | *.so
13 | *.dylib
14 | *.dll
15 |
16 | # Fortran module files
17 | *.mod
18 |
19 | # Compiled Static libraries
20 | *.lai
21 | *.la
22 | *.a
23 | *.lib
24 |
25 | # Executables
26 | *.exe
27 | *.out
28 | *.app
29 |
30 | #
31 | # Package only files
32 | #
33 |
34 | # Compiled Bytecode, precompiled output and assembly
35 | *.amx
36 | *.lst
37 | *.asm
38 |
39 | # Vendor directory for dependencies
40 | dependencies/
41 |
42 | # Dependency versions lockfile
43 | pawn.lock
44 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONSingleton.h:
--------------------------------------------------------------------------------
1 | #ifndef JSONSINGLETON_H
2 | #define JSONSINGLETON_H
3 |
4 | template class JSONSingleton {
5 | public:
6 | static inline T get(void){
7 | return get_singleton() -> ptr;
8 | }
9 | static inline void set(T p){
10 | get_singleton() -> ptr = p;
11 | }
12 | private:
13 | inline JSONSingleton() : ptr(NULL) { }
14 | JSONSingleton(const JSONSingleton &);
15 | JSONSingleton operator = (const JSONSingleton &);
16 | static inline JSONSingleton * get_singleton(void){
17 | static JSONSingleton instance;
18 | return &instance;
19 | }
20 | T ptr;
21 | };
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | TestSuite.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 8DD76F620486A84900D96B5E
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/libjson/JSONOptions.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_OPTIONS_H
2 | #define JSON_OPTIONS_H
3 |
4 | #define JSON_LIBRARY
5 | #define JSON_ISO_STRICT
6 | #define JSON_SAFE
7 | #define JSON_STDERROR
8 | //#define JSON_UNICODE
9 | #define JSON_REF_COUNT
10 | #define JSON_ITERATORS
11 | #define JSON_WRITE_PRIORITY MED
12 | #define JSON_READ_PRIORITY HIGH
13 | #define JSON_ESCAPE_WRITES
14 | #define JSON_CASE_INSENSITIVE_FUNCTIONS
15 | #define JSON_BOOL_TYPE char
16 | #define JSON_NUMBER_TYPE float
17 | #define JSON_CASTABLE
18 | #define JSON_SECURITY_MAX_NEST_LEVEL 128
19 | #define JSON_SECURITY_MAX_STRING_LENGTH 33554432
20 | #define JSON_SECURITY_MAX_STREAM_OBJECTS 128
21 | #define JSON_NO_EXCEPTIONS
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/BaseTest.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_BASETEST_H
2 | #define JSON_TESTSUITE_BASETEST_H
3 |
4 | #include "../TestSuite/UnitTest.h"
5 | #include
6 |
7 | class libjson_CodeCoverage;
8 |
9 | class BaseTest {
10 | public:
11 | BaseTest(const std::string & name) : _name(name), coverage(0) {}
12 | virtual ~BaseTest(void){};
13 | virtual void setUp(const std::string & methodName){ UnitTest::SetPrefix(_name + "::" + methodName); }
14 | virtual void tearDown(void){}
15 | protected:
16 | const std::string _name;
17 | libjson_CodeCoverage * coverage;
18 | private:
19 | BaseTest(const BaseTest &);
20 | BaseTest & operator=(const BaseTest &);
21 | };
22 |
23 | #endif
24 |
25 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/_atof.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_NUMBER_TO_STRING__ATOF_H
2 | #define JSON_TESTSUITE_NUMBER_TO_STRING__ATOF_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testNumberToString__atof : public BaseTest {
7 | public:
8 | testNumberToString__atof(const std::string & name);
9 | virtual ~testNumberToString__atof();
10 | void testPositive(void);
11 | void testNegative(void);
12 | void testPositive_ScientificNotation(void);
13 | void testNegative_ScientificNotation(void);
14 | void testPositive_SignedScientificNotation(void);
15 | void testNegative_SignedScientificNotation(void);
16 | void testStrict(void);
17 | void testNotNumbers(void);
18 | };
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/Unknown_C.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_UNKNOWN_C_HEADER
2 | #define JSON_UNKNOWN_C_HEADER
3 |
4 | #if !defined(__GNUC__) && !defined(_MSC_VER)
5 |
6 | #define json_deprecated(method, warning) method
7 |
8 | #define json_nothrow
9 | #define json_throws(x)
10 | #define json_pure json_nothrow
11 | #define json_read_priority
12 | #define json_write_priority
13 | #define json_malloc_attr json_nothrow
14 | #define json_hot
15 | #define json_cold
16 | #define json_likely(x) x
17 | #define json_unlikely(x) x
18 |
19 | #ifdef JSON_LESS_MEMORY
20 | #define PACKED(x) :x
21 | #define BITS(x) :x
22 | #endif
23 |
24 | #endif
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/Visual_C.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_VISUAL_C_HEADER
2 | #define JSON_VISUAL_C_HEADER
3 |
4 | #ifdef _MSC_VER
5 |
6 | #define json_deprecated(method, warning) __declspec(deprecated(warning)) method
7 |
8 | #define json_nothrow
9 | #define json_throws(x)
10 | #define json_pure json_nothrow
11 | #define json_read_priority
12 | #define json_write_priority
13 | #define json_malloc_attr json_nothrow
14 | #define json_hot
15 | #define json_cold
16 | #define json_likely(x) x
17 | #define json_unlikely(x) x
18 |
19 | #ifdef JSON_LESS_MEMORY
20 | #define PACKED(x) :x
21 | #define BITS(x) :x
22 | #endif
23 |
24 | #endif
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/isNumeric.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_NUMBER_TO_STRING__IS_NUMERIC_H
2 | #define JSON_TESTSUITE_NUMBER_TO_STRING__IS_NUMERIC_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testNumberToString__isNumeric : public BaseTest {
7 | public:
8 | testNumberToString__isNumeric(const std::string & name);
9 | virtual ~testNumberToString__isNumeric();
10 | void testPositive(void);
11 | void testNegative(void);
12 | void testPositive_ScientificNotation(void);
13 | void testNegative_ScientificNotation(void);
14 | void testPositive_SignedScientificNotation(void);
15 | void testNegative_SignedScientificNotation(void);
16 | void testStrict(void);
17 | void testNotStrict(void);
18 | void testNotNumbers(void);
19 | };
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidNumber.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_NUMBER_H
2 | #define JSON_TESTSUITE_JSON_VALIDATOR__IS_VALID_NUMBER_H
3 |
4 | #include "../BaseTest.h"
5 |
6 | class testJSONValidator__isValidNumber : public BaseTest {
7 | public:
8 | testJSONValidator__isValidNumber(const std::string & name) : BaseTest(name){}
9 | void testPositive(void);
10 | void testNegative(void);
11 | void testPositive_ScientificNotation(void);
12 | void testNegative_ScientificNotation(void);
13 | void testPositive_SignedScientificNotation(void);
14 | void testNegative_SignedScientificNotation(void);
15 | void testStrict(void);
16 | void testNotStrict(void);
17 | void testNotNumbers(void);
18 | void testSuddenEnd(void);
19 | };
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONGlobals/jsonSingleton.cpp:
--------------------------------------------------------------------------------
1 | #include "jsonSingleton.h"
2 | #include "../../Source/JSONGlobals.h"
3 |
4 | json_global_decl(std::string, WITHVALUE, "myvalue");
5 | json_global_decl(std::string, WITHOUTVALUE, );
6 |
7 | void testJSONGlobals__jsonSingleton::testValue(void){
8 | std::string * p1 = &jsonSingletonWITHVALUE::getValue();
9 | std::string * p2 = &json_global(WITHVALUE);
10 | assertEquals(p1, p2);
11 | assertEquals(json_global(WITHVALUE), "myvalue");
12 | assertEquals(jsonSingletonWITHVALUE::getValue(), "myvalue");
13 | }
14 |
15 | void testJSONGlobals__jsonSingleton::testNoValue(void){
16 | std::string * p1 = &jsonSingletonWITHOUTVALUE::getValue();
17 | std::string * p2 = &json_global(WITHOUTVALUE);
18 | assertEquals(p1, p2);
19 | assertEquals(json_global(WITHOUTVALUE), "");
20 | assertEquals(jsonSingletonWITHOUTVALUE::getValue(), "");
21 | }
22 |
--------------------------------------------------------------------------------
/src/Platform.cpp:
--------------------------------------------------------------------------------
1 | #include "Platform.h"
2 |
3 | #include
4 |
5 | Platform::JSONError Platform::Error = Platform::JSONError::JSON_ERROR_NONE;
6 | int Platform::SecondaryError = 0;
7 |
8 | char* Platform::GetExecutablePath(char pBuf[], const size_t sSize)
9 | {
10 | return ::_getcwd(pBuf, sSize);
11 | }
12 |
13 | CALLBACK_RETURN Platform::GetLastError(CALLBACK_PARAMS)
14 | {
15 | return Error;
16 | }
17 |
18 | CALLBACK_RETURN Platform::GetLastErrorSecondary(CALLBACK_PARAMS)
19 | {
20 | return SecondaryError;
21 | }
22 |
23 | CALLBACK_RETURN Platform::GetErrorSecondaryString(CALLBACK_PARAMS)
24 | {
25 | cell *out_addr = 0;
26 | amx_GetAddr(pAmx, pParams[2], &out_addr);
27 | char* pString = std::strerror(pParams[1]);
28 |
29 | if (pString == nullptr)
30 | return 0;
31 |
32 | amx_SetString(out_addr, pString, pParams[4], 0, pParams[3]);
33 |
34 | return 1;
35 | }
36 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/securityTest.cpp:
--------------------------------------------------------------------------------
1 | #include "securityTest.h"
2 | #include "Resources/validyMacros.h"
3 | #include "../../Source/JSONValidator.h"
4 |
5 | void testJSONValidator__securityTest::testsecurity(void){
6 | #ifdef JSON_SECURITY_MAX_NEST_LEVEL
7 | #if (JSON_SECURITY_MAX_NEST_LEVEL != 128)
8 | #error, test suite only wants a nest security level of 100
9 | #endif
10 | {
11 | json_string json(JSON_TEXT("{"));
12 | for(unsigned int i = 0; i < 127; ++i){
13 | json += JSON_TEXT("\"n\":{");
14 | }
15 | json += json_string(128, '}');
16 | assertTrue(JSONValidator::isValidRoot(json.c_str()));
17 | }
18 | {
19 | json_string json(JSON_TEXT("{"));
20 | for(unsigned int i = 0; i < 128; ++i){
21 | json += JSON_TEXT("\"n\":{");
22 | }
23 | json += json_string(129, '}');
24 | assertFalse(JSONValidator::isValidRoot(json.c_str()));
25 | }
26 | #endif
27 | }
28 |
--------------------------------------------------------------------------------
/src/AMXUtil.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define CALLBACK_RETURN cell AMX_NATIVE_CALL
4 | #define CALLBACK_PARAMS AMX* pAmx, cell* pParams
5 |
6 | typedef void(*logprintf_t)(char* format, ...);
7 |
8 | #include
9 | #include
10 |
11 | struct PAWNArray
12 | {
13 | cell* address;
14 | size_t length;
15 | };
16 |
17 | class AMXUtil
18 | {
19 | public:
20 | static cell Invoke(const char* szFunction, const char* szFormat, ...);
21 | static void SetAMXFunctions(void* pFunctionData);
22 | static char* GetStringFromCell(AMX* pAmx, cell cellString);
23 | static inline const std::list& GetAMXList() { return m_lAMX; };
24 | static inline void AddAMX(AMX* pAmx) { m_lAMX.push_back(pAmx); };
25 | static inline void RemoveAMX(AMX* pAmx) { m_lAMX.remove(pAmx); };
26 | static inline void SetPrintFunction(logprintf_t func) { Printf = func; };
27 |
28 | static logprintf_t Printf;
29 |
30 | private:
31 | static std::list m_lAMX;
32 |
33 | };
34 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/Strings_Defs.h:
--------------------------------------------------------------------------------
1 | #ifndef STRINGS_DEFS_HEADER
2 | #define STRINGS_DEFS_HEADER
3 |
4 | #include "../../../JSONOptions.h"
5 |
6 | #ifdef JSON_UNICODE
7 | #define json_char wchar_t
8 | #define json_uchar wchar_t
9 | #ifdef __cplusplus
10 | #include /* need wide characters */
11 | #ifndef JSON_STRING_HEADER
12 | #include
13 | #endif
14 | #else
15 | #include /* need wide characters */
16 | #endif
17 | #define JSON_TEXT(s) L ## s
18 | #define json_strlen wcslen
19 | #define json_strcmp wcscmp
20 | #else
21 | #define json_char char
22 | #define json_uchar unsigned char
23 | #ifdef __cplusplus
24 | #ifndef JSON_STRING_HEADER
25 | #include
26 | #endif
27 | #else
28 | #include /* still need it for strlen and such */
29 | #endif
30 | #define JSON_TEXT(s) s
31 | #define json_strlen strlen
32 | #define json_strcmp strcmp
33 | #endif
34 |
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/src/Platform.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #if (defined WIN32 || defined _WIN32)
7 | #define PATH_SEPARATOR "\\"
8 |
9 | #include
10 | #include
11 | #else
12 | #define PATH_SEPARATOR "/"
13 | #define _getcwd getcwd
14 |
15 | #include
16 | #include
17 | #endif
18 |
19 | #include "AMXUtil.h"
20 |
21 | class Platform
22 | {
23 | public:
24 | enum JSONError : int {
25 | JSON_ERROR_NONE = 0,
26 | JSON_ERROR_SCRIPTFILES_PATH_NOT_FOUND = 1,
27 | JSON_ERROR_FAILED_READING_FILE = 2,
28 | JSON_ERROR_INVALID_JSON_PATH = 3
29 | };
30 |
31 | static char* GetExecutablePath(char pBuf[], size_t sSize = FILENAME_MAX);
32 |
33 | static CALLBACK_RETURN GetLastError(CALLBACK_PARAMS);
34 | static CALLBACK_RETURN GetLastErrorSecondary(CALLBACK_PARAMS);
35 | static CALLBACK_RETURN GetErrorSecondaryString(CALLBACK_PARAMS);
36 |
37 | static JSONError Error;
38 | static int SecondaryError;
39 |
40 | };
41 |
--------------------------------------------------------------------------------
/src/SDK/amx/sclinux.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Things needed to compile under linux.
3 | *
4 | * Should be reworked totally to use GNU's 'configure'
5 | */
6 | #ifndef SCLINUX_H
7 | #define SCLINUX_H
8 |
9 | #define stricmp(a,b) strcasecmp(a,b)
10 | #define strnicmp(a,b,c) strncasecmp(a,b,c)
11 |
12 | /*
13 | * WinWorld wants '\'. Unices do not.
14 | */
15 | #define DIRECTORY_SEP_CHAR '/'
16 | #define DIRECTORY_SEP_STR "/"
17 |
18 | /*
19 | * SC assumes that a computer is Little Endian unless told otherwise. It uses
20 | * (and defines) the macros BYTE_ORDER and BIG_ENDIAN.
21 | * For Linux, we must overrule these settings with those defined in glibc.
22 | */
23 | #if !defined __BYTE_ORDER
24 | # include
25 | #endif
26 |
27 | #if defined __OpenBSD__ || defined __FreeBSD__
28 | # define __BYTE_ORDER BYTE_ORDER
29 | # define __LITTLE_ENDIAN LITTLE_ENDIAN
30 | # define __BIG_ENDIAN BIG_ENDIAN
31 | #endif
32 |
33 | #if !defined __BYTE_ORDER
34 | # error "Can't figure computer byte order (__BYTE_ORDER macro not found)"
35 | #endif
36 |
37 | #endif /* SCLINUX_H */
38 |
--------------------------------------------------------------------------------
/src/Util.cpp:
--------------------------------------------------------------------------------
1 | #include "Util.h"
2 |
3 | #include
4 |
5 | #include "Platform.h"
6 | #include "AMXUtil.h"
7 |
8 | char* Util::ReadFile(const char szPath[])
9 | {
10 | FILE* pFile = nullptr;
11 | char* pResult = nullptr;
12 | long lFileSize = 0L;
13 | size_t bytesRead = 0U;
14 |
15 | if ((pFile = std::fopen(szPath, "rb")) == nullptr) {
16 | Platform::SecondaryError = errno;
17 | return nullptr;
18 | }
19 |
20 | if (std::fseek(pFile, 0, SEEK_END) != 0) {
21 | Platform::SecondaryError = errno;
22 | std::fclose(pFile);
23 | return nullptr;
24 | }
25 |
26 | if ((lFileSize = std::ftell(pFile)) == -1L) {
27 | Platform::SecondaryError = errno;
28 | std::fclose(pFile);
29 | return nullptr;
30 | }
31 |
32 | std::rewind(pFile);
33 |
34 | pResult = new char[lFileSize + 1];
35 | if ((bytesRead = std::fread(pResult, sizeof(char), lFileSize, pFile)) != lFileSize) {
36 | std::fclose(pFile);
37 | return nullptr;
38 | }
39 |
40 | std::fclose(pFile);
41 |
42 | pResult[bytesRead] = 0;
43 | return pResult;
44 | }
45 |
--------------------------------------------------------------------------------
/src/JSONParser.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "AMXUtil.h"
9 |
10 | class JSONParser
11 | {
12 | public:
13 | static CALLBACK_RETURN ParseFile(CALLBACK_PARAMS);
14 | static CALLBACK_RETURN ParseString(CALLBACK_PARAMS);
15 | static CALLBACK_RETURN Close(CALLBACK_PARAMS);
16 | static CALLBACK_RETURN GetType(CALLBACK_PARAMS);
17 | static CALLBACK_RETURN GetNode(CALLBACK_PARAMS);
18 | static CALLBACK_RETURN GetString(CALLBACK_PARAMS);
19 | static CALLBACK_RETURN GetBool(CALLBACK_PARAMS);
20 | static CALLBACK_RETURN GetInt(CALLBACK_PARAMS);
21 | static CALLBACK_RETURN GetFloat(CALLBACK_PARAMS);
22 | static CALLBACK_RETURN GetArray(CALLBACK_PARAMS);
23 | static CALLBACK_RETURN GetArraySize(CALLBACK_PARAMS);
24 | static CALLBACK_RETURN GetArrayElement(CALLBACK_PARAMS);
25 | static CALLBACK_RETURN GetName(CALLBACK_PARAMS);
26 |
27 | private:
28 | static JSONNODE* json_get_recursive(JSONNODE* pRootNode, char* szPath, const char cDelim);
29 |
30 | };
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Nikola Yanakiev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | GXX=g++
2 | CFLAGS=-fPIC -fpermissive -c -w -std=c++11 -ISDK/ -Ilibjson/
3 | BFLAGS=-fshort-wchar -shared
4 | FLAGS=-DLINUX -D__LINUX__ -DNDEBUG -v -g0 -m32 -O2
5 | BUILDDIR=build
6 | BUILDFILE=SAMPSON.so
7 |
8 | all:
9 | @echo '====================== Build started ======================='
10 | mkdir -p $(BUILDDIR)
11 | cd libjson; make SHARED=0
12 | @echo '====================== Compiling SDK ======================='
13 | $(GXX) $(FLAGS) $(CFLAGS) SDK/*.cpp
14 | @echo '===================== Compiling plugin ====================='
15 | $(GXX) $(FLAGS) $(CFLAGS) *.cpp
16 | @echo '====================== Building plugin ====================='
17 | $(GXX) $(FLAGS) $(BFLAGS) -o $(BUILDDIR)/$(BUILDFILE) *.o -Wl,--whole-archive libjson/libjson.a -Wl,--no-whole-archive
18 | @echo '====================== Build finished ======================'
19 | rm *.o
20 | @echo '====================== Clean finished ======================'
21 |
22 | clean:
23 | @echo '====================== Clean started ======================='
24 | cd libjson; make clean
25 | rm *.o
26 | @echo '====================== Clean finished ======================'
27 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONPreparse.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBJSON_GUARD_PREPARSE_H
2 | #define LIBJSON_GUARD_PREPARSE_H
3 |
4 | #include "JSONDebug.h"
5 | #include "JSONNode.h"
6 |
7 | #if (defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY))
8 |
9 | #ifdef JSON_COMMENTS
10 | #define COMMENT_PARAM(name) ,const json_string & name
11 | #else
12 | #define COMMENT_PARAM(name)
13 | #endif
14 |
15 | class JSONPreparse {
16 | public:
17 | static JSONNode isValidNumber(json_string::const_iterator & ptr, json_string::const_iterator & end) json_read_priority;
18 | static JSONNode isValidMember(json_string::const_iterator & ptr, json_string::const_iterator & end) json_read_priority;
19 | static json_string isValidString(json_string::const_iterator & ptr, json_string::const_iterator & end) json_read_priority;
20 | static void isValidNamedObject(json_string::const_iterator & ptr, json_string::const_iterator & end, JSONNode & parent COMMENT_PARAM(comment)) json_read_priority;
21 | static JSONNode isValidObject(json_string::const_iterator & ptr, json_string::const_iterator & end) json_read_priority;
22 | static JSONNode isValidArray(json_string::const_iterator & ptr, json_string::const_iterator & end) json_read_priority;
23 | static JSONNode isValidRoot(const json_string & json) json_throws(std::invalid_argument) json_read_priority;
24 | };
25 |
26 | #endif
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSON_Base64.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBJSON_GUARD_BASE64_H
2 | #define LIBJSON_GUARD_BASE64_H
3 |
4 | #include "JSONDebug.h"
5 | #if defined(JSON_BINARY) || defined(JSON_EXPOSE_BASE64) //if this is not needed, don't waste space compiling it
6 |
7 | #include "../Dependencies/libbase64++/libbase64++.h"
8 |
9 | class JSONBase64 {
10 | public:
11 | inline static json_string json_encode64(const unsigned char * binary, size_t bytes) json_nothrow json_cold;
12 | inline static std::string json_decode64(const json_string & encoded) json_nothrow json_cold;
13 | private:
14 | JSONBase64(void);
15 | };
16 |
17 | json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes) json_nothrow {
18 | #if defined JSON_DEBUG || defined JSON_SAFE
19 | return libbase64::encode(binary, bytes);
20 | #else
21 | return libbase64::encode(binary, bytes);
22 | #endif
23 | }
24 |
25 | std::string JSONBase64::json_decode64(const json_string & encoded) json_nothrow {
26 | #if defined JSON_DEBUG || defined JSON_SAFE
27 | return libbase64::decode(encoded);
28 | #else
29 | return libbase64::decode(encoded);
30 | #endif
31 | }
32 |
33 |
34 | #endif
35 | #endif
36 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
19 |
20 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDebug.cpp:
--------------------------------------------------------------------------------
1 | #include "JSONDebug.h"
2 | #ifdef JSON_DEBUG
3 |
4 | #ifdef JSON_STDERROR
5 | #include //need std::cerr
6 | #else
7 | #include "JSONSingleton.h"
8 | //otherwise, use a callback to tell the end user what happened
9 | json_error_callback_t JSONDebug::register_callback(json_error_callback_t callback) json_nothrow {
10 | json_error_callback_t res = JSONSingleton::get();
11 | JSONSingleton::set(callback);
12 | return res;
13 | }
14 | #endif
15 |
16 | //Something went wrong or an assert failed
17 | void JSONDebug::_JSON_FAIL(const json_string & msg) json_nothrow {
18 | #ifdef JSON_STDERROR //no callback, just use stderror
19 | #ifndef JSON_UNICODE
20 | std::cerr << msg << std::endl;
21 | #else
22 | std::cerr << std::string(msg.begin(), msg.end()) << std::endl;
23 | #endif
24 | #else
25 | if (json_error_callback_t ErrorCallback = JSONSingleton::get()){ //only do anything if the callback is registered
26 | #ifdef JSON_LIBRARY
27 | ErrorCallback(msg.c_str());
28 | #else
29 | ErrorCallback(msg);
30 | #endif
31 | }
32 | #endif
33 | }
34 |
35 | //asserts that condition is true, more useful than cassert because it lets you keep going
36 | void JSONDebug::_JSON_ASSERT(bool condition, const json_string & msg) json_nothrow {
37 | if (json_unlikely(!condition)){
38 | _JSON_FAIL(msg);
39 | }
40 | }
41 | #endif
42 |
43 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONMemoryPool.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBJSON_GUARD_MEMORY_POOL_H
2 | #define LIBJSON_GUARD_MEMORY_POOL_H
3 |
4 | #ifdef JSON_MEMORY_POOL
5 |
6 | #include "../Dependencies/mempool++/mempool.h"
7 |
8 | //this macro expands to the number of bytes a pool gets based on block size and number of 32s of the total pool it gets
9 | #define jsonPoolPart(bytes_per_block, thirty_seconds_of_mem) bytes_per_block, ((thirty_seconds_of_mem * JSON_MEMORY_POOL / 32) / bytes_per_block)
10 |
11 | #ifdef JSON_PREPARSE
12 | #define NODEPOOL jsonPoolPart(sizeof(JSONNode), 1)
13 | #define INTERNALNODEPOOL jsonPoolPart(sizeof(internalJSONNode), 3)
14 | #define MEMPOOL_1 jsonPoolPart(8, 2)
15 | #define MEMPOOL_2 jsonPoolPart(16, 2)
16 | #define MEMPOOL_3 jsonPoolPart(32, 2)
17 | #define MEMPOOL_4 jsonPoolPart(64, 2)
18 | #define MEMPOOL_5 jsonPoolPart(128, 3)
19 | #define MEMPOOL_6 jsonPoolPart(256, 4)
20 | #define MEMPOOL_7 jsonPoolPart(512, 5)
21 | #define MEMPOOL_8 jsonPoolPart(4096, 8)
22 | #else
23 | #define NODEPOOL jsonPoolPart(sizeof(JSONNode), 2)
24 | #define INTERNALNODEPOOL jsonPoolPart(sizeof(internalJSONNode), 7)
25 | #define MEMPOOL_1 jsonPoolPart(8, 1)
26 | #define MEMPOOL_2 jsonPoolPart(16, 1)
27 | #define MEMPOOL_3 jsonPoolPart(32, 1)
28 | #define MEMPOOL_4 jsonPoolPart(64, 1)
29 | #define MEMPOOL_5 jsonPoolPart(128, 3)
30 | #define MEMPOOL_6 jsonPoolPart(256, 3)
31 | #define MEMPOOL_7 jsonPoolPart(512, 5)
32 | #define MEMPOOL_8 jsonPoolPart(4096, 8)
33 | #endif
34 |
35 | #endif
36 |
37 | #endif
38 |
39 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONValidator.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_VALIDATOR_H
2 | #define JSON_VALIDATOR_H
3 |
4 | #include "JSONDebug.h"
5 |
6 | #ifdef JSON_VALIDATE
7 |
8 | #ifdef JSON_SECURITY_MAX_NEST_LEVEL
9 | #define DEPTH_PARAM ,size_t depth_param
10 | #define DEPTH_ARG(arg) ,arg
11 | #define INC_DEPTH()\
12 | if (++depth_param > JSON_SECURITY_MAX_NEST_LEVEL){\
13 | JSON_FAIL(JSON_TEXT("Exceeded JSON_SECURITY_MAX_NEST_LEVEL"));\
14 | return false;\
15 | }
16 | #else
17 | #define DEPTH_PARAM
18 | #define DEPTH_ARG(arg)
19 | #define INC_DEPTH() (void)0
20 | #endif
21 |
22 | class JSONValidator {
23 | public:
24 | static bool isValidNumber(const json_char * & ptr) json_nothrow json_read_priority;
25 | static bool isValidMember(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
26 | static bool isValidString(const json_char * & ptr) json_nothrow json_read_priority;
27 | static bool isValidNamedObject(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
28 | static bool isValidObject(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
29 | static bool isValidArray(const json_char * & ptr DEPTH_PARAM) json_nothrow json_read_priority;
30 | static bool isValidRoot(const json_char * json) json_nothrow json_read_priority;
31 | #ifdef JSON_STREAM
32 | static bool isValidPartialRoot(const json_char * json) json_nothrow json_read_priority;
33 | #endif
34 | private:
35 | JSONValidator(void);
36 | };
37 |
38 | #endif
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/src/libjson/License.txt:
--------------------------------------------------------------------------------
1 | This license is also available in Documentation.pdf
2 |
3 | Copyright 2010 Jonathan Wallace. All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 |
9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 |
11 | THIS SOFTWARE IS PROVIDED BY JONATHAN WALLACE ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JONATHAN WALLACE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 |
13 | The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Jonathan Wallace.
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_FAIL.cpp:
--------------------------------------------------------------------------------
1 | #include "JSON_FAIL.h"
2 | #include "../../Source/JSONDebug.h"
3 |
4 | #if defined JSON_DEBUG
5 | #ifndef JSON_STDERROR
6 | static json_string last;
7 | #ifdef JSON_LIBRARY
8 | static void callback(const json_char * p){ last = p; }
9 | #else
10 | static void callback(const json_string & p){ last = p; }
11 | #endif
12 | #endif
13 | #endif
14 |
15 | const json_string fail_constf = JSON_TEXT("fail"); //should pass the same pointer all the way through, no copies
16 | const json_string null_constf = JSON_TEXT("");
17 | #if defined JSON_DEBUG || defined JSON_SAFE
18 | json_error_callback_t origCallbackf = NULL;
19 | #endif
20 |
21 | void testJSONDebug_JSON_FAIL::setUp(const std::string & methodName){
22 | BaseTest::setUp(methodName);
23 | #if defined JSON_DEBUG
24 | #ifndef JSON_STDERROR
25 | origCallbackf = JSONDebug::register_callback(callback); //check that the callback was called
26 | last = null_constf;
27 | #endif
28 | #endif
29 | }
30 |
31 | void testJSONDebug_JSON_FAIL::tearDown(void){
32 | BaseTest::tearDown();
33 | #if defined JSON_DEBUG
34 | #ifndef JSON_STDERROR
35 | JSONDebug::register_callback(origCallbackf); //check that the callback was called
36 | #endif
37 | #endif
38 | }
39 |
40 |
41 | /**
42 | * Make sure fails do call the callback
43 | */
44 | void testJSONDebug_JSON_FAIL::testFail(void){
45 | #if defined JSON_DEBUG
46 | #ifndef JSON_STDERROR
47 | JSON_FAIL(fail_constf);
48 | assertEquals(last, fail_constf); //make sure the callback was actually called
49 | #endif
50 | #endif
51 | }
52 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDebug.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBJSON_GUARD_DEBUG_H
2 | #define LIBJSON_GUARD_DEBUG_H
3 |
4 | #include "JSONDefs.h"
5 | #include "JSONStats.h"
6 |
7 | #ifdef JSON_DEBUG
8 | #ifdef JSON_SAFE
9 | #define JSON_ASSERT_SAFE(condition, msg, code)\
10 | {\
11 | if (json_unlikely(!(condition))){\
12 | JSON_FAIL(msg);\
13 | code\
14 | }\
15 | }
16 | #define JSON_FAIL_SAFE(msg, code)\
17 | {\
18 | JSON_FAIL(msg);\
19 | code\
20 | }
21 | #else
22 | #define JSON_ASSERT_SAFE(condition, msg, code) JSON_ASSERT(condition, msg)
23 | #define JSON_FAIL_SAFE(msg, code) JSON_FAIL(msg)
24 | #endif
25 |
26 | #define JSON_FAIL(msg) JSONDebug::_JSON_FAIL(msg)
27 | #define JSON_ASSERT(bo, msg) JSONDebug::_JSON_ASSERT(bo, msg)
28 |
29 | class JSONDebug {
30 | public:
31 | #ifndef JSON_STDERROR
32 | static json_error_callback_t register_callback(json_error_callback_t callback) json_nothrow json_cold;
33 | #endif
34 | static void _JSON_FAIL(const json_string & msg) json_nothrow json_cold;
35 | static void _JSON_ASSERT(bool condition, const json_string & msg) json_nothrow json_cold;
36 | };
37 | #else
38 | #ifdef JSON_SAFE
39 | #define JSON_ASSERT_SAFE(condition, msg, code)\
40 | {\
41 | if (json_unlikely(!(condition))){\
42 | code\
43 | }\
44 | }
45 | #define JSON_FAIL_SAFE(msg, code)\
46 | {\
47 | code\
48 | }
49 | #else
50 | #define JSON_ASSERT_SAFE(condition, msg, code)
51 | #define JSON_FAIL_SAFE(msg, code)
52 | #endif
53 |
54 | #define JSON_ASSERT(condition, msg)
55 | #define JSON_FAIL(msg)
56 | #endif
57 |
58 | #endif
59 |
60 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/Resources/validyMacros.h~:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_VALIDATOR_RESOURCES_VALIDITY_MACROS_H
2 | #define JSON_TESTSUITE_JSON_VALIDATOR_RESOURCES_VALIDITY_MACROS_H
3 |
4 | #include "../../../JSONOptions.h"
5 |
6 | #ifdef JSON_VALIDATE
7 |
8 | #define assertValid(x, method, nextchar)\
9 | {\
10 | json_string temp(JSON_TEXT(x));\
11 | const json_char * ptr = temp.c_str();\
12 | assertTrue(JSONValidator::method(ptr) && ((*ptr)==JSON_TEXT(nextchar)));\
13 | }
14 |
15 | #define assertNotValid(x, method, nextchar)\
16 | {\
17 | json_string temp(JSON_TEXT(x));\
18 | const json_char * ptr = temp.c_str();\
19 | assertTrue(!JSONValidator::method(ptr) || ((*ptr)!=JSON_TEXT(nextchar)));\
20 | }
21 |
22 | #ifdef JSON_SECURITY_MAX_NEST_LEVEL
23 | #define assertValid_Depth(x, method, nextchar)\
24 | {\
25 | json_string temp(JSON_TEXT(x));\
26 | const json_char * ptr = temp.c_str();\
27 | assertTrue(JSONValidator::method(ptr, 1) && ((*ptr)==JSON_TEXT(nextchar)));\
28 | }
29 |
30 | #define assertNotValid_Depth(x, method, nextchar)\
31 | {\
32 | json_string temp(JSON_TEXT(x));\
33 | const json_char * ptr = temp.c_str();\
34 | assertTrue(!JSONValidator::method(ptr, 1) || ((*ptr)!=JSON_TEXT(nextchar)));\
35 | }
36 | #else
37 | #define assertValid_Depth(x, method, nextchar) assertValid(x, method, nextchar)
38 | #define assertNotValid_Depth(x, method, nextchar) assertNotValid(x, method, nextchar)
39 | #endif
40 |
41 | #else
42 | #define assertValid(x, method, nextchar)
43 | #define assertNotValid(x, method, nextchar)
44 | #define assertValid_Depth(x, method, nextchar)
45 | #define assertNotValid_Depth(x, method, nextchar)
46 | #endif
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/Resources/validyMacros.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_TESTSUITE_JSON_VALIDATOR_RESOURCES_VALIDITY_MACROS_H
2 | #define JSON_TESTSUITE_JSON_VALIDATOR_RESOURCES_VALIDITY_MACROS_H
3 |
4 | #include "../../../../JSONOptions.h"
5 |
6 | #ifdef JSON_VALIDATE
7 |
8 | #define assertValid(x, method, nextchar)\
9 | {\
10 | json_string temp(JSON_TEXT(x));\
11 | const json_char * ptr = temp.c_str();\
12 | assertTrue(JSONValidator::method(ptr) && ((*ptr)==JSON_TEXT(nextchar)));\
13 | }
14 |
15 | #define assertNotValid(x, method, nextchar)\
16 | {\
17 | json_string temp(JSON_TEXT(x));\
18 | const json_char * ptr = temp.c_str();\
19 | assertTrue(!JSONValidator::method(ptr) || ((*ptr)!=JSON_TEXT(nextchar)));\
20 | }
21 |
22 | #ifdef JSON_SECURITY_MAX_NEST_LEVEL
23 | #define assertValid_Depth(x, method, nextchar)\
24 | {\
25 | json_string temp(JSON_TEXT(x));\
26 | const json_char * ptr = temp.c_str();\
27 | assertTrue(JSONValidator::method(ptr, 1) && ((*ptr)==JSON_TEXT(nextchar)));\
28 | }
29 |
30 | #define assertNotValid_Depth(x, method, nextchar)\
31 | {\
32 | json_string temp(JSON_TEXT(x));\
33 | const json_char * ptr = temp.c_str();\
34 | assertTrue(!JSONValidator::method(ptr, 1) || ((*ptr)!=JSON_TEXT(nextchar)));\
35 | }
36 | #else
37 | #define assertValid_Depth(x, method, nextchar) assertValid(x, method, nextchar)
38 | #define assertNotValid_Depth(x, method, nextchar) assertNotValid(x, method, nextchar)
39 | #endif
40 |
41 | #else
42 | #define assertValid(x, method, nextchar)
43 | #define assertNotValid(x, method, nextchar)
44 | #define assertValid_Depth(x, method, nextchar)
45 | #define assertNotValid_Depth(x, method, nextchar)
46 | #endif
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONValidator/isValidRoot.cpp:
--------------------------------------------------------------------------------
1 | #include "isValidRoot.h"
2 | #include "Resources/validyMacros.h"
3 | #include "../../Source/JSONValidator.h"
4 |
5 | void testJSONValidator__isValidRoot::testRoots(void){
6 | #ifdef JSON_VALIDATE
7 | assertTrue(JSONValidator::isValidRoot(JSON_TEXT("{}")));
8 | assertTrue(JSONValidator::isValidRoot(JSON_TEXT("[]")));
9 | assertTrue(JSONValidator::isValidRoot(JSON_TEXT("[\"stuff\"]")));
10 | #endif
11 | }
12 |
13 | void testJSONValidator__isValidRoot::testNotRoots(void){
14 | #ifdef JSON_VALIDATE
15 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("{]")));
16 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("[}")));
17 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("{}aoe")));
18 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("[]aoe")));
19 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("aoe")));
20 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("")));
21 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("[\"stuff\":{},]")));
22 | #endif
23 | }
24 |
25 | void testJSONValidator__isValidRoot::testSuddenEnd(void){
26 | #ifdef JSON_VALIDATE
27 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("")));
28 |
29 | //--- void testJSONValidator__isValidRoot::testRoots(void){
30 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("{")));
31 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("[")));
32 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("[\"stuff")));
33 |
34 | //---void testJSONValidator__isValidRoot::testNotRoots(void){
35 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("{}aoe")));
36 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("[]aoe")));
37 | assertFalse(JSONValidator::isValidRoot(JSON_TEXT("aoe")));
38 | #endif
39 | }
40 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/_areFloatsEqual.cpp:
--------------------------------------------------------------------------------
1 | #include "_areFloatsEqual.h"
2 | #include "../../Source/NumberToString.h"
3 |
4 |
5 | /**
6 | * Tests that numbers that are actually equal are identified that way
7 | */
8 | void testNumberToString__areFloatsEqual::testEqual(void){
9 | assertTrue(_floatsAreEqual( 0.0, 0.0));
10 | assertTrue(_floatsAreEqual( 1.0, 1.0));
11 | assertTrue(_floatsAreEqual( 1.1, 1.1));
12 | assertTrue(_floatsAreEqual(-1.0, -1.0));
13 | assertTrue(_floatsAreEqual( 0.1, 0.1));
14 | assertTrue(_floatsAreEqual(-0.1, -0.1));
15 | }
16 |
17 |
18 | /**
19 | * Make sure that numbers that are very different are identified as not equal
20 | */
21 | void testNumberToString__areFloatsEqual::testNotEqual(void){
22 | assertFalse(_floatsAreEqual( 1.0, -1.0));
23 | assertFalse(_floatsAreEqual( 1.0, 0.0));
24 | assertFalse(_floatsAreEqual(-1.0, -.0));
25 | assertFalse(_floatsAreEqual( 0.1, 0.0));
26 | assertFalse(_floatsAreEqual(-0.1, 0.0));
27 | assertFalse(_floatsAreEqual(1.0, 1.0001));
28 | assertFalse(_floatsAreEqual(1.0001, 1.0));
29 | }
30 |
31 |
32 | /**
33 | * Make sure numbers that are different, but within the threshold of
34 | * floats/doubles being equal are identified as equal
35 | */
36 | void testNumberToString__areFloatsEqual::testCloseEnough(void){
37 | //check the exact threshold
38 | assertFalse(_floatsAreEqual( 0.0, JSON_FLOAT_THRESHHOLD));
39 | assertFalse(_floatsAreEqual( 0.0, -JSON_FLOAT_THRESHHOLD));
40 |
41 | //check things beneath that threashold
42 | assertTrue(_floatsAreEqual(0.0, JSON_FLOAT_THRESHHOLD / 2));
43 | assertTrue(_floatsAreEqual(0.0, JSON_FLOAT_THRESHHOLD / -2));
44 | assertTrue(_floatsAreEqual(-0.1, -0.1));
45 | assertTrue(_floatsAreEqual(1.000000001, 1.0));
46 | assertTrue(_floatsAreEqual(1.0, 1.000000001));
47 | }
48 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestBinary.cpp:
--------------------------------------------------------------------------------
1 | #include "TestSuite.h"
2 | #include "../Source/JSON_Base64.h"
3 |
4 | #if defined(JSON_BINARY) || defined(JSON_EXPOSE_BASE64)
5 | void TestSuite::TestBase64(void){
6 | UnitTest::SetPrefix("TestBinary.cpp - Base 64");
7 |
8 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"A", 1)), "A");
9 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"AB", 2)), "AB");
10 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABC", 3)), "ABC");
11 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCD", 4)), "ABCD");
12 | #ifdef JSON_SAFE
13 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"", 0)), "");
14 | assertEquals(JSONBase64::json_decode64(JSON_TEXT("123!abc")), "");
15 | assertEquals(JSONBase64::json_decode64(JSON_TEXT("123=abc")), "");
16 | assertEquals(JSONBase64::json_decode64(JSON_TEXT("123abc===")), "");
17 | #endif
18 |
19 | unsigned char temp[255];
20 | for(unsigned int i = 0; i < 255; ++i){
21 | temp[i] = (unsigned char)i;
22 | }
23 | json_string ts = JSONBase64::json_encode64(temp, 255);
24 | std::string rs = JSONBase64::json_decode64(ts);
25 | assertEquals(rs.size(), 255);
26 | assertEquals(memcmp(rs.data(), temp, 255), 0);
27 |
28 | #if defined(JSON_LIBRARY) && defined(JSON_EXPOSE_BASE64)
29 | json_char * test = json_encode64(temp, 255);
30 | assertNotNull(test);
31 | unsigned long _size;
32 | void * bin = json_decode64(test, & _size);
33 | assertNotNull(bin);
34 | assertEquals(_size, 255);
35 | assertEquals(memcmp(bin, temp, 255), 0);
36 | json_free(test);
37 | json_free(bin);
38 | #endif
39 | }
40 | #endif
41 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_FAIL_SAFE.cpp:
--------------------------------------------------------------------------------
1 | #include "JSON_FAIL_SAFE.h"
2 | #include "../../Source/JSONDebug.h"
3 |
4 | #if defined JSON_DEBUG
5 | #ifndef JSON_STDERROR
6 | static json_string last;
7 | #ifdef JSON_LIBRARY
8 | static void callback(const json_char * p){ last = p; }
9 | #else
10 | static void callback(const json_string & p){ last = p; }
11 | #endif
12 | #endif
13 | #endif
14 |
15 | const json_string fail_constfs = JSON_TEXT("fail"); //should pass the same pointer all the way through, no copies
16 | const json_string null_constfs = JSON_TEXT("");
17 | #if defined JSON_DEBUG || defined JSON_SAFE
18 | json_error_callback_t origCallbackfs = NULL;
19 | #endif
20 |
21 | void testJSONDebug_JSON_FAIL_SAFE::setUp(const std::string & methodName){
22 | BaseTest::setUp(methodName);
23 | #if defined JSON_DEBUG
24 | #ifndef JSON_STDERROR
25 | origCallbackfs = JSONDebug::register_callback(callback); //check that the callback was called
26 | last = null_constfs;
27 | #endif
28 | #endif
29 | }
30 |
31 | void testJSONDebug_JSON_FAIL_SAFE::tearDown(void){
32 | BaseTest::tearDown();
33 | #if defined JSON_DEBUG
34 | #ifndef JSON_STDERROR
35 | JSONDebug::register_callback(origCallbackfs); //check that the callback was called
36 | #endif
37 | #endif
38 | }
39 |
40 |
41 | /**
42 | * Make sure fails do call the callback and run extra code
43 | */
44 | void testJSONDebug_JSON_FAIL_SAFE::testFail(void){
45 | int i = 0;
46 | JSON_FAIL_SAFE(fail_constfs, i = 1;);
47 | #if defined(JSON_SAFE)
48 | assertEquals(i, 1); //safe caught the code
49 | #else
50 | assertEquals(i, 0); //fell through because no safety catch
51 | #endif
52 |
53 | #if defined JSON_DEBUG
54 | #ifndef JSON_STDERROR
55 | assertEquals(last, fail_constfs); //make sure the callback was actually called
56 | #endif
57 | #endif
58 | }
59 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/Benchmark/makefile:
--------------------------------------------------------------------------------
1 | OS=$(shell uname)
2 | ifeq ($(OS), Darwin)
3 | fastflag = -fast
4 | else
5 | fastflag = -O3
6 | endif
7 |
8 | single:
9 | g++ main.cpp \
10 | ../../Source/internalJSONNode.cpp \
11 | ../../Source/JSONChildren.cpp ../../Source/JSONDebug.cpp \
12 | ../../Source/JSONIterators.cpp ../../Source/JSONMemory.cpp \
13 | ../../Source/JSONNode_Mutex.cpp ../../Source/JSONNode.cpp \
14 | ../../Source/JSONWorker.cpp ../../Source/JSONWriter.cpp \
15 | ../../Source/libjson.cpp ../../Source/JSONValidator.cpp \
16 | ../../Source/JSONStream.cpp ../../Source/JSONAllocator.cpp \
17 | ../../Source/JSONPreparse.cpp \
18 | -Wfatal-errors -DNDEBUG $(fastflag) -ffast-math -fexpensive-optimizations -o testapp
19 |
20 | debug:
21 | g++ main.cpp \
22 | ../../Source/internalJSONNode.cpp \
23 | ../../Source/JSONChildren.cpp ../../Source/JSONDebug.cpp \
24 | ../../Source/JSONIterators.cpp ../../Source/JSONMemory.cpp \
25 | ../../Source/JSONNode_Mutex.cpp ../../Source/JSONNode.cpp \
26 | ../../Source/JSONWorker.cpp ../../Source/JSONWriter.cpp \
27 | ../../Source/libjson.cpp ../../Source/JSONValidator.cpp \
28 | ../../Source/JSONStream.cpp ../../Source/JSONAllocator.cpp \
29 | ../../Source/JSONPreparse.cpp \
30 | -Wfatal-errors -DJSON_DEBUG -o testapp
31 |
32 | small:
33 | g++ main.cpp \
34 | ../../Source/internalJSONNode.cpp \
35 | ../../Source/JSONChildren.cpp ../../Source/JSONDebug.cpp \
36 | ../../Source/JSONIterators.cpp ../../Source/JSONMemory.cpp \
37 | ../../Source/JSONNode_Mutex.cpp ../../Source/JSONNode.cpp \
38 | ../../Source/JSONWorker.cpp ../../Source/JSONWriter.cpp \
39 | ../../Source/libjson.cpp ../../Source/JSONValidator.cpp \
40 | ../../Source/JSONStream.cpp ../../Source/JSONAllocator.cpp \
41 | ../../Source/JSONPreparse.cpp \
42 | -Wfatal-errors -DNDEBUG -Os -ffast-math -DJSON_LESS_MEMORY -o testapp
43 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_ASSERT.cpp:
--------------------------------------------------------------------------------
1 | #include "JSON_ASSERT.h"
2 | #include "../../Source/JSONDebug.h"
3 |
4 | #if defined JSON_DEBUG
5 | #ifndef JSON_STDERROR
6 | static json_string last;
7 | #ifdef JSON_LIBRARY
8 | static void callback(const json_char * p){ last = p; }
9 | #else
10 | static void callback(const json_string & p){ last = p; }
11 | #endif
12 | #endif
13 | #endif
14 |
15 | const json_string fail_consta = JSON_TEXT("fail"); //should pass the same pointer all the way through, no copies
16 | const json_string null_consta = JSON_TEXT("");
17 | #if defined JSON_DEBUG || defined JSON_SAFE
18 | json_error_callback_t origCallbacka = NULL;
19 | #endif
20 |
21 | void testJSONDebug_JSON_ASSERT::setUp(const std::string & methodName){
22 | BaseTest::setUp(methodName);
23 | #if defined JSON_DEBUG
24 | #ifndef JSON_STDERROR
25 | origCallbacka = JSONDebug::register_callback(callback); //check that the callback was called
26 | last = null_consta;
27 | #endif
28 | #endif
29 | }
30 |
31 | void testJSONDebug_JSON_ASSERT::tearDown(void){
32 | BaseTest::tearDown();
33 | #if defined JSON_DEBUG
34 | #ifndef JSON_STDERROR
35 | JSONDebug::register_callback(origCallbacka); //check that the callback was called
36 | #endif
37 | #endif
38 | }
39 |
40 |
41 | /**
42 | * Make sure asserts that pass do not call the callback or run extra code
43 | */
44 | void testJSONDebug_JSON_ASSERT::testPass(void){
45 | #if defined JSON_DEBUG
46 | #ifndef JSON_STDERROR
47 | JSON_ASSERT(1 == 1, fail_consta);
48 | assertEquals(last, null_consta); //make sure the callback was not called
49 | #endif
50 | #endif
51 | }
52 |
53 |
54 | /**
55 | * Make sure asserts that fail do call the callback and run extra code
56 | */
57 | void testJSONDebug_JSON_ASSERT::testFail(void){
58 | #if defined JSON_DEBUG
59 | #ifndef JSON_STDERROR
60 | JSON_ASSERT(1 == 0, fail_consta);
61 | assertEquals(last, fail_consta); //make sure the callback was actually called
62 | #endif
63 | #endif
64 | }
65 |
--------------------------------------------------------------------------------
/src/plugin.cpp:
--------------------------------------------------------------------------------
1 | #define PLUGIN_VERSION "0.2.0"
2 |
3 | #include
4 | #include
5 |
6 | #include "AMXUtil.h"
7 | #include "JSONParser.h"
8 | #include "Platform.h"
9 |
10 | PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
11 | {
12 | return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
13 | }
14 |
15 | PLUGIN_EXPORT bool PLUGIN_CALL Load(void** ppData)
16 | {
17 | AMXUtil::SetAMXFunctions(ppData[PLUGIN_DATA_AMX_EXPORTS]);
18 | AMXUtil::SetPrintFunction((logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF]);
19 | AMXUtil::Printf("============== SAMPSON v" PLUGIN_VERSION " by King_Hual loaded ==============");
20 | return 1;
21 | }
22 |
23 | PLUGIN_EXPORT void PLUGIN_CALL Unload()
24 | {
25 | AMXUtil::Printf("============= SAMPSON v" PLUGIN_VERSION " by King_Hual unloaded =============");
26 | }
27 |
28 | AMX_NATIVE_INFO PluginNatives[] =
29 | {
30 | { "json_parse_file", JSONParser::ParseFile },
31 | { "json_parse_string", JSONParser::ParseString },
32 | { "json_close", JSONParser::Close },
33 | { "json_get_string", JSONParser::GetString },
34 | { "json_get_type", JSONParser::GetType },
35 | { "json_get_node", JSONParser::GetNode },
36 | { "json_get_bool", JSONParser::GetBool },
37 | { "json_get_int", JSONParser::GetInt },
38 | { "json_get_float", JSONParser::GetFloat },
39 | { "json_get_array", JSONParser::GetArray },
40 | { "json_array_count", JSONParser::GetArraySize },
41 | { "json_array_at", JSONParser::GetArrayElement },
42 | { "json_get_name", JSONParser::GetName },
43 | { "json_get_last_error", Platform::GetLastError },
44 | { "json_get_last_error_extra", Platform::GetLastErrorSecondary },
45 | { "json_get_error_extra_string", Platform::GetErrorSecondaryString },
46 | { 0, 0 }
47 | };
48 |
49 | PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX* pAmx)
50 | {
51 | AMXUtil::AddAMX(pAmx);
52 | return amx_Register(pAmx, PluginNatives, -1);
53 | }
54 |
55 | PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX* pAmx)
56 | {
57 | AMXUtil::RemoveAMX(pAmx);
58 | return AMX_ERR_NONE;
59 | }
60 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/NumberToString/_ftoa.cpp:
--------------------------------------------------------------------------------
1 | #include "_ftoa.h"
2 | #include "../../Source/NumberToString.h"
3 |
4 |
5 | /**
6 | * Test that the float to string function works
7 | */
8 | void testNumberToString__ftoa::testRandomNumbers(void){
9 | //random numbers to varying precision
10 | assertEquals(NumberToString::_ftoa((json_number) 1.2), JSON_TEXT( "1.2"));
11 | assertEquals(NumberToString::_ftoa((json_number) -1.2), JSON_TEXT( "-1.2"));
12 | assertEquals(NumberToString::_ftoa((json_number) 1.02), JSON_TEXT( "1.02"));
13 | assertEquals(NumberToString::_ftoa((json_number) -1.02), JSON_TEXT( "-1.02"));
14 | assertEquals(NumberToString::_ftoa((json_number) 1.002), JSON_TEXT( "1.002"));
15 | assertEquals(NumberToString::_ftoa((json_number) -1.002), JSON_TEXT( "-1.002"));
16 | assertEquals(NumberToString::_ftoa((json_number) 3.1415), JSON_TEXT( "3.1415"));
17 | assertEquals(NumberToString::_ftoa((json_number) -3.1415), JSON_TEXT( "-3.1415"));
18 | }
19 |
20 |
21 | /**
22 | * This function reverts to one of the int functions in case of an int because
23 | * they are faster. This tests that.
24 | */
25 | void testNumberToString__ftoa::testSpecializedInts(void){
26 | assertEquals(NumberToString::_ftoa((json_number) 1.0), JSON_TEXT( "1"));
27 | assertEquals(NumberToString::_ftoa((json_number) 10.0), JSON_TEXT( "10"));
28 | assertEquals(NumberToString::_ftoa((json_number) -1.0), JSON_TEXT( "-1"));
29 | assertEquals(NumberToString::_ftoa((json_number)-10.0), JSON_TEXT("-10"));
30 | assertEquals(NumberToString::_ftoa((json_number) 0.0), JSON_TEXT( "0"));
31 | assertEquals(NumberToString::_ftoa((json_number) -0.0), JSON_TEXT( "0"));
32 |
33 | //close enough to an int
34 | assertEquals(NumberToString::_ftoa((json_number) 1.000000001), JSON_TEXT( "1"));
35 | assertEquals(NumberToString::_ftoa((json_number) -1.000000001), JSON_TEXT( "-1"));
36 | assertEquals(NumberToString::_ftoa((json_number) 0.000000001), JSON_TEXT( "0"));
37 | assertEquals(NumberToString::_ftoa((json_number) -0.000000001), JSON_TEXT( "0"));
38 | }
39 |
--------------------------------------------------------------------------------
/src/SAMPSON.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27004.2006
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SAMPSON", "SAMPSON.vcxproj", "{9851555C-5434-492F-B7C5-D34662049A9B}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA} = {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}
9 | EndProjectSection
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "statLibJson", "libjson\libjson.vcxproj", "{153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Win32 = Debug|Win32
16 | Release|Win32 = Release|Win32
17 | small|Win32 = small|Win32
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {9851555C-5434-492F-B7C5-D34662049A9B}.Debug|Win32.ActiveCfg = Debug|Win32
21 | {9851555C-5434-492F-B7C5-D34662049A9B}.Debug|Win32.Build.0 = Debug|Win32
22 | {9851555C-5434-492F-B7C5-D34662049A9B}.Release|Win32.ActiveCfg = Release|Win32
23 | {9851555C-5434-492F-B7C5-D34662049A9B}.Release|Win32.Build.0 = Release|Win32
24 | {9851555C-5434-492F-B7C5-D34662049A9B}.small|Win32.ActiveCfg = small|Win32
25 | {9851555C-5434-492F-B7C5-D34662049A9B}.small|Win32.Build.0 = small|Win32
26 | {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}.Debug|Win32.ActiveCfg = Debug|Win32
27 | {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}.Debug|Win32.Build.0 = Debug|Win32
28 | {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}.Release|Win32.ActiveCfg = Release|Win32
29 | {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}.Release|Win32.Build.0 = Release|Win32
30 | {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}.small|Win32.ActiveCfg = small|Win32
31 | {153A6FE5-40A9-4C31-B0C2-1C68D2E37BEA}.small|Win32.Build.0 = small|Win32
32 | EndGlobalSection
33 | GlobalSection(SolutionProperties) = preSolution
34 | HideSolutionNode = FALSE
35 | EndGlobalSection
36 | GlobalSection(ExtensibilityGlobals) = postSolution
37 | SolutionGuid = {D4E3A2D9-F0D0-4974-AE4F-48A3EEFDD36D}
38 | EndGlobalSection
39 | EndGlobal
40 |
--------------------------------------------------------------------------------
/src/SAMPSON.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {e5281bb1-e316-4946-a1c1-54df799c43da}
6 |
7 |
8 | {f9f51206-ec41-41d6-a853-43fe09b12feb}
9 |
10 |
11 | {ec3110fd-019c-42d4-9ddb-280b7fc3fba1}
12 |
13 |
14 |
15 |
16 | SDK
17 |
18 |
19 | Plugin
20 |
21 |
22 | Plugin
23 |
24 |
25 | Plugin
26 |
27 |
28 |
29 | Plugin
30 |
31 |
32 | Plugin
33 |
34 |
35 |
36 |
37 | Plugin
38 |
39 |
40 |
41 |
42 | SDK
43 |
44 |
45 | SDK\amx
46 |
47 |
48 | SDK\amx
49 |
50 |
51 | Plugin
52 |
53 |
54 | Plugin
55 |
56 |
57 |
58 | Plugin
59 |
60 |
61 | Plugin
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/AMXUtil.cpp:
--------------------------------------------------------------------------------
1 | #include "AMXUtil.h"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | extern void* pAMXFunctions;
8 |
9 | logprintf_t AMXUtil::Printf;
10 | std::list AMXUtil::m_lAMX;
11 |
12 | cell AMXUtil::Invoke(const char* szFunction, const char* szFormat, ...)
13 | {
14 | cell iReturnValue = 1;
15 | std::vector| returnValues(m_lAMX.size(), 1);
16 | size_t idx = 0;
17 | va_list argPtr;
18 |
19 | for (std::list::iterator it = m_lAMX.begin(); it != m_lAMX.end(); ++it, ++idx) {
20 | AMX* pAmx = *it;
21 | int iFuncIdx;
22 |
23 | if (amx_FindPublic(pAmx, szFunction, &iFuncIdx) != 0) {
24 | continue;
25 | }
26 |
27 | cell addresses[16];
28 | unsigned int addrIdx = 0;
29 |
30 | if (szFormat) {
31 | va_start(argPtr, szFormat);
32 |
33 | for (unsigned int i = 0; i < strlen(szFormat); ++i) {
34 | if (szFormat[i] == 'i') {
35 | amx_Push(pAmx, va_arg(argPtr, int));
36 | }
37 | else if (szFormat[i] == 's') {
38 | amx_PushString(pAmx, &addresses[addrIdx++], NULL, va_arg(argPtr, char*), false, false);
39 | }
40 | else if (szFormat[i] == 'a') {
41 | cell iAmxAddr, *pPhysAddr;
42 |
43 | PAWNArray array = va_arg(argPtr, PAWNArray);
44 | amx_Allot(pAmx, array.length, &iAmxAddr, &pPhysAddr);
45 | memcpy(pPhysAddr, array.address, array.length * sizeof(cell));
46 | amx_Push(pAmx, iAmxAddr);
47 |
48 | }
49 | }
50 |
51 | va_end(argPtr);
52 | }
53 |
54 | amx_Exec(pAmx, &returnValues[idx], iFuncIdx);
55 |
56 | if (!returnValues[idx]) {
57 | iReturnValue = 0;
58 | }
59 |
60 | for (unsigned int i = 0; i < addrIdx; ++i) {
61 | amx_Release(pAmx, addresses[i]);
62 | }
63 |
64 | }
65 |
66 | return iReturnValue;
67 | }
68 |
69 | void AMXUtil::SetAMXFunctions(void* pFunctionData)
70 | {
71 | pAMXFunctions = pFunctionData;
72 | }
73 |
74 | char* AMXUtil::GetStringFromCell(AMX* pAmx, cell cellString)
75 | {
76 | cell* pAddr = 0;
77 | int iLen = 0;
78 | char* pStr;
79 |
80 | amx_GetAddr(pAmx, cellString, &pAddr);
81 | amx_StrLen(pAddr, &iLen);
82 | ++iLen;
83 | pStr = new char[iLen];
84 | amx_GetString(pStr, pAddr, 0, iLen);
85 | return pStr;
86 | }
87 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONDefs/GNU_C.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_GNU_C_HEADER
2 | #define JSON_GUN_C_HEADER
3 |
4 | #ifdef __GNUC__
5 |
6 | #define json_deprecated(method, warning) method __attribute__((deprecated))
7 |
8 | #if (__GNUC__ >= 3)
9 | #define JSON_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
10 | #else
11 | #define JSON_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
12 | #endif
13 |
14 | #if (JSON_GCC_VERSION >= 40300)
15 | #define json_hot __attribute__ ((hot))
16 | #define json_cold __attribute__ ((cold))
17 | #define json_pure json_nothrow __attribute__ ((pure, hot))
18 | #define json_malloc_attr json_nothrow __attribute__ ((malloc, hot))
19 |
20 | /* Can do priorities */
21 | #if (JSON_WRITE_PRIORITY == HIGH)
22 | #define json_write_priority __attribute__ ((hot))
23 | #elif (JSON_WRITE_PRIORITY == LOW)
24 | #define json_write_priority __attribute__ ((cold))
25 | #else
26 | #define json_write_priority
27 | #endif
28 |
29 | #if (JSON_READ_PRIORITY == HIGH)
30 | #define json_read_priority __attribute__ ((hot))
31 | #elif (JSON_READ_PRIORITY == LOW)
32 | #define json_read_priority __attribute__ ((cold))
33 | #else
34 | #define json_read_priority
35 | #endif
36 |
37 | #define json_likely(x) __builtin_expect((long)((bool)(x)),1)
38 | #define json_unlikely(x) __builtin_expect((long)((bool)(x)),0)
39 | #else
40 | #if (JSON_GCC_VERSION >= 29600)
41 | #define json_pure json_nothrow __attribute__ ((pure))
42 | #define json_likely(x) __builtin_expect((long)((bool)(x)),1)
43 | #define json_unlikely(x) __builtin_expect((long)((bool)(x)),0)
44 | #else
45 | #define json_pure json_nothrow
46 | #define json_likely(x) x
47 | #define json_unlikely(x) x
48 | #endif
49 |
50 | #define json_malloc_attr json_nothrow __attribute__ ((malloc))
51 | #define json_write_priority
52 | #define json_read_priority
53 | #define json_hot
54 | #define json_cold
55 | #endif
56 |
57 | #define json_nothrow throw()
58 | #define json_throws(x) throw(x)
59 |
60 | #ifdef JSON_LESS_MEMORY
61 | #define PACKED(x) :x __attribute__ ((packed))
62 | #define BITS(x) :x
63 | #endif
64 |
65 | #endif
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSONDebug/JSON_ASSERT_SAFE.cpp:
--------------------------------------------------------------------------------
1 | #include "JSON_ASSERT_SAFE.h"
2 | #include "../../Source/JSONDebug.h"
3 |
4 | #if defined JSON_DEBUG
5 | #ifndef JSON_STDERROR
6 | static json_string last;
7 | #ifdef JSON_LIBRARY
8 | static void callback(const json_char * p){ last = p; }
9 | #else
10 | static void callback(const json_string & p){ last = p; }
11 | #endif
12 | #endif
13 | #endif
14 |
15 | const json_string fail_const = JSON_TEXT("fail"); //should pass the same pointer all the way through, no copies
16 | const json_string null_const = JSON_TEXT("");
17 | #if defined JSON_DEBUG || defined JSON_SAFE
18 | json_error_callback_t origCallback = NULL;
19 | #endif
20 |
21 | void testJSONDebug_JSON_ASSERT_SAFE::setUp(const std::string & methodName){
22 | BaseTest::setUp(methodName);
23 | #if defined JSON_DEBUG
24 | #ifndef JSON_STDERROR
25 | origCallback = JSONDebug::register_callback(callback); //check that the callback was called
26 | last = null_const;
27 | #endif
28 | #endif
29 | }
30 |
31 | void testJSONDebug_JSON_ASSERT_SAFE::tearDown(void){
32 | BaseTest::tearDown();
33 | #if defined JSON_DEBUG
34 | #ifndef JSON_STDERROR
35 | JSONDebug::register_callback(origCallback); //check that the callback was called
36 | #endif
37 | #endif
38 | }
39 |
40 |
41 | /**
42 | * Make sure asserts that pass do not call the callback or run extra code
43 | */
44 | void testJSONDebug_JSON_ASSERT_SAFE::testPass(void){
45 | int i = 0;
46 | JSON_ASSERT_SAFE(1 == 1, fail_const, i = 1;);
47 | assertEquals(i, 0);
48 |
49 | #if defined JSON_DEBUG
50 | #ifndef JSON_STDERROR
51 | assertEquals(last, null_const); //make sure the callback was not called
52 | #endif
53 | #endif
54 | }
55 |
56 |
57 | /**
58 | * Make sure asserts that fail do call the callback and run extra code
59 | */
60 | void testJSONDebug_JSON_ASSERT_SAFE::testFail(void){
61 | int i = 0;
62 | JSON_ASSERT_SAFE(1 == 0, fail_const, i = 1;);
63 | #if defined(JSON_SAFE)
64 | assertEquals(i, 1); //safe caught the code
65 | #else
66 | assertEquals(i, 0); //fell through because no safety catch
67 | #endif
68 |
69 | #if defined JSON_DEBUG
70 | #ifndef JSON_STDERROR
71 | assertEquals(last, fail_const); //make sure the callback was actually called
72 | #endif
73 | #endif
74 | }
75 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite2Creator.php:
--------------------------------------------------------------------------------
1 |
7 |
8 | #if !defined JSON_DEFAULT_DELIMITER
9 | #define JSON_DEFAULT_DELIMITER '/'
10 | #endif
11 |
12 | #define JSON_NULL 0
13 | #define JSON_STRING 1
14 | #define JSON_NUMBER 2
15 | #define JSON_BOOL 3
16 | #define JSON_ARRAY 4
17 | #define JSON_NODE 5
18 |
19 | #define JSON_ERROR_NONE 0
20 | #define JSON_ERROR_JSON_ERROR_SCRIPTFILES_PATH_NOT_FOUND 1
21 | #define JSON_ERROR_FAILED_READING_FILE 2
22 | #define JSON_ERROR_INVALID_JSON_PATH 3
23 |
24 | native JSONNode:json_parse_file(const file_path[]);
25 | native JSONNode:json_parse_string(const string[]);
26 | native json_close(JSONNode:node);
27 | native json_get_type(JSONNode:node, const path[] = '\0', const path_delim = JSON_DEFAULT_DELIMITER);
28 | native JSONNode:json_get_node(JSONNode:node, const path[], const path_delim = JSON_DEFAULT_DELIMITER);
29 | native bool:json_get_bool(JSONNode:node, const path[] = '\0', const path_delim = JSON_DEFAULT_DELIMITER);
30 | native json_get_int(JSONNode:node, const path[] = '\0', const path_delim = JSON_DEFAULT_DELIMITER);
31 | native Float:json_get_float(JSONNode:node, const path[] = '\0', const path_delim = JSON_DEFAULT_DELIMITER);
32 | native json_get_string(JSONNode:node, dst[], const len = sizeof(dst), const path[] = '\0', const bool:packed = false, const path_delim = JSON_DEFAULT_DELIMITER);
33 | native json_get_name(JSONNode:node, dst[], const len = sizeof(dst), const bool:packed = false);
34 |
35 | native JSONArray:json_get_array(JSONNode:node, const path[] = '\0', const path_delim = JSON_DEFAULT_DELIMITER);
36 | native json_array_count(JSONArray:array);
37 | native JSONNode:json_array_at(JSONArray:array, const index);
38 |
39 | native json_get_last_error();
40 | native json_get_last_error_extra();
41 | native json_get_error_extra_string(errno, dst[] , const len = sizeof(dst));
42 |
43 | stock json_get_error_string(errno, dst[], const len = sizeof(dst))
44 | {
45 | switch (errno)
46 | {
47 | case JSON_ERROR_NONE:
48 | {
49 | strcat(dst, "None", len);
50 | }
51 | case JSON_ERROR_JSON_ERROR_SCRIPTFILES_PATH_NOT_FOUND:
52 | {
53 | strcat(dst, "Could not get scriptfiles path", len);
54 | }
55 | case JSON_ERROR_FAILED_READING_FILE:
56 | {
57 | strcat(dst, "Could not read input file.", len);
58 | }
59 | case JSON_ERROR_INVALID_JSON_PATH:
60 | {
61 | strcat(dst, "Invalid JSON path given. Node does not exist.", len);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestInequality.cpp:
--------------------------------------------------------------------------------
1 | #include "TestSuite.h"
2 |
3 | void TestSuite::TestInequality(void){
4 | UnitTest::SetPrefix("TestInequality.cpp - Inequality");
5 | #ifdef JSON_LIBRARY
6 | JSONNODE * test1 = json_new(JSON_NODE);
7 | JSONNODE * test2 = json_new(JSON_NODE);
8 | json_set_a(test1, JSON_TEXT("hello"));
9 | json_set_a(test2, JSON_TEXT("world"));
10 | assertFalse(json_equal(test1, test2));
11 |
12 | json_set_i(test2,13);
13 | assertFalse(json_equal(test1, test2));
14 |
15 | json_set_f(test2, 13.5f);
16 | assertFalse(json_equal(test1, test2));
17 |
18 | json_set_b(test2, true);
19 | assertFalse(json_equal(test1, test2));
20 |
21 | json_set_b(test2, false);
22 | assertFalse(json_equal(test1, test2));
23 |
24 | json_nullify(test2);
25 | assertFalse(json_equal(test1, test2));
26 | json_delete(test1);
27 | json_delete(test2);
28 | #else
29 | JSONNode test1;
30 | JSONNode test2;
31 | test1 = JSON_TEXT("hello");
32 | test2 = JSON_TEXT("world");
33 | assertNotEquals(test1, test2);
34 | assertNotEquals(test1, JSON_TEXT("hi"));
35 | assertNotEquals(test2, 13.5f);
36 | assertNotEquals(test2, 14);
37 | assertNotEquals(test2, true);
38 | assertNotEquals(test2, false);
39 |
40 | test2 = 13;
41 | assertNotEquals(test1, test2);
42 | assertNotEquals(test2, 13.5f);
43 | assertNotEquals(test2, 14);
44 | assertNotEquals(test2, true);
45 | assertNotEquals(test2, false);
46 | assertNotEquals(test2, JSON_TEXT("13")); //not the same type
47 |
48 | test2 = 13.5f;
49 | assertNotEquals(test1, test2);
50 | assertNotEquals(test2, 13);
51 | assertNotEquals(test2, 14);
52 | assertNotEquals(test2, true);
53 | assertNotEquals(test2, false);
54 | assertNotEquals(test2, JSON_TEXT("13.5")); //not the same type
55 |
56 | test2 = true;
57 | assertNotEquals(test1, test2);
58 | assertNotEquals(test2, 13.5f);
59 | assertNotEquals(test2, 14);
60 | assertNotEquals(test2, false);
61 | assertNotEquals(test2, JSON_TEXT("true")); //not the same type
62 |
63 | test2 = false;
64 | assertNotEquals(test1, test2);
65 | assertNotEquals(test2, 13.5f);
66 | assertNotEquals(test2, 14);
67 | assertNotEquals(test2, true);
68 | assertNotEquals(test2, JSON_TEXT("false")); //not the same type
69 |
70 | test2.nullify();
71 | assertNotEquals(test1, test2);
72 | assertNotEquals(test2, 13.5f);
73 | assertNotEquals(test2, 14);
74 | assertNotEquals(test2, true);
75 | assertNotEquals(test2, false);
76 | assertNotEquals(test2, "null"); //not the same type
77 | #endif
78 | }
79 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite2/JSON_Base64/json_encode64.cpp:
--------------------------------------------------------------------------------
1 | #include "json_encode64.h"
2 | #include "../../Source/JSON_Base64.h"
3 |
4 | /**
5 | * Make sure that these two function reverse each other
6 | */
7 | void testJSON_Base64__json_encode64::testReverseEachOther(void){
8 | #if defined(JSON_BINARY) || defined(JSON_EXPOSE_BASE64)
9 | #ifdef JSON_SAFE
10 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"", 0)), "");
11 | #endif
12 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"A", 1)), "A");
13 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"AB", 2)), "AB");
14 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABC", 3)), "ABC");
15 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCD", 4)), "ABCD");
16 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDE", 5)), "ABCDE");
17 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEF", 6)), "ABCDEF");
18 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEFG", 7)), "ABCDEFG");
19 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEFGH", 8)), "ABCDEFGH");
20 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEFGHI", 9)), "ABCDEFGHI");
21 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEFGHIJ", 10)), "ABCDEFGHIJ");
22 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEFGHIJK", 11)), "ABCDEFGHIJK");
23 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEFGHIJKL", 12)), "ABCDEFGHIJKL");
24 | assertEquals(JSONBase64::json_decode64(JSONBase64::json_encode64((unsigned char *)"ABCDEFGHIJKLM", 13)), "ABCDEFGHIJKLM");
25 | #endif
26 | }
27 |
28 | /**
29 | * Make sure all characters work in the code
30 | */
31 | void testJSON_Base64__json_encode64::testAllChars(void){
32 | #if defined(JSON_BINARY) || defined(JSON_EXPOSE_BASE64)
33 |
34 | //create a binary chunk of data to use with every char
35 | unsigned char temp[255];
36 | for(unsigned int i = 0; i < 255; ++i){
37 | temp[i] = (unsigned char)i;
38 | }
39 |
40 | //loop through all of the lengths
41 | for(unsigned int length = 1; length < 255; ++length){
42 | json_string ts = JSONBase64::json_encode64(temp, length);
43 | std::string rs = JSONBase64::json_decode64(ts);
44 | assertEquals(rs.size(), length);
45 | assertEquals(memcmp(rs.data(), temp, length), 0);
46 | }
47 | #endif
48 | }
49 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONAllocator.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_ALLOCATOR_H
2 | #define JSON_ALLOCATOR_H
3 |
4 | #include "JSONStats.h"
5 | #if defined(JSON_MEMORY_CALLBACKS) || defined(JSON_MEMORY_POOL)
6 |
7 | #include
8 |
9 | //need these for the json_nothrow
10 | #include "JSONDefs/Visual_C.h"
11 | #include "JSONDefs/GNU_C.h"
12 | #include "JSONDefs/Unknown_C.h"
13 |
14 | class JSONAllocatorRelayer {
15 | public:
16 | static void * alloc(size_t bytes) json_nothrow json_hot;
17 | static void dealloc(void * ptr) json_nothrow json_hot;
18 | };
19 |
20 | template class json_allocator;
21 |
22 | // specialize for void:
23 | template <> class json_allocator {
24 | public:
25 | typedef void* pointer;
26 | typedef const void* const_pointer;
27 | // reference to void members are impossible.
28 | typedef void value_type;
29 | template struct rebind { typedef json_allocator other; };
30 | };
31 |
32 | template class json_allocator {
33 | public:
34 | typedef size_t size_type;
35 | typedef ptrdiff_t difference_type;
36 | typedef T* pointer;
37 | typedef const T* const_pointer;
38 | typedef T& reference;
39 | typedef const T& const_reference;
40 | typedef T value_type;
41 | template struct rebind { typedef json_allocator other; };
42 |
43 | //LIBJSON_OBJECT(json_allocator);
44 |
45 | inline json_allocator() json_nothrow {
46 | //LIBJSON_CTOR;
47 | }
48 | inline json_allocator(const json_allocator&) json_nothrow {
49 | //LIBJSON_COPY_CTOR;
50 | }
51 | template inline json_allocator(const json_allocator&) json_nothrow {
52 | //LIBJSON_COPY_CTOR;
53 | }
54 | inline ~json_allocator() json_nothrow {
55 | //LIBJSON_DTOR;
56 | }
57 |
58 | inline pointer address(reference x) const { return &x; }
59 | inline const_pointer address(const_reference x) const { return &x; }
60 |
61 | inline pointer allocate(size_type n, json_allocator::const_pointer = 0) json_hot {
62 | return (pointer)JSONAllocatorRelayer::alloc(n * sizeof(T));
63 | }
64 | inline void deallocate(pointer p, size_type) json_hot {
65 | JSONAllocatorRelayer::dealloc(p);
66 | }
67 |
68 | inline size_type max_size() const json_nothrow { return 0xEFFFFFFF; }
69 |
70 | inline void construct(pointer p, const T& val){
71 | new(p)T(val);
72 | };
73 | inline void destroy(pointer p){
74 | ((T*)p) -> ~T();
75 | }
76 | };
77 |
78 | template inline bool operator==(const json_allocator&, const json_allocator&) json_nothrow { return true; }
79 | template inline bool operator!=(const json_allocator&, const json_allocator&) json_nothrow { return false; }
80 |
81 | #endif
82 | #endif
83 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONStream.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBJSON_GUARD_STREAM_H
2 | #define LIBJSON_GUARD_STREAM_H
3 |
4 | #include "JSONDebug.h"
5 |
6 | #ifdef JSON_STREAM
7 |
8 | #ifdef JSON_LESS_MEMORY
9 | #ifdef __GNUC__
10 | #pragma pack(push, 1)
11 | #elif _MSC_VER
12 | #pragma pack(push, JSONStream_pack, 1)
13 | #endif
14 | #endif
15 |
16 | #ifdef JSON_MEMORY_CALLBACKS
17 | #include "JSONMemory.h"
18 | #endif
19 |
20 | #ifndef JSON_LIBRARY
21 | class JSONNode; //foreward declaration
22 | typedef void (*json_stream_callback_t)(JSONNode &, void *);
23 | #endif
24 |
25 | class JSONStream {
26 | public:
27 | LIBJSON_OBJECT(JSONStream);
28 | JSONStream(json_stream_callback_t call_p, json_stream_e_callback_t call_e = NULL, void * callbackIdentifier = JSONSTREAM_SELF) json_nothrow;
29 | JSONStream(const JSONStream & orig) json_nothrow;
30 | JSONStream & operator =(const JSONStream & orig) json_nothrow;
31 | ~JSONStream(void) json_nothrow { LIBJSON_DTOR; }
32 | #ifdef JSON_LIBRARY
33 | JSONStream & operator << (const json_char * str) json_nothrow;
34 | #else
35 | JSONStream & operator << (const json_string & str) json_nothrow;
36 | #endif
37 |
38 | static void deleteJSONStream(JSONStream * stream) json_nothrow {
39 | #ifdef JSON_MEMORY_CALLBACKS
40 | stream -> ~JSONStream();
41 | libjson_free(stream);
42 | #else
43 | delete stream;
44 | #endif
45 | }
46 |
47 | static JSONStream * newJSONStream(json_stream_callback_t callback, json_stream_e_callback_t call_e, void * callbackIdentifier) json_nothrow {
48 | #ifdef JSON_MEMORY_CALLBACKS
49 | return new(json_malloc(1)) JSONStream(callback, call_e, callbackIdentifier);
50 | #else
51 | return new JSONStream(callback, call_e, callbackIdentifier);
52 | #endif
53 | }
54 |
55 | inline void reset() json_nothrow {
56 | state = true;
57 | buffer.clear();
58 | }
59 | JSON_PRIVATE
60 | inline void * getIdentifier(void) json_nothrow {
61 | if (callback_identifier == JSONSTREAM_SELF){
62 | return (void*)this;
63 | }
64 | return callback_identifier;
65 | }
66 |
67 | #if (JSON_READ_PRIORITY == HIGH) && (!(defined(JSON_LESS_MEMORY)))
68 | template
69 | static size_t FindNextRelevant(const json_string & value_t, const size_t pos) json_nothrow json_read_priority;
70 | #else
71 | static size_t FindNextRelevant(json_char ch, const json_string & value_t, const size_t pos) json_nothrow json_read_priority;
72 | #endif
73 |
74 | void parse(void) json_nothrow;
75 | json_string buffer;
76 | json_stream_callback_t call;
77 | json_stream_e_callback_t err_call;
78 | void * callback_identifier;
79 | bool state BITS(1);
80 | };
81 |
82 | #ifdef JSON_LESS_MEMORY
83 | #ifdef __GNUC__
84 | #pragma pack(pop)
85 | #elif _MSC_VER
86 | #pragma pack(pop, JSONStream_pack)
87 | #endif
88 | #endif
89 |
90 | #endif
91 |
92 | #endif
93 |
94 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.xcodeproj/xcuserdata/wallace.xcuserdatad/xcschemes/TestSuite.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
14 |
20 |
21 |
22 |
23 |
24 |
29 |
30 |
31 |
32 |
38 |
39 |
45 |
46 |
47 |
48 |
49 |
50 |
55 |
56 |
62 |
63 |
64 |
65 |
67 |
68 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.cpp:
--------------------------------------------------------------------------------
1 | #include "TestSuite.h"
2 | #include "../Source/JSONNode.h"
3 |
4 | #ifndef JSON_STDERROR
5 | #ifdef JSON_DEBUG
6 | #ifdef JSON_LIBRARY
7 | static void callback(const json_char * msg_c){
8 | json_string msg(msg_c);
9 | #else
10 | static void callback(const json_string & msg){
11 | #endif
12 | #ifdef JSON_STRING_HEADER
13 | echo("callback triggered, but can't display string");
14 | #else
15 | #ifdef JSON_UNICODE
16 | const std::string res = std::string(msg.begin(), msg.end());
17 | echo(res);
18 | #else
19 | echo(msg);
20 | #endif
21 | #endif
22 | }
23 | #endif
24 | #endif
25 |
26 | void TestSuite::TestSelf(void){
27 | UnitTest::SetPrefix("TestSuite.cpp - Self Test");
28 | #ifndef JSON_STDERROR
29 | #ifdef JSON_DEBUG
30 | #ifdef JSON_LIBRARY
31 | json_register_debug_callback(callback);
32 | #else
33 | libjson::register_debug_callback(callback);
34 | #endif
35 | #endif
36 | #endif
37 | assertUnitTest();
38 |
39 | #if defined(JSON_SAFE) && ! defined(JSON_LIBRARY)
40 | bool temp = false;
41 | JSON_ASSERT_SAFE(true, JSON_TEXT(""), temp = true;);
42 | assertFalse(temp);
43 | JSON_ASSERT_SAFE(false, JSON_TEXT(""), temp = true;);
44 | assertTrue(temp);
45 |
46 | temp = false;
47 | JSON_FAIL_SAFE(JSON_TEXT(""), temp = true;);
48 | assertTrue(temp);
49 | #endif
50 |
51 | echo("If this fails, then edit JSON_INDEX_TYPE in JSONOptions.h");
52 | assertLessThanEqualTo(sizeof(json_index_t), sizeof(void*));
53 | }
54 |
55 | //makes sure that libjson didn't leak memory somewhere
56 | void TestSuite::TestFinal(void){
57 | #ifdef JSON_UNIT_TEST
58 | UnitTest::SetPrefix("TestSuite.cpp - Memory Leak");
59 | echo("Node allocations: " << JSONNode::getNodeAllocationCount());
60 | echo("Node deallocations: " << JSONNode::getNodeDeallocationCount());
61 | assertEquals(JSONNode::getNodeAllocationCount(), JSONNode::getNodeDeallocationCount());
62 |
63 | echo("internal allocations: " << JSONNode::getInternalAllocationCount());
64 | echo("internal deallocations: " << JSONNode::getInternalDeallocationCount());
65 | assertEquals(JSONNode::getInternalAllocationCount(), JSONNode::getInternalDeallocationCount());
66 |
67 | echo("children allocations: " << JSONNode::getChildrenAllocationCount());
68 | echo("children deallocations: " << JSONNode::getChildrenDeallocationCount());
69 | assertEquals(JSONNode::getChildrenAllocationCount(), JSONNode::getChildrenDeallocationCount());
70 |
71 | #if defined(JSON_MEMORY_CALLBACKS) || defined(JSON_MEMORY_POOL)
72 | echo("stl allocations: " << JSONAllocatorRelayer::getAllocationCount());
73 | echo("stl deallocations: " << JSONAllocatorRelayer::getDeallocationCount());
74 | echo("stl bytes: " << JSONAllocatorRelayer::getAllocationByteCount());
75 | assertEquals(JSONAllocatorRelayer::getAllocationCount(), JSONAllocatorRelayer::getDeallocationCount());
76 | #endif
77 | #endif
78 | }
79 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestEquality.cpp:
--------------------------------------------------------------------------------
1 | #include "TestSuite.h"
2 | #include "../Source/JSONNode.h"
3 |
4 | void TestSuite::TestEquality(void){
5 | UnitTest::SetPrefix("TestEquality.cpp - Equality");
6 | #ifdef JSON_LIBRARY
7 | JSONNODE * test1 = json_new(JSON_NODE);
8 | JSONNODE * test2 = json_new(JSON_NODE);
9 | assertTrue(json_equal(test1, test2));
10 |
11 | //check literally the same internal pointer
12 | json_set_n(test2, test1);
13 | #ifdef JSON_UNIT_TEST
14 | #ifdef JSON_REF_COUNT
15 | assertEquals(((JSONNode*)test1) -> internal, ((JSONNode*)test2) -> internal);
16 | #else
17 | assertNotEquals(((JSONNode*)test1) -> internal, ((JSONNode*)test2) -> internal);
18 | #endif
19 | #endif
20 | assertTrue(json_equal(test1, test2));
21 |
22 | json_set_a(test1, JSON_TEXT("hello"));
23 | json_set_a(test2, JSON_TEXT("hello"));
24 | assertTrue(json_equal(test1, test2));
25 |
26 | json_set_f(test1, 13.5f);
27 | json_set_f(test2, 13.5f);
28 | assertTrue(json_equal(test1, test2));
29 |
30 | json_set_i(test1, 13);
31 | json_set_f(test2, 13.0f);
32 | assertTrue(json_equal(test1, test2));
33 |
34 | json_set_b(test1, true);
35 | json_set_b(test2, (int)true);
36 | assertTrue(json_equal(test1, test2));
37 |
38 | json_set_b(test1, false);
39 | json_set_b(test2, (int)false);
40 | assertTrue(json_equal(test1, test2));
41 |
42 | json_nullify(test1);
43 | json_nullify(test2);
44 | assertTrue(json_equal(test1, test2));
45 | JSONNODE * test3 = json_new(JSON_NULL);
46 | assertTrue(json_equal(test1, test3));
47 | assertTrue(json_equal(test3, test3));
48 |
49 | json_delete(test1);
50 | json_delete(test2);
51 | json_delete(test3);
52 | #else
53 | JSONNode test1;
54 | JSONNode test2;
55 | assertEquals(test1, test2);
56 |
57 | //check literally the same internal pointer
58 | test2 = test1;
59 | #ifdef JSON_UNIT_TEST
60 | #ifdef JSON_REF_COUNT
61 | assertEquals(test1.internal, test2.internal);
62 | #else
63 | assertNotEquals(test1.internal, test2.internal);
64 | #endif
65 | #endif
66 | assertEquals(test1, test2);
67 |
68 | test1 = JSON_TEXT("hello");
69 | test2 = JSON_TEXT("hello");
70 | assertEquals(test1, JSON_TEXT("hello"));
71 | assertEquals(test1, test2);
72 |
73 | test1 = 13.5f;
74 | test2 = 13.5f;
75 | assertEquals(test1, 13.5f);
76 | assertEquals(test1, test2);
77 |
78 | test1 = 13;
79 | test2 = 13.0f;
80 | assertEquals(test1, 13.0f);
81 | assertEquals(test1, 13);
82 | assertEquals(test1, test2);
83 |
84 | test1 = true;
85 | test2 = true;
86 | assertEquals(test1, true);
87 | assertEquals(test1, test2);
88 |
89 | test1 = false;
90 | test2 = false;
91 | assertEquals(test1, false);
92 | assertEquals(test1, test2);
93 |
94 | test1.nullify();
95 | test2.nullify();
96 | assertEquals(test1, test2);
97 | JSONNode test3 = JSONNode(JSON_NULL);
98 | assertEquals(test1, test3);
99 | assertEquals(test2, test3);
100 | #endif
101 | }
102 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONWorker.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_WORKER_H
2 | #define JSON_WORKER_H
3 |
4 | #include "JSONNode.h"
5 | #include "JSONSharedString.h"
6 |
7 | class JSONWorker {
8 | public:
9 | static json_string RemoveWhiteSpaceAndComments(const json_string & value_t, bool escapeQuotes) json_nothrow json_read_priority;
10 | static json_char * RemoveWhiteSpaceAndCommentsC(const json_string & value_t, bool escapeQuotes) json_nothrow json_read_priority;
11 |
12 | #ifdef JSON_READ_PRIORITY
13 | static JSONNode parse(const json_string & json) json_throws(std::invalid_argument) json_read_priority;
14 | static JSONNode parse_unformatted(const json_string & json) json_throws(std::invalid_argument) json_read_priority;
15 |
16 | static JSONNode _parse_unformatted(const json_char * json, const json_char * const end) json_throws(std::invalid_argument) json_read_priority;
17 |
18 | static json_char * RemoveWhiteSpace(const json_string & value_t, size_t & len, bool escapeQuotes) json_nothrow json_read_priority;
19 |
20 | static void DoArray(const internalJSONNode * parent, const json_string & value_t) json_nothrow json_read_priority;
21 | static void DoNode(const internalJSONNode * parent, const json_string & value_t) json_nothrow json_read_priority;
22 |
23 | #ifdef JSON_LESS_MEMORY
24 | #define NAME_ENCODED this, true
25 | #define STRING_ENCODED this, false
26 | static json_string FixString(const json_string & value_t, const internalJSONNode * flag, bool which) json_nothrow json_read_priority;
27 | #else
28 | #define NAME_ENCODED _name_encoded
29 | #define STRING_ENCODED _string_encoded
30 | static json_string FixString(const json_string & value_t, bool & flag) json_nothrow json_read_priority;
31 | #endif
32 | #endif
33 |
34 | #if defined(JSON_READ_PRIORITY) || defined(JSON_STREAM)
35 | #if (JSON_READ_PRIORITY == HIGH) && (!(defined(JSON_LESS_MEMORY)))
36 | template
37 | static size_t FindNextRelevant(const json_string & value_t, const size_t pos) json_nothrow json_read_priority;
38 | #else
39 | static size_t FindNextRelevant(json_char ch, const json_string & value_t, const size_t pos) json_nothrow json_read_priority;
40 | #endif
41 | #endif
42 | static void UnfixString(const json_string & value_t, bool flag, json_string & res) json_nothrow;
43 | JSON_PRIVATE
44 | #ifdef JSON_READ_PRIORITY
45 | static json_char Hex(const json_char * & pos) json_nothrow;
46 | static json_uchar UTF8(const json_char * & pos, const json_char * const end) json_nothrow;
47 | #endif
48 | #ifdef JSON_ESCAPE_WRITES
49 | static json_string toUTF8(json_uchar p) json_nothrow;
50 | #endif
51 | #ifdef JSON_UNICODE
52 | static void UTF(const json_char * & pos, json_string & result, const json_char * const end) json_nothrow;
53 | #ifdef JSON_ESCAPE_WRITES
54 | static json_string toSurrogatePair(json_uchar pos) json_nothrow;
55 | #endif
56 | #endif
57 | #ifdef JSON_READ_PRIORITY
58 | static void SpecialChar(const json_char * & pos, const json_char * const end, json_string & res) json_nothrow;
59 | static void NewNode(const internalJSONNode * parent, const json_string & name, const json_string & value, bool array) json_nothrow;
60 | #endif
61 | private:
62 | JSONWorker(void);
63 | };
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 9/3/10 \" DATE
7 | .Dt TestSuite 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm TestSuite,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.h~:
--------------------------------------------------------------------------------
1 | #ifndef TESTSUITE_H
2 | #define TESTSUITE_H
3 |
4 | #include "UnitTest.h"
5 | #include "../JSONOptions.h"
6 | #include "../libjson.h"
7 | #include "../Source/JSONNode.h"
8 |
9 | #include
10 | using namespace std;
11 |
12 | /*
13 | This class tests libjson's internal working and it's
14 | C++ interface
15 | */
16 |
17 | #ifdef JSON_UNICODE
18 | #define assertCStringSame(a, b) assertCStringEqualsW(a, b)
19 | #define assertCStringNotSame(a, b) assertCStringNotEqualsW(a, b)
20 | #else
21 | #define assertCStringSame(a, b) assertCStringEquals(a, b)
22 | #define assertCStringNotSame(a, b) assertCStringNotEquals(a, b)
23 | #endif
24 |
25 |
26 | class TestSuite {
27 | public:
28 | static void TestSelf(void);
29 | static void TestString(void);
30 | static void TestConverters(void);
31 | #ifdef JSON_BINARY
32 | static void TestBase64(void);
33 | #endif
34 | static void TestReferenceCounting(void);
35 | static void TestConstructors(void);
36 | static void TestAssigning(void);
37 | static void TestEquality(void);
38 | static void TestInequality(void);
39 | static void TestChildren(void);
40 | static void TestFunctions(void);
41 | static void TestIterators(void);
42 | static void TestInspectors(void);
43 | static void TestNamespace(void);
44 | static void TestValidator(void);
45 | static void TestStreams(void);
46 | #ifdef JSON_WRITE_PRIORITY
47 | static void TestWriter(void);
48 | #endif
49 | #ifdef JSON_COMMENTS
50 | static void TestComments(void);
51 | #endif
52 | #ifdef JSON_MUTEX_CALLBACKS
53 | static void TestMutex(void);
54 | static void TestThreading(void);
55 | #endif
56 | static void TestSharedString(void);
57 | static void TestFinal(void);
58 |
59 |
60 |
61 |
62 |
63 | #ifdef JSON_LIBRARY
64 | static void testParsingItself(JSONNODE * x){
65 | #if defined(JSON_WRITE_PRIORITY) && defined(JSON_READ_PRIORITY)
66 | {
67 | json_char * written = json_write(x);
68 | JSONNODE * copy = json_parse(written);
69 | assertTrue(json_equal(x, copy));
70 | json_delete(copy);
71 | json_free(written);
72 | }
73 | {
74 | json_char * written = json_write_formatted(x);
75 | JSONNODE * copy = json_parse(written);
76 | assertTrue(json_equal(x, copy));
77 | json_delete(copy);
78 | json_free(written);
79 | }
80 | {
81 | json_char * written = json_write_formatted(x);
82 | json_char * written2 = json_write(x);
83 | json_char * stripped = json_strip_white_space(written);
84 | assertCStringSame(written2, stripped);
85 | json_free(stripped);
86 | json_free(written);
87 | json_free(written2);
88 | }
89 | #endif
90 | {
91 | JSONNODE * copy = json_duplicate(x);
92 | assertTrue(json_equal(x, copy));
93 | json_delete(copy);
94 | }
95 | }
96 | #else
97 | static void testParsingItself(JSONNode & x){
98 | #if defined(JSON_WRITE_PRIORITY) && defined(JSON_READ_PRIORITY)
99 | assertEquals(libjson::parse(x.write()), x);
100 | assertEquals(libjson::parse(x.write_formatted()), x);
101 | assertEquals(libjson::strip_white_space(x.write_formatted()), x.write());
102 | #endif
103 | assertEquals(x, x.duplicate())
104 | }
105 | #endif
106 | };
107 |
108 | #endif
109 |
110 |
--------------------------------------------------------------------------------
/src/libjson/_internal/TestSuite/TestSuite.h:
--------------------------------------------------------------------------------
1 | #ifndef TESTSUITE_H
2 | #define TESTSUITE_H
3 |
4 | #include "UnitTest.h"
5 | #include "../../JSONOptions.h"
6 | #include "../../libjson.h"
7 | #include "../Source/JSONNode.h"
8 |
9 | #include
10 | using namespace std;
11 |
12 | /*
13 | This class tests libjson's internal working and it's
14 | C++ interface
15 | */
16 |
17 | #ifdef JSON_UNICODE
18 | #define assertCStringSame(a, b) assertCStringEqualsW(a, b)
19 | #define assertCStringNotSame(a, b) assertCStringNotEqualsW(a, b)
20 | #else
21 | #define assertCStringSame(a, b) assertCStringEquals(a, b)
22 | #define assertCStringNotSame(a, b) assertCStringNotEquals(a, b)
23 | #endif
24 |
25 |
26 | class TestSuite {
27 | public:
28 | static void TestSelf(void);
29 | static void TestString(void);
30 | static void TestConverters(void);
31 | #ifdef JSON_BINARY
32 | static void TestBase64(void);
33 | #endif
34 | static void TestReferenceCounting(void);
35 | static void TestConstructors(void);
36 | static void TestAssigning(void);
37 | static void TestEquality(void);
38 | static void TestInequality(void);
39 | static void TestChildren(void);
40 | static void TestFunctions(void);
41 | static void TestIterators(void);
42 | static void TestInspectors(void);
43 | static void TestNamespace(void);
44 | static void TestValidator(void);
45 | static void TestStreams(void);
46 | #ifdef JSON_WRITE_PRIORITY
47 | static void TestWriter(void);
48 | #endif
49 | #ifdef JSON_COMMENTS
50 | static void TestComments(void);
51 | #endif
52 | #ifdef JSON_MUTEX_CALLBACKS
53 | static void TestMutex(void);
54 | static void TestThreading(void);
55 | #endif
56 | static void TestSharedString(void);
57 | static void TestFinal(void);
58 |
59 |
60 |
61 |
62 |
63 | #ifdef JSON_LIBRARY
64 | static void testParsingItself(JSONNODE * x){
65 | #if defined(JSON_WRITE_PRIORITY) && defined(JSON_READ_PRIORITY)
66 | {
67 | json_char * written = json_write(x);
68 | JSONNODE * copy = json_parse(written);
69 | assertTrue(json_equal(x, copy));
70 | json_delete(copy);
71 | json_free(written);
72 | }
73 | {
74 | json_char * written = json_write_formatted(x);
75 | JSONNODE * copy = json_parse(written);
76 | assertTrue(json_equal(x, copy));
77 | json_delete(copy);
78 | json_free(written);
79 | }
80 | {
81 | json_char * written = json_write_formatted(x);
82 | json_char * written2 = json_write(x);
83 | json_char * stripped = json_strip_white_space(written);
84 | assertCStringSame(written2, stripped);
85 | json_free(stripped);
86 | json_free(written);
87 | json_free(written2);
88 | }
89 | #endif
90 | {
91 | JSONNODE * copy = json_duplicate(x);
92 | assertTrue(json_equal(x, copy));
93 | json_delete(copy);
94 | }
95 | }
96 | #else
97 | static void testParsingItself(JSONNode & x){
98 | #if defined(JSON_WRITE_PRIORITY) && defined(JSON_READ_PRIORITY)
99 | assertEquals(libjson::parse(x.write()), x);
100 | assertEquals(libjson::parse(x.write_formatted()), x);
101 | assertEquals(libjson::strip_white_space(x.write_formatted()), x.write());
102 | #endif
103 | assertEquals(x, x.duplicate())
104 | }
105 | #endif
106 | };
107 |
108 | #endif
109 |
110 |
--------------------------------------------------------------------------------
/src/libjson/_internal/Source/JSONStats.h:
--------------------------------------------------------------------------------
1 | #ifndef TestSuite_JSONStats_h
2 | #define TestSuite_JSONStats_h
3 |
4 | #include "../../JSONOptions.h"
5 |
6 | #if defined(JSON_UNIT_TEST) || defined(JSON_DEBUG)
7 | #define LIBJSON_OBJECT(name)\
8 | static size_t & getCtorCounter(void){\
9 | static size_t count = 0;\
10 | static int i = JSONStats::setCallbacks(getCtorCounter, getCopyCtorCounter, getAssignmentCounter, getDtorCounter, #name);\
11 | return count;\
12 | }\
13 | static size_t & getCopyCtorCounter(void){\
14 | static size_t count = 0;\
15 | static int i = JSONStats::setCallbacks(getCtorCounter, getCopyCtorCounter, getAssignmentCounter, getDtorCounter, #name);\
16 | return count;\
17 | }\
18 | static size_t & getAssignmentCounter(void){\
19 | static size_t count = 0;\
20 | static int i = JSONStats::setCallbacks(getCtorCounter, getCopyCtorCounter, getAssignmentCounter, getDtorCounter, #name);\
21 | return count;\
22 | }\
23 | static size_t & getDtorCounter(void){\
24 | static size_t count = 0;\
25 | static int i = JSONStats::setCallbacks(getCtorCounter, getCopyCtorCounter, getAssignmentCounter, getDtorCounter, #name);\
26 | return count;\
27 | }
28 | #define LIBJSON_CTOR getCtorCounter() += 1
29 | #define LIBJSON_COPY_CTOR getCopyCtorCounter() += 1
30 | #define LIBJSON_ASSIGNMENT getAssignmentCounter() += 1
31 | #define LIBJSON_DTOR getDtorCounter() += 1
32 |
33 | #include |