├── .gitignore
├── JSONExport.app
└── Contents
│ ├── Frameworks
│ ├── libswiftAppKit.dylib
│ ├── libswiftCore.dylib
│ ├── libswiftCoreData.dylib
│ ├── libswiftCoreGraphics.dylib
│ ├── libswiftCoreImage.dylib
│ ├── libswiftDarwin.dylib
│ ├── libswiftDispatch.dylib
│ ├── libswiftFoundation.dylib
│ └── libswiftObjectiveC.dylib
│ ├── Info.plist
│ ├── MacOS
│ └── JSONExport
│ ├── PkgInfo
│ ├── Resources
│ ├── AppIcon.icns
│ ├── Base.lproj
│ │ └── Main.storyboardc
│ │ │ ├── Info.plist
│ │ │ ├── MainMenu.nib
│ │ │ ├── NSWindowController-B8D-0N-5wS.nib
│ │ │ └── XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
│ ├── Swift-Class.json
│ ├── Swift-CoreData.json
│ ├── Swift-Mappable.json
│ ├── Swift-Realm.json
│ ├── Swift-Struct.json
│ └── SwiftyJSON-Class.json
│ └── _CodeSignature
│ └── CodeResources
├── JSONExport.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── xiaobo.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── ahmed.xcuserdatad
│ └── xcschemes
│ │ ├── JSONExport.xcscheme
│ │ └── xcschememanagement.plist
│ └── xiaobo.xcuserdatad
│ └── xcschemes
│ ├── JSONExport.xcscheme
│ └── xcschememanagement.plist
├── JSONExport
├── AppDelegate.swift
├── Base.lproj
│ └── Main.storyboard
├── Constructor.swift
├── DataType.swift
├── FileContentBuilder.swift
├── FilePreviewCell.swift
├── FileRepresenter.swift
├── HeaderFileData.swift
├── HeaderFileRepresenter.swift
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ ├── 128x128.png
│ │ ├── 16x16.png
│ │ ├── 256x256.png
│ │ ├── 32x32-1.png
│ │ ├── 32x32.png
│ │ ├── 64x64.png
│ │ └── Contents.json
├── Info.plist
├── JSONExport-Bridging-Header.h
├── LangModel.swift
├── NoodleLineNumberMarker.h
├── NoodleLineNumberMarker.m
├── NoodleLineNumberView.h
├── NoodleLineNumberView.m
├── Property.swift
├── SharedConstants.swift
├── SharedUtilityMethods.swift
├── StringExtension.swift
├── Supported Languages
│ ├── Swift-Class.json
│ ├── Swift-CoreData.json
│ ├── Swift-Mappable.json
│ ├── Swift-Realm.json
│ ├── Swift-Struct.json
│ └── SwiftyJSON-Class.json
├── UtilityMethod.swift
└── ViewController.swift
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | JSONExport.xcodeproj/project.xcworkspace/xcshareddata/JSONExport.xccheckout
3 | JSONExport.xcodeproj/project.xcworkspace/xcuserdata/ahmed.xcuserdatad/UserInterfaceState.xcuserstate
4 | JSONExport.xcodeproj/xcuserdata/ahmed.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
5 | JSONExport.xcodeproj/project.xcworkspace/xcuserdata/ahmedali.xcuserdatad/UserInterfaceState.xcuserstate
6 | JSONExport.xcodeproj/xcuserdata/ahmedali.xcuserdatad/xcschemes/JSONExport.xcscheme
7 | JSONExport.xcodeproj/xcuserdata/ahmedali.xcuserdatad/xcschemes/xcschememanagement.plist
8 |
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftAppKit.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftAppKit.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftCore.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftCore.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftCoreData.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftCoreData.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftCoreGraphics.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftCoreGraphics.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftCoreImage.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftCoreImage.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftDarwin.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftDarwin.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftDispatch.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftDispatch.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftFoundation.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftFoundation.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Frameworks/libswiftObjectiveC.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Frameworks/libswiftObjectiveC.dylib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildMachineOSBuild
6 | 15E65
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleExecutable
10 | JSONExport
11 | CFBundleIconFile
12 | AppIcon
13 | CFBundleIdentifier
14 | ahmed.ali.JSONExport
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | JSONExport
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | 1.0.0
23 | CFBundleSignature
24 | ????
25 | CFBundleSupportedPlatforms
26 |
27 | MacOSX
28 |
29 | CFBundleVersion
30 | 1
31 | DTCompiler
32 | com.apple.compilers.llvm.clang.1_0
33 | DTPlatformBuild
34 | 7D175
35 | DTPlatformVersion
36 | GM
37 | DTSDKBuild
38 | 15E60
39 | DTSDKName
40 | macosx10.11
41 | DTXcode
42 | 0730
43 | DTXcodeBuild
44 | 7D175
45 | LSMinimumSystemVersion
46 | 10.10
47 | NSHumanReadableCopyright
48 | Copyright © 2014 Ahmed Ali. All rights reserved.
49 | NSMainStoryboardFile
50 | Main
51 | NSPrincipalClass
52 | NSApplication
53 |
54 |
55 |
--------------------------------------------------------------------------------
/JSONExport.app/Contents/MacOS/JSONExport:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/MacOS/JSONExport
--------------------------------------------------------------------------------
/JSONExport.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/AppIcon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Resources/AppIcon.icns
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.app/Contents/Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Swift-Class.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "reservedKeywords": [
5 | "abstract",
6 | "assert",
7 | "boolean",
8 | "break",
9 | "byte",
10 | "case",
11 | "catch",
12 | "char",
13 | "class",
14 | "const",
15 | "continue",
16 | "default",
17 | "do",
18 | "double",
19 | "else",
20 | "enum",
21 | "extends",
22 | "false",
23 | "final",
24 | "finally",
25 | "float",
26 | "for",
27 | "goto",
28 | "if",
29 | "implements",
30 | "import",
31 | "instanceof",
32 | "int",
33 | "interface",
34 | "long",
35 | "native",
36 | "new",
37 | "null",
38 | "package",
39 | "private",
40 | "protected",
41 | "public",
42 | "return",
43 | "short",
44 | "static",
45 | "strictfp",
46 | "super",
47 | "switch",
48 | "synchronized",
49 | "this",
50 | "throw",
51 | "throws",
52 | "transient",
53 | "true",
54 | "try",
55 | "void",
56 | "volatile",
57 | "while",
58 | "class",
59 | "description"
60 | ],
61 | "booleanGetter": "",
62 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
63 | "utilityMethods": [
64 | {
65 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
66 | "bodyEnd": "\t}\n",
67 | "signature": "\tfunc toDictionary() -> NSDictionary",
68 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
69 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
70 | "returnStatement": "\t\treturn dictionary\n",
71 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
72 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
73 | "bodyStart": "\n\t{\n"
74 | },
75 | {
76 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
77 | "bodyEnd": "\n\t}\n",
78 | "signature": " @objc required init(coder aDecoder: NSCoder)",
79 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
80 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
81 | "returnStatement": "",
82 | "body": "",
83 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
84 | "bodyStart": "\n\t{\n"
85 | },
86 | {
87 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
88 | "bodyEnd": "\n\t}\n",
89 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
90 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
91 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
92 | "returnStatement": "",
93 | "body": "",
94 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
95 | "bodyStart": "\n\t{\n"
96 | }
97 | ],
98 | "dataTypes": {
99 | "stringType": "String",
100 | "boolType": "Bool",
101 | "floatType": "Float",
102 | "doubleType": "Double",
103 | "characterType": "Character",
104 | "longType": "Double",
105 | "intType": "Int"
106 | },
107 | "wordsToRemoveToGetArrayElementsType": [
108 | "[",
109 | "]"
110 | ],
111 | "defaultParentWithUtilityMethods": "NSObject, NSCoding",
112 | "constructors": [
113 | {
114 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
115 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\t = (fromDictionary: Data)\n\t\t}\n",
116 | "bodyEnd": "\t}\n",
117 | "fetchBasicTypePropertyFromMap": "\t\t = dictionary[\"\"] as? \n",
118 | "signature": "\tinit(fromDictionary dictionary: NSDictionary)",
119 | "fetchArrayOfCustomTypePropertyFromMap": "\t\t = ()\n\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = (fromDictionary: dic)\n\t\t\t\t.append(value)\n\t\t\t}\n\t\t}\n",
120 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
121 | "bodyStart": "{\n"
122 | }
123 | ],
124 | "modelDefinition": "\nclass ",
125 | "genericType": "AnyObject",
126 | "getter": "",
127 | "setter": "",
128 | "displayLangName": "Swift - Class",
129 | "fileExtension": "swift",
130 | "basicTypesWithSpecialFetchingNeeds": [
131 | ],
132 | "arrayType": "[]",
133 | "modelDefinitionWithParent": "\n\nclass : ",
134 | "instanceVarDefinition": "\tvar : !\n",
135 | "supportsFirstLineStatement": "false",
136 | "modelEnd": "\n}",
137 | "staticImports": "import Foundation",
138 | "langName": "Swift"
139 | }
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Swift-CoreData.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "supportMutualRelationships": "true",
5 | "basicTypesWithSpecialStoringNeeds": [
6 | "Int",
7 | "Bool",
8 | "Character",
9 | "Float",
10 | "Double"
11 | ],
12 | "reservedKeywords": [
13 | "abstract",
14 | "assert",
15 | "boolean",
16 | "break",
17 | "byte",
18 | "case",
19 | "catch",
20 | "char",
21 | "class",
22 | "const",
23 | "continue",
24 | "default",
25 | "do",
26 | "double",
27 | "else",
28 | "enum",
29 | "extends",
30 | "false",
31 | "final",
32 | "finally",
33 | "float",
34 | "for",
35 | "goto",
36 | "if",
37 | "implements",
38 | "import",
39 | "instanceof",
40 | "int",
41 | "interface",
42 | "long",
43 | "native",
44 | "new",
45 | "null",
46 | "package",
47 | "private",
48 | "protected",
49 | "public",
50 | "return",
51 | "short",
52 | "static",
53 | "strictfp",
54 | "super",
55 | "switch",
56 | "synchronized",
57 | "this",
58 | "throw",
59 | "throws",
60 | "transient",
61 | "true",
62 | "try",
63 | "void",
64 | "volatile",
65 | "while",
66 | "class",
67 | "description"
68 | ],
69 | "booleanGetter": "",
70 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
71 | "instanceVarWithSpeicalDefinition": "\t@NSManaged var : \n",
72 | "utilityMethods": [
73 | {
74 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
75 | "bodyEnd": "\t}\n",
76 | "signature": "\tfunc toDictionary() -> NSDictionary",
77 | "forEachPropertyWithSpecialStoringNeeds": "\t\tdictionary[\"\"] = \n",
78 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
79 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
80 | "returnStatement": "\t\treturn dictionary\n",
81 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
82 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
83 | "bodyStart": "\n\t{\n"
84 | }
85 | ],
86 | "dataTypes": {
87 | "stringType": "String",
88 | "boolType": "Bool",
89 | "floatType": "Float",
90 | "doubleType": "Double",
91 | "characterType": "Character",
92 | "longType": "Double",
93 | "intType": "Int"
94 | },
95 | "wordsToRemoveToGetArrayElementsType": [
96 | "[",
97 | "]"
98 | ],
99 | "constructors": [
100 | {
101 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\t = Value\n\t\t}\n",
102 | "bodyStart": "\t{\n\t\tlet entity = NSEntityDescription.entityForName(\"\", inManagedObjectContext: context)!\n\t\tsuper.init(entity: entity, insertIntoManagedObjectContext: context)\n",
103 | "bodyEnd": "\t}\n",
104 | "fetchBasicTypePropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\t = Value\n\t\t}\n",
105 | "signature": "\tinit(fromDictionary dictionary: NSDictionary, context: NSManagedObjectContext)",
106 | "fetchArrayOfCustomTypePropertyFromMap": "\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tvar Set = NSMutableSet()\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = (fromDictionary: dic, context:context)\n\t\t\t\tSet.addObject(value)\n\t\t\t}\n\t\t\t = Set\n\t\t}\n",
107 | "comment": "\t/**\n\t * Instantiate the instance using the passed dictionary values to set the properties values\n\t */\n",
108 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\t = (fromDictionary: Data, context:context)\n\t\t}\n"
109 | }
110 | ],
111 | "modelDefinition": "\nclass : NSManagedObject",
112 | "genericType": "AnyObject",
113 | "getter": "",
114 | "setter": "",
115 | "fileExtension": "swift",
116 | "arrayType": "NSMutableSet",
117 | "modelDefinitionWithParent": "\n\nclass : ",
118 | "displayLangName": "Swift - CoreData",
119 | "basicTypesWithSpecialFetchingNeeds": [
120 | "Int",
121 | "Bool",
122 | "Character",
123 | "Float",
124 | "Double"
125 | ],
126 | "instanceVarDefinition": "\t@NSManaged var : !\n",
127 | "supportsFirstLineStatement": "false",
128 | "modelEnd": "\n}",
129 | "typesNeedSpecialDefinition": [
130 | "Int",
131 | "Bool",
132 | "Character",
133 | "Float",
134 | "Double"
135 | ],
136 | "staticImports": "import Foundation\nimport CoreData",
137 | "langName": "Swift"
138 | }
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Swift-Mappable.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "reservedKeywords": [
5 | "abstract",
6 | "assert",
7 | "boolean",
8 | "break",
9 | "byte",
10 | "case",
11 | "catch",
12 | "char",
13 | "class",
14 | "const",
15 | "continue",
16 | "default",
17 | "do",
18 | "double",
19 | "else",
20 | "enum",
21 | "extends",
22 | "false",
23 | "final",
24 | "finally",
25 | "float",
26 | "for",
27 | "goto",
28 | "if",
29 | "implements",
30 | "import",
31 | "instanceof",
32 | "int",
33 | "interface",
34 | "long",
35 | "native",
36 | "new",
37 | "null",
38 | "package",
39 | "private",
40 | "protected",
41 | "public",
42 | "return",
43 | "short",
44 | "static",
45 | "strictfp",
46 | "super",
47 | "switch",
48 | "synchronized",
49 | "this",
50 | "throw",
51 | "throws",
52 | "transient",
53 | "true",
54 | "try",
55 | "void",
56 | "volatile",
57 | "while",
58 | "class",
59 | "description"
60 | ],
61 | "booleanGetter": "",
62 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
63 | "utilityMethods": [
64 | {
65 | "forEachProperty": "\t\t <- map[\"\"]\n",
66 | "bodyEnd": "\t}\n",
67 | "signature": "\tfunc mapping(map: Map)",
68 | "forEachCustomTypeProperty": "\t\t <- map[\"\"]\n",
69 | "forEachArrayOfCustomTypeProperty": "\t\t <- map[\"\"]\n",
70 | "returnStatement": "\t\t\n",
71 | "body": "",
72 | "comment": "",
73 | "bodyStart": "\n\t{\n"
74 | },
75 | {
76 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
77 | "bodyEnd": "\n\t}\n",
78 | "signature": " @objc required init(coder aDecoder: NSCoder)",
79 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
80 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
81 | "returnStatement": "",
82 | "body": "",
83 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
84 | "bodyStart": "\n\t{\n"
85 | },
86 | {
87 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
88 | "bodyEnd": "\n\t}\n",
89 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
90 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
91 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
92 | "returnStatement": "",
93 | "body": "",
94 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
95 | "bodyStart": "\n\t{\n"
96 | }
97 | ],
98 | "dataTypes": {
99 | "stringType": "String",
100 | "boolType": "Bool",
101 | "floatType": "Float",
102 | "doubleType": "Double",
103 | "characterType": "Character",
104 | "longType": "Double",
105 | "intType": "Int"
106 | },
107 | "wordsToRemoveToGetArrayElementsType": [
108 | "[",
109 | "]"
110 | ],
111 | "defaultParentWithUtilityMethods": "NSObject, NSCoding, Mappable",
112 | "constructors": [
113 | {
114 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
115 | "bodyStart": "{\n\t\treturn ()",
116 | "bodyEnd": "\n\t}\n",
117 | "fetchBasicTypePropertyFromMap": "",
118 | "signature": "\tclass func newInstance(map: Map) -> Mappable?",
119 | "fetchArrayOfCustomTypePropertyFromMap": "",
120 | "comment": "",
121 | "fetchCustomTypePropertyFromMap": ""
122 | },
123 | {
124 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
125 | "bodyStart": "{",
126 | "bodyEnd": "}\n",
127 | "fetchBasicTypePropertyFromMap": "",
128 | "signature": "\tprivate override init()",
129 | "fetchArrayOfCustomTypePropertyFromMap": "",
130 | "comment": "",
131 | "fetchCustomTypePropertyFromMap": ""
132 | }
133 | ],
134 | "modelDefinition": "\nclass ",
135 | "genericType": "AnyObject",
136 | "getter": "",
137 | "setter": "",
138 | "displayLangName": "Swift - Mappable",
139 | "fileExtension": "swift",
140 | "basicTypesWithSpecialFetchingNeeds": [
141 | ],
142 | "arrayType": "[]",
143 | "modelDefinitionWithParent": "\n\nclass : ",
144 | "instanceVarDefinition": "\tvar : ?\n",
145 | "supportsFirstLineStatement": "false",
146 | "modelEnd": "\n}",
147 | "staticImports": "import Foundation",
148 | "langName": "Swift"
149 | }
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Swift-Realm.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": " {\n",
3 | "importForEachCustomType": "",
4 | "basicTypesWithSpecialStoringNeeds": [
5 | "Int",
6 | "Bool",
7 | "Int",
8 | "Float",
9 | "Double"
10 | ],
11 | "supportMutualRelationships": "true",
12 | "reservedKeywords": [
13 | "abstract",
14 | "assert",
15 | "boolean",
16 | "break",
17 | "byte",
18 | "case",
19 | "catch",
20 | "char",
21 | "class",
22 | "const",
23 | "continue",
24 | "default",
25 | "do",
26 | "double",
27 | "else",
28 | "enum",
29 | "extends",
30 | "false",
31 | "final",
32 | "finally",
33 | "float",
34 | "for",
35 | "goto",
36 | "if",
37 | "implements",
38 | "import",
39 | "instanceof",
40 | "int",
41 | "interface",
42 | "long",
43 | "native",
44 | "new",
45 | "null",
46 | "package",
47 | "private",
48 | "protected",
49 | "public",
50 | "return",
51 | "short",
52 | "static",
53 | "strictfp",
54 | "super",
55 | "switch",
56 | "synchronized",
57 | "this",
58 | "throw",
59 | "throws",
60 | "transient",
61 | "true",
62 | "try",
63 | "void",
64 | "volatile",
65 | "while",
66 | "class",
67 | "description"
68 | ],
69 | "booleanGetter": "",
70 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
71 | "instanceVarWithSpeicalDefinition": "\tdynamic var : \n",
72 | "utilityMethods": [
73 | {
74 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
75 | "bodyEnd": "\t}\n",
76 | "signature": "\tfunc toDictionary() -> NSDictionary",
77 | "forEachPropertyWithSpecialStoringNeeds": "\t\tdictionary[\"\"] = \n",
78 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor i in 0 ..< .count {\n\t\t\t\tif let Element = [i] as? {\n\t\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t\t}\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
79 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
80 | "returnStatement": "\t\treturn dictionary\n",
81 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
82 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
83 | "bodyStart": "\n\t{\n"
84 | },
85 | {
86 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
87 | "bodyEnd": "\n\t}\n",
88 | "signature": " @objc required init(coder aDecoder: NSCoder)",
89 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
90 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
91 | "returnStatement": "",
92 | "forEachPropertyWithSpecialStoringNeeds": " = aDecoder.decodeObjectForKey(\"\") as? \n",
93 | "body": "",
94 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
95 | "bodyStart": "\n\t{\n"
96 | },
97 | {
98 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
99 | "bodyEnd": "\n\t}\n",
100 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
101 | "forEachPropertyWithSpecialStoringNeeds": " = aDecoder.decodeObjectForKey(\"\") as? \n",
102 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
103 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
104 | "returnStatement": "",
105 | "body": "",
106 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
107 | "bodyStart": "\n\t{\n"
108 | }
109 | ],
110 | "dataTypes": {
111 | "stringType": "String",
112 | "boolType": "Bool",
113 | "floatType": "Float",
114 | "doubleType": "Double",
115 | "characterType": "Int",
116 | "longType": "Double",
117 | "intType": "Int"
118 | },
119 | "wordsToRemoveToGetArrayElementsType": [
120 | "[",
121 | "]"
122 | ],
123 | "defaultParentWithUtilityMethods": "Object, NSCoding",
124 | "constructors": [
125 | {
126 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\tthis. = Value\n\t\t}\n",
127 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\tthis. = .fromDictionary(Data)\n\t\t}\n",
128 | "bodyEnd": "\t\treturn this\n\t}\n",
129 | "fetchBasicTypePropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\tthis. = Value\n\t\t}\n",
130 | "signature": "\tclass func fromDictionary(dictionary: NSDictionary) -> ",
131 | "fetchArrayOfCustomTypePropertyFromMap": "\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tvar Items = List(objectClassName: .className())\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = .fromDictionary(dic)\n\t\t\t\tItems.addObject(value)\n\t\t\t}\n\t\t\t = Items\n\t\t}\n",
132 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
133 | "bodyStart": "\t{\n\t\tlet this = ()\n"
134 | }
135 | ],
136 | "modelDefinition": "\nclass : Object",
137 | "genericType": "AnyObject",
138 | "getter": "",
139 | "setter": "",
140 | "fileExtension": "swift",
141 | "arrayType": "List",
142 | "modelDefinitionWithParent": "\n\nclass : ",
143 | "displayLangName": "Swift - Realm",
144 | "basicTypesWithSpecialFetchingNeeds": [
145 | "Int",
146 | "Bool",
147 | "Int",
148 | "Float",
149 | "Double"
150 | ],
151 | "instanceVarDefinition": "\tdynamic var : !\n",
152 | "supportsFirstLineStatement": "false",
153 | "modelEnd": "\n}",
154 | "typesNeedSpecialDefinition": [
155 | "Int",
156 | "Bool",
157 | "Int",
158 | "Float",
159 | "Double"
160 | ],
161 | "staticImports": "",
162 | "langName": "Swift"
163 | }
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/Swift-Struct.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "reservedKeywords": [
5 | "abstract",
6 | "assert",
7 | "boolean",
8 | "break",
9 | "byte",
10 | "case",
11 | "catch",
12 | "char",
13 | "class",
14 | "const",
15 | "continue",
16 | "default",
17 | "do",
18 | "double",
19 | "else",
20 | "enum",
21 | "extends",
22 | "false",
23 | "final",
24 | "finally",
25 | "float",
26 | "for",
27 | "goto",
28 | "if",
29 | "implements",
30 | "import",
31 | "instanceof",
32 | "int",
33 | "interface",
34 | "long",
35 | "native",
36 | "new",
37 | "null",
38 | "package",
39 | "private",
40 | "protected",
41 | "public",
42 | "return",
43 | "short",
44 | "static",
45 | "strictfp",
46 | "super",
47 | "switch",
48 | "synchronized",
49 | "this",
50 | "throw",
51 | "throws",
52 | "transient",
53 | "true",
54 | "try",
55 | "void",
56 | "volatile",
57 | "while",
58 | "class",
59 | "description"
60 | ],
61 | "booleanGetter": "",
62 | "briefDescription": "Defines how your JSON objects can be mapped to Swift structures using the built-in NSJSONSerialization class",
63 | "utilityMethods": [
64 | {
65 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
66 | "bodyEnd": "\t}\n",
67 | "signature": "\tfunc toDictionary() -> NSDictionary",
68 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
69 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
70 | "returnStatement": "\t\treturn dictionary\n",
71 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
72 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
73 | "bodyStart": "\n\t{\n"
74 | }
75 | ],
76 | "dataTypes": {
77 | "stringType": "String",
78 | "boolType": "Bool",
79 | "floatType": "Float",
80 | "doubleType": "Double",
81 | "characterType": "Character",
82 | "longType": "Double",
83 | "intType": "Int"
84 | },
85 | "wordsToRemoveToGetArrayElementsType": [
86 | "[",
87 | "]"
88 | ],
89 | "constructors": [
90 | {
91 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
92 | "bodyStart": "{\n",
93 | "bodyEnd": "\t}\n",
94 | "fetchBasicTypePropertyFromMap": "\t\t = dictionary[\"\"] as? \n",
95 | "signature": "\tinit(fromDictionary dictionary: NSDictionary)",
96 | "fetchArrayOfCustomTypePropertyFromMap": "\t\t = ()\n\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = (fromDictionary: dic)\n\t\t\t\t.append(value)\n\t\t\t}\n\t\t}\n",
97 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
98 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\t\t = (fromDictionary: Data)\n\t\t\t}\n"
99 | }
100 | ],
101 | "modelDefinition": "\nstruct ",
102 | "genericType": "AnyObject",
103 | "getter": "",
104 | "setter": "",
105 | "fileExtension": "swift",
106 | "arrayType": "[]",
107 | "basicTypesWithSpecialFetchingNeeds": [
108 | ],
109 | "displayLangName": "Swift - Struct",
110 | "instanceVarDefinition": "\tvar : !\n",
111 | "supportsFirstLineStatement": "false",
112 | "modelEnd": "\n}",
113 | "staticImports": "import Foundation",
114 | "langName": "Swift"
115 | }
--------------------------------------------------------------------------------
/JSONExport.app/Contents/Resources/SwiftyJSON-Class.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "basicTypesWithSpecialFetchingNeedsReplacements": [
4 | "intValue",
5 | "boolValue",
6 | "charValue",
7 | "floatValue",
8 | "doubleValue",
9 | "stringValue",
10 | "stringValue"
11 | ],
12 | "importForEachCustomType": "",
13 | "reservedKeywords": [
14 | "abstract",
15 | "assert",
16 | "boolean",
17 | "break",
18 | "byte",
19 | "case",
20 | "catch",
21 | "char",
22 | "class",
23 | "const",
24 | "continue",
25 | "default",
26 | "do",
27 | "double",
28 | "else",
29 | "enum",
30 | "extends",
31 | "false",
32 | "final",
33 | "finally",
34 | "float",
35 | "for",
36 | "goto",
37 | "if",
38 | "implements",
39 | "import",
40 | "instanceof",
41 | "int",
42 | "interface",
43 | "long",
44 | "native",
45 | "new",
46 | "null",
47 | "package",
48 | "private",
49 | "protected",
50 | "public",
51 | "return",
52 | "short",
53 | "static",
54 | "strictfp",
55 | "super",
56 | "switch",
57 | "synchronized",
58 | "this",
59 | "throw",
60 | "throws",
61 | "transient",
62 | "true",
63 | "try",
64 | "void",
65 | "volatile",
66 | "while",
67 | "class",
68 | "description"
69 | ],
70 | "booleanGetter": "",
71 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the SwiftyJSON library",
72 | "utilityMethods": [
73 | {
74 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
75 | "bodyEnd": "\t}\n",
76 | "signature": "\tfunc toDictionary() -> NSDictionary",
77 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
78 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
79 | "returnStatement": "\t\treturn dictionary\n",
80 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
81 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
82 | "bodyStart": "\n\t{\n"
83 | },
84 | {
85 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
86 | "bodyEnd": "\n\t}\n",
87 | "signature": " @objc required init(coder aDecoder: NSCoder)",
88 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
89 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
90 | "returnStatement": "",
91 | "body": "",
92 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
93 | "bodyStart": "\n\t{\n"
94 | },
95 | {
96 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
97 | "bodyEnd": "\n\t}\n",
98 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
99 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
100 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
101 | "returnStatement": "",
102 | "body": "",
103 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
104 | "bodyStart": "\n\t{\n"
105 | }
106 | ],
107 | "dataTypes": {
108 | "stringType": "String",
109 | "boolType": "Bool",
110 | "floatType": "Float",
111 | "doubleType": "Double",
112 | "characterType": "Character",
113 | "longType": "Double",
114 | "intType": "Int"
115 | },
116 | "wordsToRemoveToGetArrayElementsType": [
117 | "[",
118 | "]"
119 | ],
120 | "defaultParentWithUtilityMethods": "NSObject, NSCoding",
121 | "constructors": [
122 | {
123 | "fetchArrayOfBasicTypePropertyFromMap": "\t\t = ()\n\t\tlet Array = json[\"\"].arrayValue\n\t\tfor Json in Array{\n\t\t\t.append(Json.)\n\t\t}\n",
124 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "\t\t = json[\"\"].\n",
125 | "bodyStart": "{\n\t\tif json == nil{\n\t\t\treturn\n\t\t}\n",
126 | "bodyEnd": "\t}\n",
127 | "fetchBasicTypePropertyFromMap": "",
128 | "signature": "\tinit(fromJson json: JSON!)",
129 | "fetchArrayOfCustomTypePropertyFromMap": "\t\t = ()\n\t\tlet Array = json[\"\"].arrayValue\n\t\tfor Json in Array{\n\t\t\tlet value = (fromJson: Json)\n\t\t\t.append(value)\n\t\t}\n",
130 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
131 | "fetchCustomTypePropertyFromMap": "\t\tlet Json = json[\"\"]\n\t\tif Json != JSON.nullJSON{\n\t\t\t = (fromJson: Json)\n\t\t}\n"
132 | }
133 | ],
134 | "modelDefinition": "\nclass ",
135 | "genericType": "AnyObject",
136 | "getter": "",
137 | "setter": "",
138 | "displayLangName": "SwiftyJSON - Class",
139 | "fileExtension": "swift",
140 | "basicTypesWithSpecialFetchingNeeds": [
141 | "Int",
142 | "Bool",
143 | "Character",
144 | "Float",
145 | "Double",
146 | "String",
147 | "AnyObject"
148 | ],
149 | "arrayType": "[]",
150 | "modelDefinitionWithParent": "\n\nclass : ",
151 | "instanceVarDefinition": "\tvar : !\n",
152 | "supportsFirstLineStatement": "false",
153 | "modelEnd": "\n}",
154 | "staticImports": "import Foundation",
155 | "langName": "Swift"
156 | }
--------------------------------------------------------------------------------
/JSONExport.app/Contents/_CodeSignature/CodeResources:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | files
6 |
7 | Resources/AppIcon.icns
8 |
9 | Ze5EBlyByZsGMq3Wmpfa0hu37mg=
10 |
11 | Resources/Base.lproj/Main.storyboardc/Info.plist
12 |
13 | hash
14 |
15 | 1o77s+2muixHq0qJkTf60pVaG4Y=
16 |
17 | optional
18 |
19 |
20 | Resources/Base.lproj/Main.storyboardc/MainMenu.nib
21 |
22 | hash
23 |
24 | f69+vC5qqHc1eGwergZKnxUmuDg=
25 |
26 | optional
27 |
28 |
29 | Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib
30 |
31 | hash
32 |
33 | mde+4EOOtn3XEwE51/5yUlYBIXg=
34 |
35 | optional
36 |
37 |
38 | Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
39 |
40 | hash
41 |
42 | 06aWVmjDcECfPj3XJlk8zhIkIVk=
43 |
44 | optional
45 |
46 |
47 | Resources/Swift-Class.json
48 |
49 | MTjzw8YZXnxkn7OoB4NthAgLh/s=
50 |
51 | Resources/Swift-CoreData.json
52 |
53 | nWy7BnFopfhC0JXAb4zgOXfYWJk=
54 |
55 | Resources/Swift-Mappable.json
56 |
57 | LQngmSiY0O4b8kuxKb0pSEuUTQc=
58 |
59 | Resources/Swift-Realm.json
60 |
61 | 9+a8uY5VySnR4BTv450s12GPMTg=
62 |
63 | Resources/Swift-Struct.json
64 |
65 | fPxZ/Ml1+evBTXTOuuAOqL/LIgw=
66 |
67 | Resources/SwiftyJSON-Class.json
68 |
69 | ood6X2e6un1UE8/VAaG7JZtb0Lc=
70 |
71 |
72 | files2
73 |
74 | Frameworks/libswiftAppKit.dylib
75 |
76 | cdhash
77 |
78 | XgUEhrJ1tfffcG9YrLbf16wihMI=
79 |
80 | requirement
81 | cdhash H"845c75128a2fd7b115ce237714169c4e6c5c3479" or cdhash H"5e050486b275b5f7df706f58acb6dfd7ac2284c2"
82 |
83 | Frameworks/libswiftCore.dylib
84 |
85 | cdhash
86 |
87 | jLEdjabkchqMANhncmPZ/EzZymM=
88 |
89 | requirement
90 | cdhash H"c54e32b8875460bb16651b6d609aff76b8192a24" or cdhash H"8cb11d8da6e4721a8c00d8677263d9fc4cd9ca63"
91 |
92 | Frameworks/libswiftCoreData.dylib
93 |
94 | cdhash
95 |
96 | 01WS6A9a5b2eyUvNVXKPf3SEW9E=
97 |
98 | requirement
99 | cdhash H"2fb276ca47a5914dee9815e269f754906c5f5f24" or cdhash H"d35592e80f5ae5bd9ec94bcd55728f7f74845bd1"
100 |
101 | Frameworks/libswiftCoreGraphics.dylib
102 |
103 | cdhash
104 |
105 | KYRXnUceyTa1NpBmRAcyUNOkEOo=
106 |
107 | requirement
108 | cdhash H"daf3de9ff018c2dca3b83405e507b839d6d0249d" or cdhash H"2984579d471ec936b536906644073250d3a410ea"
109 |
110 | Frameworks/libswiftCoreImage.dylib
111 |
112 | cdhash
113 |
114 | s8ecCSmyAfU2U2TgWXS9GGxgZ1s=
115 |
116 | requirement
117 | cdhash H"c9cf0b4820e3fbb6d5cf6a978ae2e1cfc41a3f81" or cdhash H"b3c79c0929b201f5365364e05974bd186c60675b"
118 |
119 | Frameworks/libswiftDarwin.dylib
120 |
121 | cdhash
122 |
123 | 0hg4cp8DHFFEWvBVELF5NOCZYCU=
124 |
125 | requirement
126 | cdhash H"3be600503f94d46a7806ddbf44de6b2c68131ad9" or cdhash H"d21838729f031c51445af05510b17934e0996025"
127 |
128 | Frameworks/libswiftDispatch.dylib
129 |
130 | cdhash
131 |
132 | laP8+4JRgMCxXpJ22dtD0MK3fO4=
133 |
134 | requirement
135 | cdhash H"2477d0e471184e1c22aec0b3121984cdda1d8dea" or cdhash H"95a3fcfb825180c0b15e9276d9db43d0c2b77cee"
136 |
137 | Frameworks/libswiftFoundation.dylib
138 |
139 | cdhash
140 |
141 | YEgSAxLAC92kuBFPgK6qqV5qYN4=
142 |
143 | requirement
144 | cdhash H"f3af62291b3aa3897edb366eabb0279ef79f52e2" or cdhash H"6048120312c00bdda4b8114f80aeaaa95e6a60de"
145 |
146 | Frameworks/libswiftObjectiveC.dylib
147 |
148 | cdhash
149 |
150 | ckypUpeOZeJCuMgsiin2irwkdb4=
151 |
152 | requirement
153 | cdhash H"827574f7e42c51488f6186555852ee4f557a3de8" or cdhash H"724ca952978e65e242b8c82c8a29f68abc2475be"
154 |
155 | Resources/AppIcon.icns
156 |
157 | hash
158 |
159 | Ze5EBlyByZsGMq3Wmpfa0hu37mg=
160 |
161 | hash2
162 |
163 | IXQjuamz1qvNh+E34Uhrz9Gc8sKwKcgjJmRP2hj+nig=
164 |
165 |
166 | Resources/Base.lproj/Main.storyboardc/Info.plist
167 |
168 | hash
169 |
170 | 1o77s+2muixHq0qJkTf60pVaG4Y=
171 |
172 | hash2
173 |
174 | ySLxLWSBFz6HpwtNg6eQreQ+5wQ4wDfD+zS8rP99+7Q=
175 |
176 | optional
177 |
178 |
179 | Resources/Base.lproj/Main.storyboardc/MainMenu.nib
180 |
181 | hash
182 |
183 | f69+vC5qqHc1eGwergZKnxUmuDg=
184 |
185 | hash2
186 |
187 | 1UlkZunavaXcUu+3KoIedRmCEKGW9pDIECX+hbQIjok=
188 |
189 | optional
190 |
191 |
192 | Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib
193 |
194 | hash
195 |
196 | mde+4EOOtn3XEwE51/5yUlYBIXg=
197 |
198 | hash2
199 |
200 | YAToSit5F72wxPqJ93WPEXfIJXr6xHQyHKrdAuhiyaA=
201 |
202 | optional
203 |
204 |
205 | Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
206 |
207 | hash
208 |
209 | 06aWVmjDcECfPj3XJlk8zhIkIVk=
210 |
211 | hash2
212 |
213 | S3WMhMBN7IZJufsvQJzuOhjY+DXmOU0Jup0JoMDhhsE=
214 |
215 | optional
216 |
217 |
218 | Resources/Swift-Class.json
219 |
220 | hash
221 |
222 | MTjzw8YZXnxkn7OoB4NthAgLh/s=
223 |
224 | hash2
225 |
226 | incq/HRMPmsHrTLGh+Xo90aLpo+SGE8LHh8g6dg9Sco=
227 |
228 |
229 | Resources/Swift-CoreData.json
230 |
231 | hash
232 |
233 | nWy7BnFopfhC0JXAb4zgOXfYWJk=
234 |
235 | hash2
236 |
237 | tT8BYiA17aUROrPdllLyE3tr0L/npJG0UZimThBNHlk=
238 |
239 |
240 | Resources/Swift-Mappable.json
241 |
242 | hash
243 |
244 | LQngmSiY0O4b8kuxKb0pSEuUTQc=
245 |
246 | hash2
247 |
248 | rhWc4Pda+FKMHRtsVnaKpQlvZNsMhsry/uCTBoNcVXY=
249 |
250 |
251 | Resources/Swift-Realm.json
252 |
253 | hash
254 |
255 | 9+a8uY5VySnR4BTv450s12GPMTg=
256 |
257 | hash2
258 |
259 | Hlfp4K6+qOuLUr/NMDNVONsvh+oig10jH7eec9D33kA=
260 |
261 |
262 | Resources/Swift-Struct.json
263 |
264 | hash
265 |
266 | fPxZ/Ml1+evBTXTOuuAOqL/LIgw=
267 |
268 | hash2
269 |
270 | o6BbxkCjYVv6BFEnFgPpX9CW26CmvRolCjHvbfbn02M=
271 |
272 |
273 | Resources/SwiftyJSON-Class.json
274 |
275 | hash
276 |
277 | ood6X2e6un1UE8/VAaG7JZtb0Lc=
278 |
279 | hash2
280 |
281 | cycE+EoLw1exeVl1i5cBJ1oy4X4pwHOtJ0jZDS4XVpU=
282 |
283 |
284 |
285 | rules
286 |
287 | ^Resources/
288 |
289 | ^Resources/.*\.lproj/
290 |
291 | optional
292 |
293 | weight
294 | 1000
295 |
296 | ^Resources/.*\.lproj/locversion.plist$
297 |
298 | omit
299 |
300 | weight
301 | 1100
302 |
303 | ^version.plist$
304 |
305 |
306 | rules2
307 |
308 | .*\.dSYM($|/)
309 |
310 | weight
311 | 11
312 |
313 | ^(.*/)?\.DS_Store$
314 |
315 | omit
316 |
317 | weight
318 | 2000
319 |
320 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/
321 |
322 | nested
323 |
324 | weight
325 | 10
326 |
327 | ^.*
328 |
329 | ^Info\.plist$
330 |
331 | omit
332 |
333 | weight
334 | 20
335 |
336 | ^PkgInfo$
337 |
338 | omit
339 |
340 | weight
341 | 20
342 |
343 | ^Resources/
344 |
345 | weight
346 | 20
347 |
348 | ^Resources/.*\.lproj/
349 |
350 | optional
351 |
352 | weight
353 | 1000
354 |
355 | ^Resources/.*\.lproj/locversion.plist$
356 |
357 | omit
358 |
359 | weight
360 | 1100
361 |
362 | ^[^/]+$
363 |
364 | nested
365 |
366 | weight
367 | 10
368 |
369 | ^embedded\.provisionprofile$
370 |
371 | weight
372 | 20
373 |
374 | ^version\.plist$
375 |
376 | weight
377 | 20
378 |
379 |
380 |
381 |
382 |
--------------------------------------------------------------------------------
/JSONExport.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JSONExport.xcodeproj/project.xcworkspace/xcuserdata/xiaobo.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport.xcodeproj/project.xcworkspace/xcuserdata/xiaobo.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JSONExport.xcodeproj/xcuserdata/ahmed.xcuserdatad/xcschemes/JSONExport.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
100 |
101 |
102 |
103 |
105 |
106 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/JSONExport.xcodeproj/xcuserdata/ahmed.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JSONExport.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E2FA87B41A059AC100648EB6
16 |
17 | primary
18 |
19 |
20 | E2FA87C61A059AC100648EB6
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JSONExport.xcodeproj/xcuserdata/xiaobo.xcuserdatad/xcschemes/JSONExport.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/JSONExport.xcodeproj/xcuserdata/xiaobo.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JSONExport.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E2FA87B41A059AC100648EB6
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JSONExport/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed on 11/2/14.
6 | // Copyright (c) 2014 Ahmed Ali. Eng.Ahmed.Ali.Awad@gmail.com.
7 | //
8 | // Redistribution and use in source and binary forms, with or without
9 | // modification, are permitted provided that the following conditions
10 | // are met:
11 | //
12 | // 1. Redistributions of source code must retain the above copyright
13 | // notice, this list of conditions and the following disclaimer.
14 | // 2. Redistributions in binary form must reproduce the above copyright
15 | // notice, this list of conditions and the following disclaimer in the
16 | // documentation and/or other materials provided with the distribution.
17 | // 3. The name of the contributor can not be used to endorse or promote products derived from this software
18 | // without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 | // OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import Cocoa
34 |
35 | @NSApplicationMain
36 | class AppDelegate: NSObject, NSApplicationDelegate {
37 |
38 |
39 |
40 | func applicationDidFinishLaunching(aNotification: NSNotification) {
41 | // Insert code here to initialize your application
42 | }
43 |
44 | func applicationWillTerminate(aNotification: NSNotification) {
45 | // Insert code here to tear down your application
46 |
47 | }
48 |
49 |
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/JSONExport/Constructor.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Constructor.swift
3 | //
4 | // Create by Ahmed Ali on 14/11/2014
5 | // Copyright (c) 2014 Mobile Developer. All rights reserved.
6 | //
7 |
8 | import Foundation
9 |
10 | class Constructor{
11 |
12 | var bodyEnd : String!
13 | var bodyStart : String!
14 | var comment : String!
15 | var fetchArrayOfCustomTypePropertyFromMap : String!
16 | var fetchArrayOfBasicTypePropertyFromMap : String!
17 | var fetchBasicTypePropertyFromMap : String!
18 | var fetchBasicTypeWithSpecialNeedsPropertyFromMap : String!
19 | var fetchCustomTypePropertyFromMap : String!
20 | var signature : String!
21 |
22 |
23 | /**
24 | * Instantiate the instance using the passed dictionary values to set the properties values
25 | */
26 | init(fromDictionary dictionary: NSDictionary){
27 | bodyEnd = dictionary["bodyEnd"] as? String
28 | bodyStart = dictionary["bodyStart"] as? String
29 | comment = dictionary["comment"] as? String
30 | fetchArrayOfCustomTypePropertyFromMap = dictionary["fetchArrayOfCustomTypePropertyFromMap"] as? String
31 | fetchArrayOfBasicTypePropertyFromMap = dictionary["fetchArrayOfBasicTypePropertyFromMap"] as? String
32 | fetchBasicTypePropertyFromMap = dictionary["fetchBasicTypePropertyFromMap"] as? String
33 | fetchBasicTypeWithSpecialNeedsPropertyFromMap = dictionary["fetchBasicTypeWithSpecialNeedsPropertyFromMap"] as? String
34 | fetchCustomTypePropertyFromMap = dictionary["fetchCustomTypePropertyFromMap"] as? String
35 | signature = dictionary["signature"] as? String
36 | }
37 |
38 |
39 | }
--------------------------------------------------------------------------------
/JSONExport/DataType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DataType.swift
3 | //
4 | // Create by Ahmed Ali on 14/11/2014
5 | // Copyright (c) 2014 Mobile Developer. All rights reserved.
6 | //
7 |
8 | import Foundation
9 |
10 | class DataType{
11 |
12 | var boolType : String!
13 | var characterType : String!
14 | var doubleType : String!
15 | var floatType : String!
16 | var intType : String!
17 | var longType : String!
18 | var stringType : String!
19 |
20 |
21 | /**
22 | * Instantiate the instance using the passed dictionary values to set the properties values
23 | */
24 | init(fromDictionary dictionary: NSDictionary){
25 | boolType = dictionary["boolType"] as? String
26 | characterType = dictionary["characterType"] as? String
27 | doubleType = dictionary["doubleType"] as? String
28 | floatType = dictionary["floatType"] as? String
29 | intType = dictionary["intType"] as? String
30 | longType = dictionary["longType"] as? String
31 | stringType = dictionary["stringType"] as? String
32 | }
33 |
34 | /**
35 | * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
36 | */
37 | func toDictionary() -> NSDictionary
38 | {
39 | let dictionary = NSMutableDictionary()
40 | if boolType != nil{
41 | dictionary["boolType"] = boolType
42 | }
43 | if characterType != nil{
44 | dictionary["characterType"] = characterType
45 | }
46 | if doubleType != nil{
47 | dictionary["doubleType"] = doubleType
48 | }
49 | if floatType != nil{
50 | dictionary["floatType"] = floatType
51 | }
52 | if intType != nil{
53 | dictionary["intType"] = intType
54 | }
55 | if longType != nil{
56 | dictionary["longType"] = longType
57 | }
58 | if stringType != nil{
59 | dictionary["stringType"] = stringType
60 | }
61 | return dictionary
62 | }
63 |
64 | }
--------------------------------------------------------------------------------
/JSONExport/FileContentBuilder.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FileGenerator.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed on 11/14/14.
6 | // Copyright (c) 2014 Ahmed Ali. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | /**
12 | Singleton used to build the file content with the current configurations
13 | */
14 | class FilesContentBuilder{
15 | /**
16 | The prefix used for first level type names (and file names as well)
17 | */
18 | var classPrefix = ""
19 |
20 | /**
21 | The language for which the files' content should be created
22 | */
23 | var lang : LangModel!
24 |
25 | /**
26 | Whether to include utility methods in the generated content
27 | */
28 | var includeUtilities = true
29 |
30 | /**
31 | Whether to include constructors (aka initializers)
32 | */
33 | var includeConstructors = true
34 |
35 | /**
36 | Whatever value will be assinged to the firstLine property, will appear as the first line in every file if the target language supports first line statement
37 | */
38 | var firstLine = ""
39 |
40 | /**
41 | If the target language supports inheritance, all the generated classes will be subclasses of this class
42 | */
43 | var parentClassName = ""
44 |
45 |
46 | var mismatchedTypes = [String : String]()
47 |
48 | /**
49 | Lazely load and return the singleton instance of the FilesContentBuilder
50 | */
51 | class var instance : FilesContentBuilder {
52 | struct Static {
53 | static var onceToken : dispatch_once_t = 0
54 | static var instance : FilesContentBuilder? = nil
55 | }
56 | dispatch_once(&Static.onceToken) {
57 | Static.instance = FilesContentBuilder()
58 | }
59 | return Static.instance!
60 | }
61 |
62 | /**
63 | Generates a file using the passed className and jsonObject example and appends it in the passed files array
64 |
65 | - parameter className: for the file to be generated, if the file already exist with different name, this className will be changed
66 | - parameter jsonObject: acts as an example of the json object, which the generated fill be able to handle
67 | - parameter files: the generated file will be appended to this array
68 | */
69 | func addFileWithName(inout className: String, jsonObject: NSDictionary, inout files : [FileRepresenter], toOneRelationWithProperty: Property! = nil)
70 | {
71 | var properties = [Property]()
72 | if !className.hasPrefix(classPrefix){
73 | className = "\(classPrefix)\(className)"
74 | }
75 | if toOneRelationWithProperty != nil && lang.supportMutualRelationships != nil && lang.supportMutualRelationships!{
76 | properties.append(toOneRelationWithProperty)
77 |
78 | }
79 | //sort all the keys in the passed json dictionary
80 | let jsonProperties = (jsonObject.allKeys as! [String]).sort()
81 |
82 | //loop all the json properties and handle each one individually
83 | for jsonPropertyName in jsonProperties{
84 | let value : AnyObject = jsonObject[jsonPropertyName]!
85 | let property = propertyForValue(value, jsonKeyName: jsonPropertyName)
86 | //Avoid duplicated property names
87 | if properties.map({$0.nativeName}).indexOf(property.nativeName) != nil{
88 | continue
89 | }
90 | //recursively handle custom types
91 | if property.isCustomClass{
92 | let rProperty = relationProperty(className)
93 | addFileWithName(&property.type, jsonObject: value as! NSDictionary, files:&files, toOneRelationWithProperty: rProperty)
94 | }else if property.isArray{
95 | let array = value as! NSArray
96 | if array.firstObject is NSDictionary{
97 |
98 | //complicated enough.....
99 | var type = property.elementsType
100 | let relatedProperty = relationProperty(className)
101 | let allProperties = unionDictionaryFromArrayElements(array);
102 | addFileWithName(&type, jsonObject: allProperties, files:&files, toOneRelationWithProperty: relatedProperty)
103 | }
104 | }
105 |
106 | properties.append(property)
107 |
108 | }
109 |
110 | //create the file
111 |
112 | let file = FileRepresenter(className: className, properties: properties, lang:lang)
113 |
114 | file.includeUtilities = includeUtilities
115 | file.includeConstructors = includeConstructors
116 | file.firstLine = firstLine
117 | file.parentClassName = parentClassName
118 |
119 | var exactMatchFound = false
120 | if let similarFile = findSimilarFile(file, inFiles: files, exactMatchFound: &exactMatchFound){
121 | //there is a similar file
122 | if !exactMatchFound{
123 | //If the found file is no exact, then any additional properties to the alread exist file instead of creating new one
124 | mergeProperties(fromFile: file, toFile: similarFile)
125 |
126 | }
127 | //Hold list of mismatches to be fixed later
128 | mismatchedTypes[className] = similarFile.className
129 |
130 | className = similarFile.className
131 |
132 | }else{
133 | files.append(file)
134 |
135 | if lang.headerFileData != nil{
136 | //add header file first
137 | let headerFile = HeaderFileRepresenter(className: className, properties: properties, lang:lang)
138 | headerFile.includeUtilities = includeUtilities
139 | headerFile.includeConstructors = includeConstructors
140 | headerFile.parentClassName = parentClassName
141 | headerFile.firstLine = firstLine
142 | files.append(headerFile)
143 | }
144 | }
145 | }
146 |
147 | /**
148 | Merges the properties from the passed fromFile to the pass toFile
149 | - parameter fromFile: in which to find any new properties
150 | - parameter toFile: to which to add any found new properties
151 | */
152 | func mergeProperties(fromFile fromFile: FileRepresenter, toFile: FileRepresenter)
153 | {
154 | for property in fromFile.properties{
155 | if toFile.properties.indexOf(property) == nil{
156 | toFile.properties.append(property)
157 | }
158 | }
159 | }
160 |
161 | /**
162 | Finds the first file in the passed files which has the same class name as the passed file
163 |
164 | - parameter file: the file to compare against
165 | - parameter inFiles: the files array to search in
166 | - parameter exactMathFound: inout param, will have the value of 'true' if any file is found that has exactly the same properties as the passed file
167 | - returns: similar file if any
168 | */
169 | func findSimilarFile(file: FileRepresenter, inFiles files: [FileRepresenter], inout exactMatchFound: Bool) -> FileRepresenter?{
170 | var similarFile : FileRepresenter?
171 | for targetFile in files{
172 |
173 | exactMatchFound = bothFilesHasSamePropreties(file1: targetFile, file2: file)
174 |
175 | if exactMatchFound || targetFile.className == file.className{
176 | similarFile = targetFile
177 |
178 | break
179 | }
180 | }
181 |
182 | return similarFile
183 | }
184 |
185 | /**
186 | Compares the properties of both files to determine if they exactly similar or no.
187 |
188 | - parameter file1: first file to compare against the second file
189 | - parameter file2: the second file to compare against the first file
190 | - returns: whether both files has exactly the same properties
191 | */
192 | func bothFilesHasSamePropreties(file1 file1: FileRepresenter, file2: FileRepresenter) -> Bool
193 | {
194 | var bothHasSameProperties = true
195 | if file1.properties.count == file2.properties.count{
196 | //there is a propability they both has the same properties
197 | for property in file1.properties{
198 | if file2.properties.indexOf(property) == nil{
199 | //property not found, no need to keep looking
200 | bothHasSameProperties = false
201 | break
202 | }
203 | }
204 | }else{
205 | bothHasSameProperties = false
206 | }
207 |
208 | return bothHasSameProperties
209 | }
210 |
211 |
212 | func fixReferenceMismatches(inFiles files: [FileRepresenter])
213 | {
214 | for file in files{
215 | for property in file.properties{
216 | if property.isCustomClass, let toType = mismatchedTypes[property.type]{
217 | property.type = toType
218 | }else if property.isArray, let toType = mismatchedTypes[property.elementsType]{
219 | property.elementsType = toType
220 | property.type = lang.arrayType.stringByReplacingOccurrencesOfString(elementType, withString: toType)
221 | }
222 | }
223 | }
224 | }
225 |
226 | /**
227 | Creates and returns a Property object whiche represents a to-one relation property
228 |
229 | - parameter relationClassName: to which the relation relates
230 | - parameter headerProperty: optional whether this property is for header file
231 |
232 | - returns: the relation property
233 | */
234 | func relationProperty(relationClassName : String) -> Property
235 | {
236 |
237 | let nativeName = relationClassName.lowercaseFirstChar()
238 | let property = Property(jsonName: nativeName, nativeName: nativeName, type: relationClassName, lang: lang)
239 | property.isCustomClass = true
240 |
241 | return property
242 | }
243 |
244 | /**
245 | Creates and returns a Property object passed on the passed value and json key name
246 |
247 | - parameter value: example value for the property
248 | - parameter jsonKeyName: for the property
249 | - returns: a Property instance
250 | */
251 | func propertyForValue(value: AnyObject, jsonKeyName: String) -> Property
252 | {
253 | let nativePropertyName = propertyNativeName(jsonKeyName)
254 | var type = propertyTypeName(value, lang:lang)
255 | // var isDictionary = false
256 | // var isArray = false
257 |
258 | var property: Property!
259 | if value is NSDictionary {
260 | type = typeNameForPropertyName(jsonKeyName)
261 | property = Property(jsonName: jsonKeyName, nativeName: nativePropertyName, type: type, isArray:false, isCustomClass: true, lang: lang)
262 |
263 | }else if value is NSArray{
264 | //we need to check its elements...
265 | let array = value as! NSArray
266 |
267 | if array.firstObject is NSDictionary{
268 | //wow complicated
269 | let leafClassName = typeNameForPropertyName(jsonKeyName)
270 |
271 | type = lang.arrayType.stringByReplacingOccurrencesOfString(elementType, withString: leafClassName)
272 |
273 | property = Property(jsonName: jsonKeyName, nativeName: nativePropertyName, type: type, isArray: true, isCustomClass: false, lang:lang)
274 | property.elementsType = leafClassName
275 | //Create a class for this type as well!
276 |
277 | property.elementsAreOfCustomType = true
278 | }else{
279 | property = Property(jsonName: jsonKeyName, nativeName: nativePropertyName, type: type, isArray: true, isCustomClass: false, lang:lang)
280 | property.elementsType = typeNameForArrayElements(value as! NSArray, lang:lang)
281 | }
282 | }else{
283 | property = Property(jsonName: jsonKeyName, nativeName: nativePropertyName, type: type, lang:lang)
284 | }
285 | property.sampleValue = value
286 | return property
287 | }
288 |
289 |
290 |
291 |
292 | /**
293 | Returns a camel case presentation from the passed json key
294 |
295 | - parameter jsonKeyName: the name of the json key to convert to suitable native property name
296 |
297 | - returns: property name
298 | */
299 | func propertyNativeName(jsonKeyName : String) -> String
300 | {
301 | var propertyName = cleanUpVersionOfPropertyNamed(jsonKeyName)
302 | propertyName = underscoresToCamelCaseForString(propertyName, startFromFirstChar: false).lowercaseFirstChar()
303 | //Fix property name that could be a reserved keyword
304 | if lang.reservedKeywords != nil && lang.reservedKeywords.contains(propertyName.lowercaseString){
305 | //Property name need to be suffixed by proper suffix, any ideas of better generlized prefix/suffix?
306 | propertyName += "Field"
307 | }
308 | return propertyName
309 | }
310 |
311 |
312 | func cleanUpVersionOfPropertyNamed(propertyName: String) -> String
313 | {
314 | let allowedCharacters = NSMutableCharacterSet.alphanumericCharacterSet()
315 | allowedCharacters.addCharactersInString("_1234567890")
316 | let cleanVersion = propertyName.componentsSeparatedByCharactersInSet(allowedCharacters.invertedSet).joinWithSeparator("")
317 | return cleanVersion
318 | }
319 |
320 | /**
321 | Returns the input string with white spaces removed, and underscors converted to camel case
322 |
323 | - parameter inputString: to convert
324 | - parameter startFromFirstChar: whether to start with upper case letter
325 | - returns: the camel case version of the input
326 | */
327 | func underscoresToCamelCaseForString(input: String, startFromFirstChar: Bool) -> String
328 | {
329 | var str = input.stringByReplacingOccurrencesOfString(" ", withString: "")
330 |
331 | str = str.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
332 | var output = ""
333 | var makeNextCharUpperCase = startFromFirstChar
334 | for char in input.characters{
335 | if char == "_" {
336 | makeNextCharUpperCase = true
337 | }else if makeNextCharUpperCase{
338 | let upperChar = String(char).uppercaseString
339 | output += upperChar
340 | makeNextCharUpperCase = false
341 | }else{
342 | makeNextCharUpperCase = false
343 | output += String(char)
344 | }
345 | }
346 |
347 | return output
348 | }
349 |
350 | /**
351 | Creats and returns the class name for the passed proeprty name
352 |
353 | - parameter propertyName: to be converted to a type name
354 | - returns: the type name
355 | */
356 | func typeNameForPropertyName(propertyName : String) -> String{
357 | var swiftClassName = underscoresToCamelCaseForString(propertyName, startFromFirstChar: true).toSingular()
358 |
359 | if !swiftClassName.hasPrefix(classPrefix){
360 | swiftClassName = "\(classPrefix)\(swiftClassName)"
361 | }
362 |
363 | return swiftClassName
364 | }
365 |
366 | }
--------------------------------------------------------------------------------
/JSONExport/FilePreviewCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FilePreviewCell.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed on 11/10/14.
6 | // Copyright (c) 2014 Ahmed Ali. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | class FilePreviewCell: NSTableCellView, NSTextViewDelegate {
12 |
13 |
14 | @IBOutlet var classNameLabel: NSTextFieldCell!
15 | @IBOutlet var constructors: NSButton!
16 | @IBOutlet var utilities: NSButton!
17 | @IBOutlet var textView: NSTextView!
18 | @IBOutlet var scrollView: NSScrollView!
19 |
20 |
21 | var file: FileRepresenter!{
22 | didSet{
23 | if file != nil{
24 | var fileName = file.className
25 | fileName += "."
26 | if file is HeaderFileRepresenter{
27 | fileName += file.lang.headerFileData.headerFileExtension
28 | }else{
29 | fileName += file.lang.fileExtension
30 | }
31 | classNameLabel.stringValue = fileName
32 | if(textView != nil){
33 | textView.string = file.toString()
34 | }
35 |
36 | if file.includeConstructors{
37 | constructors.state = NSOnState
38 | }else{
39 | constructors.state = NSOffState
40 | }
41 | if file.includeUtilities{
42 | utilities.state = NSOnState
43 | }else{
44 | utilities.state = NSOffState
45 | }
46 | }else{
47 | classNameLabel.stringValue = ""
48 | }
49 | }
50 | }
51 |
52 |
53 |
54 | override func awakeFromNib() {
55 | super.awakeFromNib()
56 | if textView != nil{
57 | textView.delegate = self
58 | setupNumberedTextView()
59 | }
60 | }
61 |
62 | func setupNumberedTextView()
63 | {
64 | let lineNumberView = NoodleLineNumberView(scrollView: scrollView)
65 | scrollView.hasHorizontalRuler = false
66 | scrollView.hasVerticalRuler = true
67 | scrollView.verticalRulerView = lineNumberView
68 | scrollView.rulersVisible = true
69 | textView.font = NSFont.userFixedPitchFontOfSize(NSFont.smallSystemFontSize())
70 |
71 | }
72 |
73 | @IBAction func toggleConstructors(sender: NSButtonCell)
74 | {
75 | if file != nil{
76 | file.includeConstructors = (sender.state == NSOnState)
77 | textView.string = file.toString()
78 |
79 | }
80 | }
81 |
82 | @IBAction func toggleUtilityMethods(sender: NSButtonCell)
83 | {
84 | if file != nil{
85 | file.includeUtilities = (sender.state == NSOnState)
86 | textView.string = file.toString()
87 | }
88 | }
89 |
90 | func textDidChange(notification: NSNotification) {
91 | file.fileContent = textView.string ?? file.fileContent
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/JSONExport/HeaderFileData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HeaderFileData.swift
3 | //
4 | // Create by Ahmed Ali on 23/11/2014
5 | // Copyright © 2014 Mobile Developer. All rights reserved.
6 | //
7 |
8 | import Foundation
9 |
10 | class HeaderFileData{
11 |
12 | var constructorSignatures : [String]!
13 | var headerFileExtension : String!
14 | var importForEachCustomType : String!
15 | var importParentHeaderFile : String!
16 | var instanceVarDefinition : String!
17 | var instanceVarWithSpeicalDefinition : String!
18 | var modelDefinition : String!
19 | var modelDefinitionWithParent : String!
20 | var defaultParentWithUtilityMethods : String!
21 | var modelEnd : String!
22 | var modelStart : String!
23 | var staticImports : String!
24 | var typesNeedSpecialDefinition : [String]!
25 | var utilityMethodSignatures : [String]!
26 |
27 |
28 | /**
29 | * Instantiate the instance using the passed dictionary values to set the properties values
30 | */
31 | init(fromDictionary dictionary: NSDictionary){
32 | constructorSignatures = dictionary["constructorSignatures"] as? [String]
33 | headerFileExtension = dictionary["headerFileExtension"] as? String
34 | importForEachCustomType = dictionary["importForEachCustomType"] as? String
35 | importParentHeaderFile = dictionary["importParentHeaderFile"] as? String
36 | instanceVarDefinition = dictionary["instanceVarDefinition"] as? String
37 |
38 | instanceVarWithSpeicalDefinition = dictionary["instanceVarWithSpeicalDefinition"] as? String
39 | modelDefinition = dictionary["modelDefinition"] as? String
40 | modelDefinitionWithParent = dictionary["modelDefinitionWithParent"] as? String
41 | defaultParentWithUtilityMethods = dictionary["defaultParentWithUtilityMethods"] as? String
42 | modelEnd = dictionary["modelEnd"] as? String
43 | modelStart = dictionary["modelStart"] as? String
44 | staticImports = dictionary["staticImports"] as? String
45 | typesNeedSpecialDefinition = dictionary["typesNeedSpecialDefinition"] as? [String]
46 | utilityMethodSignatures = dictionary["utilityMethodSignatures"] as? [String]
47 |
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/JSONExport/HeaderFileRepresenter.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HeaderFileRepresenter.swift
3 | // JSONExport
4 | // Created by Ahmed Ali on 11/23/14.
5 | // Copyright (c) 2014 Ahmed Ali. Eng.Ahmed.Ali.Awad@gmail.com.
6 | //
7 | // Redistribution and use in source and binary forms, with or without
8 | // modification, are permitted provided that the following conditions
9 | // are met:
10 | //
11 | // 1. Redistributions of source code must retain the above copyright
12 | // notice, this list of conditions and the following disclaimer.
13 | // 2. Redistributions in binary form must reproduce the above copyright
14 | // notice, this list of conditions and the following disclaimer in the
15 | // documentation and/or other materials provided with the distribution.
16 | // 3. The name of the contributor can not be used to endorse or promote products derived from this software
17 | // without specific prior written permission.
18 | //
19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30 | // OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 |
33 | import Foundation
34 | import AddressBook
35 |
36 | class HeaderFileRepresenter : FileRepresenter{
37 | /**
38 | Generates the header file content and stores it in the fileContent property
39 | */
40 | override func toString() -> String{
41 | fileContent = ""
42 | appendCopyrights()
43 | appendStaticImports()
44 | appendImportParentHeader()
45 | appendCustomImports()
46 |
47 | //start the model defination
48 | var definition = ""
49 | if lang.headerFileData.modelDefinitionWithParent != nil && parentClassName.characters.count > 0{
50 | definition = lang.headerFileData.modelDefinitionWithParent.stringByReplacingOccurrencesOfString(modelName, withString: className)
51 | definition = definition.stringByReplacingOccurrencesOfString(modelWithParentClassName, withString: parentClassName)
52 | }else if includeUtilities && lang.defaultParentWithUtilityMethods != nil{
53 | definition = lang.headerFileData.modelDefinitionWithParent.stringByReplacingOccurrencesOfString(modelName, withString: className)
54 | definition = definition.stringByReplacingOccurrencesOfString(modelWithParentClassName, withString: lang.headerFileData.defaultParentWithUtilityMethods)
55 | }else{
56 | definition = lang.headerFileData.modelDefinition.stringByReplacingOccurrencesOfString(modelName, withString: className)
57 | }
58 |
59 | fileContent += definition
60 | //start the model content body
61 | fileContent += "\(lang.modelStart)"
62 |
63 | appendProperties()
64 | appendInitializers()
65 | appendUtilityMethods()
66 | fileContent += lang.modelEnd
67 | return fileContent
68 | }
69 |
70 |
71 |
72 | /**
73 | Appends the lang.headerFileData.staticImports if any
74 | */
75 | override func appendStaticImports()
76 | {
77 | if lang.headerFileData.staticImports != nil{
78 | fileContent += lang.headerFileData.staticImports
79 | fileContent += "\n"
80 | }
81 | }
82 |
83 | func appendImportParentHeader()
84 | {
85 | if lang.headerFileData.importParentHeaderFile != nil && parentClassName.characters.count > 0{
86 | fileContent += lang.headerFileData.importParentHeaderFile.stringByReplacingOccurrencesOfString(modelWithParentClassName, withString: parentClassName)
87 | }
88 | }
89 |
90 | /**
91 | Tries to access the address book in order to fetch basic information about the author so it can include a nice copyright statment
92 | */
93 | override func appendCopyrights()
94 | {
95 | if let me = ABAddressBook.sharedAddressBook()?.me(){
96 | fileContent += "//\n//\t\(className).\(lang.headerFileData.headerFileExtension)\n"
97 | if let firstName = me.valueForProperty(kABFirstNameProperty as String) as? String{
98 | fileContent += "//\n//\tCreate by \(firstName)"
99 | if let lastName = me.valueForProperty(kABLastNameProperty as String) as? String{
100 | fileContent += " \(lastName)"
101 | }
102 | }
103 |
104 |
105 | fileContent += " on \(getTodayFormattedDay())\n//\tCopyright © \(getYear())"
106 |
107 | if let organization = me.valueForProperty(kABOrganizationProperty as String) as? String{
108 | fileContent += " \(organization)"
109 | }
110 |
111 | fileContent += ". All rights reserved.\n//\n\n"
112 | fileContent += "//\t模型生成器 JSONExport: https://github.com/Ahmed-Ali/JSONExport\n\n"
113 | }
114 |
115 | }
116 |
117 |
118 | /**
119 | Loops on all properties which has a custom type and appends the custom import from the lang.headerFileData's importForEachCustomType property
120 |
121 | */
122 | override func appendCustomImports()
123 | {
124 | if lang.importForEachCustomType != nil{
125 | for property in properties{
126 | if property.isCustomClass{
127 | fileContent += lang.headerFileData.importForEachCustomType.stringByReplacingOccurrencesOfString(modelName, withString: property.type)
128 | }else if property.isArray{
129 | //if it is an array of custom types
130 | if(property.elementsType != lang.genericType){
131 | let basicTypes = lang.dataTypes.toDictionary().allValues as! [String]
132 | if basicTypes.indexOf(property.elementsType) == nil{
133 | fileContent += lang.headerFileData.importForEachCustomType.stringByReplacingOccurrencesOfString(modelName, withString: property.elementsType)
134 | }
135 | }
136 |
137 | }
138 | }
139 | }
140 | }
141 |
142 | /**
143 | Appends all the properties using the Property.stringPresentation method
144 | */
145 | override func appendProperties()
146 | {
147 | fileContent += "\n"
148 | for property in properties{
149 | fileContent += property.toString(true)
150 | }
151 | }
152 |
153 | /**
154 | Appends all the defined constructors (aka initializers) in lang.constructors to the fileContent
155 | */
156 | override func appendInitializers()
157 | {
158 | if !includeConstructors{
159 | return
160 | }
161 | fileContent += "\n"
162 | for constructorSignature in lang.headerFileData.constructorSignatures{
163 |
164 | fileContent += constructorSignature
165 |
166 | fileContent = fileContent.stringByReplacingOccurrencesOfString(modelName, withString: className)
167 | }
168 | }
169 |
170 |
171 | /**
172 | Appends all the defined utility methods in lang.utilityMethods to the fileContent
173 | */
174 | override func appendUtilityMethods()
175 | {
176 | if !includeUtilities{
177 | return
178 | }
179 | fileContent += "\n"
180 | for methodSignature in lang.headerFileData.utilityMethodSignatures{
181 | fileContent += methodSignature
182 | }
183 | }
184 | }
--------------------------------------------------------------------------------
/JSONExport/Images.xcassets/AppIcon.appiconset/128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport/Images.xcassets/AppIcon.appiconset/128x128.png
--------------------------------------------------------------------------------
/JSONExport/Images.xcassets/AppIcon.appiconset/16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport/Images.xcassets/AppIcon.appiconset/16x16.png
--------------------------------------------------------------------------------
/JSONExport/Images.xcassets/AppIcon.appiconset/256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport/Images.xcassets/AppIcon.appiconset/256x256.png
--------------------------------------------------------------------------------
/JSONExport/Images.xcassets/AppIcon.appiconset/32x32-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport/Images.xcassets/AppIcon.appiconset/32x32-1.png
--------------------------------------------------------------------------------
/JSONExport/Images.xcassets/AppIcon.appiconset/32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport/Images.xcassets/AppIcon.appiconset/32x32.png
--------------------------------------------------------------------------------
/JSONExport/Images.xcassets/AppIcon.appiconset/64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yagamis/JSONExport/98246501c55769c0d20da548f2c5834fcbe5487f/JSONExport/Images.xcassets/AppIcon.appiconset/64x64.png
--------------------------------------------------------------------------------
/JSONExport/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "16x16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "32x32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "32x32-1.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "64x64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "128x128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "256x256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "idiom" : "mac",
41 | "size" : "256x256",
42 | "scale" : "1x"
43 | },
44 | {
45 | "idiom" : "mac",
46 | "size" : "256x256",
47 | "scale" : "2x"
48 | },
49 | {
50 | "idiom" : "mac",
51 | "size" : "512x512",
52 | "scale" : "1x"
53 | },
54 | {
55 | "idiom" : "mac",
56 | "size" : "512x512",
57 | "scale" : "2x"
58 | }
59 | ],
60 | "info" : {
61 | "version" : 1,
62 | "author" : "xcode"
63 | }
64 | }
--------------------------------------------------------------------------------
/JSONExport/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSMinimumSystemVersion
26 | $(MACOSX_DEPLOYMENT_TARGET)
27 | NSHumanReadableCopyright
28 | Copyright © 2014 Ahmed Ali. All rights reserved.
29 | NSMainStoryboardFile
30 | Main
31 | NSPrincipalClass
32 | NSApplication
33 |
34 |
35 |
--------------------------------------------------------------------------------
/JSONExport/JSONExport-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 | #import "NoodleLineNumberView.h"
--------------------------------------------------------------------------------
/JSONExport/LangModel.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LangModel.swift
3 | //
4 | // Create by Ahmed Ali on 14/11/2014
5 | // Copyright (c) 2014 Mobile Developer. All rights reserved.
6 | //
7 |
8 | import Foundation
9 |
10 | class LangModel{
11 |
12 | var arrayType : String!
13 | var basicTypesWithSpecialFetchingNeeds : [String]!
14 | var basicTypesWithSpecialFetchingNeedsReplacements : [String]!
15 | var basicTypesWithSpecialStoringNeeds : [String]!
16 | var booleanGetter : String!
17 | var briefDescription : String!
18 | var constructors : [Constructor]!
19 | var dataTypes : DataType!
20 | var displayLangName : String!
21 | var fileExtension : String!
22 | var genericType : String!
23 | var getter : String!
24 | var importForEachCustomType : String!
25 | var importHeaderFile : String!
26 | var instanceVarDefinition : String!
27 | var instanceVarWithSpeicalDefinition : String!
28 | var typesNeedSpecialDefinition : [String]!
29 | var langName : String!
30 | var constVarDefinition : String!
31 | var modelDefinition : String!
32 | var modelDefinitionWithParent : String!
33 | var defaultParentWithUtilityMethods : String!
34 | var modelEnd : String!
35 | var modelStart : String!
36 | var setter : String!
37 | var staticImports : String!
38 | var supportsFirstLineStatement : Bool!
39 | var firstLineHint : String!
40 | var utilityMethods : [UtilityMethod]!
41 | var reservedKeywords : [String]!
42 | var wordsToRemoveToGetArrayElementsType : [String]!
43 | var headerFileData : HeaderFileData!
44 | var supportMutualRelationships : Bool!
45 |
46 | /**
47 | * Instantiate the instance using the passed dictionary values to set the properties values
48 | */
49 | init(fromDictionary dictionary: NSDictionary){
50 | arrayType = dictionary["arrayType"] as? String
51 | basicTypesWithSpecialFetchingNeeds = dictionary["basicTypesWithSpecialFetchingNeeds"] as? [String]
52 | basicTypesWithSpecialFetchingNeedsReplacements = dictionary["basicTypesWithSpecialFetchingNeedsReplacements"] as? [String]
53 | basicTypesWithSpecialStoringNeeds = dictionary["basicTypesWithSpecialStoringNeeds"] as? [String]
54 | booleanGetter = dictionary["booleanGetter"] as? String
55 | briefDescription = dictionary["briefDescription"] as? String
56 |
57 | constructors = [Constructor]()
58 | if let constructorsArray = dictionary["constructors"] as? [NSDictionary]{
59 | for dic in constructorsArray{
60 | let value = Constructor(fromDictionary: dic)
61 | constructors.append(value)
62 | }
63 | }
64 | if let dataTypesData = dictionary["dataTypes"] as? NSDictionary{
65 | dataTypes = DataType(fromDictionary: dataTypesData)
66 | }
67 | importHeaderFile = dictionary["importHeaderFile"] as? String
68 | displayLangName = dictionary["displayLangName"] as? String
69 | fileExtension = dictionary["fileExtension"] as? String
70 | genericType = dictionary["genericType"] as? String
71 | getter = dictionary["getter"] as? String
72 | importForEachCustomType = dictionary["importForEachCustomType"] as? String
73 | instanceVarDefinition = dictionary["instanceVarDefinition"] as? String
74 | instanceVarWithSpeicalDefinition = dictionary["instanceVarWithSpeicalDefinition"] as? String
75 | typesNeedSpecialDefinition = dictionary["typesNeedSpecialDefinition"] as? [String]
76 |
77 | langName = dictionary["langName"] as? String
78 | constVarDefinition = dictionary["constVarDefinition"] as? String
79 | modelDefinition = dictionary["modelDefinition"] as? String
80 | modelDefinitionWithParent = dictionary["modelDefinitionWithParent"] as? String
81 | defaultParentWithUtilityMethods = dictionary["defaultParentWithUtilityMethods"] as? String
82 | modelEnd = dictionary["modelEnd"] as? String
83 | modelStart = dictionary["modelStart"] as? String
84 | setter = dictionary["setter"] as? String
85 | staticImports = dictionary["staticImports"] as? String
86 | supportsFirstLineStatement = (dictionary["supportsFirstLineStatement"] as? NSString)?.boolValue
87 | firstLineHint = dictionary["firstLineHint"] as? String
88 | utilityMethods = [UtilityMethod]()
89 | if let utilityMethodsArray = dictionary["utilityMethods"] as? [NSDictionary]{
90 | for dic in utilityMethodsArray{
91 | let value = UtilityMethod(fromDictionary: dic)
92 | utilityMethods.append(value)
93 | }
94 | }
95 | reservedKeywords = dictionary["reservedKeywords"] as? [String]
96 | wordsToRemoveToGetArrayElementsType = dictionary["wordsToRemoveToGetArrayElementsType"] as? [String]
97 |
98 | if let headerFileDataData = dictionary["headerFileData"] as? NSDictionary{
99 | headerFileData = HeaderFileData(fromDictionary: headerFileDataData)
100 | }
101 |
102 | supportMutualRelationships = (dictionary["supportMutualRelationships"] as? NSString)?.boolValue
103 | }
104 |
105 |
106 |
107 | }
--------------------------------------------------------------------------------
/JSONExport/NoodleLineNumberMarker.h:
--------------------------------------------------------------------------------
1 | //
2 | // NoodleLineNumberMarker.h
3 | // NoodleKit
4 | //
5 | // Created by Paul Kim on 9/30/08.
6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person
9 | // obtaining a copy of this software and associated documentation
10 | // files (the "Software"), to deal in the Software without
11 | // restriction, including without limitation the rights to use,
12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the
14 | // Software is furnished to do so, subject to the following
15 | // conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be
18 | // included in all copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | // OTHER DEALINGS IN THE SOFTWARE.
28 | //
29 |
30 | #import
31 |
32 | /*
33 | Marker for NoodleLineNumberView.
34 |
35 | For more details, see the related blog post at: http://www.noodlesoft.com/blog/2008/10/05/displaying-line-numbers-with-nstextview/
36 | */
37 |
38 | @interface NoodleLineNumberMarker : NSRulerMarker
39 | {
40 | NSUInteger _lineNumber;
41 | }
42 |
43 | - (id)initWithRulerView:(NSRulerView *)aRulerView lineNumber:(CGFloat)line image:(NSImage *)anImage imageOrigin:(NSPoint)imageOrigin;
44 |
45 | - (void)setLineNumber:(NSUInteger)line;
46 | - (NSUInteger)lineNumber;
47 |
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/JSONExport/NoodleLineNumberMarker.m:
--------------------------------------------------------------------------------
1 | //
2 | // NoodleLineNumberMarker.m
3 | // NoodleKit
4 | //
5 | // Created by Paul Kim on 9/30/08.
6 | // Copyright (c) 2008 Noodlesoft, LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person
9 | // obtaining a copy of this software and associated documentation
10 | // files (the "Software"), to deal in the Software without
11 | // restriction, including without limitation the rights to use,
12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the
14 | // Software is furnished to do so, subject to the following
15 | // conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be
18 | // included in all copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | // OTHER DEALINGS IN THE SOFTWARE.
28 | //
29 |
30 | #import "NoodleLineNumberMarker.h"
31 |
32 |
33 | @implementation NoodleLineNumberMarker
34 |
35 | - (id)initWithRulerView:(NSRulerView *)aRulerView lineNumber:(CGFloat)line image:(NSImage *)anImage imageOrigin:(NSPoint)imageOrigin
36 | {
37 | if ((self = [super initWithRulerView:aRulerView markerLocation:0.0 image:anImage imageOrigin:imageOrigin]) != nil)
38 | {
39 | _lineNumber = line;
40 | }
41 | return self;
42 | }
43 |
44 | - (void)setLineNumber:(NSUInteger)line
45 | {
46 | _lineNumber = line;
47 | }
48 |
49 | - (NSUInteger)lineNumber
50 | {
51 | return _lineNumber;
52 | }
53 |
54 | #pragma mark NSCoding methods
55 |
56 | #define NOODLE_LINE_CODING_KEY @"line"
57 |
58 | - (id)initWithCoder:(NSCoder *)decoder
59 | {
60 | if ((self = [super initWithCoder:decoder]) != nil)
61 | {
62 | if ([decoder allowsKeyedCoding])
63 | {
64 | _lineNumber = [[decoder decodeObjectForKey:NOODLE_LINE_CODING_KEY] unsignedIntegerValue];
65 | }
66 | else
67 | {
68 | _lineNumber = [[decoder decodeObject] unsignedIntegerValue];
69 | }
70 | }
71 | return self;
72 | }
73 |
74 | - (void)encodeWithCoder:(NSCoder *)encoder
75 | {
76 | [super encodeWithCoder:encoder];
77 |
78 | if ([encoder allowsKeyedCoding])
79 | {
80 | [encoder encodeObject:[NSNumber numberWithUnsignedInteger:_lineNumber] forKey:NOODLE_LINE_CODING_KEY];
81 | }
82 | else
83 | {
84 | [encoder encodeObject:[NSNumber numberWithUnsignedInteger:_lineNumber]];
85 | }
86 | }
87 |
88 |
89 | #pragma mark NSCopying methods
90 |
91 | - (id)copyWithZone:(NSZone *)zone
92 | {
93 | id copy;
94 |
95 | copy = [super copyWithZone:zone];
96 | [copy setLineNumber:_lineNumber];
97 |
98 | return copy;
99 | }
100 |
101 |
102 | @end
103 |
--------------------------------------------------------------------------------
/JSONExport/NoodleLineNumberView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NoodleLineNumberView.h
3 | // NoodleKit
4 | //
5 | // Created by Paul Kim on 9/28/08.
6 | // Copyright (c) 2008-2012 Noodlesoft, LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person
9 | // obtaining a copy of this software and associated documentation
10 | // files (the "Software"), to deal in the Software without
11 | // restriction, including without limitation the rights to use,
12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the
14 | // Software is furnished to do so, subject to the following
15 | // conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be
18 | // included in all copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | // OTHER DEALINGS IN THE SOFTWARE.
28 | //
29 |
30 | #import
31 |
32 | /*
33 | Displays line numbers for an NSTextView.
34 |
35 | For more details, see the related blog post at: http://www.noodlesoft.com/blog/2008/10/05/displaying-line-numbers-with-nstextview/
36 | */
37 |
38 | @class NoodleLineNumberMarker;
39 |
40 | @interface NoodleLineNumberView : NSRulerView
41 | {
42 | // Array of character indices for the beginning of each line
43 | NSMutableArray *_lineIndices;
44 | // When text is edited, this is the start of the editing region. All line calculations after this point are invalid
45 | // and need to be recalculated.
46 | NSUInteger _invalidCharacterIndex;
47 |
48 | // Maps line numbers to markers
49 | NSMutableDictionary *_linesToMarkers;
50 |
51 | NSFont *_font;
52 | NSColor *_textColor;
53 | NSColor *_alternateTextColor;
54 | NSColor *_backgroundColor;
55 | }
56 |
57 | @property (readwrite, retain) NSFont *font;
58 | @property (readwrite, retain) NSColor *textColor;
59 | @property (readwrite, retain) NSColor *alternateTextColor;
60 | @property (readwrite, retain) NSColor *backgroundColor;
61 |
62 | - (id)initWithScrollView:(NSScrollView *)aScrollView;
63 |
64 | - (NSUInteger)lineNumberForLocation:(CGFloat)location;
65 | - (NoodleLineNumberMarker *)markerAtLine:(NSUInteger)line;
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/JSONExport/Property.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PropertyPresenter.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed on 11/2/14.
6 | // Copyright (c) 2014 Ahmed Ali. Eng.Ahmed.Ali.Awad@gmail.com.
7 | //
8 | // Redistribution and use in source and binary forms, with or without
9 | // modification, are permitted provided that the following conditions
10 | // are met:
11 | //
12 | // 1. Redistributions of source code must retain the above copyright
13 | // notice, this list of conditions and the following disclaimer.
14 | // 2. Redistributions in binary form must reproduce the above copyright
15 | // notice, this list of conditions and the following disclaimer in the
16 | // documentation and/or other materials provided with the distribution.
17 | // 3. The name of the contributor can not be used to endorse or promote products derived from this software
18 | // without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 | // OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import Foundation
34 |
35 | /**
36 | Represents all the meta data needed to export a JSON property in a valid syntax for the target language
37 | */
38 | class Property : Equatable{
39 |
40 | /**
41 | The native name that is suitable to export the JSON property in the target language
42 | */
43 | var nativeName : String
44 |
45 | /**
46 | The JSON property name to fetch the value of this property from a JSON object
47 | */
48 | var jsonName : String
49 |
50 | var constName : String?
51 |
52 | /**
53 | The string representation for the property type
54 | */
55 | var type : String
56 |
57 | /**
58 | Whether the property represents a custom type
59 | */
60 | var isCustomClass : Bool
61 |
62 | /**
63 | Whether the property represents an array
64 | */
65 | var isArray : Bool
66 |
67 | /**
68 | The target language model
69 | */
70 | var lang : LangModel
71 |
72 | /**
73 | A sample value which this property represents
74 | */
75 | var sampleValue : AnyObject!
76 |
77 |
78 | /**
79 | If this property is an array, this property should contain the type for its elements
80 | */
81 | var elementsType = ""
82 |
83 | /**
84 | For array properties, depetermines if the elements type is a custom type
85 | */
86 | var elementsAreOfCustomType = false
87 |
88 | /**
89 | Returns a valid property declaration using the LangModel.instanceVarDefinition value
90 | */
91 | func toString(forHeaderFile: Bool = false) -> String
92 | {
93 | var string : String!
94 | if forHeaderFile{
95 | if lang.headerFileData.instanceVarWithSpeicalDefinition != nil && lang.headerFileData.typesNeedSpecialDefinition.indexOf(type) != nil{
96 | string = lang.headerFileData.instanceVarWithSpeicalDefinition
97 | }else{
98 | string = lang.headerFileData.instanceVarDefinition
99 | }
100 |
101 |
102 | }else{
103 | if lang.instanceVarWithSpeicalDefinition != nil && lang.typesNeedSpecialDefinition.indexOf(type) != nil{
104 | string = lang.instanceVarWithSpeicalDefinition
105 | }else{
106 | string = lang.instanceVarDefinition
107 | }
108 | }
109 |
110 | string = string.stringByReplacingOccurrencesOfString(varType, withString: type)
111 | string = string.stringByReplacingOccurrencesOfString(varName, withString: nativeName)
112 | return string
113 | }
114 |
115 | func toConstVar(className: String) -> String
116 | {
117 | var string : String!
118 | if lang.constVarDefinition != nil {
119 | string = lang.constVarDefinition
120 | } else {
121 | string = ""
122 | }
123 | self.constName = "k"+className+nativeName.uppercaseFirstChar()
124 |
125 | string = string.stringByReplacingOccurrencesOfString(constKeyName, withString: constName!)
126 | string = string.stringByReplacingOccurrencesOfString(jsonKeyName, withString: jsonName)
127 | return string
128 | }
129 |
130 |
131 | /**
132 | The designated initializer for the class
133 | */
134 | init(jsonName: String, nativeName: String, type: String, isArray: Bool, isCustomClass: Bool, lang: LangModel)
135 | {
136 | self.jsonName = jsonName.stringByReplacingOccurrencesOfString(" ", withString: "")
137 | self.nativeName = nativeName.stringByReplacingOccurrencesOfString(" ", withString: "")
138 | self.type = type
139 | self.isArray = isArray
140 | self.isCustomClass = isCustomClass
141 | self.lang = lang
142 | }
143 |
144 |
145 | /**
146 | Convenience initializer which calls the designated initializer with isArray = false and isCustomClass = false
147 | */
148 | convenience init(jsonName: String, nativeName: String, type: String, lang: LangModel){
149 | self.init(jsonName: jsonName, nativeName: nativeName, type: type, isArray: false, isCustomClass: false, lang: lang)
150 | }
151 |
152 |
153 |
154 |
155 | }
156 |
157 | //For Equatable implementation
158 | func ==(lhs: Property, rhs: Property) -> Bool
159 | {
160 | var matched = ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
161 | if !matched{
162 | matched = (lhs.nativeName == rhs.nativeName && lhs.jsonName == rhs.jsonName && lhs.type == rhs.type && lhs.isCustomClass == rhs.isCustomClass && lhs.isArray == rhs.isArray && lhs.elementsType == rhs.elementsType && lhs.elementsAreOfCustomType == rhs.elementsAreOfCustomType)
163 | }
164 | return matched
165 | }
--------------------------------------------------------------------------------
/JSONExport/SharedConstants.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SharedConstants.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed on 11/7/14.
6 | // Copyright (c) 2014 Ahmed Ali. Eng.Ahmed.Ali.Awad@gmail.com.
7 | //
8 | // Redistribution and use in source and binary forms, with or without
9 | // modification, are permitted provided that the following conditions
10 | // are met:
11 | //
12 | // 1. Redistributions of source code must retain the above copyright
13 | // notice, this list of conditions and the following disclaimer.
14 | // 2. Redistributions in binary form must reproduce the above copyright
15 | // notice, this list of conditions and the following disclaimer in the
16 | // documentation and/or other materials provided with the distribution.
17 | // 3. The name of the contributor can not be used to endorse or promote products derived from this software
18 | // without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 | // OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import Foundation
34 |
35 | let elementType = ""
36 | let modelName = ""
37 | let modelWithParentClassName = ""
38 | let varName = ""
39 | let capitalizedVarName = ""
40 | let varType = ""
41 | let varTypeReplacement = ""
42 | let capitalizedVarType = ""
43 | let lowerCaseVarType = ""
44 | let lowerCaseModelName = ""
45 | let jsonKeyName = ""
46 | let constKeyName = ""
47 | let additionalCustomTypeProperty = ""
48 |
49 |
--------------------------------------------------------------------------------
/JSONExport/SharedUtilityMethods.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SharedUtilityMethods.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed Ali on 11/23/14.
6 | // Copyright (c) 2014 Ahmed Ali. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | /**
13 | Creats and returns the type name for the passed value
14 |
15 | - parameter value: example value to figure out its type
16 | - returns: the type name
17 | */
18 | func propertyTypeName(value : AnyObject, lang: LangModel) -> String
19 | {
20 | var name = ""
21 | if value is NSArray{
22 | name = typeNameForArrayOfElements(value as! NSArray, lang:lang)
23 | }else if value is NSNumber{
24 | name = typeForNumber(value as! NSNumber, lang: lang)
25 | }else if value is NSString{
26 | let booleans : [String] = ["True", "true", "TRUE", "False", "false", "FALSE"]
27 | if booleans.indexOf((value as! String)) != nil{
28 | name = lang.dataTypes.boolType
29 | }else{
30 | name = lang.dataTypes.stringType
31 | }
32 | }else if value is NSNull{
33 | name = lang.genericType
34 | }
35 |
36 | return name
37 | }
38 |
39 | /**
40 | Tries to figur out the type of the elements of the passed array and returns the type that can be used as the type of any element in the array
41 |
42 | - parameter elements: array to try to find out which type is suitable for its elements
43 |
44 | - returns: typeName the type name as String
45 | */
46 |
47 | func typeNameForArrayElements(elements: NSArray, lang: LangModel) -> String{
48 | var typeName : String!
49 | let genericType = lang.genericType
50 | if elements.count == 0{
51 | typeName = genericType
52 | }
53 | for element in elements{
54 | let currElementTypeName = propertyTypeName(element, lang: lang)
55 |
56 | if typeName == nil{
57 | typeName = currElementTypeName
58 |
59 | }else{
60 | if typeName != currElementTypeName{
61 | typeName = genericType
62 | break
63 | }
64 | }
65 | }
66 |
67 | return typeName
68 | }
69 |
70 | /**
71 | Tries to figur out the type of the elements of the passed array and returns the type of the array that can hold these values
72 |
73 | - parameter elements: array to try to find out which type is suitable for its elements
74 |
75 | - returns: the type name
76 | */
77 | func typeNameForArrayOfElements(elements: NSArray, lang: LangModel) -> String{
78 | var typeName : String!
79 | let genericType = lang.arrayType.stringByReplacingOccurrencesOfString(elementType, withString: lang.genericType)
80 | if elements.count == 0{
81 | typeName = genericType
82 | }
83 | for element in elements{
84 | let currElementTypeName = propertyTypeName(element, lang: lang)
85 |
86 | let arrayTypeName = lang.arrayType.stringByReplacingOccurrencesOfString(elementType, withString: currElementTypeName)
87 |
88 | if typeName == nil{
89 | typeName = arrayTypeName
90 |
91 | }else{
92 | if typeName != arrayTypeName{
93 | typeName = genericType
94 | break
95 | }
96 | }
97 | }
98 |
99 | return typeName
100 | }
101 |
102 | /**
103 | Returns one of the possible types for any numeric value (int, float, double, etc...)
104 |
105 | - parameter number: the numeric value
106 | - returns: the type name
107 | */
108 | func typeForNumber(number : NSNumber, lang: LangModel) -> String
109 | {
110 | let numberType = CFNumberGetType(number as CFNumberRef)
111 |
112 | var typeName : String!
113 | switch numberType{
114 | case .CharType:
115 | if (number.intValue == 0 || number.intValue == 1){
116 | //it seems to be boolean
117 | typeName = lang.dataTypes.boolType
118 | }else{
119 | typeName = lang.dataTypes.characterType
120 | }
121 | case .ShortType, .IntType:
122 | typeName = lang.dataTypes.intType
123 | case .FloatType, .Float32Type, .Float64Type:
124 | typeName = lang.dataTypes.floatType
125 | case .DoubleType:
126 | typeName = lang.dataTypes.doubleType
127 | case .LongType, .LongLongType:
128 | typeName = lang.dataTypes.longType
129 | default:
130 | typeName = lang.dataTypes.intType
131 | }
132 |
133 | return typeName
134 | }
135 |
136 |
137 | /**
138 | Creates and returns a dictionary who is built up by combining all the dictionary elements in the passed array.
139 |
140 | - parameter array: array of dictionaries.
141 | - returns: dictionary that combines all the dictionary elements in the array.
142 | */
143 | func unionDictionaryFromArrayElements(array: NSArray) -> NSDictionary
144 | {
145 | let dictionary = NSMutableDictionary()
146 | for item in array{
147 | if let dic = item as? NSDictionary{
148 | //loop all over its keys
149 | for key in dic.allKeys as! [String]{
150 | dictionary[key] = dic[key]
151 | }
152 | }
153 | }
154 | return dictionary
155 | }
156 |
157 |
158 | /**
159 | Cleans up the passed string from any characters that can make it invalid JSON string.
160 |
161 | - parameter jsonStr: the JSON string to be cleaned up
162 | - returns: a clean version of the passed string
163 | */
164 |
165 | func jsonStringByRemovingUnwantedCharacters(jsonString: String) -> String
166 | {
167 | var str = jsonString;
168 | str = str.stringByReplacingOccurrencesOfString("“", withString: "\"")
169 | str = str.stringByReplacingOccurrencesOfString("”", withString: "\"")
170 | return stringByRemovingControlCharacters(str)
171 | }
172 |
173 | /**
174 | Cleans up the passed string from any control characters.
175 |
176 | - parameter string: the string to be cleaned up
177 | - returns: a clean version of the passed string
178 | */
179 |
180 | func stringByRemovingControlCharacters(string: String) -> String
181 | {
182 | let controlChars = NSCharacterSet.controlCharacterSet()
183 | var range = string.rangeOfCharacterFromSet(controlChars)
184 | var cleanString = string;
185 | while range != nil && !range!.isEmpty{
186 | cleanString = cleanString.stringByReplacingCharactersInRange(range!, withString: "")
187 | range = cleanString.rangeOfCharacterFromSet(controlChars)
188 | }
189 |
190 | return cleanString
191 |
192 | }
193 |
194 |
195 |
196 | func runOnBackground(task: () -> Void)
197 | {
198 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { () -> Void in
199 | task();
200 | })
201 | }
202 |
203 | func runOnUiThread(task: () -> Void)
204 | {
205 | dispatch_async(dispatch_get_main_queue(), { () -> Void in
206 | task();
207 | })
208 | }
209 |
210 |
--------------------------------------------------------------------------------
/JSONExport/StringExtension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // StringExtension.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed on 11/8/14.
6 | // Copyright (c) 2014 Ahmed Ali. Eng.Ahmed.Ali.Awad@gmail.com.
7 | //
8 | // Redistribution and use in source and binary forms, with or without
9 | // modification, are permitted provided that the following conditions
10 | // are met:
11 | //
12 | // 1. Redistributions of source code must retain the above copyright
13 | // notice, this list of conditions and the following disclaimer.
14 | // 2. Redistributions in binary form must reproduce the above copyright
15 | // notice, this list of conditions and the following disclaimer in the
16 | // documentation and/or other materials provided with the distribution.
17 | // 3. The name of the contributor can not be used to endorse or promote products derived from this software
18 | // without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 | // OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import Foundation
34 |
35 | extension String{
36 | /**
37 | Very simple method converts the last characters of a string to convert from plural to singular. For example "parties" will be changed to "party" and "stars" will be changed to "star"
38 | The method does not handle any special cases, like uncountable name i.e "people" will not be converted to "person"
39 | */
40 | func toSingular() -> String
41 | {
42 | var singular = self
43 | let length = self.characters.count
44 | if length > 3{
45 | let range = Range(start: endIndex.advancedBy(-3), end: endIndex)
46 | let lastThreeChars = self.substringWithRange(range)
47 | if lastThreeChars == "ies" {
48 | singular = self.stringByReplacingOccurrencesOfString(lastThreeChars, withString: "y", options: [], range: range)
49 | return singular
50 | }
51 |
52 | }
53 | if length > 2{
54 | let range = Range(start: endIndex.advancedBy(-1), end: endIndex)
55 | let lastChar = self.substringWithRange(range)
56 | if lastChar == "s" {
57 | singular = self.stringByReplacingOccurrencesOfString(lastChar, withString: "", options: [], range: range)
58 | return singular
59 | }
60 | }
61 | return singular
62 | }
63 |
64 | /**
65 | Converts the first character to its lower case version
66 |
67 | - returns: the converted version
68 | */
69 | func lowercaseFirstChar() -> String{
70 | if self.characters.count > 0{
71 | let range = Range(start: startIndex, end: startIndex.advancedBy(1))
72 | let firstLowerChar = self.substringWithRange(range).lowercaseString
73 |
74 | return self.stringByReplacingCharactersInRange(range, withString: firstLowerChar)
75 | }else{
76 | return self
77 | }
78 |
79 | }
80 |
81 | /**
82 | Converts the first character to its upper case version
83 |
84 | - returns: the converted version
85 | */
86 | func uppercaseFirstChar() -> String{
87 | if self.characters.count > 0{
88 | let range = Range(start: startIndex, end: startIndex.advancedBy(1))
89 | let firstUpperChar = self.substringWithRange(range).uppercaseString
90 |
91 | return self.stringByReplacingCharactersInRange(range, withString: firstUpperChar)
92 | }else{
93 | return self
94 | }
95 |
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/JSONExport/Supported Languages/Swift-Class.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "reservedKeywords": [
5 | "abstract",
6 | "assert",
7 | "boolean",
8 | "break",
9 | "byte",
10 | "case",
11 | "catch",
12 | "char",
13 | "class",
14 | "const",
15 | "continue",
16 | "default",
17 | "do",
18 | "double",
19 | "else",
20 | "enum",
21 | "extends",
22 | "false",
23 | "final",
24 | "finally",
25 | "float",
26 | "for",
27 | "goto",
28 | "if",
29 | "implements",
30 | "import",
31 | "instanceof",
32 | "int",
33 | "interface",
34 | "long",
35 | "native",
36 | "new",
37 | "null",
38 | "package",
39 | "private",
40 | "protected",
41 | "public",
42 | "return",
43 | "short",
44 | "static",
45 | "strictfp",
46 | "super",
47 | "switch",
48 | "synchronized",
49 | "this",
50 | "throw",
51 | "throws",
52 | "transient",
53 | "true",
54 | "try",
55 | "void",
56 | "volatile",
57 | "while",
58 | "class",
59 | "description"
60 | ],
61 | "booleanGetter": "",
62 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
63 | "utilityMethods": [
64 | {
65 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
66 | "bodyEnd": "\t}\n",
67 | "signature": "\tfunc toDictionary() -> NSDictionary",
68 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
69 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
70 | "returnStatement": "\t\treturn dictionary\n",
71 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
72 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
73 | "bodyStart": "\n\t{\n"
74 | },
75 | {
76 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
77 | "bodyEnd": "\n\t}\n",
78 | "signature": " @objc required init(coder aDecoder: NSCoder)",
79 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
80 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
81 | "returnStatement": "",
82 | "body": "",
83 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
84 | "bodyStart": "\n\t{\n"
85 | },
86 | {
87 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
88 | "bodyEnd": "\n\t}\n",
89 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
90 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
91 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
92 | "returnStatement": "",
93 | "body": "",
94 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
95 | "bodyStart": "\n\t{\n"
96 | }
97 | ],
98 | "dataTypes": {
99 | "stringType": "String",
100 | "boolType": "Bool",
101 | "floatType": "Float",
102 | "doubleType": "Double",
103 | "characterType": "Character",
104 | "longType": "Double",
105 | "intType": "Int"
106 | },
107 | "wordsToRemoveToGetArrayElementsType": [
108 | "[",
109 | "]"
110 | ],
111 | "defaultParentWithUtilityMethods": "NSObject, NSCoding",
112 | "constructors": [
113 | {
114 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
115 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\t = (fromDictionary: Data)\n\t\t}\n",
116 | "bodyEnd": "\t}\n",
117 | "fetchBasicTypePropertyFromMap": "\t\t = dictionary[\"\"] as? \n",
118 | "signature": "\tinit(fromDictionary dictionary: NSDictionary)",
119 | "fetchArrayOfCustomTypePropertyFromMap": "\t\t = ()\n\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = (fromDictionary: dic)\n\t\t\t\t.append(value)\n\t\t\t}\n\t\t}\n",
120 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
121 | "bodyStart": "{\n"
122 | }
123 | ],
124 | "modelDefinition": "\nclass ",
125 | "genericType": "AnyObject",
126 | "getter": "",
127 | "setter": "",
128 | "displayLangName": "Swift - Class",
129 | "fileExtension": "swift",
130 | "basicTypesWithSpecialFetchingNeeds": [
131 | ],
132 | "arrayType": "[]",
133 | "modelDefinitionWithParent": "\n\nclass : ",
134 | "instanceVarDefinition": "\tvar : !\n",
135 | "supportsFirstLineStatement": "false",
136 | "modelEnd": "\n}",
137 | "staticImports": "import Foundation",
138 | "langName": "Swift"
139 | }
--------------------------------------------------------------------------------
/JSONExport/Supported Languages/Swift-CoreData.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "supportMutualRelationships": "true",
5 | "basicTypesWithSpecialStoringNeeds": [
6 | "Int",
7 | "Bool",
8 | "Character",
9 | "Float",
10 | "Double"
11 | ],
12 | "reservedKeywords": [
13 | "abstract",
14 | "assert",
15 | "boolean",
16 | "break",
17 | "byte",
18 | "case",
19 | "catch",
20 | "char",
21 | "class",
22 | "const",
23 | "continue",
24 | "default",
25 | "do",
26 | "double",
27 | "else",
28 | "enum",
29 | "extends",
30 | "false",
31 | "final",
32 | "finally",
33 | "float",
34 | "for",
35 | "goto",
36 | "if",
37 | "implements",
38 | "import",
39 | "instanceof",
40 | "int",
41 | "interface",
42 | "long",
43 | "native",
44 | "new",
45 | "null",
46 | "package",
47 | "private",
48 | "protected",
49 | "public",
50 | "return",
51 | "short",
52 | "static",
53 | "strictfp",
54 | "super",
55 | "switch",
56 | "synchronized",
57 | "this",
58 | "throw",
59 | "throws",
60 | "transient",
61 | "true",
62 | "try",
63 | "void",
64 | "volatile",
65 | "while",
66 | "class",
67 | "description"
68 | ],
69 | "booleanGetter": "",
70 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
71 | "instanceVarWithSpeicalDefinition": "\t@NSManaged var : \n",
72 | "utilityMethods": [
73 | {
74 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
75 | "bodyEnd": "\t}\n",
76 | "signature": "\tfunc toDictionary() -> NSDictionary",
77 | "forEachPropertyWithSpecialStoringNeeds": "\t\tdictionary[\"\"] = \n",
78 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
79 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
80 | "returnStatement": "\t\treturn dictionary\n",
81 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
82 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
83 | "bodyStart": "\n\t{\n"
84 | }
85 | ],
86 | "dataTypes": {
87 | "stringType": "String",
88 | "boolType": "Bool",
89 | "floatType": "Float",
90 | "doubleType": "Double",
91 | "characterType": "Character",
92 | "longType": "Double",
93 | "intType": "Int"
94 | },
95 | "wordsToRemoveToGetArrayElementsType": [
96 | "[",
97 | "]"
98 | ],
99 | "constructors": [
100 | {
101 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\t = Value\n\t\t}\n",
102 | "bodyStart": "\t{\n\t\tlet entity = NSEntityDescription.entityForName(\"\", inManagedObjectContext: context)!\n\t\tsuper.init(entity: entity, insertIntoManagedObjectContext: context)\n",
103 | "bodyEnd": "\t}\n",
104 | "fetchBasicTypePropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\t = Value\n\t\t}\n",
105 | "signature": "\tinit(fromDictionary dictionary: NSDictionary, context: NSManagedObjectContext)",
106 | "fetchArrayOfCustomTypePropertyFromMap": "\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tvar Set = NSMutableSet()\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = (fromDictionary: dic, context:context)\n\t\t\t\tSet.addObject(value)\n\t\t\t}\n\t\t\t = Set\n\t\t}\n",
107 | "comment": "\t/**\n\t * Instantiate the instance using the passed dictionary values to set the properties values\n\t */\n",
108 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\t = (fromDictionary: Data, context:context)\n\t\t}\n"
109 | }
110 | ],
111 | "modelDefinition": "\nclass : NSManagedObject",
112 | "genericType": "AnyObject",
113 | "getter": "",
114 | "setter": "",
115 | "fileExtension": "swift",
116 | "arrayType": "NSMutableSet",
117 | "modelDefinitionWithParent": "\n\nclass : ",
118 | "displayLangName": "Swift - CoreData",
119 | "basicTypesWithSpecialFetchingNeeds": [
120 | "Int",
121 | "Bool",
122 | "Character",
123 | "Float",
124 | "Double"
125 | ],
126 | "instanceVarDefinition": "\t@NSManaged var : !\n",
127 | "supportsFirstLineStatement": "false",
128 | "modelEnd": "\n}",
129 | "typesNeedSpecialDefinition": [
130 | "Int",
131 | "Bool",
132 | "Character",
133 | "Float",
134 | "Double"
135 | ],
136 | "staticImports": "import Foundation\nimport CoreData",
137 | "langName": "Swift"
138 | }
--------------------------------------------------------------------------------
/JSONExport/Supported Languages/Swift-Mappable.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "reservedKeywords": [
5 | "abstract",
6 | "assert",
7 | "boolean",
8 | "break",
9 | "byte",
10 | "case",
11 | "catch",
12 | "char",
13 | "class",
14 | "const",
15 | "continue",
16 | "default",
17 | "do",
18 | "double",
19 | "else",
20 | "enum",
21 | "extends",
22 | "false",
23 | "final",
24 | "finally",
25 | "float",
26 | "for",
27 | "goto",
28 | "if",
29 | "implements",
30 | "import",
31 | "instanceof",
32 | "int",
33 | "interface",
34 | "long",
35 | "native",
36 | "new",
37 | "null",
38 | "package",
39 | "private",
40 | "protected",
41 | "public",
42 | "return",
43 | "short",
44 | "static",
45 | "strictfp",
46 | "super",
47 | "switch",
48 | "synchronized",
49 | "this",
50 | "throw",
51 | "throws",
52 | "transient",
53 | "true",
54 | "try",
55 | "void",
56 | "volatile",
57 | "while",
58 | "class",
59 | "description"
60 | ],
61 | "booleanGetter": "",
62 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
63 | "utilityMethods": [
64 | {
65 | "forEachProperty": "\t\t <- map[\"\"]\n",
66 | "bodyEnd": "\t}\n",
67 | "signature": "\tfunc mapping(map: Map)",
68 | "forEachCustomTypeProperty": "\t\t <- map[\"\"]\n",
69 | "forEachArrayOfCustomTypeProperty": "\t\t <- map[\"\"]\n",
70 | "returnStatement": "\t\t\n",
71 | "body": "",
72 | "comment": "",
73 | "bodyStart": "\n\t{\n"
74 | },
75 | {
76 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
77 | "bodyEnd": "\n\t}\n",
78 | "signature": " @objc required init(coder aDecoder: NSCoder)",
79 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
80 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
81 | "returnStatement": "",
82 | "body": "",
83 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
84 | "bodyStart": "\n\t{\n"
85 | },
86 | {
87 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
88 | "bodyEnd": "\n\t}\n",
89 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
90 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
91 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
92 | "returnStatement": "",
93 | "body": "",
94 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
95 | "bodyStart": "\n\t{\n"
96 | }
97 | ],
98 | "dataTypes": {
99 | "stringType": "String",
100 | "boolType": "Bool",
101 | "floatType": "Float",
102 | "doubleType": "Double",
103 | "characterType": "Character",
104 | "longType": "Double",
105 | "intType": "Int"
106 | },
107 | "wordsToRemoveToGetArrayElementsType": [
108 | "[",
109 | "]"
110 | ],
111 | "defaultParentWithUtilityMethods": "NSObject, NSCoding, Mappable",
112 | "constructors": [
113 | {
114 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
115 | "bodyStart": "{\n\t\treturn ()",
116 | "bodyEnd": "\n\t}\n",
117 | "fetchBasicTypePropertyFromMap": "",
118 | "signature": "\tclass func newInstance(map: Map) -> Mappable?",
119 | "fetchArrayOfCustomTypePropertyFromMap": "",
120 | "comment": "",
121 | "fetchCustomTypePropertyFromMap": ""
122 | },
123 | {
124 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
125 | "bodyStart": "{",
126 | "bodyEnd": "}\n",
127 | "fetchBasicTypePropertyFromMap": "",
128 | "signature": "\tprivate override init()",
129 | "fetchArrayOfCustomTypePropertyFromMap": "",
130 | "comment": "",
131 | "fetchCustomTypePropertyFromMap": ""
132 | }
133 | ],
134 | "modelDefinition": "\nclass ",
135 | "genericType": "AnyObject",
136 | "getter": "",
137 | "setter": "",
138 | "displayLangName": "Swift - Mappable",
139 | "fileExtension": "swift",
140 | "basicTypesWithSpecialFetchingNeeds": [
141 | ],
142 | "arrayType": "[]",
143 | "modelDefinitionWithParent": "\n\nclass : ",
144 | "instanceVarDefinition": "\tvar : ?\n",
145 | "supportsFirstLineStatement": "false",
146 | "modelEnd": "\n}",
147 | "staticImports": "import Foundation",
148 | "langName": "Swift"
149 | }
--------------------------------------------------------------------------------
/JSONExport/Supported Languages/Swift-Realm.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": " {\n",
3 | "importForEachCustomType": "",
4 | "basicTypesWithSpecialStoringNeeds": [
5 | "Int",
6 | "Bool",
7 | "Int",
8 | "Float",
9 | "Double"
10 | ],
11 | "supportMutualRelationships": "true",
12 | "reservedKeywords": [
13 | "abstract",
14 | "assert",
15 | "boolean",
16 | "break",
17 | "byte",
18 | "case",
19 | "catch",
20 | "char",
21 | "class",
22 | "const",
23 | "continue",
24 | "default",
25 | "do",
26 | "double",
27 | "else",
28 | "enum",
29 | "extends",
30 | "false",
31 | "final",
32 | "finally",
33 | "float",
34 | "for",
35 | "goto",
36 | "if",
37 | "implements",
38 | "import",
39 | "instanceof",
40 | "int",
41 | "interface",
42 | "long",
43 | "native",
44 | "new",
45 | "null",
46 | "package",
47 | "private",
48 | "protected",
49 | "public",
50 | "return",
51 | "short",
52 | "static",
53 | "strictfp",
54 | "super",
55 | "switch",
56 | "synchronized",
57 | "this",
58 | "throw",
59 | "throws",
60 | "transient",
61 | "true",
62 | "try",
63 | "void",
64 | "volatile",
65 | "while",
66 | "class",
67 | "description"
68 | ],
69 | "booleanGetter": "",
70 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the built-in NSJSONSerialization class",
71 | "instanceVarWithSpeicalDefinition": "\tdynamic var : \n",
72 | "utilityMethods": [
73 | {
74 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
75 | "bodyEnd": "\t}\n",
76 | "signature": "\tfunc toDictionary() -> NSDictionary",
77 | "forEachPropertyWithSpecialStoringNeeds": "\t\tdictionary[\"\"] = \n",
78 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor i in 0 ..< .count {\n\t\t\t\tif let Element = [i] as? {\n\t\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t\t}\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
79 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
80 | "returnStatement": "\t\treturn dictionary\n",
81 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
82 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
83 | "bodyStart": "\n\t{\n"
84 | },
85 | {
86 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
87 | "bodyEnd": "\n\t}\n",
88 | "signature": " @objc required init(coder aDecoder: NSCoder)",
89 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
90 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
91 | "returnStatement": "",
92 | "forEachPropertyWithSpecialStoringNeeds": " = aDecoder.decodeObjectForKey(\"\") as? \n",
93 | "body": "",
94 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
95 | "bodyStart": "\n\t{\n"
96 | },
97 | {
98 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
99 | "bodyEnd": "\n\t}\n",
100 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
101 | "forEachPropertyWithSpecialStoringNeeds": " = aDecoder.decodeObjectForKey(\"\") as? \n",
102 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
103 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
104 | "returnStatement": "",
105 | "body": "",
106 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
107 | "bodyStart": "\n\t{\n"
108 | }
109 | ],
110 | "dataTypes": {
111 | "stringType": "String",
112 | "boolType": "Bool",
113 | "floatType": "Float",
114 | "doubleType": "Double",
115 | "characterType": "Int",
116 | "longType": "Double",
117 | "intType": "Int"
118 | },
119 | "wordsToRemoveToGetArrayElementsType": [
120 | "[",
121 | "]"
122 | ],
123 | "defaultParentWithUtilityMethods": "Object, NSCoding",
124 | "constructors": [
125 | {
126 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\tthis. = Value\n\t\t}\n",
127 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\tthis. = .fromDictionary(Data)\n\t\t}\n",
128 | "bodyEnd": "\t\treturn this\n\t}\n",
129 | "fetchBasicTypePropertyFromMap": "\t\tif let Value = dictionary[\"\"] as? {\n\t\t\tthis. = Value\n\t\t}\n",
130 | "signature": "\tclass func fromDictionary(dictionary: NSDictionary) -> ",
131 | "fetchArrayOfCustomTypePropertyFromMap": "\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tvar Items = List(objectClassName: .className())\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = .fromDictionary(dic)\n\t\t\t\tItems.addObject(value)\n\t\t\t}\n\t\t\t = Items\n\t\t}\n",
132 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
133 | "bodyStart": "\t{\n\t\tlet this = ()\n"
134 | }
135 | ],
136 | "modelDefinition": "\nclass : Object",
137 | "genericType": "AnyObject",
138 | "getter": "",
139 | "setter": "",
140 | "fileExtension": "swift",
141 | "arrayType": "List",
142 | "modelDefinitionWithParent": "\n\nclass : ",
143 | "displayLangName": "Swift - Realm",
144 | "basicTypesWithSpecialFetchingNeeds": [
145 | "Int",
146 | "Bool",
147 | "Int",
148 | "Float",
149 | "Double"
150 | ],
151 | "instanceVarDefinition": "\tdynamic var : !\n",
152 | "supportsFirstLineStatement": "false",
153 | "modelEnd": "\n}",
154 | "typesNeedSpecialDefinition": [
155 | "Int",
156 | "Bool",
157 | "Int",
158 | "Float",
159 | "Double"
160 | ],
161 | "staticImports": "",
162 | "langName": "Swift"
163 | }
--------------------------------------------------------------------------------
/JSONExport/Supported Languages/Swift-Struct.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "importForEachCustomType": "",
4 | "reservedKeywords": [
5 | "abstract",
6 | "assert",
7 | "boolean",
8 | "break",
9 | "byte",
10 | "case",
11 | "catch",
12 | "char",
13 | "class",
14 | "const",
15 | "continue",
16 | "default",
17 | "do",
18 | "double",
19 | "else",
20 | "enum",
21 | "extends",
22 | "false",
23 | "final",
24 | "finally",
25 | "float",
26 | "for",
27 | "goto",
28 | "if",
29 | "implements",
30 | "import",
31 | "instanceof",
32 | "int",
33 | "interface",
34 | "long",
35 | "native",
36 | "new",
37 | "null",
38 | "package",
39 | "private",
40 | "protected",
41 | "public",
42 | "return",
43 | "short",
44 | "static",
45 | "strictfp",
46 | "super",
47 | "switch",
48 | "synchronized",
49 | "this",
50 | "throw",
51 | "throws",
52 | "transient",
53 | "true",
54 | "try",
55 | "void",
56 | "volatile",
57 | "while",
58 | "class",
59 | "description"
60 | ],
61 | "booleanGetter": "",
62 | "briefDescription": "Defines how your JSON objects can be mapped to Swift structures using the built-in NSJSONSerialization class",
63 | "utilityMethods": [
64 | {
65 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
66 | "bodyEnd": "\t}\n",
67 | "signature": "\tfunc toDictionary() -> NSDictionary",
68 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
69 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
70 | "returnStatement": "\t\treturn dictionary\n",
71 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
72 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
73 | "bodyStart": "\n\t{\n"
74 | }
75 | ],
76 | "dataTypes": {
77 | "stringType": "String",
78 | "boolType": "Bool",
79 | "floatType": "Float",
80 | "doubleType": "Double",
81 | "characterType": "Character",
82 | "longType": "Double",
83 | "intType": "Int"
84 | },
85 | "wordsToRemoveToGetArrayElementsType": [
86 | "[",
87 | "]"
88 | ],
89 | "constructors": [
90 | {
91 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
92 | "bodyStart": "{\n",
93 | "bodyEnd": "\t}\n",
94 | "fetchBasicTypePropertyFromMap": "\t\t = dictionary[\"\"] as? \n",
95 | "signature": "\tinit(fromDictionary dictionary: NSDictionary)",
96 | "fetchArrayOfCustomTypePropertyFromMap": "\t\t = ()\n\t\tif let Array = dictionary[\"\"] as? [NSDictionary]{\n\t\t\tfor dic in Array{\n\t\t\t\tlet value = (fromDictionary: dic)\n\t\t\t\t.append(value)\n\t\t\t}\n\t\t}\n",
97 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
98 | "fetchCustomTypePropertyFromMap": "\t\tif let Data = dictionary[\"\"] as? NSDictionary{\n\t\t\t\t = (fromDictionary: Data)\n\t\t\t}\n"
99 | }
100 | ],
101 | "modelDefinition": "\nstruct ",
102 | "genericType": "AnyObject",
103 | "getter": "",
104 | "setter": "",
105 | "fileExtension": "swift",
106 | "arrayType": "[]",
107 | "basicTypesWithSpecialFetchingNeeds": [
108 | ],
109 | "displayLangName": "Swift - Struct",
110 | "instanceVarDefinition": "\tvar : !\n",
111 | "supportsFirstLineStatement": "false",
112 | "modelEnd": "\n}",
113 | "staticImports": "import Foundation",
114 | "langName": "Swift"
115 | }
--------------------------------------------------------------------------------
/JSONExport/Supported Languages/SwiftyJSON-Class.json:
--------------------------------------------------------------------------------
1 | {
2 | "modelStart": "{\n",
3 | "basicTypesWithSpecialFetchingNeedsReplacements": [
4 | "intValue",
5 | "boolValue",
6 | "charValue",
7 | "floatValue",
8 | "doubleValue",
9 | "stringValue",
10 | "stringValue"
11 | ],
12 | "importForEachCustomType": "",
13 | "reservedKeywords": [
14 | "abstract",
15 | "assert",
16 | "boolean",
17 | "break",
18 | "byte",
19 | "case",
20 | "catch",
21 | "char",
22 | "class",
23 | "const",
24 | "continue",
25 | "default",
26 | "do",
27 | "double",
28 | "else",
29 | "enum",
30 | "extends",
31 | "false",
32 | "final",
33 | "finally",
34 | "float",
35 | "for",
36 | "goto",
37 | "if",
38 | "implements",
39 | "import",
40 | "instanceof",
41 | "int",
42 | "interface",
43 | "long",
44 | "native",
45 | "new",
46 | "null",
47 | "package",
48 | "private",
49 | "protected",
50 | "public",
51 | "return",
52 | "short",
53 | "static",
54 | "strictfp",
55 | "super",
56 | "switch",
57 | "synchronized",
58 | "this",
59 | "throw",
60 | "throws",
61 | "transient",
62 | "true",
63 | "try",
64 | "void",
65 | "volatile",
66 | "while",
67 | "class",
68 | "description"
69 | ],
70 | "booleanGetter": "",
71 | "briefDescription": "Defines how your JSON objects can be mapped to Swift classes using the SwiftyJSON library",
72 | "utilityMethods": [
73 | {
74 | "forEachProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = \n\t\t}\n",
75 | "bodyEnd": "\t}\n",
76 | "signature": "\tfunc toDictionary() -> NSDictionary",
77 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\tdictionary[\"\"] = .toDictionary()\n\t\t}\n",
78 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\tvar dictionaryElements = [NSDictionary]()\n\t\t\tfor Element in {\n\t\t\t\tdictionaryElements.append(Element.toDictionary())\n\t\t\t}\n\t\t\tdictionary[\"\"] = dictionaryElements\n\t\t}\n",
79 | "returnStatement": "\t\treturn dictionary\n",
80 | "body": "\t\tvar dictionary = NSMutableDictionary()\n",
81 | "comment": "\t/**\n\t * 把所有属性值存到一个NSDictionary对象,键是相应的属性名。\n\t */\n",
82 | "bodyStart": "\n\t{\n"
83 | },
84 | {
85 | "forEachProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
86 | "bodyEnd": "\n\t}\n",
87 | "signature": " @objc required init(coder aDecoder: NSCoder)",
88 | "forEachCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
89 | "forEachArrayOfCustomTypeProperty": " = aDecoder.decodeObjectForKey(\"\") as? \n",
90 | "returnStatement": "",
91 | "body": "",
92 | "comment": "\n /**\n * NSCoding required initializer.\n * Fills the data from the passed decoder\n */\n",
93 | "bodyStart": "\n\t{\n"
94 | },
95 | {
96 | "forEachProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
97 | "bodyEnd": "\n\t}\n",
98 | "signature": " @objc func encodeWithCoder(aCoder: NSCoder)",
99 | "forEachCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
100 | "forEachArrayOfCustomTypeProperty": "\t\tif != nil{\n\t\t\taCoder.encodeObject(, forKey: \"\")\n\t\t}\n",
101 | "returnStatement": "",
102 | "body": "",
103 | "comment": "\n /**\n * NSCoding required method.\n * Encodes mode properties into the decoder\n */\n",
104 | "bodyStart": "\n\t{\n"
105 | }
106 | ],
107 | "dataTypes": {
108 | "stringType": "String",
109 | "boolType": "Bool",
110 | "floatType": "Float",
111 | "doubleType": "Double",
112 | "characterType": "Character",
113 | "longType": "Double",
114 | "intType": "Int"
115 | },
116 | "wordsToRemoveToGetArrayElementsType": [
117 | "[",
118 | "]"
119 | ],
120 | "defaultParentWithUtilityMethods": "NSObject, NSCoding",
121 | "constructors": [
122 | {
123 | "fetchArrayOfBasicTypePropertyFromMap": "\t\t = ()\n\t\tlet Array = json[\"\"].arrayValue\n\t\tfor Json in Array{\n\t\t\t.append(Json.)\n\t\t}\n",
124 | "fetchBasicTypeWithSpecialNeedsPropertyFromMap": "\t\t = json[\"\"].\n",
125 | "bodyStart": "{\n\t\tif json == nil{\n\t\t\treturn\n\t\t}\n",
126 | "bodyEnd": "\t}\n",
127 | "fetchBasicTypePropertyFromMap": "",
128 | "signature": "\tinit(fromJson json: JSON!)",
129 | "fetchArrayOfCustomTypePropertyFromMap": "\t\t = ()\n\t\tlet Array = json[\"\"].arrayValue\n\t\tfor Json in Array{\n\t\t\tlet value = (fromJson: Json)\n\t\t\t.append(value)\n\t\t}\n",
130 | "comment": "\t/**\n\t * 用字典来初始化一个实例并设置各个属性值\n\t */\n",
131 | "fetchCustomTypePropertyFromMap": "\t\tlet Json = json[\"\"]\n\t\tif Json != JSON.nullJSON{\n\t\t\t = (fromJson: Json)\n\t\t}\n"
132 | }
133 | ],
134 | "modelDefinition": "\nclass ",
135 | "genericType": "AnyObject",
136 | "getter": "",
137 | "setter": "",
138 | "displayLangName": "SwiftyJSON - Class",
139 | "fileExtension": "swift",
140 | "basicTypesWithSpecialFetchingNeeds": [
141 | "Int",
142 | "Bool",
143 | "Character",
144 | "Float",
145 | "Double",
146 | "String",
147 | "AnyObject"
148 | ],
149 | "arrayType": "[]",
150 | "modelDefinitionWithParent": "\n\nclass : ",
151 | "instanceVarDefinition": "\tvar : !\n",
152 | "supportsFirstLineStatement": "false",
153 | "modelEnd": "\n}",
154 | "staticImports": "import Foundation",
155 | "langName": "Swift"
156 | }
--------------------------------------------------------------------------------
/JSONExport/UtilityMethod.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UtilityMethod.swift
3 | //
4 | // Create by Ahmed Ali on 14/11/2014
5 | // Copyright (c) 2014 Mobile Developer. All rights reserved.
6 | //
7 |
8 | import Foundation
9 |
10 | class UtilityMethod{
11 |
12 |
13 | var body : String!
14 | var bodyEnd : String!
15 | var bodyStart : String!
16 | var comment : String!
17 | var forEachArrayOfCustomTypeProperty : String!
18 | var forEachProperty : String!
19 | var forEachCustomTypeProperty : String!
20 | var returnStatement : String!
21 | var signature : String!
22 | var forEachPropertyWithSpecialStoringNeeds : String!
23 |
24 | /**
25 | * Instantiate the instance using the passed dictionary values to set the properties values
26 | */
27 | init(fromDictionary dictionary: NSDictionary){
28 | forEachCustomTypeProperty = dictionary["forEachCustomTypeProperty"] as? String
29 | body = dictionary["body"] as? String
30 | bodyEnd = dictionary["bodyEnd"] as? String
31 | bodyStart = dictionary["bodyStart"] as? String
32 | comment = dictionary["comment"] as? String
33 | forEachArrayOfCustomTypeProperty = dictionary["forEachArrayOfCustomTypeProperty"] as? String
34 | forEachProperty = dictionary["forEachProperty"] as? String
35 | returnStatement = dictionary["returnStatement"] as? String
36 | signature = dictionary["signature"] as? String
37 | forEachPropertyWithSpecialStoringNeeds = dictionary["forEachPropertyWithSpecialStoringNeeds"] as? String
38 | }
39 |
40 |
41 |
42 | }
--------------------------------------------------------------------------------
/JSONExport/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // JSONExport
4 | //
5 | // Created by Ahmed on 11/2/14.
6 | // Copyright (c) 2014 Ahmed Ali. Eng.Ahmed.Ali.Awad@gmail.com.
7 | //
8 | // Redistribution and use in source and binary forms, with or without
9 | // modification, are permitted provided that the following conditions
10 | // are met:
11 | //
12 | // 1. Redistributions of source code must retain the above copyright
13 | // notice, this list of conditions and the following disclaimer.
14 | // 2. Redistributions in binary form must reproduce the above copyright
15 | // notice, this list of conditions and the following disclaimer in the
16 | // documentation and/or other materials provided with the distribution.
17 | // 3. The name of the contributor can not be used to endorse or promote products derived from this software
18 | // without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 | // OF THE POSSIBILITY OF SUCH DAMAGE.
32 | //
33 |
34 | import Cocoa
35 |
36 | class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTableViewDelegate, NSTableViewDataSource, NSTextViewDelegate {
37 |
38 | //Shows the list of files' preview
39 | @IBOutlet weak var tableView: NSTableView!
40 |
41 | //Connected to the top right corner to show the current parsing status
42 | @IBOutlet weak var statusTextField: NSTextField!
43 |
44 | //Connected to the save button
45 | @IBOutlet weak var saveButton: NSButton!
46 |
47 | //Connected to the JSON input text view
48 | @IBOutlet var sourceText: NSTextView!
49 |
50 | //Connected to the scroll view which wraps the sourceText
51 | @IBOutlet weak var scrollView: NSScrollView!
52 |
53 | //Connected to Constructors check box
54 | @IBOutlet weak var generateConstructors: NSButtonCell!
55 |
56 | //Connected to Utility Methods check box
57 | @IBOutlet weak var generateUtilityMethods: NSButtonCell!
58 |
59 | //Connected to root class name field
60 | @IBOutlet weak var classNameField: NSTextFieldCell!
61 |
62 | //Connected to parent class name field
63 | @IBOutlet weak var parentClassName: NSTextField!
64 |
65 | //Connected to class prefix field
66 | @IBOutlet weak var classPrefixField: NSTextField!
67 |
68 | //Connected to the first line statement field
69 | @IBOutlet weak var firstLineField: NSTextField!
70 |
71 | //Connected to the languages pop up
72 | @IBOutlet weak var languagesPopup: NSPopUpButton!
73 |
74 | //Holds the currently selected language
75 | var selectedLang : LangModel!
76 |
77 | //Returns the title of the selected language in the languagesPopup
78 | var selectedLanguageName : String
79 | {
80 | return languagesPopup.titleOfSelectedItem!
81 | }
82 |
83 | //Should hold list of supported languages, where the key is the language name and the value is LangModel instance
84 | var langs : [String : LangModel] = [String : LangModel]()
85 |
86 | //Holds list of the generated files
87 | var files : [FileRepresenter] = [FileRepresenter]()
88 |
89 | override func viewDidLoad() {
90 | super.viewDidLoad()
91 | saveButton.enabled = false
92 | loadSupportedLanguages()
93 | setupNumberedTextView()
94 | setLanguagesSelection()
95 | updateUIFieldsForSelectedLanguage()
96 | }
97 |
98 | /**
99 | Sets the values of languagesPopup items' titles
100 | */
101 | func setLanguagesSelection()
102 | {
103 | let langNames = Array(langs.keys).sort()
104 | languagesPopup.removeAllItems()
105 | languagesPopup.addItemsWithTitles(langNames)
106 |
107 | }
108 |
109 | /**
110 | Sets the needed configurations for show the line numbers in the input text view
111 | */
112 | func setupNumberedTextView()
113 | {
114 | let lineNumberView = NoodleLineNumberView(scrollView: scrollView)
115 | scrollView.hasHorizontalRuler = false
116 | scrollView.hasVerticalRuler = true
117 | scrollView.verticalRulerView = lineNumberView
118 | scrollView.rulersVisible = true
119 | sourceText.font = NSFont.userFixedPitchFontOfSize(NSFont.smallSystemFontSize())
120 |
121 | }
122 |
123 | /**
124 | Updates the visible fields according to the selected language
125 | */
126 | func updateUIFieldsForSelectedLanguage()
127 | {
128 | loadSelectedLanguageModel()
129 | if selectedLang.supportsFirstLineStatement != nil && selectedLang.supportsFirstLineStatement!.boolValue{
130 | firstLineField.hidden = false
131 | firstLineField.placeholderString = selectedLang.firstLineHint
132 | }else{
133 | firstLineField.hidden = true
134 | }
135 |
136 | if selectedLang.modelDefinitionWithParent != nil || selectedLang.headerFileData?.modelDefinitionWithParent != nil{
137 | parentClassName.hidden = false
138 | }else{
139 | parentClassName.hidden = true
140 | }
141 | }
142 |
143 |
144 |
145 | //MARK: - Handling pre defined languages
146 | func loadSupportedLanguages()
147 | {
148 | if let langFiles = NSBundle.mainBundle().URLsForResourcesWithExtension("json", subdirectory: nil) as [NSURL]!{
149 | for langFile in langFiles{
150 | if let data = NSData(contentsOfURL: langFile), langDictionary = (try? NSJSONSerialization.JSONObjectWithData(data, options: [])) as? NSDictionary{
151 | let lang = LangModel(fromDictionary: langDictionary)
152 | if langs[lang.displayLangName] != nil{
153 | continue
154 | }
155 | langs[lang.displayLangName] = lang
156 | }
157 |
158 |
159 | }
160 | }
161 |
162 | }
163 |
164 |
165 |
166 | //MARK: - Handlind events
167 |
168 | @IBAction func toggleConstructors(sender: AnyObject)
169 | {
170 | generateClasses()
171 | }
172 |
173 |
174 | @IBAction func toggleUtilities(sender: AnyObject)
175 | {
176 | generateClasses()
177 | }
178 |
179 | @IBAction func rootClassNameChanged(sender: AnyObject) {
180 | generateClasses()
181 | }
182 |
183 | @IBAction func parentClassNameChanged(sender: AnyObject)
184 | {
185 | generateClasses()
186 | }
187 |
188 |
189 | @IBAction func classPrefixChanged(sender: AnyObject)
190 | {
191 | generateClasses()
192 | }
193 |
194 |
195 | @IBAction func selectedLanguageChanged(sender: AnyObject)
196 | {
197 | updateUIFieldsForSelectedLanguage()
198 | generateClasses();
199 | }
200 |
201 |
202 | @IBAction func firstLineChanged(sender: AnyObject)
203 | {
204 | generateClasses()
205 | }
206 |
207 | //MARK: - NSTextDelegate
208 |
209 | func textDidChange(notification: NSNotification) {
210 | generateClasses()
211 | }
212 |
213 |
214 | //MARK: - Language selection handling
215 | func loadSelectedLanguageModel()
216 | {
217 | selectedLang = langs[selectedLanguageName]
218 |
219 | }
220 |
221 |
222 | //MARK: - NSUserNotificationCenterDelegate
223 | func userNotificationCenter(center: NSUserNotificationCenter,
224 | shouldPresentNotification notification: NSUserNotification) -> Bool
225 | {
226 | return true
227 | }
228 |
229 |
230 | //MARK: - Showing the open panel and save files
231 | @IBAction func saveFiles(sender: AnyObject)
232 | {
233 | let openPanel = NSOpenPanel()
234 | openPanel.allowsOtherFileTypes = false
235 | openPanel.treatsFilePackagesAsDirectories = false
236 | openPanel.canChooseFiles = false
237 | openPanel.canChooseDirectories = true
238 | openPanel.canCreateDirectories = true
239 | openPanel.prompt = "Choose"
240 | openPanel.beginSheetModalForWindow(self.view.window!, completionHandler: { (button : Int) -> Void in
241 | if button == NSFileHandlingPanelOKButton{
242 |
243 | self.saveToPath(openPanel.URL!.path!)
244 |
245 | self.showDoneSuccessfully()
246 | }
247 | })
248 | }
249 |
250 |
251 | /**
252 | Saves all the generated files in the specified path
253 |
254 | - parameter path: in which to save the files
255 | */
256 | func saveToPath(path : String)
257 | {
258 | var error : NSError?
259 | for file in files{
260 | let fileContent = file.fileContent
261 | var fileExtension = selectedLang.fileExtension
262 | if file is HeaderFileRepresenter{
263 | fileExtension = selectedLang.headerFileData.headerFileExtension
264 | }
265 | let filePath = "\(path)/\(file.className).\(fileExtension)"
266 |
267 | do {
268 | try fileContent.writeToFile(filePath, atomically: false, encoding: NSUTF8StringEncoding)
269 | } catch let error1 as NSError {
270 | error = error1
271 | }
272 | if error != nil{
273 | showError(error!)
274 | break
275 | }
276 |
277 | }
278 | }
279 |
280 |
281 | //MARK: - Messages
282 | /**
283 | Shows the top right notification. Call it after saving the files successfully
284 | */
285 | func showDoneSuccessfully()
286 | {
287 | let notification = NSUserNotification()
288 | notification.title = "成功!"
289 | notification.informativeText = "你的 \(selectedLang.langName) 模型文件成功生成。"
290 | notification.deliveryDate = NSDate()
291 |
292 | let center = NSUserNotificationCenter.defaultUserNotificationCenter()
293 | center.delegate = self
294 | center.deliverNotification(notification)
295 | }
296 |
297 | /**
298 | Shows an NSAlert for the passed error
299 | */
300 | func showError(error: NSError!)
301 | {
302 | if error == nil{
303 | return;
304 | }
305 | let alert = NSAlert(error: error)
306 | alert.runModal()
307 | }
308 |
309 | /**
310 | Shows the passed error status message
311 | */
312 | func showErrorStatus(errorMessage: String)
313 | {
314 |
315 | statusTextField.textColor = NSColor.brownColor()
316 | statusTextField.stringValue = errorMessage
317 | }
318 |
319 | /**
320 | Shows the passed success status message
321 | */
322 | func showSuccessStatus(successMessage: String)
323 | {
324 |
325 | statusTextField.textColor = NSColor.blueColor()
326 | statusTextField.stringValue = successMessage
327 | }
328 |
329 |
330 |
331 | //MARK: - Generate files content
332 | /**
333 | Validates the sourceText string input, and takes any needed action to generate the model classes and view them in the preview panel
334 | */
335 | func generateClasses()
336 | {
337 | saveButton.enabled = false
338 | var str = sourceText.string!
339 |
340 | if str.characters.count == 0{
341 | //Nothing to do, just clear any generated files
342 | files.removeAll(keepCapacity: false)
343 | tableView.reloadData()
344 | return;
345 | }
346 | var rootClassName = classNameField.stringValue
347 | if rootClassName.characters.count == 0{
348 | rootClassName = "RootClass"
349 | }
350 | sourceText.editable = false
351 | //Do the lengthy process in background, it takes time with more complicated JSONs
352 | runOnBackground {
353 | str = jsonStringByRemovingUnwantedCharacters(str)
354 | if let data = str.dataUsingEncoding(NSUTF8StringEncoding){
355 | var error : NSError?
356 | do {
357 | let jsonData : AnyObject = try NSJSONSerialization.JSONObjectWithData(data, options: [])
358 | var json : NSDictionary!
359 | if jsonData is NSDictionary{
360 | //fine nothing to do
361 | json = jsonData as! NSDictionary
362 | }else{
363 | json = unionDictionaryFromArrayElements(jsonData as! NSArray)
364 | }
365 | self.loadSelectedLanguageModel()
366 | self.files.removeAll(keepCapacity: false)
367 | let fileGenerator = self.prepareAndGetFilesBuilder()
368 | fileGenerator.addFileWithName(&rootClassName, jsonObject: json, files: &self.files)
369 | fileGenerator.fixReferenceMismatches(inFiles: self.files)
370 | self.files = Array(self.files.reverse())
371 | runOnUiThread{
372 | self.sourceText.editable = true
373 | self.showSuccessStatus("有效JSON")
374 | self.saveButton.enabled = true
375 |
376 | self.tableView.reloadData()
377 | }
378 | } catch let error1 as NSError {
379 | error = error1
380 | runOnUiThread({ () -> Void in
381 | self.sourceText.editable = true
382 | self.saveButton.enabled = false
383 | if error != nil{
384 | print(error)
385 | }
386 | self.showErrorStatus("JSON对象无效!")
387 | })
388 |
389 | } catch {
390 | fatalError()
391 | }
392 | }
393 | }
394 | }
395 |
396 | /**
397 | Creates and returns an instance of FilesContentBuilder. It also configure the values from the UI components to the instance. I.e includeConstructors
398 |
399 | - returns: instance of configured FilesContentBuilder
400 | */
401 | func prepareAndGetFilesBuilder() -> FilesContentBuilder
402 | {
403 | let filesBuilder = FilesContentBuilder.instance
404 | filesBuilder.includeConstructors = (generateConstructors.state == NSOnState)
405 | filesBuilder.includeUtilities = (generateUtilityMethods.state == NSOnState)
406 | filesBuilder.firstLine = firstLineField.stringValue
407 | filesBuilder.lang = selectedLang
408 | filesBuilder.classPrefix = classPrefixField.stringValue
409 | filesBuilder.parentClassName = parentClassName.stringValue
410 | return filesBuilder
411 | }
412 |
413 |
414 |
415 |
416 | //MARK: - NSTableViewDataSource
417 | func numberOfRowsInTableView(tableView: NSTableView) -> Int
418 | {
419 | return files.count
420 | }
421 |
422 |
423 | //MARK: - NSTableViewDelegate
424 | func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView?
425 | {
426 | let cell = tableView.makeViewWithIdentifier("fileCell", owner: self) as! FilePreviewCell
427 | let file = files[row]
428 | cell.file = file
429 |
430 | return cell
431 | }
432 |
433 |
434 |
435 | }
436 |
437 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 Ahmed-Ali
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | 1- The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 | 2- For paid software, you MUST include a reference to the original project repoistory: https://github.com/Ahmed-Ali/JSONExport
13 | or contact the author (Ahmed Ali) to obtain permission to not include this reference.
14 |
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | JSONExport的汉化版
2 |
3 | 把任意JSON字符串生成Swift对应的模型(类、结构体、Core Data类、Realm类、SwiftlyJSON类),
4 | 并可生成帮助方法(把实例转回NSDictionary)。
5 |
--------------------------------------------------------------------------------