diff --git a/src/apps/haikudepot/Jamfile b/src/apps/haikudepot/Jamfile index dc76250103..e81dff6784 100644 --- a/src/apps/haikudepot/Jamfile +++ b/src/apps/haikudepot/Jamfile @@ -1,7 +1,44 @@ SubDir HAIKU_TOP src apps haikudepot ; +include [ FDirName $(HAIKU_TOP) src apps haikudepot build jam + HdsSchemaGenRules ] ; + UsePrivateHeaders interface kernel net package shared storage support ; +local generatedTargetDirectory = $(TARGET_COMMON_DEBUG_LOCATE_TARGET) ; + +# During the build process, some sources are generated into directories. These +# are the directories. + +local dumpExportRepositoryBulkListerTargetDirectory = + [ FDirName $(TARGET_COMMON_DEBUG_LOCATE_TARGET) + dumpexportrepositorybulklistener ] ; +local dumpExportPkgBulkListenerTargetDirectory = + [ FDirName $(TARGET_COMMON_DEBUG_LOCATE_TARGET) + dumpexportpkgbulklistener ] ; +local dumpExportPkgModelTargetDirectory = + [ FDirName $(TARGET_COMMON_DEBUG_LOCATE_TARGET) + dumpexportpkgmodel ] ; +local dumpExportRepositoryModelTargetDirectory = + [ FDirName $(TARGET_COMMON_DEBUG_LOCATE_TARGET) + dumpexportrepositorymodel ] ; + +# During the build process, some sources are generated into a directory. In +# order to maintain a timestamp on that generation process, a dummy file is +# used to signify the target of the generation. The leafname of this dummy file +# is defined here. + +local dummyFile = "dummy.dat" ; + +local dumpExportRepositoryBulkListerTargetFile = + [ FDirName $(dumpExportRepositoryBulkListerTargetDirectory) $(dummyFile) ] ; +local dumpExportPkgBulkListenerTargetFile = + [ FDirName $(dumpExportPkgBulkListenerTargetDirectory) $(dummyFile) ] ; +local dumpExportPkgModelTargetFile = + [ FDirName $(dumpExportPkgModelTargetDirectory) $(dummyFile) ] ; +local dumpExportRepositoryModelTargetFile = + [ FDirName $(dumpExportRepositoryModelTargetDirectory) $(dummyFile) ] ; + # source directories local sourceDirs = edits_generic @@ -10,8 +47,6 @@ local sourceDirs = ui ui_generic server - server/dumpexportrepository - server/dumpexportpkg tar util ; @@ -22,6 +57,10 @@ for sourceDir in $(sourceDirs) { } SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src servers package ] ; +SEARCH_SOURCE += $(dumpExportRepositoryBulkListerTargetDirectory) ; +SEARCH_SOURCE += $(dumpExportPkgBulkListenerTargetDirectory) ; +SEARCH_SOURCE += $(dumpExportPkgModelTargetDirectory) ; +SEARCH_SOURCE += $(dumpExportRepositoryModelTargetDirectory) ; local textDocumentSources = # edits_generic @@ -51,7 +90,7 @@ local textDocumentSources = UndoableEditListener.cpp ; -Application HaikuDepot : +local applicationSources = App.cpp BarberPole.cpp BitmapButton.cpp @@ -86,16 +125,6 @@ Application HaikuDepot : UserLoginWindow.cpp WorkStatusView.cpp - # network + server - model - DumpExportPkg.cpp - DumpExportPkgCategory.cpp - DumpExportPkgJsonListener.cpp - DumpExportPkgScreenshot.cpp - DumpExportPkgVersion.cpp - DumpExportRepository.cpp - DumpExportRepositorySource.cpp - DumpExportRepositoryJsonListener.cpp - # network + server / local processes AbstractProcess.cpp AbstractServerProcess.cpp @@ -128,10 +157,48 @@ Application HaikuDepot : # package_daemon ProblemWindow.cpp ResultWindow.cpp +; - # text view stuff - $(textDocumentSources) +local generatedPkgModelSourceFiles = + DumpExportPkg.cpp + DumpExportPkgCategory.cpp + DumpExportPkgScreenshot.cpp + DumpExportPkgVersion.cpp +; +local generatedRepositoryModelSourceFiles = + DumpExportRepository.cpp + DumpExportRepositorySource.cpp + DumpExportRepositorySourceMirror.cpp +; + +local generatedPkgParserSourceFiles = + DumpExportPkgJsonListener.cpp +; + +local generatedRepositoryParserSourceFiles = + DumpExportRepositoryJsonListener.cpp +; + +local generatedSourceFiles = + # network + server - model + DumpExportPkg.cpp + DumpExportPkgCategory.cpp + DumpExportPkgScreenshot.cpp + DumpExportPkgVersion.cpp + DumpExportRepository.cpp + DumpExportRepositorySource.cpp + DumpExportRepositorySourceMirror.cpp + + # network + server - parser + DumpExportPkgJsonListener.cpp + DumpExportRepositoryJsonListener.cpp +; + +Application HaikuDepot + : $(applicationSources) $(textDocumentSources) + $(generatedPkgModelSourceFiles) $(generatedRepositoryModelSourceFiles) + $(generatedPkgParserSourceFiles) $(generatedRepositoryParserSourceFiles) : be package bnetapi translation libcolumnlistview.a shared [ TargetLibstdc++ ] [ TargetLibsupc++ ] localestub : HaikuDepot.rdef @@ -161,3 +228,50 @@ Application TextDocumentTest : : be translation shared [ TargetLibsupc++ ] ; + +# The following use of rules configures the generation of .cpp and .h files from +# JSON schemas that are defined in the HaikuDepotServer system. See the +# included Jam rules and actions for the definitions. + +HdsSchemaGenModel $(dumpExportPkgModelTargetFile) + : dumpexportpkg.json : jsonschema2cppmodel.py ; + +HdsSchemaGenModel $(dumpExportRepositoryModelTargetFile) + : dumpexportrepository.json : jsonschema2cppmodel.py ; + +HdsSchemaGenBulkParser $(dumpExportRepositoryBulkListerTargetFile) + : dumpexportrepository.json : jsonschema2cppparser.py ; + +HdsSchemaGenBulkParser $(dumpExportPkgBulkListenerTargetFile) + : dumpexportpkg.json : jsonschema2cppparser.py ; + +HdsSchemaGenAppSrcDependsOnGeneration + [ FGristFiles $(generatedPkgParserSourceFiles) ] + [ FGristFiles $(generatedPkgParserSourceFiles:S=.h) ] + : $(dumpExportPkgBulkListenerTargetFile) ; + +HdsSchemaGenAppSrcDependsOnGeneration + [ FGristFiles $(generatedRepositoryParserSourceFiles) ] + [ FGristFiles $(generatedRepositoryParserSourceFiles:S=.h) ] + : $(dumpExportRepositoryBulkListerTargetFile) ; + +HdsSchemaGenAppSrcDependsOnGeneration + [ FGristFiles $(generatedRepositoryModelSourceFiles) ] + [ FGristFiles $(generatedRepositoryModelSourceFiles:S=.h) ] + : $(dumpExportRepositoryModelTargetFile) ; + +HdsSchemaGenAppSrcDependsOnGeneration + [ FGristFiles $(generatedPkgModelSourceFiles) ] + [ FGristFiles $(generatedPkgModelSourceFiles:S=.h) ] + : $(dumpExportPkgModelTargetFile) ; + +# This will ensure that if any of the generated files' header files change, then +# the application should be re-built. + +Depends [ FGristFiles $(applicationSources:S=.o) ] + : + [ FGristFiles $(generatedPkgParserSourceFiles:S=.h) ] + [ FGristFiles $(generatedRepositoryParserSourceFiles:S=.h) ] + [ FGristFiles $(generatedRepositoryModelSourceFiles:S=.h) ] + [ FGristFiles $(generatedPkgModelSourceFiles:S=.h) ] +; \ No newline at end of file diff --git a/src/apps/haikudepot/build/jam/HdsSchemaGenRules b/src/apps/haikudepot/build/jam/HdsSchemaGenRules new file mode 100644 index 0000000000..7e40f4deeb --- /dev/null +++ b/src/apps/haikudepot/build/jam/HdsSchemaGenRules @@ -0,0 +1,93 @@ +# ===================================== +# Copyright 2019, Andrew Lindesay +# Distributed under the terms of the MIT License. +# ===================================== + +# HaikuDepotServer has a number of data-transfer-objects (DTO) that are defined +# by JSON schemas. The server uses these schemas to produce the objects at +# compile time. Likewise, the schema files also generate C++ side DTO model +# objects in the form of .cpp and .h files as well. This way the +# HaikuDepotServer server and HaikuDepot desktop application are able to +# communicate more 'safely'. The schema files still need to be copied from +# the server source to the Haiku source, but the generation process will ensure +# that the data-structures are consistent. +# +# The C++ side classes are generated with python scripts that are included in +# the Haiku source. These rules and actions take care of making sure that the +# python scripts are run when necessary to generate the C++ side classes. Note +# that there are two sorts of classes generated here; the model DTO objects and +# also the supporting classes that parse the DTO objects. The parsing classes +# are intended to be used with Haiku JSON parsing systems. + +# pragma mark - Generic + +actions HdsSchemaGenTouch +{ + touch $(1) +} + +# pragma mark - Model Class Generation + +# 1 : the dummy file in the class generation directory (target) +# 2 : the JSON schema file +# 3 : the Python script to use + +rule HdsSchemaGenModel +{ + SEARCH on $(2) = [ FDirName $(SUBDIR) server schema ] ; + SEARCH on $(3) = [ FDirName $(SUBDIR) build scripts ] ; + + Clean $(1:D) ; + Depends $(1) : $(2) $(3) ; + + MkDir $(1:D) ; + HdsSchemaGenModel1 $(1) : $(2) $(3) $(1:D) ; + HdsSchemaGenTouch $(1) ; +} + +actions HdsSchemaGenModel1 +{ + python $(2[2]) -i $(2[1]) --outputdirectory $(2[3]) +} + +# pragma mark - Bulk Parsing Class Generation + +# 1 : the dummy file in the class generation directory (target) +# 2 : the JSON schema file +# 3 : the Python script to use + +rule HdsSchemaGenBulkParser +{ + SEARCH on $(2) = [ FDirName $(SUBDIR) server schema ] ; + SEARCH on $(3) = [ FDirName $(SUBDIR) build scripts ] ; + + Clean $(1:D) ; + Depends $(1) : $(2) $(3) ; + + MkDir $(1:D) ; + HdsSchemaGenBulkParser1 $(1) : $(2) $(3) $(1:D) ; + HdsSchemaGenTouch $(1) ; +} + +actions HdsSchemaGenBulkParser1 +{ + python $(2[2]) -i $(2[1]) --outputdirectory $(2[3]) --supportbulkcontainer +} + +# pragma mark - Registering Generated Classes + +# Because a number of .cpp and .h files will be generated from a single python +# script's run, it is necessary to introduce a dependency between the known +# output files and the target for a given python script run. + +# 1 : generated files (.h and .cpp) +# 2 : target that will generate the generated files + +rule HdsSchemaGenAppSrcDependsOnGeneration { + local generatedSource ; + local applicationSource ; + + MakeLocate $(1) : $(2:D) ; + Depends $(1) : $(2) ; + Clean $(1) ; +} \ No newline at end of file diff --git a/src/apps/haikudepot/build/scripts/hdsjsonschemacommon.py b/src/apps/haikudepot/build/scripts/hdsjsonschemacommon.py new file mode 100644 index 0000000000..0435801384 --- /dev/null +++ b/src/apps/haikudepot/build/scripts/hdsjsonschemacommon.py @@ -0,0 +1,95 @@ + +# ===================================== +# Copyright 2017-2019, Andrew Lindesay +# Distributed under the terms of the MIT License. +# ===================================== + +# common material related to generation of schema-generated artifacts. + +import datetime + + +# The possible JSON types +JSON_TYPE_STRING = "string" +JSON_TYPE_OBJECT = "object" +JSON_TYPE_ARRAY = "array" +JSON_TYPE_BOOLEAN = "boolean" +JSON_TYPE_INTEGER = "integer" +JSON_TYPE_NUMBER = "number" + + +# The possible C++ types +CPP_TYPE_STRING = "BString" +CPP_TYPE_ARRAY = "List" +CPP_TYPE_BOOLEAN = "bool" +CPP_TYPE_INTEGER = "int64" +CPP_TYPE_NUMBER = "double" + + +def uniondicts(d1, d2): + d = dict(d1) + d.update(d2) + return d + + +def javatypetocppname(javaname): + return javaname[javaname.rindex('.')+1:] + + +def propnametocppname(propname): + return propname[0:1].upper() + propname[1:] + + +def propnametocppmembername(propname): + return 'f' + propnametocppname(propname) + + +def propmetatojsoneventtypename(propmetadata): + type = propmetadata['type'] + + + +def propmetadatatocpptypename(propmetadata): + type = propmetadata['type'] + + if type == JSON_TYPE_STRING: + return CPP_TYPE_STRING + if type == JSON_TYPE_BOOLEAN: + return CPP_TYPE_BOOLEAN + if type == JSON_TYPE_INTEGER: + return CPP_TYPE_INTEGER + if type == JSON_TYPE_NUMBER: + return CPP_TYPE_NUMBER + if type == JSON_TYPE_OBJECT: + javatype = propmetadata['javaType'] + + if not javatype or 0 == len(javatype): + raise Exception('missing "javaType" field') + + return javatypetocppname(javatype) + + if type == JSON_TYPE_ARRAY: + itemsmetadata = propmetadata['items'] + itemsjavatype = itemsmetadata['javaType'] + + if not itemsjavatype or 0 == len(itemsjavatype): + raise Exception('missing "javaType" field') + + return "%s <%s*, true>" % (CPP_TYPE_ARRAY, javatypetocppname(itemsjavatype)) + + raise Exception('unknown json-schema type [' + type + ']') + + +def propmetadatatypeisscalar(propmetadata): + type = propmetadata['type'] + return type == JSON_TYPE_BOOLEAN or type == JSON_TYPE_INTEGER or type == JSON_TYPE_NUMBER + + +def writetopcomment(f, inputfilename, variant): + f.write(( + '/*\n' + ' * Generated %s Object\n' + ' * source json-schema : %s\n' + ' * generated at : %s\n' + ' */\n' + ) % (variant, inputfilename, datetime.datetime.now().isoformat())) diff --git a/src/apps/haikudepot/build/scripts/jsonschema2cppmodel.py b/src/apps/haikudepot/build/scripts/jsonschema2cppmodel.py new file mode 100644 index 0000000000..ce4b453a43 --- /dev/null +++ b/src/apps/haikudepot/build/scripts/jsonschema2cppmodel.py @@ -0,0 +1,396 @@ +#!/usr/bin/python + +# ===================================== +# Copyright 2017-2019, Andrew Lindesay +# Distributed under the terms of the MIT License. +# ===================================== + +# This simple tool will read a JSON schema and will then generate +# some model objects that can be used to hold the data-structure +# in the C++ environment. + +import json +import argparse +import os +import hdsjsonschemacommon as jscom +import string + + +def hasanylistproperties(schema): + for propname, propmetadata in schema['properties'].items(): + if propmetadata['type'] == 'array': + return True + return False + + +def writelistaccessors(outputfile, cppclassname, cppname, cppmembername, cppcontainertype): + + dict = { + 'cppclassname' : cppclassname, + 'cppname': cppname, + 'cppmembername': cppmembername, + 'cppcontainertype': cppcontainertype + } + + outputfile.write( + string.Template(""" +void +${cppclassname}::AddTo${cppname}(${cppcontainertype}* value) +{ + if (${cppmembername} == NULL) + ${cppmembername} = new List<${cppcontainertype}*, true>(); + ${cppmembername}->Add(value); +} + + +void +${cppclassname}::Set${cppname}(List<${cppcontainertype}*, true>* value) +{ + ${cppmembername} = value; +} + + +int32 +${cppclassname}::Count${cppname}() +{ + if (${cppmembername} == NULL) + return 0; + return ${cppmembername}->CountItems(); +} + + +${cppcontainertype}* +${cppclassname}::${cppname}ItemAt(int32 index) +{ + return ${cppmembername}->ItemAt(index); +} + + +bool +${cppclassname}::${cppname}IsNull() +{ + return ${cppmembername} == NULL; +} +""").substitute(dict)) + + +def writelistaccessorsheader(outputfile, cppname, cppcontainertype): + dict = { + 'cppname': cppname, + 'cppcontainertype': cppcontainertype + } + + outputfile.write( + string.Template(""" void AddTo${cppname}(${cppcontainertype}* value); + void Set${cppname}(List<${cppcontainertype}*, true>* value); + int32 Count${cppname}(); + ${cppcontainertype}* ${cppname}ItemAt(int32 index); + bool ${cppname}IsNull(); +""").substitute(dict)) + + +def writetakeownershipaccessors(outputfile, cppclassname, cppname, cppmembername, cpptype): + + dict = { + 'cppclassname': cppclassname, + 'cppname': cppname, + 'cppmembername': cppmembername, + 'cpptype': cpptype + } + + outputfile.write( + string.Template(""" +${cpptype}* +${cppclassname}::${cppname}() +{ + return ${cppmembername}; +} + + +void +${cppclassname}::Set${cppname}(${cpptype}* value) +{ + ${cppmembername} = value; +} + + +void +${cppclassname}::Set${cppname}Null() +{ + if (!${cppname}IsNull()) { + delete ${cppmembername}; + ${cppmembername} = NULL; + } +} + + +bool +${cppclassname}::${cppname}IsNull() +{ + return ${cppmembername} == NULL; +} +""").substitute(dict)) + + +def writetakeownershipaccessorsheader(outputfile, cppname, cpptype): + outputfile.write(' %s* %s();\n' % (cpptype, cppname)) + outputfile.write(' void Set%s(%s* value);\n' % (cppname, cpptype)) + outputfile.write(' void Set%sNull();\n' % cppname) + outputfile.write(' bool %sIsNull();\n' % cppname) + + +def writescalaraccessors(outputfile, cppclassname, cppname, cppmembername, cpptype): + + dict = { + 'cppclassname': cppclassname, + 'cppname': cppname, + 'cppmembername': cppmembername, + 'cpptype': cpptype + } + + outputfile.write( + string.Template(""" +${cpptype} +${cppclassname}::${cppname}() +{ + return *${cppmembername}; +} + + +void +${cppclassname}::Set${cppname}(${cpptype} value) +{ + if (${cppname}IsNull()) + ${cppmembername} = new ${cpptype}[1]; + ${cppmembername}[0] = value; +} + + +void +${cppclassname}::Set${cppname}Null() +{ + if (!${cppname}IsNull()) { + delete ${cppmembername}; + ${cppmembername} = NULL; + } +} + + +bool +${cppclassname}::${cppname}IsNull() +{ + return ${cppmembername} == NULL; +} +""").substitute(dict)) + + +def writescalaraccessorsheader(outputfile, cppname, cpptype): + outputfile.write( + string.Template(""" + ${cpptype} ${cppname}(); + void Set${cppname}(${cpptype} value); + void Set${cppname}Null(); + bool ${cppname}IsNull(); +""").substitute({'cppname': cppname, 'cpptype': cpptype})) + + +def writeaccessors(outputfile, cppclassname, propname, propmetadata): + type = propmetadata['type'] + + if type == 'array': + writelistaccessors(outputfile, + cppclassname, + jscom.propnametocppname(propname), + jscom.propnametocppmembername(propname), + jscom.javatypetocppname(propmetadata['items']['javaType'])) + elif jscom.propmetadatatypeisscalar(propmetadata): + writescalaraccessors(outputfile, + cppclassname, + jscom.propnametocppname(propname), + jscom.propnametocppmembername(propname), + jscom.propmetadatatocpptypename(propmetadata)) + else: + writetakeownershipaccessors(outputfile, + cppclassname, + jscom.propnametocppname(propname), + jscom.propnametocppmembername(propname), + jscom.propmetadatatocpptypename(propmetadata)) + + +def writeaccessorsheader(outputfile, propname, propmetadata): + type = propmetadata['type'] + + if type == 'array': + writelistaccessorsheader(outputfile, + jscom.propnametocppname(propname), + jscom.javatypetocppname(propmetadata['items']['javaType'])) + elif jscom.propmetadatatypeisscalar(propmetadata): + writescalaraccessorsheader(outputfile, + jscom.propnametocppname(propname), + jscom.propmetadatatocpptypename(propmetadata)) + else: + writetakeownershipaccessorsheader(outputfile, + jscom.propnametocppname(propname), + jscom.propmetadatatocpptypename(propmetadata)) + + +def writedestructorlogicforlist(outputfile, propname, propmetadata): + dict = { + 'cppmembername': jscom.propnametocppmembername(propname), + 'cpptype': jscom.javatypetocppname(propmetadata['items']['javaType']) + } + + outputfile.write( + string.Template(""" int32 count = ${cppmembername}->CountItems(); + for (i = 0; i < count; i++) + delete ${cppmembername}->ItemAt(i); +""").substitute(dict)) + + +def writedestructor(outputfile, cppname, schema): + outputfile.write('\n\n%s::~%s()\n{\n' % (cppname, cppname)) + + if hasanylistproperties(schema): + outputfile.write(' int32 i;\n\n') + + for propname, propmetadata in schema['properties'].items(): + propmembername = jscom.propnametocppmembername(propname) + + outputfile.write(' if (%s != NULL) {\n' % propmembername) + + if propmetadata['type'] == 'array': + writedestructorlogicforlist(outputfile, propname, propmetadata) + + outputfile.write(( + ' delete %s;\n' + ) % propmembername) + + outputfile.write(' }\n\n') + + outputfile.write('}\n') + + +def writeconstructor(outputfile, cppname, schema): + outputfile.write('\n\n%s::%s()\n{\n' % (cppname, cppname)) + + for propname, propmetadata in schema['properties'].items(): + outputfile.write(' %s = NULL;\n' % jscom.propnametocppmembername(propname)) + + outputfile.write('}\n') + + +def writeheaderincludes(outputfile, properties): + for propname, propmetadata in properties.items(): + jsontype = propmetadata['type'] + javatype = None + + if jsontype == 'object': + javatype = propmetadata['javaType'] + + if jsontype == 'array': + javatype = propmetadata['items']['javaType'] + + if javatype is not None: + outputfile.write('#include "%s.h"\n' % jscom.javatypetocppname(javatype)) + + +def schematocppmodels(inputfile, schema, outputdirectory): + if schema['type'] != 'object': + raise Exception('expecting object') + + javatype = schema['javaType'] + + if not javatype or 0 == len(javatype): + raise Exception('missing "javaType" field') + + cppclassname = jscom.javatypetocppname(javatype) + cpphfilename = os.path.join(outputdirectory, cppclassname + '.h') + cppifilename = os.path.join(outputdirectory, cppclassname + '.cpp') + + with open(cpphfilename, 'w') as cpphfile: + + jscom.writetopcomment(cpphfile, os.path.split(inputfile)[1], 'Model') + guarddefname = 'GEN_JSON_SCHEMA_MODEL__%s_H' % (cppclassname.upper()) + + cpphfile.write(string.Template(""" +#ifndef ${guarddefname} +#define ${guarddefname} + +#include "List.h" +#include "String.h" + +""").substitute({'guarddefname': guarddefname})) + + writeheaderincludes(cpphfile, schema['properties']) + + cpphfile.write(string.Template(""" +class ${cppclassname} { +public: + ${cppclassname}(); + virtual ~${cppclassname}(); + + +""").substitute({'cppclassname': cppclassname})) + + for propname, propmetadata in schema['properties'].items(): + writeaccessorsheader(cpphfile, propname, propmetadata) + cpphfile.write('\n') + + # Now add the instance variables for the object as well. + + cpphfile.write('private:\n') + + for propname, propmetadata in schema['properties'].items(): + cpphfile.write(' %s* %s;\n' % ( + jscom.propmetadatatocpptypename(propmetadata), + jscom.propnametocppmembername(propname))) + + cpphfile.write(( + '};\n\n' + '#endif // %s' + ) % guarddefname) + + with open(cppifilename, 'w') as cppifile: + + jscom.writetopcomment(cppifile, os.path.split(inputfile)[1], 'Model') + + cppifile.write('#include "%s.h"\n' % cppclassname) + + writeconstructor(cppifile, cppclassname, schema) + writedestructor(cppifile, cppclassname, schema) + + for propname, propmetadata in schema['properties'].items(): + writeaccessors(cppifile, cppclassname, propname, propmetadata) + cppifile.write('\n') + + # Now write out any subordinate structures. + + for propname, propmetadata in schema['properties'].items(): + jsontype = propmetadata['type'] + + if jsontype == 'array': + schematocppmodels(inputfile, propmetadata['items'], outputdirectory) + + if jsontype == 'object': + schematocppmodels(inputfile, propmetadata, outputdirectory) + + +def main(): + parser = argparse.ArgumentParser(description='Convert JSON schema to Haiku C++ Models') + parser.add_argument('-i', '--inputfile', required=True, help='The input filename containing the JSON schema') + parser.add_argument('--outputdirectory', help='The output directory where the C++ files should be written') + + args = parser.parse_args() + + outputdirectory = args.outputdirectory + + if not outputdirectory: + outputdirectory = '.' + + with open(args.inputfile) as inputfile: + schema = json.load(inputfile) + schematocppmodels(args.inputfile, schema, outputdirectory) + +if __name__ == "__main__": + main() + diff --git a/src/apps/haikudepot/build/scripts/jsonschema2cppparser.py b/src/apps/haikudepot/build/scripts/jsonschema2cppparser.py new file mode 100644 index 0000000000..ca8b8a6f9b --- /dev/null +++ b/src/apps/haikudepot/build/scripts/jsonschema2cppparser.py @@ -0,0 +1,1320 @@ +#!/usr/bin/python + +# ===================================== +# Copyright 2017-2019, Andrew Lindesay +# Distributed under the terms of the MIT License. +# ===================================== + +# This simple tool will read a JSON schema and will then generate a +# listener for use the 'BJson' class in the Haiku system. This +# allows data conforming to the schema to be able to be parsed. + +import string +import json +import argparse +import os +import hdsjsonschemacommon as jscom + + +# This naming is related to a sub-type in the schema; maybe not the top-level. + +class CppParserSubTypeNaming: + _cppmodelclassname = None + _naming = None + + def __init__(self, schema, naming): + javatype = schema['javaType'] + + if not javatype or 0 == len(javatype): + raise Exception('missing "javaType" field') + + self._cppmodelclassname = jscom.javatypetocppname(javatype) + self._naming = naming + + def cppmodelclassname(self): + return self._cppmodelclassname + + def cppstackedlistenerclassname(self): + return self._cppmodelclassname + '_' + self._naming.generatejsonlistenername('Stacked') + + def cppstackedlistlistenerclassname(self): + return self._cppmodelclassname + '_List_' + self._naming.generatejsonlistenername('Stacked') + + def todict(self): + return { + 'subtype_cppmodelclassname': self.cppmodelclassname(), + 'subtype_cppstackedlistenerclassname': self.cppstackedlistenerclassname(), + 'subtype_cppstackedlistlistenerclassname': self.cppstackedlistlistenerclassname() + } + + +# This naming relates to the whole schema. It's point of reference is the top level. + +class CppParserNaming: + _schemaroot = None + + def __init__(self, schemaroot): + self._schemaroot = schemaroot + + def cpprootmodelclassname(self): + if self._schemaroot['type'] != 'object': + raise Exception('expecting object') + + javatype = self._schemaroot['javaType'] + + if not javatype or 0 == len(javatype): + raise Exception('missing "javaType" field') + + return jscom.javatypetocppname(javatype) + + def generatejsonlistenername(self, prefix): + return prefix + self.cpprootmodelclassname() + 'JsonListener' + + def cppsupermainlistenerclassname(self): + return self.generatejsonlistenername('AbstractMain') + + def cppsinglemainlistenerclassname(self): + return self.generatejsonlistenername("Single") + + def cppbulkcontainermainlistenerclassname(self): + return self.generatejsonlistenername('BulkContainer') + + def cppsuperstackedlistenerclassname(self): + return self.generatejsonlistenername('AbstractStacked') + + def cppbulkcontainerstackedlistenerclassname(self): + return self.generatejsonlistenername('BulkContainerStacked') + + def cppbulkcontaineritemliststackedlistenerclassname(self): + return self.generatejsonlistenername('BulkContainerItemsStacked') + +# this is a sub-class of the root object json listener that can call out to the +# item listener as the root objects are parsed. + + def cppitemlistenerstackedlistenerclassname(self): + return self.generatejsonlistenername('ItemEmittingStacked') + + def cppgeneralobjectstackedlistenerclassname(self): + return self.generatejsonlistenername('GeneralObjectStacked') + + def cppgeneralarraystackedlistenerclassname(self): + return self.generatejsonlistenername('GeneralArrayStacked') + + def cppitemlistenerclassname(self): + return self.cpprootmodelclassname() + 'Listener' + + def todict(self): + return { + 'cpprootmodelclassname': self.cpprootmodelclassname(), + 'cppsupermainlistenerclassname': self.cppsupermainlistenerclassname(), + 'cppsinglemainlistenerclassname': self.cppsinglemainlistenerclassname(), + 'cppbulkcontainermainlistenerclassname': self.cppbulkcontainermainlistenerclassname(), + 'cppbulkcontainerstackedlistenerclassname': self.cppbulkcontainerstackedlistenerclassname(), + 'cppbulkcontaineritemliststackedlistenerclassname': self.cppbulkcontaineritemliststackedlistenerclassname(), + 'cppsuperstackedlistenerclassname': self.cppsuperstackedlistenerclassname(), + 'cppitemlistenerstackedlistenerclassname': self.cppitemlistenerstackedlistenerclassname(), + 'cppgeneralobjectstackedlistenerclassname': self.cppgeneralobjectstackedlistenerclassname(), + 'cppgeneralarraystackedlistenerclassname': self.cppgeneralarraystackedlistenerclassname(), + 'cppitemlistenerclassname': self.cppitemlistenerclassname() + } + + +class CppParserImplementationState: + + _interfacehandledcppnames = [] + _implementationhandledcppnames = [] + _outputfile = None + _naming = None + + def __init__(self, outputfile, naming): + self._outputfile = outputfile + self._naming = naming + + def isinterfacehandledcppname(self, name): + return name in self._interfacehandledcppnames + + def addinterfacehandledcppname(self, name): + self._interfacehandledcppnames.append(name) + + def isimplementationhandledcppname(self, name): + return name in self._implementationhandledcppnames + + def addimplementationhandledcppname(self, name): + self._implementationhandledcppnames.append(name) + + def naming(self): + return self._naming + + def outputfile(self): + return self._outputfile + + +def writerootstackedlistenerinterface(istate): + istate.outputfile().write( + string.Template(""" +/*! This class is the top level of the stacked listeners. The stack structure + is maintained in a linked list and sub-classes implement specific behaviors + depending where in the parse tree the stacked listener is working at. +*/ +class ${cppsuperstackedlistenerclassname} : public BJsonEventListener { +public: + ${cppsuperstackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent); + ~${cppsuperstackedlistenerclassname}(); + + void HandleError(status_t status, int32 line, const char* message); + void Complete(); + + status_t ErrorStatus(); + + ${cppsuperstackedlistenerclassname}* Parent(); + + virtual bool WillPop(); + +protected: + ${cppsupermainlistenerclassname}* fMainListener; + + bool Pop(); + void Push(${cppsuperstackedlistenerclassname}* stackedListener); + + +private: + ${cppsuperstackedlistenerclassname}* fParent; +}; +""").substitute(istate.naming().todict())) + + +def writerootstackedlistenerimplementation(istate): + istate.outputfile().write( + string.Template(""" +${cppsuperstackedlistenerclassname}::${cppsuperstackedlistenerclassname} ( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent) +{ + fMainListener = mainListener; + fParent = parent; +} + +${cppsuperstackedlistenerclassname}::~${cppsuperstackedlistenerclassname}() +{ +} + +void +${cppsuperstackedlistenerclassname}::HandleError(status_t status, int32 line, const char* message) +{ + fMainListener->HandleError(status, line, message); +} + +void +${cppsuperstackedlistenerclassname}::Complete() +{ + fMainListener->Complete(); +} + +status_t +${cppsuperstackedlistenerclassname}::ErrorStatus() +{ + return fMainListener->ErrorStatus(); +} + +${cppsuperstackedlistenerclassname}* +${cppsuperstackedlistenerclassname}::Parent() +{ + return fParent; +} + +void +${cppsuperstackedlistenerclassname}::Push(${cppsuperstackedlistenerclassname}* stackedListener) +{ + fMainListener->SetStackedListener(stackedListener); +} + +bool +${cppsuperstackedlistenerclassname}::WillPop() +{ + return true; +} + +bool +${cppsuperstackedlistenerclassname}::Pop() +{ + bool result = WillPop(); + fMainListener->SetStackedListener(fParent); + return result; +} +""").substitute(istate.naming().todict())) + + +def writeageneralstackedlistenerinterface(istate, alistenerclassname): + istate.outputfile().write( + string.Template(""" +class ${alistenerclassname} : public ${cppsuperstackedlistenerclassname} { +public: + ${alistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent); + ~${alistenerclassname}(); + + + bool Handle(const BJsonEvent& event); +}; +""").substitute(jscom.uniondicts( + istate.naming().todict(), + {'alistenerclassname': alistenerclassname} + ))) + + +def writegeneralstackedlistenerinterface(istate): + writeageneralstackedlistenerinterface(istate, istate.naming().cppgeneralarraystackedlistenerclassname()) + writeageneralstackedlistenerinterface(istate, istate.naming().cppgeneralobjectstackedlistenerclassname()) + + +def writegeneralnoopstackedlistenerconstructordestructor(istate, aclassname): + + istate.outputfile().write( + string.Template(""" +${aclassname}::${aclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent) + : + ${cppsuperstackedlistenerclassname}(mainListener, parent) +{ +} + +${aclassname}::~${aclassname}() +{ +} +""").substitute(jscom.uniondicts( + istate.naming().todict(), + {'aclassname': aclassname})) + ) + + +def writegeneralstackedlistenerimplementation(istate): + outfile = istate.outputfile() + generalobjectclassname = istate.naming().cppgeneralobjectstackedlistenerclassname() + generalarrayclassname = istate.naming().cppgeneralarraystackedlistenerclassname() + substitutedict = { + 'generalobjectclassname': generalobjectclassname, + 'generalarrayclassname': generalarrayclassname + } + +# general object consumer that will parse-and-discard any json objects. + + writegeneralnoopstackedlistenerconstructordestructor(istate, generalobjectclassname) + + istate.outputfile().write( + string.Template(""" +bool +${generalobjectclassname}::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_OBJECT_NAME: + case B_JSON_NUMBER: + case B_JSON_STRING: + case B_JSON_TRUE: + case B_JSON_FALSE: + case B_JSON_NULL: + // ignore + break; + + + case B_JSON_OBJECT_START: + Push(new ${generalobjectclassname}(fMainListener, this)); + break; + + + case B_JSON_ARRAY_START: + Push(new ${generalarrayclassname}(fMainListener, this)); + break; + + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of array"); + break; + + + case B_JSON_OBJECT_END: + { + bool status = Pop() && (ErrorStatus() == B_OK); + delete this; + return status; + } + + + } + + + return ErrorStatus() == B_OK; +} +""").substitute(substitutedict)) + + # general array consumer that will parse-and-discard any json arrays. + + writegeneralnoopstackedlistenerconstructordestructor(istate, generalarrayclassname) + + outfile.write( + string.Template(""" +bool +${generalarrayclassname}::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_OBJECT_NAME: + case B_JSON_NUMBER: + case B_JSON_STRING: + case B_JSON_TRUE: + case B_JSON_FALSE: + case B_JSON_NULL: + // ignore + break; + + + case B_JSON_OBJECT_START: + Push(new ${generalobjectclassname}(fMainListener, this)); + break; + + + case B_JSON_ARRAY_START: + Push(new ${generalarrayclassname}(fMainListener, this)); + break; + + + case B_JSON_OBJECT_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of object"); + break; + + + case B_JSON_ARRAY_END: + { + bool status = Pop() && (ErrorStatus() == B_OK); + delete this; + return status; + } + + + } + + + return ErrorStatus() == B_OK; +} +""").substitute(substitutedict)) + + +def writestackedlistenerinterface(istate, subschema): + naming = istate.naming() + subtypenaming = CppParserSubTypeNaming(subschema, naming) + + if not istate.isinterfacehandledcppname(subtypenaming.cppmodelclassname()): + istate.addinterfacehandledcppname(subtypenaming.cppmodelclassname()) + + istate.outputfile().write( + string.Template(""" +class ${subtype_cppstackedlistenerclassname} : public ${cppsuperstackedlistenerclassname} { +public: + ${subtype_cppstackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent); + ~${subtype_cppstackedlistenerclassname}(); + + + bool Handle(const BJsonEvent& event); + + + ${subtype_cppmodelclassname}* Target(); + + +protected: + ${subtype_cppmodelclassname}* fTarget; + BString fNextItemName; +}; + +class ${subtype_cppstackedlistlistenerclassname} : public ${cppsuperstackedlistenerclassname} { +public: + ${subtype_cppstackedlistlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent); + ~${subtype_cppstackedlistlistenerclassname}(); + + + bool Handle(const BJsonEvent& event); + + + List<${subtype_cppmodelclassname}*, true>* Target(); // list of %s pointers + + +private: + List<${subtype_cppmodelclassname}*, true>* fTarget; +}; +""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict()))) + + for propname, propmetadata in subschema['properties'].items(): + if propmetadata['type'] == 'array': + writestackedlistenerinterface(istate, propmetadata['items']) + elif propmetadata['type'] == 'object': + writestackedlistenerinterface(istate, propmetadata) + + +def writebulkcontainerstackedlistenerinterface(istate, schema): + naming = istate.naming() + subtypenaming = CppParserSubTypeNaming(schema, naming) + outfile = istate.outputfile() + +# This is a sub-class of the main model object listener. It will ping out to an item listener +# when parsing is complete. + + outfile.write( + string.Template(""" +class ${cppitemlistenerstackedlistenerclassname} : public ${subtype_cppstackedlistenerclassname} { +public: + ${cppitemlistenerstackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent, + ${cppitemlistenerclassname}* itemListener); + ~${cppitemlistenerstackedlistenerclassname}(); + + + bool WillPop(); + + +private: + ${cppitemlistenerclassname}* fItemListener; +}; + + +class ${cppbulkcontainerstackedlistenerclassname} : public ${cppsuperstackedlistenerclassname} { +public: + ${cppbulkcontainerstackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent, + ${cppitemlistenerclassname}* itemListener); + ~${cppbulkcontainerstackedlistenerclassname}(); + + + bool Handle(const BJsonEvent& event); + + +private: + BString fNextItemName; + ${cppitemlistenerclassname}* fItemListener; +}; + + +class ${cppbulkcontaineritemliststackedlistenerclassname} : public ${cppsuperstackedlistenerclassname} { +public: + ${cppbulkcontaineritemliststackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent, + ${cppitemlistenerclassname}* itemListener); + ~${cppbulkcontaineritemliststackedlistenerclassname}(); + + + bool Handle(const BJsonEvent& event); + bool WillPop(); + + +private: + ${cppitemlistenerclassname}* fItemListener; +}; +""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict()))) + + +def writestackedlistenerfieldimplementation( + istate, + propname, + cppeventdataexpression): + + istate.outputfile().write( + string.Template(""" + if (fNextItemName == "${propname}") + fTarget->Set${cpppropname}(${cppeventdataexpression}); + """).substitute({ + 'propname': propname, + 'cpppropname': jscom.propnametocppname(propname), + 'cppeventdataexpression': cppeventdataexpression + })) + + +def writenullstackedlistenerfieldimplementation( + istate, + propname): + + istate.outputfile().write( + string.Template(""" + if (fNextItemName == "${propname}") + fTarget->Set${cpppropname}Null(); + """).substitute({ + 'propname': propname, + 'cpppropname': jscom.propnametocppname(propname) + })) + + +def writestackedlistenerfieldsimplementation( + istate, + schema, + selectedcpptypename, + jsoneventtypename, + cppeventdataexpression): + + outfile = istate.outputfile() + + outfile.write(' case ' + jsoneventtypename + ':\n') + + for propname, propmetadata in schema['properties'].items(): + cpptypename = jscom.propmetadatatocpptypename(propmetadata) + + if cpptypename == selectedcpptypename: + writestackedlistenerfieldimplementation(istate, propname, cppeventdataexpression) + + outfile.write(' fNextItemName.SetTo("");\n') + outfile.write(' break;\n') + + +def writestackedlistenertypedobjectimplementation(istate, schema): + outfile = istate.outputfile() + naming = istate.naming(); + subtypenaming = CppParserSubTypeNaming(schema, naming) + + outfile.write( + string.Template(""" +${subtype_cppstackedlistenerclassname}::${subtype_cppstackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent) + : + ${cppsuperstackedlistenerclassname}(mainListener, parent) +{ + fTarget = new ${subtype_cppmodelclassname}(); +} + + +${subtype_cppstackedlistenerclassname}::~${subtype_cppstackedlistenerclassname}() +{ +} + + +${subtype_cppmodelclassname}* +${subtype_cppstackedlistenerclassname}::Target() +{ + return fTarget; +} + + +bool +${subtype_cppstackedlistenerclassname}::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); + break; + + + case B_JSON_OBJECT_NAME: + fNextItemName = event.Content(); + break; + + + case B_JSON_OBJECT_END: + { + bool status = Pop() && (ErrorStatus() == B_OK); + delete this; + return status; + } + +""").substitute(jscom.uniondicts( + naming.todict(), + subtypenaming.todict()))) + + # now extract the fields from the schema that need to be fed in. + + writestackedlistenerfieldsimplementation( + istate, schema, + jscom.CPP_TYPE_STRING, 'B_JSON_STRING', 'new BString(event.Content())') + + writestackedlistenerfieldsimplementation( + istate, schema, + jscom.CPP_TYPE_BOOLEAN, 'B_JSON_TRUE', 'true') + + writestackedlistenerfieldsimplementation( + istate, schema, + jscom.CPP_TYPE_BOOLEAN, 'B_JSON_FALSE', 'false') + + outfile.write(' case B_JSON_NULL:\n') + outfile.write(' {\n') + + for propname, propmetadata in schema['properties'].items(): + # TODO; deal with array case somehow. + if 'array' != propmetadata['type']: + writenullstackedlistenerfieldimplementation(istate, propname) + outfile.write(' fNextItemName.SetTo("");\n') + outfile.write(' break;\n') + outfile.write(' }\n') + + # number type is a bit complex because it can either be a double or it can be an + # integral value. + + outfile.write(' case B_JSON_NUMBER:\n') + outfile.write(' {\n') + + for propname, propmetadata in schema['properties'].items(): + propcpptypename = jscom.propmetadatatocpptypename(propmetadata) + if propcpptypename == jscom.CPP_TYPE_INTEGER: + writestackedlistenerfieldimplementation(istate, propname, 'event.ContentInteger()') + elif propcpptypename == jscom.CPP_TYPE_NUMBER: + writestackedlistenerfieldimplementation(istate, propname, 'event.ContentDouble()') + outfile.write(' fNextItemName.SetTo("");\n') + outfile.write(' break;\n') + outfile.write(' }\n') + + # object type; could be a sub-type or otherwise just drop into a placebo consumer to keep the parse + # structure working. This would most likely be additional sub-objects that are additional to the + # expected schema. + + outfile.write(' case B_JSON_OBJECT_START:\n') + outfile.write(' {\n') + + objectifclausekeyword = 'if' + + for propname, propmetadata in schema['properties'].items(): + if propmetadata['type'] == jscom.JSON_TYPE_OBJECT: + subtypenaming = CppParserSubTypeNaming(propmetadata, naming) + + outfile.write(' %s (fNextItemName == "%s") {\n' % (objectifclausekeyword, propname)) + outfile.write(' %s* nextListener = new %s(fMainListener, this);\n' % ( + subtypenaming.cppstackedlistenerclassname(), + subtypenaming.cppstackedlistenerclassname())) + outfile.write(' fTarget->Set%s(nextListener->Target());\n' % ( + subtypenaming.cppmodelclassname())) + outfile.write(' Push(nextListener);\n') + outfile.write(' }\n') + + objectifclausekeyword = 'else if' + + outfile.write(' %s (1 == 1) {\n' % objectifclausekeyword) + outfile.write(' %s* nextListener = new %s(fMainListener, this);\n' % ( + naming.cppgeneralobjectstackedlistenerclassname(), + naming.cppgeneralobjectstackedlistenerclassname())) + outfile.write(' Push(nextListener);\n') + outfile.write(' }\n') + outfile.write(' fNextItemName.SetTo("");\n') + outfile.write(' break;\n') + outfile.write(' }\n') + + # array type; could be an array of objects or otherwise just drop into a placebo consumer to keep + # the parse structure working. + + outfile.write(' case B_JSON_ARRAY_START:\n') + outfile.write(' {\n') + + objectifclausekeyword = 'if' + + for propname, propmetadata in schema['properties'].items(): + if propmetadata['type'] == jscom.JSON_TYPE_ARRAY: + subtypenaming = CppParserSubTypeNaming(propmetadata['items'], naming) + + outfile.write(' %s (fNextItemName == "%s") {\n' % (objectifclausekeyword, propname)) + outfile.write(' %s* nextListener = new %s(fMainListener, this);\n' % ( + subtypenaming.cppstackedlistlistenerclassname(), + subtypenaming.cppstackedlistlistenerclassname())) + outfile.write(' fTarget->Set%s(nextListener->Target());\n' % ( + jscom.propnametocppname(propname))) + outfile.write(' Push(nextListener);\n') + outfile.write(' }\n') + + objectifclausekeyword = 'else if' + + outfile.write(' %s (1 == 1) {\n' % objectifclausekeyword) + outfile.write(' %s* nextListener = new %s(fMainListener, this);\n' % ( + naming.cppsuperstackedlistenerclassname(), + naming.cppgeneralarraystackedlistenerclassname())) + outfile.write(' Push(nextListener);\n') + outfile.write(' }\n') + outfile.write(' fNextItemName.SetTo("");\n') + outfile.write(' break;\n') + outfile.write(' }\n') + + outfile.write(""" + } + + + return ErrorStatus() == B_OK; +} +""") + + +def writestackedlistenertypedobjectlistimplementation(istate, schema): + naming = istate.naming() + subtypenaming = CppParserSubTypeNaming(schema, naming) + outfile = istate.outputfile() + + outfile.write( + string.Template(""" +${subtype_cppstackedlistlistenerclassname}::${subtype_cppstackedlistlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, + ${cppsuperstackedlistenerclassname}* parent) + : + ${cppsuperstackedlistenerclassname}(mainListener, parent) +{ + fTarget = new List<${subtype_cppmodelclassname}*, true>(); +} + + +${subtype_cppstackedlistlistenerclassname}::~${subtype_cppstackedlistlistenerclassname}() +{ +} + + +List<${subtype_cppmodelclassname}*, true>* +${subtype_cppstackedlistlistenerclassname}::Target() +{ + return fTarget; +} + + +bool +${subtype_cppstackedlistlistenerclassname}::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + + case B_JSON_ARRAY_END: + { + bool status = Pop() && (ErrorStatus() == B_OK); + delete this; + return status; + } + + + case B_JSON_OBJECT_START: + { + ${subtype_cppstackedlistenerclassname}* nextListener = + new ${subtype_cppstackedlistenerclassname}(fMainListener, this); + fTarget->Add(nextListener->Target()); + Push(nextListener); + break; + } + + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing an array of ${subtype_cppmodelclassname}"); + break; + } + + + return ErrorStatus() == B_OK; +} +""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict()))) + + +def writebulkcontainerstackedlistenerimplementation(istate, schema): + naming = istate.naming() + subtypenaming = CppParserSubTypeNaming(schema, naming) + outfile = istate.outputfile() + + outfile.write( + string.Template(""" +${cppitemlistenerstackedlistenerclassname}::${cppitemlistenerstackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, ${cppsuperstackedlistenerclassname}* parent, + ${cppitemlistenerclassname}* itemListener) +: +${subtype_cppstackedlistenerclassname}(mainListener, parent) +{ + fItemListener = itemListener; +} + + +${cppitemlistenerstackedlistenerclassname}::~${cppitemlistenerstackedlistenerclassname}() +{ +} + + +bool +${cppitemlistenerstackedlistenerclassname}::WillPop() +{ + bool result = fItemListener->Handle(fTarget); + delete fTarget; + fTarget = NULL; + return result; +} + + +${cppbulkcontainerstackedlistenerclassname}::${cppbulkcontainerstackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, ${cppsuperstackedlistenerclassname}* parent, + ${cppitemlistenerclassname}* itemListener) +: +${cppsuperstackedlistenerclassname}(mainListener, parent) +{ + fItemListener = itemListener; +} + + +${cppbulkcontainerstackedlistenerclassname}::~${cppbulkcontainerstackedlistenerclassname}() +{ +} + + +bool +${cppbulkcontainerstackedlistenerclassname}::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); + break; + + + case B_JSON_OBJECT_NAME: + fNextItemName = event.Content(); + break; + + + case B_JSON_OBJECT_START: + Push(new ${cppgeneralobjectstackedlistenerclassname}(fMainListener, this)); + break; + + + case B_JSON_ARRAY_START: + if (fNextItemName == "items") + Push(new ${cppbulkcontaineritemliststackedlistenerclassname}(fMainListener, this, fItemListener)); + else + Push(new ${cppgeneralarraystackedlistenerclassname}(fMainListener, this)); + break; + + + case B_JSON_OBJECT_END: + { + bool status = Pop() && (ErrorStatus() == B_OK); + delete this; + return status; + } + + + default: + // ignore + break; + } + + + return ErrorStatus() == B_OK; +} + + +${cppbulkcontaineritemliststackedlistenerclassname}::${cppbulkcontaineritemliststackedlistenerclassname}( + ${cppsupermainlistenerclassname}* mainListener, ${cppsuperstackedlistenerclassname}* parent, + ${cppitemlistenerclassname}* itemListener) +: +${cppsuperstackedlistenerclassname}(mainListener, parent) +{ + fItemListener = itemListener; +} + + +${cppbulkcontaineritemliststackedlistenerclassname}::~${cppbulkcontaineritemliststackedlistenerclassname}() +{ +} + + +bool +${cppbulkcontaineritemliststackedlistenerclassname}::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + + case B_JSON_OBJECT_START: + Push(new ${cppitemlistenerstackedlistenerclassname}(fMainListener, this, fItemListener)); + break; + + + case B_JSON_ARRAY_END: + { + bool status = Pop() && (ErrorStatus() == B_OK); + delete this; + return status; + } + + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected json event"); + break; + } + + + return ErrorStatus() == B_OK; +} + + +bool +${cppbulkcontaineritemliststackedlistenerclassname}::WillPop() +{ + fItemListener->Complete(); + return true; +} + + +""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict()))) + + +def writestackedlistenerimplementation(istate, schema): + subtypenaming = CppParserSubTypeNaming(schema, istate.naming()) + + if not istate.isimplementationhandledcppname(subtypenaming.cppmodelclassname()): + istate.addimplementationhandledcppname(subtypenaming.cppmodelclassname()) + + writestackedlistenertypedobjectimplementation(istate, schema) + writestackedlistenertypedobjectlistimplementation(istate, schema) # TODO; only if necessary. + + # now create the parser types for any subordinate objects descending. + + for propname, propmetadata in schema['properties'].items(): + if propmetadata['type'] == 'array': + writestackedlistenerimplementation(istate, propmetadata['items']) + elif propmetadata['type'] == 'object': + writestackedlistenerimplementation(istate, propmetadata) + + +def writemainlistenerimplementation(istate, schema, supportbulkcontainer): + outfile = istate.outputfile() + naming = istate.naming() + subtypenaming = CppParserSubTypeNaming(schema, istate.naming()) + +# super (abstract) listener + + outfile.write( + string.Template(""" +${cppsupermainlistenerclassname}::${cppsupermainlistenerclassname}() +{ + fStackedListener = NULL; + fErrorStatus = B_OK; +} + + +${cppsupermainlistenerclassname}::~${cppsupermainlistenerclassname}() +{ +} + + +void +${cppsupermainlistenerclassname}::HandleError(status_t status, int32 line, const char* message) +{ + if (message != NULL) { + fprintf(stderr, "an error has arisen processing json for '${cpprootmodelclassname}'; %s\\n", message); + } else { + fprintf(stderr, "an error has arisen processing json for '${cpprootmodelclassname}'\\n"); + } + fErrorStatus = status; +} + + +void +${cppsupermainlistenerclassname}::Complete() +{ +} + + +status_t +${cppsupermainlistenerclassname}::ErrorStatus() +{ + return fErrorStatus; +} + +void +${cppsupermainlistenerclassname}::SetStackedListener( + ${cppsuperstackedlistenerclassname}* stackedListener) +{ + fStackedListener = stackedListener; +} + +""").substitute(naming.todict())) + +# single parser + + outfile.write( + string.Template(""" +${cppsinglemainlistenerclassname}::${cppsinglemainlistenerclassname}() +: +${cppsupermainlistenerclassname}() +{ + fTarget = NULL; +} + + +${cppsinglemainlistenerclassname}::~${cppsinglemainlistenerclassname}() +{ +} + + +bool +${cppsinglemainlistenerclassname}::Handle(const BJsonEvent& event) +{ + if (fErrorStatus != B_OK) + return false; + + + if (fStackedListener != NULL) + return fStackedListener->Handle(event); + + + switch (event.EventType()) { + + + case B_JSON_OBJECT_START: + { + ${subtype_cppstackedlistenerclassname}* nextListener = new ${subtype_cppstackedlistenerclassname}( + this, NULL); + fTarget = nextListener->Target(); + SetStackedListener(nextListener); + break; + } + + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing top level for ${cpprootmodelclassname}"); + break; + } + + + return ErrorStatus() == B_OK; +} + + +${cpprootmodelclassname}* +${cppsinglemainlistenerclassname}::Target() +{ + return fTarget; +} + +""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict()))) + + if supportbulkcontainer: + + # create a main listener that can work through the list of top level model objects and ping the listener + + outfile.write( + string.Template(""" +${cppbulkcontainermainlistenerclassname}::${cppbulkcontainermainlistenerclassname}( + ${cppitemlistenerclassname}* itemListener) : ${cppsupermainlistenerclassname}() +{ + fItemListener = itemListener; +} + + +${cppbulkcontainermainlistenerclassname}::~${cppbulkcontainermainlistenerclassname}() +{ +} + + +bool +${cppbulkcontainermainlistenerclassname}::Handle(const BJsonEvent& event) +{ + if (fErrorStatus != B_OK) + return false; + + + if (fStackedListener != NULL) + return fStackedListener->Handle(event); + + + switch (event.EventType()) { + + + case B_JSON_OBJECT_START: + { + ${cppbulkcontainerstackedlistenerclassname}* nextListener = + new ${cppbulkcontainerstackedlistenerclassname}( + this, NULL, fItemListener); + SetStackedListener(nextListener); + return true; + break; + } + + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing top level for ${cppbulkcontainermainlistenerclassname}"); + break; + } + + + return ErrorStatus() == B_OK; +} + +""").substitute(jscom.uniondicts(naming.todict(), subtypenaming.todict()))) + + +def schematocppparser(inputfile, schema, outputdirectory, supportbulkcontainer): + naming = CppParserNaming(schema) + cppheaderleafname = naming.cpprootmodelclassname() + 'JsonListener.h' + cppheaderfilename = os.path.join(outputdirectory, cppheaderleafname) + cppimplementationfilename = os.path.join(outputdirectory, naming.cpprootmodelclassname() + 'JsonListener.cpp') + + with open(cppheaderfilename, 'w') as cpphfile: + jscom.writetopcomment(cpphfile, os.path.split(inputfile)[1], 'Listener') + guarddefname = 'GEN_JSON_SCHEMA_PARSER__%s_H' % (naming.cppsinglemainlistenerclassname().upper()) + + cpphfile.write( + string.Template(""" +#ifndef ${guarddefname} +#define ${guarddefname} +""").substitute({'guarddefname': guarddefname})) + + cpphfile.write( + string.Template(""" +#include + +#include "${cpprootmodelclassname}.h" + +class ${cppsuperstackedlistenerclassname}; + +class ${cppsupermainlistenerclassname} : public BJsonEventListener { +friend class ${cppsuperstackedlistenerclassname}; +public: + ${cppsupermainlistenerclassname}(); + virtual ~${cppsupermainlistenerclassname}(); + + + void HandleError(status_t status, int32 line, const char* message); + void Complete(); + status_t ErrorStatus(); + + +protected: + void SetStackedListener( + ${cppsuperstackedlistenerclassname}* listener); + status_t fErrorStatus; + ${cppsuperstackedlistenerclassname}* fStackedListener; +}; + + +/*! Use this listener when you want to parse some JSON data that contains + just a single instance of ${cpprootmodelclassname}. +*/ +class ${cppsinglemainlistenerclassname} + : public ${cppsupermainlistenerclassname} { +friend class ${cppsuperstackedlistenerclassname}; +public: + ${cppsinglemainlistenerclassname}(); + virtual ~${cppsinglemainlistenerclassname}(); + + + bool Handle(const BJsonEvent& event); + ${cpprootmodelclassname}* Target(); + + +private: + ${cpprootmodelclassname}* fTarget; +}; + +""").substitute(naming.todict())) + +# class interface for concrete class of single listener + + + # If bulk enveloping is selected then also output a listener and an interface + # which can deal with call-backs. + + if supportbulkcontainer: + cpphfile.write( + string.Template(""" +/*! Concrete sub-classes of this class are able to respond to each + ${cpprootmodelclassname}* instance as + it is parsed from the bulk container. When the stream is + finished, the Complete() method is invoked. + + + Note that the item object will be deleted after the Handle method + is invoked. The Handle method need not take responsibility + for deleting the item itself. +*/ +class ${cppitemlistenerclassname} { +public: + virtual bool Handle(${cpprootmodelclassname}* item) = 0; + virtual void Complete() = 0; +}; +""").substitute(naming.todict())) + + cpphfile.write( + string.Template(""" + + +/*! Use this listener, together with an instance of a concrete + subclass of ${cppitemlistenerclassname} + in order to parse the JSON data in a specific "bulk + container" format. Each time that an instance of + ${cpprootmodelclassname} + is parsed, the instance item listener will be invoked. +*/ +class ${cppbulkcontainermainlistenerclassname} + : public ${cppsupermainlistenerclassname} { +friend class ${cppsuperstackedlistenerclassname}; +public: + ${cppbulkcontainermainlistenerclassname}( + ${cppitemlistenerclassname}* itemListener); + ~${cppbulkcontainermainlistenerclassname}(); + + + bool Handle(const BJsonEvent& event); + + +private: + ${cppitemlistenerclassname}* fItemListener; +}; +""").substitute(naming.todict())) + + cpphfile.write('\n#endif // %s' % guarddefname) + + with open(cppimplementationfilename, 'w') as cppifile: + istate = CppParserImplementationState(cppifile, naming) + jscom.writetopcomment(cppifile, os.path.split(inputfile)[1], 'Listener') + cppifile.write('#include "%s"\n' % cppheaderleafname) + cppifile.write('#include "List.h"\n\n') + cppifile.write('#include \n\n') + + cppifile.write('// #pragma mark - private interfaces for the stacked listeners\n\n') + + writerootstackedlistenerinterface(istate) + writegeneralstackedlistenerinterface(istate) + writestackedlistenerinterface(istate, schema) + + if supportbulkcontainer: + writebulkcontainerstackedlistenerinterface(istate, schema) + + cppifile.write('// #pragma mark - implementations for the stacked listeners\n\n') + + writerootstackedlistenerimplementation(istate) + writegeneralstackedlistenerimplementation(istate) + writestackedlistenerimplementation(istate, schema) + + if supportbulkcontainer: + writebulkcontainerstackedlistenerimplementation(istate, schema) + + cppifile.write('// #pragma mark - implementations for the main listeners\n\n') + + writemainlistenerimplementation(istate, schema, supportbulkcontainer) + + +def main(): + parser = argparse.ArgumentParser(description='Convert JSON schema to Haiku C++ Parsers') + parser.add_argument('-i', '--inputfile', required=True, help='The input filename containing the JSON schema') + parser.add_argument('--outputdirectory', help='The output directory where the C++ files should be written') + parser.add_argument('--supportbulkcontainer', help='Produce a parser that deals with a bulk envelope of items', + action='store_true') + + args = parser.parse_args() + + outputdirectory = args.outputdirectory + + if not outputdirectory: + outputdirectory = '.' + + with open(args.inputfile) as inputfile: + schema = json.load(inputfile) + schematocppparser(args.inputfile, schema, outputdirectory, args.supportbulkcontainer or False) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp b/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp index b87f7450f9..596a2a2a5c 100644 --- a/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp +++ b/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2017-2018, Andrew Lindesay . + * Copyright 2017-2019, Andrew Lindesay . * All rights reserved. Distributed under the terms of the MIT License. */ @@ -162,9 +162,6 @@ PackageFillingPkgListener::ConsumePackage(const PackageInfoRef& package, if (!pkg->ProminenceOrderingIsNull()) package->SetProminence(pkg->ProminenceOrdering()); - if (!pkg->PkgChangelogContentIsNull()) - package->SetChangelog(*(pkg->PkgChangelogContent())); - int32 countPkgScreenshots = pkg->CountPkgScreenshots(); for (i = 0; i < countPkgScreenshots; i++) { diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.cpp deleted file mode 100644 index 68108afb1d..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.116794 - */ -#include "DumpExportPkg.h" - - -DumpExportPkg::DumpExportPkg() -{ - fPkgChangelogContent = NULL; - fName = NULL; - fPkgVersions = NULL; - fDerivedRating = NULL; - fPkgScreenshots = NULL; - fProminenceOrdering = NULL; - fPkgCategories = NULL; - fModifyTimestamp = NULL; -} - - -DumpExportPkg::~DumpExportPkg() -{ - int32 i; - - if (fPkgChangelogContent != NULL) { - delete fPkgChangelogContent; - } - - if (fName != NULL) { - delete fName; - } - - if (fPkgVersions != NULL) { - int32 count = fPkgVersions->CountItems(); - for (i = 0; i < count; i++) - delete fPkgVersions->ItemAt(i); - delete fPkgVersions; - } - - if (fDerivedRating != NULL) { - delete fDerivedRating; - } - - if (fPkgScreenshots != NULL) { - int32 count = fPkgScreenshots->CountItems(); - for (i = 0; i < count; i++) - delete fPkgScreenshots->ItemAt(i); - delete fPkgScreenshots; - } - - if (fProminenceOrdering != NULL) { - delete fProminenceOrdering; - } - - if (fPkgCategories != NULL) { - int32 count = fPkgCategories->CountItems(); - for (i = 0; i < count; i++) - delete fPkgCategories->ItemAt(i); - delete fPkgCategories; - } - - if (fModifyTimestamp != NULL) { - delete fModifyTimestamp; - } - -} - -BString* -DumpExportPkg::PkgChangelogContent() -{ - return fPkgChangelogContent; -} - - -void -DumpExportPkg::SetPkgChangelogContent(BString* value) -{ - fPkgChangelogContent = value; -} - - -void -DumpExportPkg::SetPkgChangelogContentNull() -{ - if (!PkgChangelogContentIsNull()) { - delete fPkgChangelogContent; - fPkgChangelogContent = NULL; - } -} - - -bool -DumpExportPkg::PkgChangelogContentIsNull() -{ - return fPkgChangelogContent == NULL; -} - - -BString* -DumpExportPkg::Name() -{ - return fName; -} - - -void -DumpExportPkg::SetName(BString* value) -{ - fName = value; -} - - -void -DumpExportPkg::SetNameNull() -{ - if (!NameIsNull()) { - delete fName; - fName = NULL; - } -} - - -bool -DumpExportPkg::NameIsNull() -{ - return fName == NULL; -} - - -void -DumpExportPkg::AddToPkgVersions(DumpExportPkgVersion* value) -{ - if (fPkgVersions == NULL) - fPkgVersions = new List(); - fPkgVersions->Add(value); -} - - -void -DumpExportPkg::SetPkgVersions(List* value) -{ - fPkgVersions = value; -} - - -int32 -DumpExportPkg::CountPkgVersions() -{ - if (fPkgVersions == NULL) - return 0; - return fPkgVersions->CountItems(); -} - - -DumpExportPkgVersion* -DumpExportPkg::PkgVersionsItemAt(int32 index) -{ - return fPkgVersions->ItemAt(index); -} - - -bool -DumpExportPkg::PkgVersionsIsNull() -{ - return fPkgVersions == NULL; -} - - -double -DumpExportPkg::DerivedRating() -{ - return *fDerivedRating; -} - - -void -DumpExportPkg::SetDerivedRating(double value) -{ - if (DerivedRatingIsNull()) - fDerivedRating = new double[1]; - fDerivedRating[0] = value; -} - - -void -DumpExportPkg::SetDerivedRatingNull() -{ - if (!DerivedRatingIsNull()) { - delete fDerivedRating; - fDerivedRating = NULL; - } -} - - -bool -DumpExportPkg::DerivedRatingIsNull() -{ - return fDerivedRating == NULL; -} - - -void -DumpExportPkg::AddToPkgScreenshots(DumpExportPkgScreenshot* value) -{ - if (fPkgScreenshots == NULL) - fPkgScreenshots = new List(); - fPkgScreenshots->Add(value); -} - - -void -DumpExportPkg::SetPkgScreenshots(List* value) -{ - fPkgScreenshots = value; -} - - -int32 -DumpExportPkg::CountPkgScreenshots() -{ - if (fPkgScreenshots == NULL) - return 0; - return fPkgScreenshots->CountItems(); -} - - -DumpExportPkgScreenshot* -DumpExportPkg::PkgScreenshotsItemAt(int32 index) -{ - return fPkgScreenshots->ItemAt(index); -} - - -bool -DumpExportPkg::PkgScreenshotsIsNull() -{ - return fPkgScreenshots == NULL; -} - - -int64 -DumpExportPkg::ProminenceOrdering() -{ - return *fProminenceOrdering; -} - - -void -DumpExportPkg::SetProminenceOrdering(int64 value) -{ - if (ProminenceOrderingIsNull()) - fProminenceOrdering = new int64[1]; - fProminenceOrdering[0] = value; -} - - -void -DumpExportPkg::SetProminenceOrderingNull() -{ - if (!ProminenceOrderingIsNull()) { - delete fProminenceOrdering; - fProminenceOrdering = NULL; - } -} - - -bool -DumpExportPkg::ProminenceOrderingIsNull() -{ - return fProminenceOrdering == NULL; -} - - -void -DumpExportPkg::AddToPkgCategories(DumpExportPkgCategory* value) -{ - if (fPkgCategories == NULL) - fPkgCategories = new List(); - fPkgCategories->Add(value); -} - - -void -DumpExportPkg::SetPkgCategories(List* value) -{ - fPkgCategories = value; -} - - -int32 -DumpExportPkg::CountPkgCategories() -{ - if (fPkgCategories == NULL) - return 0; - return fPkgCategories->CountItems(); -} - - -DumpExportPkgCategory* -DumpExportPkg::PkgCategoriesItemAt(int32 index) -{ - return fPkgCategories->ItemAt(index); -} - - -bool -DumpExportPkg::PkgCategoriesIsNull() -{ - return fPkgCategories == NULL; -} - - -int64 -DumpExportPkg::ModifyTimestamp() -{ - return *fModifyTimestamp; -} - - -void -DumpExportPkg::SetModifyTimestamp(int64 value) -{ - if (ModifyTimestampIsNull()) - fModifyTimestamp = new int64[1]; - fModifyTimestamp[0] = value; -} - - -void -DumpExportPkg::SetModifyTimestampNull() -{ - if (!ModifyTimestampIsNull()) { - delete fModifyTimestamp; - fModifyTimestamp = NULL; - } -} - - -bool -DumpExportPkg::ModifyTimestampIsNull() -{ - return fModifyTimestamp == NULL; -} - diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.h deleted file mode 100644 index 4d0a97edbc..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.115160 - */ - -#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKG_H -#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKG_H - -#include "List.h" -#include "String.h" - -#include "DumpExportPkgVersion.h" -#include "DumpExportPkgScreenshot.h" -#include "DumpExportPkgCategory.h" - -class DumpExportPkg { -public: - DumpExportPkg(); - virtual ~DumpExportPkg(); - - BString* PkgChangelogContent(); - void SetPkgChangelogContent(BString* value); - void SetPkgChangelogContentNull(); - bool PkgChangelogContentIsNull(); - - BString* Name(); - void SetName(BString* value); - void SetNameNull(); - bool NameIsNull(); - - void AddToPkgVersions(DumpExportPkgVersion* value); - void SetPkgVersions(List* value); - int32 CountPkgVersions(); - DumpExportPkgVersion* PkgVersionsItemAt(int32 index); - bool PkgVersionsIsNull(); - - - double DerivedRating(); - void SetDerivedRating(double value); - void SetDerivedRatingNull(); - bool DerivedRatingIsNull(); - - void AddToPkgScreenshots(DumpExportPkgScreenshot* value); - void SetPkgScreenshots(List* value); - int32 CountPkgScreenshots(); - DumpExportPkgScreenshot* PkgScreenshotsItemAt(int32 index); - bool PkgScreenshotsIsNull(); - - - int64 ProminenceOrdering(); - void SetProminenceOrdering(int64 value); - void SetProminenceOrderingNull(); - bool ProminenceOrderingIsNull(); - - void AddToPkgCategories(DumpExportPkgCategory* value); - void SetPkgCategories(List* value); - int32 CountPkgCategories(); - DumpExportPkgCategory* PkgCategoriesItemAt(int32 index); - bool PkgCategoriesIsNull(); - - - int64 ModifyTimestamp(); - void SetModifyTimestamp(int64 value); - void SetModifyTimestampNull(); - bool ModifyTimestampIsNull(); - -private: - BString* fPkgChangelogContent; - BString* fName; - List * fPkgVersions; - double* fDerivedRating; - List * fPkgScreenshots; - int64* fProminenceOrdering; - List * fPkgCategories; - int64* fModifyTimestamp; -}; - -#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKG_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.cpp deleted file mode 100644 index dc42713917..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.118616 - */ -#include "DumpExportPkgCategory.h" - - -DumpExportPkgCategory::DumpExportPkgCategory() -{ - fCode = NULL; -} - - -DumpExportPkgCategory::~DumpExportPkgCategory() -{ - if (fCode != NULL) { - delete fCode; - } - -} - -BString* -DumpExportPkgCategory::Code() -{ - return fCode; -} - - -void -DumpExportPkgCategory::SetCode(BString* value) -{ - fCode = value; -} - - -void -DumpExportPkgCategory::SetCodeNull() -{ - if (!CodeIsNull()) { - delete fCode; - fCode = NULL; - } -} - - -bool -DumpExportPkgCategory::CodeIsNull() -{ - return fCode == NULL; -} - diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.h deleted file mode 100644 index bef12f0bd4..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.118521 - */ - -#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGCATEGORY_H -#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGCATEGORY_H - -#include "List.h" -#include "String.h" - - -class DumpExportPkgCategory { -public: - DumpExportPkgCategory(); - virtual ~DumpExportPkgCategory(); - - BString* Code(); - void SetCode(BString* value); - void SetCodeNull(); - bool CodeIsNull(); - -private: - BString* fCode; -}; - -#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGCATEGORY_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.cpp deleted file mode 100644 index 4af8f45994..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.cpp +++ /dev/null @@ -1,1347 +0,0 @@ -/* - * Generated Listener Object - * source json-schema : dumpexport.json - * generated at : 2017-12-17T20:45:25.516772 - */ -#include "DumpExportPkgJsonListener.h" -#include "List.h" - -#include - -// #pragma mark - private interfaces for the stacked listeners - - -/*! This class is the top level of the stacked listeners. The stack structure - is maintained in a linked list and sub-classes implement specific behaviors - depending where in the parse tree the stacked listener is working at. -*/ -class AbstractStackedDumpExportPkgJsonListener : public BJsonEventListener { -public: - AbstractStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~AbstractStackedDumpExportPkgJsonListener(); - - void HandleError(status_t status, int32 line, const char* message); - void Complete(); - - status_t ErrorStatus(); - - AbstractStackedDumpExportPkgJsonListener* Parent(); - - virtual bool WillPop(); - -protected: - AbstractMainDumpExportPkgJsonListener* fMainListener; - - bool Pop(); - void Push(AbstractStackedDumpExportPkgJsonListener* stackedListener); - -private: - AbstractStackedDumpExportPkgJsonListener* fParent; -}; - -class GeneralArrayStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - GeneralArrayStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~GeneralArrayStackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); -}; - -class GeneralObjectStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - GeneralObjectStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~GeneralObjectStackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); -}; - -class DumpExportPkg_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkg_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkg_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - DumpExportPkg* Target(); - -protected: - DumpExportPkg* fTarget; - BString fNextItemName; -}; - -class DumpExportPkg_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkg_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkg_List_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - List* Target(); // list of %s pointers - -private: - List* fTarget; -}; - -class DumpExportPkgVersion_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkgVersion_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkgVersion_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - DumpExportPkgVersion* Target(); - -protected: - DumpExportPkgVersion* fTarget; - BString fNextItemName; -}; - -class DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - List* Target(); // list of %s pointers - -private: - List* fTarget; -}; - -class DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - DumpExportPkgScreenshot* Target(); - -protected: - DumpExportPkgScreenshot* fTarget; - BString fNextItemName; -}; - -class DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - List* Target(); // list of %s pointers - -private: - List* fTarget; -}; - -class DumpExportPkgCategory_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkgCategory_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkgCategory_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - DumpExportPkgCategory* Target(); - -protected: - DumpExportPkgCategory* fTarget; - BString fNextItemName; -}; - -class DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent); - ~DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - - List* Target(); // list of %s pointers - -private: - List* fTarget; -}; - -class ItemEmittingStackedDumpExportPkgJsonListener : public DumpExportPkg_StackedDumpExportPkgJsonListener { -public: - ItemEmittingStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent, - DumpExportPkgListener* itemListener); - ~ItemEmittingStackedDumpExportPkgJsonListener(); - - bool WillPop(); - -private: - DumpExportPkgListener* fItemListener; -}; - - -class BulkContainerStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - BulkContainerStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent, - DumpExportPkgListener* itemListener); - ~BulkContainerStackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - -private: - BString fNextItemName; - DumpExportPkgListener* fItemListener; -}; - - -class BulkContainerItemsStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { -public: - BulkContainerItemsStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent, - DumpExportPkgListener* itemListener); - ~BulkContainerItemsStackedDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - bool WillPop(); - -private: - DumpExportPkgListener* fItemListener; -}; -// #pragma mark - implementations for the stacked listeners - - -AbstractStackedDumpExportPkgJsonListener::AbstractStackedDumpExportPkgJsonListener ( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) -{ - fMainListener = mainListener; - fParent = parent; -} - -AbstractStackedDumpExportPkgJsonListener::~AbstractStackedDumpExportPkgJsonListener() -{ -} - -void -AbstractStackedDumpExportPkgJsonListener::HandleError(status_t status, int32 line, const char* message) -{ - fMainListener->HandleError(status, line, message); -} - -void -AbstractStackedDumpExportPkgJsonListener::Complete() -{ - fMainListener->Complete(); -} - -status_t -AbstractStackedDumpExportPkgJsonListener::ErrorStatus() -{ - return fMainListener->ErrorStatus(); -} - -AbstractStackedDumpExportPkgJsonListener* -AbstractStackedDumpExportPkgJsonListener::Parent() -{ - return fParent; -} - -void -AbstractStackedDumpExportPkgJsonListener::Push(AbstractStackedDumpExportPkgJsonListener* stackedListener) -{ - fMainListener->SetStackedListener(stackedListener); -} - -bool -AbstractStackedDumpExportPkgJsonListener::WillPop() -{ - return true; -} - -bool -AbstractStackedDumpExportPkgJsonListener::Pop() -{ - bool result = WillPop(); - fMainListener->SetStackedListener(fParent); - return result; -} - -GeneralObjectStackedDumpExportPkgJsonListener::GeneralObjectStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ -} - -GeneralObjectStackedDumpExportPkgJsonListener::~GeneralObjectStackedDumpExportPkgJsonListener() -{ -} - -bool -GeneralObjectStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_OBJECT_NAME: - case B_JSON_NUMBER: - case B_JSON_STRING: - case B_JSON_TRUE: - case B_JSON_FALSE: - case B_JSON_NULL: - // ignore - break; - - case B_JSON_OBJECT_START: - Push(new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_START: - Push(new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of array"); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - } - - return ErrorStatus() == B_OK; -} - -GeneralArrayStackedDumpExportPkgJsonListener::GeneralArrayStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ -} - -GeneralArrayStackedDumpExportPkgJsonListener::~GeneralArrayStackedDumpExportPkgJsonListener() -{ -} - -bool -GeneralArrayStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_OBJECT_NAME: - case B_JSON_NUMBER: - case B_JSON_STRING: - case B_JSON_TRUE: - case B_JSON_FALSE: - case B_JSON_NULL: - // ignore - break; - - case B_JSON_OBJECT_START: - Push(new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_START: - Push(new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this)); - break; - - case B_JSON_OBJECT_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of object"); - break; - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkg_StackedDumpExportPkgJsonListener::DumpExportPkg_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new DumpExportPkg(); -} - - -DumpExportPkg_StackedDumpExportPkgJsonListener::~DumpExportPkg_StackedDumpExportPkgJsonListener() -{ -} - - -DumpExportPkg* -DumpExportPkg_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkg_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_STRING: - - if (fNextItemName == "pkgChangelogContent") - fTarget->SetPkgChangelogContent(new BString(event.Content())); - - if (fNextItemName == "name") - fTarget->SetName(new BString(event.Content())); - fNextItemName.SetTo(""); - break; - case B_JSON_TRUE: - fNextItemName.SetTo(""); - break; - case B_JSON_FALSE: - fNextItemName.SetTo(""); - break; - case B_JSON_NULL: - { - - if (fNextItemName == "pkgChangelogContent") - fTarget->SetPkgChangelogContentNull(); - - if (fNextItemName == "name") - fTarget->SetNameNull(); - - if (fNextItemName == "derivedRating") - fTarget->SetDerivedRatingNull(); - - if (fNextItemName == "prominenceOrdering") - fTarget->SetProminenceOrderingNull(); - - if (fNextItemName == "modifyTimestamp") - fTarget->SetModifyTimestampNull(); - fNextItemName.SetTo(""); - break; - } - case B_JSON_NUMBER: - { - - if (fNextItemName == "derivedRating") - fTarget->SetDerivedRating(event.ContentDouble()); - - if (fNextItemName == "prominenceOrdering") - fTarget->SetProminenceOrdering(event.ContentInteger()); - - if (fNextItemName == "modifyTimestamp") - fTarget->SetModifyTimestamp(event.ContentInteger()); - fNextItemName.SetTo(""); - break; - } - case B_JSON_OBJECT_START: - { - if (1 == 1) { - GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - case B_JSON_ARRAY_START: - { - if (fNextItemName == "pkgVersions") { - DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener(fMainListener, this); - fTarget->SetPkgVersions(nextListener->Target()); - Push(nextListener); - } - else if (fNextItemName == "pkgScreenshots") { - DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener(fMainListener, this); - fTarget->SetPkgScreenshots(nextListener->Target()); - Push(nextListener); - } - else if (fNextItemName == "pkgCategories") { - DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener(fMainListener, this); - fTarget->SetPkgCategories(nextListener->Target()); - Push(nextListener); - } - else if (1 == 1) { - AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkg_List_StackedDumpExportPkgJsonListener::DumpExportPkg_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new List(); -} - - -DumpExportPkg_List_StackedDumpExportPkgJsonListener::~DumpExportPkg_List_StackedDumpExportPkgJsonListener() -{ -} - - -List* -DumpExportPkg_List_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkg_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_OBJECT_START: - { - DumpExportPkg_StackedDumpExportPkgJsonListener* nextListener = - new DumpExportPkg_StackedDumpExportPkgJsonListener(fMainListener, this); - fTarget->Add(nextListener->Target()); - Push(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing an array of DumpExportPkg"); - break; - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkgVersion_StackedDumpExportPkgJsonListener::DumpExportPkgVersion_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new DumpExportPkgVersion(); -} - - -DumpExportPkgVersion_StackedDumpExportPkgJsonListener::~DumpExportPkgVersion_StackedDumpExportPkgJsonListener() -{ -} - - -DumpExportPkgVersion* -DumpExportPkgVersion_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkgVersion_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_STRING: - - if (fNextItemName == "major") - fTarget->SetMajor(new BString(event.Content())); - - if (fNextItemName == "description") - fTarget->SetDescription(new BString(event.Content())); - - if (fNextItemName == "title") - fTarget->SetTitle(new BString(event.Content())); - - if (fNextItemName == "summary") - fTarget->SetSummary(new BString(event.Content())); - - if (fNextItemName == "micro") - fTarget->SetMicro(new BString(event.Content())); - - if (fNextItemName == "preRelease") - fTarget->SetPreRelease(new BString(event.Content())); - - if (fNextItemName == "architectureCode") - fTarget->SetArchitectureCode(new BString(event.Content())); - - if (fNextItemName == "minor") - fTarget->SetMinor(new BString(event.Content())); - fNextItemName.SetTo(""); - break; - case B_JSON_TRUE: - fNextItemName.SetTo(""); - break; - case B_JSON_FALSE: - fNextItemName.SetTo(""); - break; - case B_JSON_NULL: - { - - if (fNextItemName == "major") - fTarget->SetMajorNull(); - - if (fNextItemName == "payloadLength") - fTarget->SetPayloadLengthNull(); - - if (fNextItemName == "description") - fTarget->SetDescriptionNull(); - - if (fNextItemName == "title") - fTarget->SetTitleNull(); - - if (fNextItemName == "summary") - fTarget->SetSummaryNull(); - - if (fNextItemName == "micro") - fTarget->SetMicroNull(); - - if (fNextItemName == "preRelease") - fTarget->SetPreReleaseNull(); - - if (fNextItemName == "architectureCode") - fTarget->SetArchitectureCodeNull(); - - if (fNextItemName == "minor") - fTarget->SetMinorNull(); - - if (fNextItemName == "revision") - fTarget->SetRevisionNull(); - fNextItemName.SetTo(""); - break; - } - case B_JSON_NUMBER: - { - - if (fNextItemName == "payloadLength") - fTarget->SetPayloadLength(event.ContentInteger()); - - if (fNextItemName == "revision") - fTarget->SetRevision(event.ContentInteger()); - fNextItemName.SetTo(""); - break; - } - case B_JSON_OBJECT_START: - { - if (1 == 1) { - GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - case B_JSON_ARRAY_START: - { - if (1 == 1) { - AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new List(); -} - - -DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::~DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener() -{ -} - - -List* -DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_OBJECT_START: - { - DumpExportPkgVersion_StackedDumpExportPkgJsonListener* nextListener = - new DumpExportPkgVersion_StackedDumpExportPkgJsonListener(fMainListener, this); - fTarget->Add(nextListener->Target()); - Push(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing an array of DumpExportPkgVersion"); - break; - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new DumpExportPkgScreenshot(); -} - - -DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::~DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener() -{ -} - - -DumpExportPkgScreenshot* -DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_STRING: - - if (fNextItemName == "code") - fTarget->SetCode(new BString(event.Content())); - fNextItemName.SetTo(""); - break; - case B_JSON_TRUE: - fNextItemName.SetTo(""); - break; - case B_JSON_FALSE: - fNextItemName.SetTo(""); - break; - case B_JSON_NULL: - { - - if (fNextItemName == "ordering") - fTarget->SetOrderingNull(); - - if (fNextItemName == "width") - fTarget->SetWidthNull(); - - if (fNextItemName == "length") - fTarget->SetLengthNull(); - - if (fNextItemName == "code") - fTarget->SetCodeNull(); - - if (fNextItemName == "height") - fTarget->SetHeightNull(); - fNextItemName.SetTo(""); - break; - } - case B_JSON_NUMBER: - { - - if (fNextItemName == "ordering") - fTarget->SetOrdering(event.ContentInteger()); - - if (fNextItemName == "width") - fTarget->SetWidth(event.ContentInteger()); - - if (fNextItemName == "length") - fTarget->SetLength(event.ContentInteger()); - - if (fNextItemName == "height") - fTarget->SetHeight(event.ContentInteger()); - fNextItemName.SetTo(""); - break; - } - case B_JSON_OBJECT_START: - { - if (1 == 1) { - GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - case B_JSON_ARRAY_START: - { - if (1 == 1) { - AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new List(); -} - - -DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::~DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener() -{ -} - - -List* -DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_OBJECT_START: - { - DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener* nextListener = - new DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener(fMainListener, this); - fTarget->Add(nextListener->Target()); - Push(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing an array of DumpExportPkgScreenshot"); - break; - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkgCategory_StackedDumpExportPkgJsonListener::DumpExportPkgCategory_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new DumpExportPkgCategory(); -} - - -DumpExportPkgCategory_StackedDumpExportPkgJsonListener::~DumpExportPkgCategory_StackedDumpExportPkgJsonListener() -{ -} - - -DumpExportPkgCategory* -DumpExportPkgCategory_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkgCategory_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_STRING: - - if (fNextItemName == "code") - fTarget->SetCode(new BString(event.Content())); - fNextItemName.SetTo(""); - break; - case B_JSON_TRUE: - fNextItemName.SetTo(""); - break; - case B_JSON_FALSE: - fNextItemName.SetTo(""); - break; - case B_JSON_NULL: - { - - if (fNextItemName == "code") - fTarget->SetCodeNull(); - fNextItemName.SetTo(""); - break; - } - case B_JSON_NUMBER: - { - fNextItemName.SetTo(""); - break; - } - case B_JSON_OBJECT_START: - { - if (1 == 1) { - GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - case B_JSON_ARRAY_START: - { - if (1 == 1) { - AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, - AbstractStackedDumpExportPkgJsonListener* parent) - : - AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fTarget = new List(); -} - - -DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::~DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener() -{ -} - - -List* -DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_OBJECT_START: - { - DumpExportPkgCategory_StackedDumpExportPkgJsonListener* nextListener = - new DumpExportPkgCategory_StackedDumpExportPkgJsonListener(fMainListener, this); - fTarget->Add(nextListener->Target()); - Push(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing an array of DumpExportPkgCategory"); - break; - } - - return ErrorStatus() == B_OK; -} - -ItemEmittingStackedDumpExportPkgJsonListener::ItemEmittingStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, AbstractStackedDumpExportPkgJsonListener* parent, - DumpExportPkgListener* itemListener) -: -DumpExportPkg_StackedDumpExportPkgJsonListener(mainListener, parent) -{ - fItemListener = itemListener; -} - - -ItemEmittingStackedDumpExportPkgJsonListener::~ItemEmittingStackedDumpExportPkgJsonListener() -{ -} - - -bool -ItemEmittingStackedDumpExportPkgJsonListener::WillPop() -{ - bool result = fItemListener->Handle(fTarget); - delete fTarget; - fTarget = NULL; - return result; -} - - -BulkContainerStackedDumpExportPkgJsonListener::BulkContainerStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, AbstractStackedDumpExportPkgJsonListener* parent, - DumpExportPkgListener* itemListener) -: -AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fItemListener = itemListener; -} - - -BulkContainerStackedDumpExportPkgJsonListener::~BulkContainerStackedDumpExportPkgJsonListener() -{ -} - - -bool -BulkContainerStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_START: - Push(new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_START: - if (fNextItemName == "items") - Push(new BulkContainerItemsStackedDumpExportPkgJsonListener(fMainListener, this, fItemListener)); - else - Push(new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this)); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - default: - // ignore - break; - } - - return ErrorStatus() == B_OK; -} - - -BulkContainerItemsStackedDumpExportPkgJsonListener::BulkContainerItemsStackedDumpExportPkgJsonListener( - AbstractMainDumpExportPkgJsonListener* mainListener, AbstractStackedDumpExportPkgJsonListener* parent, - DumpExportPkgListener* itemListener) -: -AbstractStackedDumpExportPkgJsonListener(mainListener, parent) -{ - fItemListener = itemListener; -} - - -BulkContainerItemsStackedDumpExportPkgJsonListener::~BulkContainerItemsStackedDumpExportPkgJsonListener() -{ -} - - -bool -BulkContainerItemsStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_OBJECT_START: - Push(new ItemEmittingStackedDumpExportPkgJsonListener(fMainListener, this, fItemListener)); - break; - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected json event"); - break; - } - - return ErrorStatus() == B_OK; -} - - -bool -BulkContainerItemsStackedDumpExportPkgJsonListener::WillPop() -{ - fItemListener->Complete(); - return true; -} - - -// #pragma mark - implementations for the main listeners - - -AbstractMainDumpExportPkgJsonListener::AbstractMainDumpExportPkgJsonListener() -{ - fStackedListener = NULL; - fErrorStatus = B_OK; -} - - -AbstractMainDumpExportPkgJsonListener::~AbstractMainDumpExportPkgJsonListener() -{ -} - - -void -AbstractMainDumpExportPkgJsonListener::HandleError(status_t status, int32 line, const char* message) -{ - if (message != NULL) { - fprintf(stderr, "an error has arisen processing json for 'DumpExportPkg'; %s\n", message); - } else { - fprintf(stderr, "an error has arisen processing json for 'DumpExportPkg'\n"); - } - fErrorStatus = status; -} - - -void -AbstractMainDumpExportPkgJsonListener::Complete() -{ -} - - -status_t -AbstractMainDumpExportPkgJsonListener::ErrorStatus() -{ - return fErrorStatus; -} - -void -AbstractMainDumpExportPkgJsonListener::SetStackedListener( - AbstractStackedDumpExportPkgJsonListener* stackedListener) -{ - fStackedListener = stackedListener; -} - - -SingleDumpExportPkgJsonListener::SingleDumpExportPkgJsonListener() -: -AbstractMainDumpExportPkgJsonListener() -{ - fTarget = NULL; -} - - -SingleDumpExportPkgJsonListener::~SingleDumpExportPkgJsonListener() -{ -} - - -bool -SingleDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - if (fErrorStatus != B_OK) - return false; - - if (fStackedListener != NULL) - return fStackedListener->Handle(event); - - switch (event.EventType()) { - - case B_JSON_OBJECT_START: - { - DumpExportPkg_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkg_StackedDumpExportPkgJsonListener( - this, NULL); - fTarget = nextListener->Target(); - SetStackedListener(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing top level for DumpExportPkg"); - break; - } - - return ErrorStatus() == B_OK; -} - - -DumpExportPkg* -SingleDumpExportPkgJsonListener::Target() -{ - return fTarget; -} - - -BulkContainerDumpExportPkgJsonListener::BulkContainerDumpExportPkgJsonListener( - DumpExportPkgListener* itemListener) : AbstractMainDumpExportPkgJsonListener() -{ - fItemListener = itemListener; -} - - -BulkContainerDumpExportPkgJsonListener::~BulkContainerDumpExportPkgJsonListener() -{ -} - - -bool -BulkContainerDumpExportPkgJsonListener::Handle(const BJsonEvent& event) -{ - if (fErrorStatus != B_OK) - return false; - - if (fStackedListener != NULL) - return fStackedListener->Handle(event); - - switch (event.EventType()) { - - case B_JSON_OBJECT_START: - { - BulkContainerStackedDumpExportPkgJsonListener* nextListener = - new BulkContainerStackedDumpExportPkgJsonListener( - this, NULL, fItemListener); - SetStackedListener(nextListener); - return true; - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing top level for BulkContainerDumpExportPkgJsonListener"); - break; - } - - return ErrorStatus() == B_OK; -} - diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.h deleted file mode 100644 index f9166b65f9..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Generated Listener Object - * source json-schema : dumpexport.json - * generated at : 2017-12-17T20:45:25.514143 - */ - -#ifndef GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTPKGJSONLISTENER_H -#define GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTPKGJSONLISTENER_H - -#include - -#include "DumpExportPkg.h" - -class AbstractStackedDumpExportPkgJsonListener; - -class AbstractMainDumpExportPkgJsonListener : public BJsonEventListener { -friend class AbstractStackedDumpExportPkgJsonListener; -public: - AbstractMainDumpExportPkgJsonListener(); - virtual ~AbstractMainDumpExportPkgJsonListener(); - - void HandleError(status_t status, int32 line, const char* message); - void Complete(); - status_t ErrorStatus(); - -protected: - void SetStackedListener( - AbstractStackedDumpExportPkgJsonListener* listener); - status_t fErrorStatus; - AbstractStackedDumpExportPkgJsonListener* fStackedListener; -}; - - -/*! Use this listener when you want to parse some JSON data that contains - just a single instance of DumpExportPkg. -*/ -class SingleDumpExportPkgJsonListener - : public AbstractMainDumpExportPkgJsonListener { -friend class AbstractStackedDumpExportPkgJsonListener; -public: - SingleDumpExportPkgJsonListener(); - virtual ~SingleDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - DumpExportPkg* Target(); - -private: - DumpExportPkg* fTarget; -}; - - -/*! Concrete sub-classes of this class are able to respond to each - DumpExportPkg* instance as - it is parsed from the bulk container. When the stream is - finished, the Complete() method is invoked. - - Note that the item object will be deleted after the Handle method - is invoked. The Handle method need not take responsibility - for deleting the item itself. -*/ -class DumpExportPkgListener { -public: - virtual bool Handle(DumpExportPkg* item) = 0; - virtual void Complete() = 0; -}; - - -/*! Use this listener, together with an instance of a concrete - subclass of DumpExportPkgListener - in order to parse the JSON data in a specific "bulk - container" format. Each time that an instance of - DumpExportPkg - is parsed, the instance item listener will be invoked. -*/ -class BulkContainerDumpExportPkgJsonListener - : public AbstractMainDumpExportPkgJsonListener { -friend class AbstractStackedDumpExportPkgJsonListener; -public: - BulkContainerDumpExportPkgJsonListener( - DumpExportPkgListener* itemListener); - ~BulkContainerDumpExportPkgJsonListener(); - - bool Handle(const BJsonEvent& event); - -private: - DumpExportPkgListener* fItemListener; -}; - -#endif // GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTPKGJSONLISTENER_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.cpp deleted file mode 100644 index 66ead56d24..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.118221 - */ -#include "DumpExportPkgScreenshot.h" - - -DumpExportPkgScreenshot::DumpExportPkgScreenshot() -{ - fOrdering = NULL; - fWidth = NULL; - fLength = NULL; - fCode = NULL; - fHeight = NULL; -} - - -DumpExportPkgScreenshot::~DumpExportPkgScreenshot() -{ - if (fOrdering != NULL) { - delete fOrdering; - } - - if (fWidth != NULL) { - delete fWidth; - } - - if (fLength != NULL) { - delete fLength; - } - - if (fCode != NULL) { - delete fCode; - } - - if (fHeight != NULL) { - delete fHeight; - } - -} - -int64 -DumpExportPkgScreenshot::Ordering() -{ - return *fOrdering; -} - - -void -DumpExportPkgScreenshot::SetOrdering(int64 value) -{ - if (OrderingIsNull()) - fOrdering = new int64[1]; - fOrdering[0] = value; -} - - -void -DumpExportPkgScreenshot::SetOrderingNull() -{ - if (!OrderingIsNull()) { - delete fOrdering; - fOrdering = NULL; - } -} - - -bool -DumpExportPkgScreenshot::OrderingIsNull() -{ - return fOrdering == NULL; -} - - -int64 -DumpExportPkgScreenshot::Width() -{ - return *fWidth; -} - - -void -DumpExportPkgScreenshot::SetWidth(int64 value) -{ - if (WidthIsNull()) - fWidth = new int64[1]; - fWidth[0] = value; -} - - -void -DumpExportPkgScreenshot::SetWidthNull() -{ - if (!WidthIsNull()) { - delete fWidth; - fWidth = NULL; - } -} - - -bool -DumpExportPkgScreenshot::WidthIsNull() -{ - return fWidth == NULL; -} - - -int64 -DumpExportPkgScreenshot::Length() -{ - return *fLength; -} - - -void -DumpExportPkgScreenshot::SetLength(int64 value) -{ - if (LengthIsNull()) - fLength = new int64[1]; - fLength[0] = value; -} - - -void -DumpExportPkgScreenshot::SetLengthNull() -{ - if (!LengthIsNull()) { - delete fLength; - fLength = NULL; - } -} - - -bool -DumpExportPkgScreenshot::LengthIsNull() -{ - return fLength == NULL; -} - - -BString* -DumpExportPkgScreenshot::Code() -{ - return fCode; -} - - -void -DumpExportPkgScreenshot::SetCode(BString* value) -{ - fCode = value; -} - - -void -DumpExportPkgScreenshot::SetCodeNull() -{ - if (!CodeIsNull()) { - delete fCode; - fCode = NULL; - } -} - - -bool -DumpExportPkgScreenshot::CodeIsNull() -{ - return fCode == NULL; -} - - -int64 -DumpExportPkgScreenshot::Height() -{ - return *fHeight; -} - - -void -DumpExportPkgScreenshot::SetHeight(int64 value) -{ - if (HeightIsNull()) - fHeight = new int64[1]; - fHeight[0] = value; -} - - -void -DumpExportPkgScreenshot::SetHeightNull() -{ - if (!HeightIsNull()) { - delete fHeight; - fHeight = NULL; - } -} - - -bool -DumpExportPkgScreenshot::HeightIsNull() -{ - return fHeight == NULL; -} - diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.h deleted file mode 100644 index 823746a04b..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.118049 - */ - -#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGSCREENSHOT_H -#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGSCREENSHOT_H - -#include "List.h" -#include "String.h" - - -class DumpExportPkgScreenshot { -public: - DumpExportPkgScreenshot(); - virtual ~DumpExportPkgScreenshot(); - - - int64 Ordering(); - void SetOrdering(int64 value); - void SetOrderingNull(); - bool OrderingIsNull(); - - - int64 Width(); - void SetWidth(int64 value); - void SetWidthNull(); - bool WidthIsNull(); - - - int64 Length(); - void SetLength(int64 value); - void SetLengthNull(); - bool LengthIsNull(); - - BString* Code(); - void SetCode(BString* value); - void SetCodeNull(); - bool CodeIsNull(); - - - int64 Height(); - void SetHeight(int64 value); - void SetHeightNull(); - bool HeightIsNull(); - -private: - int64* fOrdering; - int64* fWidth; - int64* fLength; - BString* fCode; - int64* fHeight; -}; - -#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGSCREENSHOT_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.cpp deleted file mode 100644 index 94d7ae67f5..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.117543 - */ -#include "DumpExportPkgVersion.h" - - -DumpExportPkgVersion::DumpExportPkgVersion() -{ - fMajor = NULL; - fPayloadLength = NULL; - fDescription = NULL; - fTitle = NULL; - fSummary = NULL; - fMicro = NULL; - fPreRelease = NULL; - fArchitectureCode = NULL; - fMinor = NULL; - fRevision = NULL; -} - - -DumpExportPkgVersion::~DumpExportPkgVersion() -{ - if (fMajor != NULL) { - delete fMajor; - } - - if (fPayloadLength != NULL) { - delete fPayloadLength; - } - - if (fDescription != NULL) { - delete fDescription; - } - - if (fTitle != NULL) { - delete fTitle; - } - - if (fSummary != NULL) { - delete fSummary; - } - - if (fMicro != NULL) { - delete fMicro; - } - - if (fPreRelease != NULL) { - delete fPreRelease; - } - - if (fArchitectureCode != NULL) { - delete fArchitectureCode; - } - - if (fMinor != NULL) { - delete fMinor; - } - - if (fRevision != NULL) { - delete fRevision; - } - -} - -BString* -DumpExportPkgVersion::Major() -{ - return fMajor; -} - - -void -DumpExportPkgVersion::SetMajor(BString* value) -{ - fMajor = value; -} - - -void -DumpExportPkgVersion::SetMajorNull() -{ - if (!MajorIsNull()) { - delete fMajor; - fMajor = NULL; - } -} - - -bool -DumpExportPkgVersion::MajorIsNull() -{ - return fMajor == NULL; -} - - -int64 -DumpExportPkgVersion::PayloadLength() -{ - return *fPayloadLength; -} - - -void -DumpExportPkgVersion::SetPayloadLength(int64 value) -{ - if (PayloadLengthIsNull()) - fPayloadLength = new int64[1]; - fPayloadLength[0] = value; -} - - -void -DumpExportPkgVersion::SetPayloadLengthNull() -{ - if (!PayloadLengthIsNull()) { - delete fPayloadLength; - fPayloadLength = NULL; - } -} - - -bool -DumpExportPkgVersion::PayloadLengthIsNull() -{ - return fPayloadLength == NULL; -} - - -BString* -DumpExportPkgVersion::Description() -{ - return fDescription; -} - - -void -DumpExportPkgVersion::SetDescription(BString* value) -{ - fDescription = value; -} - - -void -DumpExportPkgVersion::SetDescriptionNull() -{ - if (!DescriptionIsNull()) { - delete fDescription; - fDescription = NULL; - } -} - - -bool -DumpExportPkgVersion::DescriptionIsNull() -{ - return fDescription == NULL; -} - - -BString* -DumpExportPkgVersion::Title() -{ - return fTitle; -} - - -void -DumpExportPkgVersion::SetTitle(BString* value) -{ - fTitle = value; -} - - -void -DumpExportPkgVersion::SetTitleNull() -{ - if (!TitleIsNull()) { - delete fTitle; - fTitle = NULL; - } -} - - -bool -DumpExportPkgVersion::TitleIsNull() -{ - return fTitle == NULL; -} - - -BString* -DumpExportPkgVersion::Summary() -{ - return fSummary; -} - - -void -DumpExportPkgVersion::SetSummary(BString* value) -{ - fSummary = value; -} - - -void -DumpExportPkgVersion::SetSummaryNull() -{ - if (!SummaryIsNull()) { - delete fSummary; - fSummary = NULL; - } -} - - -bool -DumpExportPkgVersion::SummaryIsNull() -{ - return fSummary == NULL; -} - - -BString* -DumpExportPkgVersion::Micro() -{ - return fMicro; -} - - -void -DumpExportPkgVersion::SetMicro(BString* value) -{ - fMicro = value; -} - - -void -DumpExportPkgVersion::SetMicroNull() -{ - if (!MicroIsNull()) { - delete fMicro; - fMicro = NULL; - } -} - - -bool -DumpExportPkgVersion::MicroIsNull() -{ - return fMicro == NULL; -} - - -BString* -DumpExportPkgVersion::PreRelease() -{ - return fPreRelease; -} - - -void -DumpExportPkgVersion::SetPreRelease(BString* value) -{ - fPreRelease = value; -} - - -void -DumpExportPkgVersion::SetPreReleaseNull() -{ - if (!PreReleaseIsNull()) { - delete fPreRelease; - fPreRelease = NULL; - } -} - - -bool -DumpExportPkgVersion::PreReleaseIsNull() -{ - return fPreRelease == NULL; -} - - -BString* -DumpExportPkgVersion::ArchitectureCode() -{ - return fArchitectureCode; -} - - -void -DumpExportPkgVersion::SetArchitectureCode(BString* value) -{ - fArchitectureCode = value; -} - - -void -DumpExportPkgVersion::SetArchitectureCodeNull() -{ - if (!ArchitectureCodeIsNull()) { - delete fArchitectureCode; - fArchitectureCode = NULL; - } -} - - -bool -DumpExportPkgVersion::ArchitectureCodeIsNull() -{ - return fArchitectureCode == NULL; -} - - -BString* -DumpExportPkgVersion::Minor() -{ - return fMinor; -} - - -void -DumpExportPkgVersion::SetMinor(BString* value) -{ - fMinor = value; -} - - -void -DumpExportPkgVersion::SetMinorNull() -{ - if (!MinorIsNull()) { - delete fMinor; - fMinor = NULL; - } -} - - -bool -DumpExportPkgVersion::MinorIsNull() -{ - return fMinor == NULL; -} - - -int64 -DumpExportPkgVersion::Revision() -{ - return *fRevision; -} - - -void -DumpExportPkgVersion::SetRevision(int64 value) -{ - if (RevisionIsNull()) - fRevision = new int64[1]; - fRevision[0] = value; -} - - -void -DumpExportPkgVersion::SetRevisionNull() -{ - if (!RevisionIsNull()) { - delete fRevision; - fRevision = NULL; - } -} - - -bool -DumpExportPkgVersion::RevisionIsNull() -{ - return fRevision == NULL; -} - diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.h deleted file mode 100644 index 331e3b0efd..0000000000 --- a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:17.117333 - */ - -#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGVERSION_H -#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGVERSION_H - -#include "List.h" -#include "String.h" - - -class DumpExportPkgVersion { -public: - DumpExportPkgVersion(); - virtual ~DumpExportPkgVersion(); - - BString* Major(); - void SetMajor(BString* value); - void SetMajorNull(); - bool MajorIsNull(); - - - int64 PayloadLength(); - void SetPayloadLength(int64 value); - void SetPayloadLengthNull(); - bool PayloadLengthIsNull(); - - BString* Description(); - void SetDescription(BString* value); - void SetDescriptionNull(); - bool DescriptionIsNull(); - - BString* Title(); - void SetTitle(BString* value); - void SetTitleNull(); - bool TitleIsNull(); - - BString* Summary(); - void SetSummary(BString* value); - void SetSummaryNull(); - bool SummaryIsNull(); - - BString* Micro(); - void SetMicro(BString* value); - void SetMicroNull(); - bool MicroIsNull(); - - BString* PreRelease(); - void SetPreRelease(BString* value); - void SetPreReleaseNull(); - bool PreReleaseIsNull(); - - BString* ArchitectureCode(); - void SetArchitectureCode(BString* value); - void SetArchitectureCodeNull(); - bool ArchitectureCodeIsNull(); - - BString* Minor(); - void SetMinor(BString* value); - void SetMinorNull(); - bool MinorIsNull(); - - - int64 Revision(); - void SetRevision(int64 value); - void SetRevisionNull(); - bool RevisionIsNull(); - -private: - BString* fMajor; - int64* fPayloadLength; - BString* fDescription; - BString* fTitle; - BString* fSummary; - BString* fMicro; - BString* fPreRelease; - BString* fArchitectureCode; - BString* fMinor; - int64* fRevision; -}; - -#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGVERSION_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.cpp b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.cpp deleted file mode 100644 index c572f22580..0000000000 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:33.021497 - */ -#include "DumpExportRepository.h" - - -DumpExportRepository::DumpExportRepository() -{ - fInformationUrl = NULL; - fCode = NULL; - fRepositorySources = NULL; - fName = NULL; - fDescription = NULL; -} - - -DumpExportRepository::~DumpExportRepository() -{ - int32 i; - - if (fInformationUrl != NULL) { - delete fInformationUrl; - } - - if (fCode != NULL) { - delete fCode; - } - - if (fRepositorySources != NULL) { - int32 count = fRepositorySources->CountItems(); - for (i = 0; i < count; i++) - delete fRepositorySources->ItemAt(i); - delete fRepositorySources; - } - - if (fName != NULL) { - delete fName; - } - - if (fDescription != NULL) { - delete fDescription; - } - -} - -BString* -DumpExportRepository::InformationUrl() -{ - return fInformationUrl; -} - - -void -DumpExportRepository::SetInformationUrl(BString* value) -{ - fInformationUrl = value; -} - - -void -DumpExportRepository::SetInformationUrlNull() -{ - if (!InformationUrlIsNull()) { - delete fInformationUrl; - fInformationUrl = NULL; - } -} - - -bool -DumpExportRepository::InformationUrlIsNull() -{ - return fInformationUrl == NULL; -} - - -BString* -DumpExportRepository::Code() -{ - return fCode; -} - - -void -DumpExportRepository::SetCode(BString* value) -{ - fCode = value; -} - - -void -DumpExportRepository::SetCodeNull() -{ - if (!CodeIsNull()) { - delete fCode; - fCode = NULL; - } -} - - -bool -DumpExportRepository::CodeIsNull() -{ - return fCode == NULL; -} - - -void -DumpExportRepository::AddToRepositorySources(DumpExportRepositorySource* value) -{ - if (fRepositorySources == NULL) - fRepositorySources = new List(); - fRepositorySources->Add(value); -} - - -void -DumpExportRepository::SetRepositorySources(List* value) -{ - fRepositorySources = value; -} - - -int32 -DumpExportRepository::CountRepositorySources() -{ - if (fRepositorySources == NULL) - return 0; - return fRepositorySources->CountItems(); -} - - -DumpExportRepositorySource* -DumpExportRepository::RepositorySourcesItemAt(int32 index) -{ - return fRepositorySources->ItemAt(index); -} - - -bool -DumpExportRepository::RepositorySourcesIsNull() -{ - return fRepositorySources == NULL; -} - - -BString* -DumpExportRepository::Name() -{ - return fName; -} - - -void -DumpExportRepository::SetName(BString* value) -{ - fName = value; -} - - -void -DumpExportRepository::SetNameNull() -{ - if (!NameIsNull()) { - delete fName; - fName = NULL; - } -} - - -bool -DumpExportRepository::NameIsNull() -{ - return fName == NULL; -} - - -BString* -DumpExportRepository::Description() -{ - return fDescription; -} - - -void -DumpExportRepository::SetDescription(BString* value) -{ - fDescription = value; -} - - -void -DumpExportRepository::SetDescriptionNull() -{ - if (!DescriptionIsNull()) { - delete fDescription; - fDescription = NULL; - } -} - - -bool -DumpExportRepository::DescriptionIsNull() -{ - return fDescription == NULL; -} - diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.h b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.h deleted file mode 100644 index c337a27e8d..0000000000 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:33.020747 - */ - -#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORY_H -#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORY_H - -#include "List.h" -#include "String.h" - -#include "DumpExportRepositorySource.h" - -class DumpExportRepository { -public: - DumpExportRepository(); - virtual ~DumpExportRepository(); - - BString* InformationUrl(); - void SetInformationUrl(BString* value); - void SetInformationUrlNull(); - bool InformationUrlIsNull(); - - BString* Code(); - void SetCode(BString* value); - void SetCodeNull(); - bool CodeIsNull(); - - void AddToRepositorySources(DumpExportRepositorySource* value); - void SetRepositorySources(List* value); - int32 CountRepositorySources(); - DumpExportRepositorySource* RepositorySourcesItemAt(int32 index); - bool RepositorySourcesIsNull(); - - BString* Name(); - void SetName(BString* value); - void SetNameNull(); - bool NameIsNull(); - - BString* Description(); - void SetDescription(BString* value); - void SetDescriptionNull(); - bool DescriptionIsNull(); - -private: - BString* fInformationUrl; - BString* fCode; - List * fRepositorySources; - BString* fName; - BString* fDescription; -}; - -#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORY_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.cpp b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.cpp deleted file mode 100644 index 68b4002147..0000000000 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.cpp +++ /dev/null @@ -1,917 +0,0 @@ -/* - * Generated Listener Object - * source json-schema : dumpexport.json - * generated at : 2017-12-18T23:07:02.401765 - */ -#include "DumpExportRepositoryJsonListener.h" -#include "List.h" - -#include - -// #pragma mark - private interfaces for the stacked listeners - - -/*! This class is the top level of the stacked listeners. The stack structure - is maintained in a linked list and sub-classes implement specific behaviors - depending where in the parse tree the stacked listener is working at. -*/ -class AbstractStackedDumpExportRepositoryJsonListener : public BJsonEventListener { -public: - AbstractStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent); - ~AbstractStackedDumpExportRepositoryJsonListener(); - - void HandleError(status_t status, int32 line, const char* message); - void Complete(); - - status_t ErrorStatus(); - - AbstractStackedDumpExportRepositoryJsonListener* Parent(); - - virtual bool WillPop(); - -protected: - AbstractMainDumpExportRepositoryJsonListener* fMainListener; - - bool Pop(); - void Push(AbstractStackedDumpExportRepositoryJsonListener* stackedListener); - -private: - AbstractStackedDumpExportRepositoryJsonListener* fParent; -}; - -class GeneralArrayStackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - GeneralArrayStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent); - ~GeneralArrayStackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); -}; - -class GeneralObjectStackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - GeneralObjectStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent); - ~GeneralObjectStackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); -}; - -class DumpExportRepository_StackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - DumpExportRepository_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent); - ~DumpExportRepository_StackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - - DumpExportRepository* Target(); - -protected: - DumpExportRepository* fTarget; - BString fNextItemName; -}; - -class DumpExportRepository_List_StackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - DumpExportRepository_List_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent); - ~DumpExportRepository_List_StackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - - List* Target(); // list of %s pointers - -private: - List* fTarget; -}; - -class DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent); - ~DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - - DumpExportRepositorySource* Target(); - -protected: - DumpExportRepositorySource* fTarget; - BString fNextItemName; -}; - -class DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent); - ~DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - - List* Target(); // list of %s pointers - -private: - List* fTarget; -}; - -class ItemEmittingStackedDumpExportRepositoryJsonListener : public DumpExportRepository_StackedDumpExportRepositoryJsonListener { -public: - ItemEmittingStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent, - DumpExportRepositoryListener* itemListener); - ~ItemEmittingStackedDumpExportRepositoryJsonListener(); - - bool WillPop(); - -private: - DumpExportRepositoryListener* fItemListener; -}; - - -class BulkContainerStackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - BulkContainerStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent, - DumpExportRepositoryListener* itemListener); - ~BulkContainerStackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - -private: - BString fNextItemName; - DumpExportRepositoryListener* fItemListener; -}; - - -class BulkContainerItemsStackedDumpExportRepositoryJsonListener : public AbstractStackedDumpExportRepositoryJsonListener { -public: - BulkContainerItemsStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent, - DumpExportRepositoryListener* itemListener); - ~BulkContainerItemsStackedDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - bool WillPop(); - -private: - DumpExportRepositoryListener* fItemListener; -}; -// #pragma mark - implementations for the stacked listeners - - -AbstractStackedDumpExportRepositoryJsonListener::AbstractStackedDumpExportRepositoryJsonListener ( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent) -{ - fMainListener = mainListener; - fParent = parent; -} - -AbstractStackedDumpExportRepositoryJsonListener::~AbstractStackedDumpExportRepositoryJsonListener() -{ -} - -void -AbstractStackedDumpExportRepositoryJsonListener::HandleError(status_t status, int32 line, const char* message) -{ - fMainListener->HandleError(status, line, message); -} - -void -AbstractStackedDumpExportRepositoryJsonListener::Complete() -{ - fMainListener->Complete(); -} - -status_t -AbstractStackedDumpExportRepositoryJsonListener::ErrorStatus() -{ - return fMainListener->ErrorStatus(); -} - -AbstractStackedDumpExportRepositoryJsonListener* -AbstractStackedDumpExportRepositoryJsonListener::Parent() -{ - return fParent; -} - -void -AbstractStackedDumpExportRepositoryJsonListener::Push(AbstractStackedDumpExportRepositoryJsonListener* stackedListener) -{ - fMainListener->SetStackedListener(stackedListener); -} - -bool -AbstractStackedDumpExportRepositoryJsonListener::WillPop() -{ - return true; -} - -bool -AbstractStackedDumpExportRepositoryJsonListener::Pop() -{ - bool result = WillPop(); - fMainListener->SetStackedListener(fParent); - return result; -} - -GeneralObjectStackedDumpExportRepositoryJsonListener::GeneralObjectStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent) - : - AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ -} - -GeneralObjectStackedDumpExportRepositoryJsonListener::~GeneralObjectStackedDumpExportRepositoryJsonListener() -{ -} - -bool -GeneralObjectStackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_OBJECT_NAME: - case B_JSON_NUMBER: - case B_JSON_STRING: - case B_JSON_TRUE: - case B_JSON_FALSE: - case B_JSON_NULL: - // ignore - break; - - case B_JSON_OBJECT_START: - Push(new GeneralObjectStackedDumpExportRepositoryJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_START: - Push(new GeneralArrayStackedDumpExportRepositoryJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of array"); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - } - - return ErrorStatus() == B_OK; -} - -GeneralArrayStackedDumpExportRepositoryJsonListener::GeneralArrayStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent) - : - AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ -} - -GeneralArrayStackedDumpExportRepositoryJsonListener::~GeneralArrayStackedDumpExportRepositoryJsonListener() -{ -} - -bool -GeneralArrayStackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_OBJECT_NAME: - case B_JSON_NUMBER: - case B_JSON_STRING: - case B_JSON_TRUE: - case B_JSON_FALSE: - case B_JSON_NULL: - // ignore - break; - - case B_JSON_OBJECT_START: - Push(new GeneralObjectStackedDumpExportRepositoryJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_START: - Push(new GeneralArrayStackedDumpExportRepositoryJsonListener(fMainListener, this)); - break; - - case B_JSON_OBJECT_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of object"); - break; - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportRepository_StackedDumpExportRepositoryJsonListener::DumpExportRepository_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent) - : - AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ - fTarget = new DumpExportRepository(); -} - - -DumpExportRepository_StackedDumpExportRepositoryJsonListener::~DumpExportRepository_StackedDumpExportRepositoryJsonListener() -{ -} - - -DumpExportRepository* -DumpExportRepository_StackedDumpExportRepositoryJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportRepository_StackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_STRING: - - if (fNextItemName == "informationUrl") - fTarget->SetInformationUrl(new BString(event.Content())); - - if (fNextItemName == "code") - fTarget->SetCode(new BString(event.Content())); - - if (fNextItemName == "name") - fTarget->SetName(new BString(event.Content())); - - if (fNextItemName == "description") - fTarget->SetDescription(new BString(event.Content())); - fNextItemName.SetTo(""); - break; - case B_JSON_TRUE: - fNextItemName.SetTo(""); - break; - case B_JSON_FALSE: - fNextItemName.SetTo(""); - break; - case B_JSON_NULL: - { - - if (fNextItemName == "informationUrl") - fTarget->SetInformationUrlNull(); - - if (fNextItemName == "code") - fTarget->SetCodeNull(); - - if (fNextItemName == "name") - fTarget->SetNameNull(); - - if (fNextItemName == "description") - fTarget->SetDescriptionNull(); - fNextItemName.SetTo(""); - break; - } - case B_JSON_NUMBER: - { - fNextItemName.SetTo(""); - break; - } - case B_JSON_OBJECT_START: - { - if (1 == 1) { - GeneralObjectStackedDumpExportRepositoryJsonListener* nextListener = new GeneralObjectStackedDumpExportRepositoryJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - case B_JSON_ARRAY_START: - { - if (fNextItemName == "repositorySources") { - DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener* nextListener = new DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener(fMainListener, this); - fTarget->SetRepositorySources(nextListener->Target()); - Push(nextListener); - } - else if (1 == 1) { - AbstractStackedDumpExportRepositoryJsonListener* nextListener = new GeneralArrayStackedDumpExportRepositoryJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportRepository_List_StackedDumpExportRepositoryJsonListener::DumpExportRepository_List_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent) - : - AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ - fTarget = new List(); -} - - -DumpExportRepository_List_StackedDumpExportRepositoryJsonListener::~DumpExportRepository_List_StackedDumpExportRepositoryJsonListener() -{ -} - - -List* -DumpExportRepository_List_StackedDumpExportRepositoryJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportRepository_List_StackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_OBJECT_START: - { - DumpExportRepository_StackedDumpExportRepositoryJsonListener* nextListener = - new DumpExportRepository_StackedDumpExportRepositoryJsonListener(fMainListener, this); - fTarget->Add(nextListener->Target()); - Push(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing an array of DumpExportRepository"); - break; - } - - return ErrorStatus() == B_OK; -} - -DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener::DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent) - : - AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ - fTarget = new DumpExportRepositorySource(); -} - - -DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener::~DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener() -{ -} - - -DumpExportRepositorySource* -DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_STRING: - - if (fNextItemName == "url") - fTarget->SetUrl(new BString(event.Content())); - - if (fNextItemName == "repoInfoUrl") - fTarget->SetRepoInfoUrl(new BString(event.Content())); - - if (fNextItemName == "code") - fTarget->SetCode(new BString(event.Content())); - fNextItemName.SetTo(""); - break; - case B_JSON_TRUE: - fNextItemName.SetTo(""); - break; - case B_JSON_FALSE: - fNextItemName.SetTo(""); - break; - case B_JSON_NULL: - { - - if (fNextItemName == "url") - fTarget->SetUrlNull(); - - if (fNextItemName == "repoInfoUrl") - fTarget->SetRepoInfoUrlNull(); - - if (fNextItemName == "code") - fTarget->SetCodeNull(); - fNextItemName.SetTo(""); - break; - } - case B_JSON_NUMBER: - { - fNextItemName.SetTo(""); - break; - } - case B_JSON_OBJECT_START: - { - if (1 == 1) { - GeneralObjectStackedDumpExportRepositoryJsonListener* nextListener = new GeneralObjectStackedDumpExportRepositoryJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - case B_JSON_ARRAY_START: - { - if (1 == 1) { - AbstractStackedDumpExportRepositoryJsonListener* nextListener = new GeneralArrayStackedDumpExportRepositoryJsonListener(fMainListener, this); - Push(nextListener); - } - fNextItemName.SetTo(""); - break; - } - - } - - return ErrorStatus() == B_OK; -} - -DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener::DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, - AbstractStackedDumpExportRepositoryJsonListener* parent) - : - AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ - fTarget = new List(); -} - - -DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener::~DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener() -{ -} - - -List* -DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener::Target() -{ - return fTarget; -} - - -bool -DumpExportRepositorySource_List_StackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - case B_JSON_OBJECT_START: - { - DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener* nextListener = - new DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener(fMainListener, this); - fTarget->Add(nextListener->Target()); - Push(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing an array of DumpExportRepositorySource"); - break; - } - - return ErrorStatus() == B_OK; -} - -ItemEmittingStackedDumpExportRepositoryJsonListener::ItemEmittingStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, AbstractStackedDumpExportRepositoryJsonListener* parent, - DumpExportRepositoryListener* itemListener) -: -DumpExportRepository_StackedDumpExportRepositoryJsonListener(mainListener, parent) -{ - fItemListener = itemListener; -} - - -ItemEmittingStackedDumpExportRepositoryJsonListener::~ItemEmittingStackedDumpExportRepositoryJsonListener() -{ -} - - -bool -ItemEmittingStackedDumpExportRepositoryJsonListener::WillPop() -{ - bool result = fItemListener->Handle(fTarget); - delete fTarget; - fTarget = NULL; - return result; -} - - -BulkContainerStackedDumpExportRepositoryJsonListener::BulkContainerStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, AbstractStackedDumpExportRepositoryJsonListener* parent, - DumpExportRepositoryListener* itemListener) -: -AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ - fItemListener = itemListener; -} - - -BulkContainerStackedDumpExportRepositoryJsonListener::~BulkContainerStackedDumpExportRepositoryJsonListener() -{ -} - - -bool -BulkContainerStackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_ARRAY_END: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); - break; - - case B_JSON_OBJECT_NAME: - fNextItemName = event.Content(); - break; - - case B_JSON_OBJECT_START: - Push(new GeneralObjectStackedDumpExportRepositoryJsonListener(fMainListener, this)); - break; - - case B_JSON_ARRAY_START: - if (fNextItemName == "items") - Push(new BulkContainerItemsStackedDumpExportRepositoryJsonListener(fMainListener, this, fItemListener)); - else - Push(new GeneralArrayStackedDumpExportRepositoryJsonListener(fMainListener, this)); - break; - - case B_JSON_OBJECT_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - default: - // ignore - break; - } - - return ErrorStatus() == B_OK; -} - - -BulkContainerItemsStackedDumpExportRepositoryJsonListener::BulkContainerItemsStackedDumpExportRepositoryJsonListener( - AbstractMainDumpExportRepositoryJsonListener* mainListener, AbstractStackedDumpExportRepositoryJsonListener* parent, - DumpExportRepositoryListener* itemListener) -: -AbstractStackedDumpExportRepositoryJsonListener(mainListener, parent) -{ - fItemListener = itemListener; -} - - -BulkContainerItemsStackedDumpExportRepositoryJsonListener::~BulkContainerItemsStackedDumpExportRepositoryJsonListener() -{ -} - - -bool -BulkContainerItemsStackedDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - switch (event.EventType()) { - - case B_JSON_OBJECT_START: - Push(new ItemEmittingStackedDumpExportRepositoryJsonListener(fMainListener, this, fItemListener)); - break; - - case B_JSON_ARRAY_END: - { - bool status = Pop() && (ErrorStatus() == B_OK); - delete this; - return status; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected json event"); - break; - } - - return ErrorStatus() == B_OK; -} - - -bool -BulkContainerItemsStackedDumpExportRepositoryJsonListener::WillPop() -{ - fItemListener->Complete(); - return true; -} - - -// #pragma mark - implementations for the main listeners - - -AbstractMainDumpExportRepositoryJsonListener::AbstractMainDumpExportRepositoryJsonListener() -{ - fStackedListener = NULL; - fErrorStatus = B_OK; -} - - -AbstractMainDumpExportRepositoryJsonListener::~AbstractMainDumpExportRepositoryJsonListener() -{ -} - - -void -AbstractMainDumpExportRepositoryJsonListener::HandleError(status_t status, int32 line, const char* message) -{ - if (message != NULL) { - fprintf(stderr, "an error has arisen processing json for 'DumpExportRepository'; %s\n", message); - } else { - fprintf(stderr, "an error has arisen processing json for 'DumpExportRepository'\n"); - } - fErrorStatus = status; -} - - -void -AbstractMainDumpExportRepositoryJsonListener::Complete() -{ -} - - -status_t -AbstractMainDumpExportRepositoryJsonListener::ErrorStatus() -{ - return fErrorStatus; -} - -void -AbstractMainDumpExportRepositoryJsonListener::SetStackedListener( - AbstractStackedDumpExportRepositoryJsonListener* stackedListener) -{ - fStackedListener = stackedListener; -} - - -SingleDumpExportRepositoryJsonListener::SingleDumpExportRepositoryJsonListener() -: -AbstractMainDumpExportRepositoryJsonListener() -{ - fTarget = NULL; -} - - -SingleDumpExportRepositoryJsonListener::~SingleDumpExportRepositoryJsonListener() -{ -} - - -bool -SingleDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - if (fErrorStatus != B_OK) - return false; - - if (fStackedListener != NULL) - return fStackedListener->Handle(event); - - switch (event.EventType()) { - - case B_JSON_OBJECT_START: - { - DumpExportRepository_StackedDumpExportRepositoryJsonListener* nextListener = new DumpExportRepository_StackedDumpExportRepositoryJsonListener( - this, NULL); - fTarget = nextListener->Target(); - SetStackedListener(nextListener); - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing top level for DumpExportRepository"); - break; - } - - return ErrorStatus() == B_OK; -} - - -DumpExportRepository* -SingleDumpExportRepositoryJsonListener::Target() -{ - return fTarget; -} - - -BulkContainerDumpExportRepositoryJsonListener::BulkContainerDumpExportRepositoryJsonListener( - DumpExportRepositoryListener* itemListener) : AbstractMainDumpExportRepositoryJsonListener() -{ - fItemListener = itemListener; -} - - -BulkContainerDumpExportRepositoryJsonListener::~BulkContainerDumpExportRepositoryJsonListener() -{ -} - - -bool -BulkContainerDumpExportRepositoryJsonListener::Handle(const BJsonEvent& event) -{ - if (fErrorStatus != B_OK) - return false; - - if (fStackedListener != NULL) - return fStackedListener->Handle(event); - - switch (event.EventType()) { - - case B_JSON_OBJECT_START: - { - BulkContainerStackedDumpExportRepositoryJsonListener* nextListener = - new BulkContainerStackedDumpExportRepositoryJsonListener( - this, NULL, fItemListener); - SetStackedListener(nextListener); - return true; - break; - } - - default: - HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, - "illegal state - unexpected json event parsing top level for BulkContainerDumpExportRepositoryJsonListener"); - break; - } - - return ErrorStatus() == B_OK; -} - diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.h b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.h deleted file mode 100644 index f79ef0b572..0000000000 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Generated Listener Object - * source json-schema : dumpexport.json - * generated at : 2017-12-18T23:07:02.399681 - */ - -#ifndef GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTREPOSITORYJSONLISTENER_H -#define GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTREPOSITORYJSONLISTENER_H - -#include - -#include "DumpExportRepository.h" - -class AbstractStackedDumpExportRepositoryJsonListener; - -class AbstractMainDumpExportRepositoryJsonListener : public BJsonEventListener { -friend class AbstractStackedDumpExportRepositoryJsonListener; -public: - AbstractMainDumpExportRepositoryJsonListener(); - virtual ~AbstractMainDumpExportRepositoryJsonListener(); - - void HandleError(status_t status, int32 line, const char* message); - void Complete(); - status_t ErrorStatus(); - -protected: - void SetStackedListener( - AbstractStackedDumpExportRepositoryJsonListener* listener); - status_t fErrorStatus; - AbstractStackedDumpExportRepositoryJsonListener* fStackedListener; -}; - - -/*! Use this listener when you want to parse some JSON data that contains - just a single instance of DumpExportRepository. -*/ -class SingleDumpExportRepositoryJsonListener - : public AbstractMainDumpExportRepositoryJsonListener { -friend class AbstractStackedDumpExportRepositoryJsonListener; -public: - SingleDumpExportRepositoryJsonListener(); - virtual ~SingleDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - DumpExportRepository* Target(); - -private: - DumpExportRepository* fTarget; -}; - - -/*! Concrete sub-classes of this class are able to respond to each - DumpExportRepository* instance as - it is parsed from the bulk container. When the stream is - finished, the Complete() method is invoked. - - Note that the item object will be deleted after the Handle method - is invoked. The Handle method need not take responsibility - for deleting the item itself. -*/ -class DumpExportRepositoryListener { -public: - virtual bool Handle(DumpExportRepository* item) = 0; - virtual void Complete() = 0; -}; - - -/*! Use this listener, together with an instance of a concrete - subclass of DumpExportRepositoryListener - in order to parse the JSON data in a specific "bulk - container" format. Each time that an instance of - DumpExportRepository - is parsed, the instance item listener will be invoked. -*/ -class BulkContainerDumpExportRepositoryJsonListener - : public AbstractMainDumpExportRepositoryJsonListener { -friend class AbstractStackedDumpExportRepositoryJsonListener; -public: - BulkContainerDumpExportRepositoryJsonListener( - DumpExportRepositoryListener* itemListener); - ~BulkContainerDumpExportRepositoryJsonListener(); - - bool Handle(const BJsonEvent& event); - -private: - DumpExportRepositoryListener* fItemListener; -}; - -#endif // GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTREPOSITORYJSONLISTENER_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.cpp b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.cpp deleted file mode 100644 index d5fef59a26..0000000000 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:33.022114 - */ -#include "DumpExportRepositorySource.h" - - -DumpExportRepositorySource::DumpExportRepositorySource() -{ - fUrl = NULL; - fRepoInfoUrl = NULL; - fCode = NULL; -} - - -DumpExportRepositorySource::~DumpExportRepositorySource() -{ - if (fUrl != NULL) { - delete fUrl; - } - - if (fRepoInfoUrl != NULL) { - delete fRepoInfoUrl; - } - - if (fCode != NULL) { - delete fCode; - } - -} - -BString* -DumpExportRepositorySource::Url() -{ - return fUrl; -} - - -void -DumpExportRepositorySource::SetUrl(BString* value) -{ - fUrl = value; -} - - -void -DumpExportRepositorySource::SetUrlNull() -{ - if (!UrlIsNull()) { - delete fUrl; - fUrl = NULL; - } -} - - -bool -DumpExportRepositorySource::UrlIsNull() -{ - return fUrl == NULL; -} - - -BString* -DumpExportRepositorySource::RepoInfoUrl() -{ - return fRepoInfoUrl; -} - - -void -DumpExportRepositorySource::SetRepoInfoUrl(BString* value) -{ - fRepoInfoUrl = value; -} - - -void -DumpExportRepositorySource::SetRepoInfoUrlNull() -{ - if (!RepoInfoUrlIsNull()) { - delete fRepoInfoUrl; - fRepoInfoUrl = NULL; - } -} - - -bool -DumpExportRepositorySource::RepoInfoUrlIsNull() -{ - return fRepoInfoUrl == NULL; -} - - -BString* -DumpExportRepositorySource::Code() -{ - return fCode; -} - - -void -DumpExportRepositorySource::SetCode(BString* value) -{ - fCode = value; -} - - -void -DumpExportRepositorySource::SetCodeNull() -{ - if (!CodeIsNull()) { - delete fCode; - fCode = NULL; - } -} - - -bool -DumpExportRepositorySource::CodeIsNull() -{ - return fCode == NULL; -} - diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.h b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.h deleted file mode 100644 index a6be61264a..0000000000 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Generated Model Object - * source json-schema : dumpexport.json - * generated at : 2017-12-07T23:22:33.021952 - */ - -#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORYSOURCE_H -#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORYSOURCE_H - -#include "List.h" -#include "String.h" - - -class DumpExportRepositorySource { -public: - DumpExportRepositorySource(); - virtual ~DumpExportRepositorySource(); - - BString* Url(); - void SetUrl(BString* value); - void SetUrlNull(); - bool UrlIsNull(); - - BString* RepoInfoUrl(); - void SetRepoInfoUrl(BString* value); - void SetRepoInfoUrlNull(); - bool RepoInfoUrlIsNull(); - - BString* Code(); - void SetCode(BString* value); - void SetCodeNull(); - bool CodeIsNull(); - -private: - BString* fUrl; - BString* fRepoInfoUrl; - BString* fCode; -}; - -#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORYSOURCE_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/schema/dumpexportpkg.json b/src/apps/haikudepot/server/schema/dumpexportpkg.json new file mode 100644 index 0000000000..7130418385 --- /dev/null +++ b/src/apps/haikudepot/server/schema/dumpexportpkg.json @@ -0,0 +1,96 @@ +{ + "$schema": "http://json-schema.org/schema#", + "id": "http://depot.haiku-os.org/schema/pkg/dumpexport.json", + "title": "Pkg", + "javaType": "org.haiku.haikudepotserver.pkg.model.dumpexport.DumpExportPkg", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifyTimestamp": { + "type": "integer" + }, + "prominenceOrdering": { + "type": "integer" + }, + "derivedRating": { + "type": "number" + }, + "pkgScreenshots": { + "type": "array", + "items": { + "type": "object", + "javaType": "org.haiku.haikudepotserver.pkg.model.dumpexport.DumpExportPkgScreenshot", + "properties": { + "code": { + "type": "string" + }, + "length": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "ordering": { + "type": "integer" + } + } + } + }, + "pkgCategories": { + "type": "array", + "items": { + "type": "object", + "javaType": "org.haiku.haikudepotserver.pkg.model.dumpexport.DumpExportPkgCategory", + "properties": { + "code": { + "type": "string" + } + } + } + }, + "pkgVersions": { + "type": "array", + "items": { + "type": "object", + "javaType": "org.haiku.haikudepotserver.pkg.model.dumpexport.DumpExportPkgVersion", + "properties": { + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "micro": { + "type": "string" + }, + "preRelease": { + "type": "string" + }, + "revision": { + "type": "integer" + }, + "architectureCode": { + "type": "string" + }, + "title": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "description": { + "type": "string" + }, + "payloadLength": { + "type": "integer" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/apps/haikudepot/server/schema/dumpexportrepository.json b/src/apps/haikudepot/server/schema/dumpexportrepository.json new file mode 100644 index 0000000000..d4676aefae --- /dev/null +++ b/src/apps/haikudepot/server/schema/dumpexportrepository.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://json-schema.org/schema#", + "id": "http://depot.haiku-os.org/schema/repository/dumpexport.json", + "title": "Repository", + "javaType": "org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepository", + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "informationUrl": { + "type": "string" + }, + "repositorySources": { + "type": "array", + "items": { + "type": "object", + "javaType": "org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepositorySource", + "properties": { + "code": { + "type": "string" + }, + "url": { + "type": "string" + }, + "repoInfoUrl": { + "type": "string" + }, + "repositorySourceMirrors": { + "type": "array", + "items": { + "type": "object", + "javaType": "org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepositorySourceMirror", + "properties": { + "countryCode": { + "type": "string" + }, + "baseUrl": { + "type": "string" + }, + "description": { + "type": "string" + }, + "isPrimary": { + "type": "boolean" + } + } + } + } + } + } + } + } +} \ No newline at end of file