Skip to content

Commit

Permalink
add fileModel
Browse files Browse the repository at this point in the history
  • Loading branch information
vvkeep committed Feb 7, 2018
1 parent f728e03 commit efb8949
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 43 deletions.
38 changes: 33 additions & 5 deletions JSONConverter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
7B45DB0F202AA572007E8D56 /* YWFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B45DB0E202AA572007E8D56 /* YWFile.swift */; };
7BD7FED7202AC1E80003AE80 /* NoodleLineNumberView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BD7FED4202AC1E80003AE80 /* NoodleLineNumberView.m */; };
7BD7FED8202AC1E80003AE80 /* NoodleLineNumberMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BD7FED6202AC1E80003AE80 /* NoodleLineNumberMarker.m */; };
7BD7FEDA202AC7C10003AE80 /* YWContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD7FED9202AC7C10003AE80 /* YWContent.swift */; };
7BD7FEDC202AC7EB0003AE80 /* YWProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD7FEDB202AC7EB0003AE80 /* YWProperty.swift */; };
7BD7FEE0202AD1470003AE80 /* YWAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD7FEDF202AD1470003AE80 /* YWAlertView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -45,6 +48,9 @@
7BD7FED4202AC1E80003AE80 /* NoodleLineNumberView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoodleLineNumberView.m; sourceTree = "<group>"; };
7BD7FED5202AC1E80003AE80 /* NoodleLineNumberView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoodleLineNumberView.h; sourceTree = "<group>"; };
7BD7FED6202AC1E80003AE80 /* NoodleLineNumberMarker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoodleLineNumberMarker.m; sourceTree = "<group>"; };
7BD7FED9202AC7C10003AE80 /* YWContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YWContent.swift; sourceTree = "<group>"; };
7BD7FEDB202AC7EB0003AE80 /* YWProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YWProperty.swift; sourceTree = "<group>"; };
7BD7FEDF202AD1470003AE80 /* YWAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YWAlertView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -84,14 +90,12 @@
7B45DAEB202A95BE007E8D56 /* Main */ = {
isa = PBXGroup;
children = (
7B45DB0E202AA572007E8D56 /* YWFile.swift */,
7BD7FEE1202AD1F30003AE80 /* MainView */,
7BD7FEDE202AC85B0003AE80 /* FileContent */,
7B45DAEC202A95BE007E8D56 /* YWJsonParserUtils.swift */,
7B45DAEE202A95BE007E8D56 /* MainWindowController.swift */,
7B45DAF2202A95BE007E8D56 /* MainWindowController.xib */,
7B45DAEF202A95BE007E8D56 /* MainViewController.swift */,
7B45DAED202A95BE007E8D56 /* MainViewController.xib */,
7B45DAF0202A95BE007E8D56 /* YWPropertyStrUtils.swift */,
7B45DAF1202A95BE007E8D56 /* YWCommon.swift */,
7BD7FEDF202AD1470003AE80 /* YWAlertView.swift */,
);
path = Main;
sourceTree = "<group>";
Expand Down Expand Up @@ -132,6 +136,27 @@
path = NoodleLineNumber;
sourceTree = "<group>";
};
7BD7FEDE202AC85B0003AE80 /* FileContent */ = {
isa = PBXGroup;
children = (
7B45DB0E202AA572007E8D56 /* YWFile.swift */,
7BD7FED9202AC7C10003AE80 /* YWContent.swift */,
7BD7FEDB202AC7EB0003AE80 /* YWProperty.swift */,
);
path = FileContent;
sourceTree = "<group>";
};
7BD7FEE1202AD1F30003AE80 /* MainView */ = {
isa = PBXGroup;
children = (
7B45DAEE202A95BE007E8D56 /* MainWindowController.swift */,
7B45DAF2202A95BE007E8D56 /* MainWindowController.xib */,
7B45DAEF202A95BE007E8D56 /* MainViewController.swift */,
7B45DAED202A95BE007E8D56 /* MainViewController.xib */,
);
path = MainView;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -218,8 +243,11 @@
7B45DB00202A95BF007E8D56 /* MainWindowController.swift in Sources */,
7B45DB02202A95BF007E8D56 /* YWPropertyStrUtils.swift in Sources */,
7B45DB08202A95BF007E8D56 /* AppDelegate.swift in Sources */,
7BD7FEDA202AC7C10003AE80 /* YWContent.swift in Sources */,
7BD7FEE0202AD1470003AE80 /* YWAlertView.swift in Sources */,
7BD7FED8202AC1E80003AE80 /* NoodleLineNumberMarker.m in Sources */,
7B45DB0F202AA572007E8D56 /* YWFile.swift in Sources */,
7BD7FEDC202AC7EB0003AE80 /* YWProperty.swift in Sources */,
7BD7FED7202AC1E80003AE80 /* NoodleLineNumberView.m in Sources */,
7B45DB05202A95BF007E8D56 /* String+Extension.swift in Sources */,
7B45DAFE202A95BF007E8D56 /* YWJsonParserUtils.swift in Sources */,
Expand Down
23 changes: 23 additions & 0 deletions JSONConverter/Classes/Main/FileContent/YWContent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// YWContent.swift
// JSONConverter
//
// Created by 姚巍 on 2018/2/7.
// Copyright © 2018年 姚巍. All rights reserved.
//

import Foundation
class YWContent {
var properties: [YWProperty]

var langStruct: LangStruct

init(properties: [YWProperty], langStruct: LangStruct) {
self.properties = properties
self.langStruct = langStruct
}

func toString() -> String {
return ""
}
}
32 changes: 32 additions & 0 deletions JSONConverter/Classes/Main/FileContent/YWFile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// YWFile.swift
// JSONExport
//
// Created by 姚巍 on 2018/2/7.
// Copyright © 2018年 Ahmed Ali. All rights reserved.
//

import Foundation

class YWFile {

/// 文件名
var name: String

var langStruct: LangStruct

var header: String = ""

var contents: [YWContent]

init(className: String, langStruct: LangStruct, contents: [YWContent]) {
self.name = className
self.langStruct = langStruct
self.contents = contents
}

func toString() -> String {
return ""
}
}

36 changes: 36 additions & 0 deletions JSONConverter/Classes/Main/FileContent/YWProperty.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// YWProperty.swift
// JSONConverter
//
// Created by 姚巍 on 2018/2/7.
// Copyright © 2018年 姚巍. All rights reserved.
//

import Foundation

enum YWPropertyType {
case `String`
case `Int`
case `Double`
case `Bool`
case `Array`
case `Dictionary`
case CustomObj
}


class YWProperty {
var nativeName: String
var jsonName: String
var type: YWPropertyType

init(nativeName: String, jsonName: String, type: YWPropertyType) {
self.nativeName = nativeName
self.jsonName = jsonName
self.type = type
}

func toString() -> String {
return ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ class MainViewController: NSViewController {

@IBAction func converBtnAction(_ sender: NSButton) {
_isConver = true
var rootClassName = rootClassField.stringValue
if rootClassName.count == 0 {
rootClassName = "RootClass"
}

if let jsonStr = jsonTextView.textStorage?.string {
guard let jsonData = jsonStr.data(using: .utf8),
let json = try? JSONSerialization.jsonObject(with: jsonData, options: .mutableContainers)else{
Expand All @@ -115,13 +110,8 @@ class MainViewController: NSViewController {
setJsonContent(content: formatJsonStr)
}

if rootClassField.stringValue.count > 0{
rootClassName = rootClassField.stringValue
}

if prefixField.stringValue.count > 0 {
prefixName = prefixField.stringValue
}
rootClassName = rootClassField.stringValue.isEmpty ? "RootClass" : rootClassField.stringValue
prefixName = prefixField.stringValue.isEmpty ? "" : prefixField.stringValue

guard let langTypeType = LangType(rawValue: converTypeBox.indexOfSelectedItem),
let structType = StructType(rawValue: converStructBox.indexOfSelectedItem) else {
Expand Down
14 changes: 14 additions & 0 deletions JSONConverter/Classes/Main/YWAlertView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// YWAlertView.swift
// JSONConverter
//
// Created by 姚巍 on 2018/2/7.
// Copyright © 2018年 姚巍. All rights reserved.
//

import Foundation
class YWAlertView {
func alertView() {

}
}
25 changes: 0 additions & 25 deletions JSONConverter/Classes/Main/YWFile.swift

This file was deleted.

1 change: 0 additions & 1 deletion JSONConverter/Classes/Main/YWJsonParserUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ extension YWJsonParserUtils {
return Name as String
}


private func handlePropertyName(propertyKey: String) -> String {
let propertyName = propertyKey as NSString
if propertyName.length > 0 {
Expand Down

0 comments on commit efb8949

Please sign in to comment.