整理目录

This commit is contained in:
zsxxsz 2014-12-14 18:29:34 +08:00
parent f0249e0ca1
commit 9077ac9790
13 changed files with 0 additions and 1010 deletions

View File

@ -1,230 +0,0 @@
<?xml version="1.0" encoding="gb2312"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="json"
ProjectGUID="{8021ECD9-04CB-463B-B287-1FB0F5486D91}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/json.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/json.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/json.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="DebugDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;ACL_DLL"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/json.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/json.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;ACL_DLL"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/json.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Ô´Îļþ"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\main.cpp">
</File>
</Filter>
<Filter
Name="Í·Îļþ"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="×ÊÔ´Îļþ"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,177 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugDll|Win32">
<Configuration>DebugDll</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseDll|Win32">
<Configuration>ReleaseDll</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8021ECD9-04CB-463B-B287-1FB0F5486D91}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)json.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)json.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)json.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ACL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)json.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)json.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;ACL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)json.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\lib_acl\lib_acl_vc2010.vcxproj">
<Project>{b40213c2-507c-4c7f-a6e1-b850c9bdc27b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,395 +0,0 @@
#include "lib_acl.h"
#define STR acl_vstring_str
static const char* default_data = \
"{ 'menu name': {\r\n"
" 'id:file': 'file',\r\n"
" 'value{': 'File',\r\n"
" 'popup{}': {\r\n"
" 'menuitem1}': [\r\n"
" {'value': 'New', 'onclick': 'CreateNewDoc()'},\r\n"
" {'value': 'Open', 'onclick': 'OpenDoc()'},\r\n"
" {'value': 'Close', 'onclick': 'CloseDoc()'}\r\n"
" ],\r\n"
" 'menuname[]': 'hello world',\r\n"
" 'inner': { 'value' : 'new ', 'value' : 'open' },\r\n"
" 'menuitem2': [\r\n"
" {'value': 'New', 'onclick': 'CreateNewDoc()'},\r\n"
" {'value': 'Open', 'onclick': 'OpenDoc()'},\r\n"
" {'value': 'Close', 'onclick': 'CloseDoc()'},\r\n"
" {{'value': 'Help', 'onclick': 'Help()'}}"
" ]\r\n"
" }\r\n"
" }\r\n,"
" 'help': 'hello world!',\r\n"
" 'menuitem2': [\r\n"
" {'value': 'New', 'onclick': 'CreateNewDoc()'},\r\n"
" {'value': 'Open', 'onclick': 'OpenDoc()'},\r\n"
" {'value': 'Close', 'onclick': 'CloseDoc()'},\r\n"
" [{'value': 'Save', 'onclick': 'SaveDoc()'}]"
" ]\r\n"
"}\r\n";
static void print_json_node(const ACL_JSON* json, const ACL_JSON_NODE* node)
{
for (int i = 1; i < node->depth; i++)
printf("\t");
printf("tag> %s, parent %s, text: %s, child: %s, type: %s\n",
STR(node->ltag), node->parent == json->root
? "root" : STR(node->parent->ltag),
STR(node->text), node->tag_node ? "yes" : "no",
acl_json_node_type(node));
}
static void test_json_foreach1(ACL_JSON* json)
{
ACL_ITER iter;
printf("------------ in %s ------------\r\n", __FUNCTION__);
acl_foreach(iter, json)
{
const ACL_JSON_NODE* node = (const ACL_JSON_NODE*) iter.data;
print_json_node(json, node);
}
ACL_FILE* fp = acl_fopen("./json.txt", "w");
acl_assert(fp);
ACL_VSTRING* buf = acl_json_build(json, NULL);
acl_fwrite(acl_vstring_str(buf), ACL_VSTRING_LEN(buf), 1, fp);
acl_fclose(fp);
acl_vstring_free(buf);
printf("\r\n");
}
static void test_json_foreach2(ACL_JSON* json)
{
ACL_ITER iter1, iter2, iter3, iter4, iter5;
ACL_JSON_NODE *node1, *node2, *node3, *node4, *node5;
printf("------------ in %s ------------\r\n", __FUNCTION__);
/* 一级结点 */
acl_foreach(iter1, json->root) {
node1 = (ACL_JSON_NODE*) iter1.data;
print_json_node(json, node1);
/* 二级结点 */
acl_foreach(iter2, node1) {
node2 = (ACL_JSON_NODE*) iter2.data;
print_json_node(json, node2);
/* 三级结点 */
acl_foreach(iter3, node2) {
node3 = (ACL_JSON_NODE*) iter3.data;
print_json_node(json, node3);
/* 四级结点 */
acl_foreach(iter4, node3) {
node4 = (ACL_JSON_NODE*) iter4.data;
print_json_node(json, node4);
/* 五级结点 */
acl_foreach(iter5, node4) {
node5 = (ACL_JSON_NODE*) iter5.data;
print_json_node(json, node5);
}
}
}
}
}
printf("\r\n");
}
static void test_json_find1(ACL_JSON* json)
{
printf("------------ in %s ------------\r\n", __FUNCTION__);
//const char* tags = "menu/*/menuitem/*/onclick";
const char* tags = "menu/popup/menuitem/*/onclick";
//const char* tags = "menu/popup/menuitem";
//const char* tags = "menu/popup/menuname";
//const char* tags = "menu/id";
printf(">>find: %s\r\n", tags);
ACL_ARRAY* a = acl_json_getElementsByTags(json, tags);
if (a == NULL) {
printf("\r\n");
return;
}
ACL_ITER iter1, iter2, iter3;
acl_foreach(iter1, a) {
ACL_JSON_NODE* node1 = (ACL_JSON_NODE*) iter1.data;
printf("%s: %s\r\n", tags, STR(node1->text));
/* 遍历 node1 结点的一级子结点 */
acl_foreach(iter2, node1) {
ACL_JSON_NODE* node2 = (ACL_JSON_NODE*) iter2.data;
/* 遍历 node2 结点的一级子结点 */
acl_foreach(iter3, node2) {
ACL_JSON_NODE* node3 =
(ACL_JSON_NODE*) iter3.data;
printf("\t%s: %s\r\n", STR(node3->ltag),
STR(node3->text));
}
printf("---------------------------------------\r\n");
}
}
acl_json_free_array(a);
printf(">>find %s end\r\n\r\n", tags);
}
static void test_json_find2(ACL_JSON* json)
{
const char* tag = "onclick";
ACL_ARRAY* a = acl_json_getElementsByTagName(json, tag);
ACL_ITER iter;
printf("------------ in %s ------------\r\n", __FUNCTION__);
if (a) {
acl_foreach(iter, a) {
ACL_JSON_NODE* node = (ACL_JSON_NODE*) iter.data;
printf("find %s result: %s\r\n", tag, STR(node->text));
}
acl_json_free_array(a);
}
tag = "help";
a = acl_json_getElementsByTagName(json, tag);
if (a) {
acl_foreach(iter, a) {
ACL_JSON_NODE* node = (ACL_JSON_NODE*) iter.data;
printf("find %s result: %s\r\n", tag, STR(node->text));
}
acl_json_free_array(a);
}
printf(">>find %s end\r\n\r\n", tag);
}
static void test_json_data(const char* data)
{
ACL_JSON* json = acl_json_alloc();
const char* ptr = data;
char buf[2];
ACL_VSTRING *tmp;
json->flag |= ACL_JSON_FLAG_PART_WORD;
if (1) {
while (*ptr)
{
buf[0] = *ptr++;
buf[1] = 0;
acl_json_update(json, buf);
/*
if (json->finish)
break;
*/
}
}
else
acl_json_update(json, data);
test_json_foreach1(json);
test_json_foreach2(json);
test_json_find1(json);
test_json_find2(json);
tmp = acl_vstring_alloc(128);
acl_json_build(json, tmp);
printf(">>>source: |%s|\r\n", data);
printf(">>>result: |%s|\r\n", acl_vstring_str(tmp));
acl_vstring_free(tmp);
acl_json_free(json);
}
static void test_json_build(void)
{
ACL_JSON* json = acl_json_alloc();
ACL_JSON_NODE* root, *node1, *node2, *node3;
root = acl_json_create_obj(json);
acl_json_node_append_child(json->root, root);
node1 = acl_json_create_leaf(json, "name1", "value1");
acl_json_node_append_child(root, node1);
node1 = acl_json_create_leaf(json, "name2", "value2");
acl_json_node_append_child(root, node1);
node1 = acl_json_create_obj(json);
node2 = acl_json_create_leaf(json, "name3", "value3");
acl_json_node_append_child(node1, node2);
node2 = acl_json_create_node(json, "name4", node1);
acl_json_node_append_child(root, node2);
//////////////////////////////////////////////////////////////////////////
node1 = acl_json_create_array(json);
node2 = acl_json_create_node(json, "name5", node1);
acl_json_node_append_child(root, node2);
node3 = acl_json_create_leaf(json, "name6", "value6");
acl_json_node_append_child(node1, node3);
node3 = acl_json_create_leaf(json, "name7", "value7");
acl_json_node_append_child(node1, node3);
node3 = acl_json_create_obj(json);
acl_json_node_append_child(node1, node3);
node2 = acl_json_create_leaf(json, "name8", "value8");
acl_json_node_append_child(node3, node2);
node2 = acl_json_create_leaf(json, "name9", "value9");
acl_json_node_append_child(node3, node2);
//////////////////////////////////////////////////////////////////////////
ACL_VSTRING* buf = acl_json_build(json, NULL);
printf("%s\r\n", acl_vstring_str(buf));
acl_vstring_free(buf);
acl_json_free(json);
}
static void test_json_default(void)
{
test_json_data(default_data);
test_json_build();
}
static void test_json_file(const char* path)
{
char* buf = acl_vstream_loadfile(path);
if (buf == NULL)
{
printf("load file %s error(%s)\r\n", path, acl_last_serror());
return;
}
printf("buf: |%s|\r\n", buf);
test_json_data(buf);
acl_myfree(buf);
}
static void test_json_benchmark(bool use_cache, bool once, int max)
{
ACL_JSON *json = acl_json_alloc();
if (use_cache)
acl_json_cache(json, 1000);
ACL_METER_TIME("-------------bat begin--------------");
for (int i = 0; i < max; i++)
{
const char* ptr = default_data;
if (once)
acl_json_update(json, ptr);
else
{
/* 每次仅输入一个字节来分析 json 数据 */
while (*ptr != 0) {
char ch2[2];
ch2[0] = *ptr;
ch2[1] = 0;
acl_json_update(json, ch2);
ptr++;
}
}
acl_json_reset(json);
}
ACL_METER_TIME("-------------bat end--------------");
acl_json_free(json);
}
static void usage(const char* program)
{
printf("usage: %s -h[help]\n"
" -f json_filepath\n"
" -b[benchmark] -c[cache for banchmark] -m benchmark_max\n"
" -s[once parse]\n"
" -M[use mempool]\r\n", program);
}
int main(int argc, char** argv)
{
#if 0
// const char* pp = "誠\";
const char* pp = "\";
while (*pp)
{
printf("ch: %d\r\n", *pp);
pp++;
}
printf("'\\': %d\r\n", '\\');
exit(0);
#endif
int ch;
int benchmark_max = 100;
bool use_default = true, benchmark = false;
bool benchmark_cache = false, once = false, use_mempool = false;
while ((ch = getopt(argc, argv, "hf:bcm:sM")) > 0)
{
switch (ch)
{
case 'h':
use_default = false;
usage(argv[0]);
return (0);
case 'f':
use_default = false;
test_json_file(optarg);
break;
case 'b':
use_default = false;
benchmark = true;
break;
case 'c':
use_default = false;
benchmark_cache = true;
break;
case 'm':
use_default = false;
benchmark_max = atoi(optarg);
break;
case 's':
once = true;
break;
case 'M':
use_mempool = true;
break;
default:
break;
}
}
if (use_mempool)
{
acl_mem_slice_init(8, 1024, 100000,
ACL_SLICE_FLAG_GC2 |
ACL_SLICE_FLAG_RTGC_OFF |
ACL_SLICE_FLAG_LP64_ALIGN);
printf("use mempool now\n");
}
if (benchmark)
test_json_benchmark(benchmark_cache, once, benchmark_max);
else if (use_default)
test_json_default();
#ifdef WIN32
getchar();
#endif
return (0);
}

View File

@ -1,22 +0,0 @@
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}

View File

@ -1,13 +0,0 @@
{ menu: {
id: 'file',
value: 'File',
popup: {
menuitem: [
{ value: 'New', onclick: 'CreateNewDoc()' },
{ value: 'Open', onclick: 'OpenDoc()' },
{ value: 'Close', onclick: 'CloseDoc()' }
],
menuitem: 'hello world'
}
}
}

View File

@ -1,11 +0,0 @@
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}

View File

@ -1,12 +0,0 @@
{
id: 'file', value: 'File',
popup: {
menuitem: [
{ value: 'New', onclick: 'CreateNewDoc()' },
{ value: 'Open', onclick: 'OpenDoc()' },
{ value: 'Close', onclick: 'CloseDoc()' }
],
menuitem: 'help'
},
help: 'hello world!'
}

View File

@ -1,26 +0,0 @@
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}

View File

@ -1,5 +0,0 @@
{
id: 'file';
value: 'File',
name: 'zsxxsz'
}

View File

@ -1,88 +0,0 @@
{"web-app": {
"servlet": [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "ksm@pobox.com",
"configGlossary:poweredBy": "Cofax",
"configGlossary:poweredByIcon": "/images/cofax.gif",
"configGlossary:staticPath": "/content/static",
"templateProcessorClass": "org.cofax.WysiwygTemplate",
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
"templatePath": "templates",
"templateOverridePath": "",
"defaultListTemplate": "listTemplate.htm",
"defaultFileTemplate": "articleTemplate.htm",
"useJSP": false,
"jspListTemplate": "listTemplate.jsp",
"jspFileTemplate": "articleTemplate.jsp",
"cachePackageTagsTrack": 200,
"cachePackageTagsStore": 200,
"cachePackageTagsRefresh": 60,
"cacheTemplatesTrack": 100,
"cacheTemplatesStore": 50,
"cacheTemplatesRefresh": 15,
"cachePagesTrack": 200,
"cachePagesStore": 100,
"cachePagesRefresh": 10,
"cachePagesDirtyRead": 10,
"searchEngineListTemplate": "forSearchEnginesList.htm",
"searchEngineFileTemplate": "forSearchEngines.htm",
"searchEngineRobotsDb": "WEB-INF/robots.db",
"useDataStore": true,
"dataStoreClass": "org.cofax.SqlDataStore",
"redirectionClass": "org.cofax.SqlRedirection",
"dataStoreName": "cofax",
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
"dataStoreUser": "sa",
"dataStorePassword": "dataStoreTestQuery",
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
"dataStoreInitConns": 10,
"dataStoreMaxConns": 100,
"dataStoreConnUsageLimit": 100,
"dataStoreLogLevel": "debug",
"maxUrlLength": 500}},
{
"servlet-name": "cofaxEmail",
"servlet-class": "org.cofax.cds.EmailServlet",
"init-param": {
"mailHost": "mail1",
"mailHostOverride": "mail2"}},
{
"servlet-name": "cofaxAdmin",
"servlet-class": "org.cofax.cds.AdminServlet"},
{
"servlet-name": "fileServlet",
"servlet-class": "org.cofax.cds.FileServlet"},
{
"servlet-name": "cofaxTools",
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
"init-param": {
"templatePath": "toolstemplates/",
"log": 1,
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
"logMaxSize": "",
"dataLog": 1,
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
"dataLogMaxSize": "",
"removePageCache": "/content/admin/remove?cache=pages&id=",
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
"lookInContext": 1,
"adminGroupID": 4,
"betaServer": true}}],
"servlet-mapping": {
"cofaxCDS": "/",
"cofaxEmail": "/cofaxutil/aemail/*",
"cofaxAdmin": "/admin/*",
"fileServlet": "/static/*",
"cofaxTools": "/tools/*"},
"taglib": {
"taglib-uri": "cofax.tld",
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}}

View File

@ -1,27 +0,0 @@
{"menu": {
"header": "SVG Viewer",
"items": [
{"id": "Open"},
{"id": "OpenNew", "label": "Open New"},
null,
{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"},
null,
{"id": "Quality"},
{"id": "Pause"},
{"id": "Mute"},
null,
{"id": "Find", "label": "Find..."},
{"id": "FindAgain", "label": "Find Again"},
{"id": "Copy"},
{"id": "CopyAgain", "label": "Copy Again"},
{"id": "CopySVG", "label": "Copy SVG"},
{"id": "ViewSVG", "label": "View SVG"},
{"id": "ViewSource", "label": "View Source"},
{"id": "SaveAs", "label": "Save As"},
null,
{"id": "Help"},
{"id": "About", "label": "About Adobe CVG Viewer..."}
]
}}

View File

@ -1 +0,0 @@
{ "value0-山本誠" : "山本誠", "value1-\[山本誠\]" : "绣錦", "山本誠-value2" : "\[大仙\]", "\[山本誠\]-value3" : "\'hello\'", "value4" : "山本誠", "value5" : "\[大仙\]"}

View File

@ -1,3 +0,0 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./json -b -m 10