Skip to content

Commit

Permalink
Merge branch 'feature/toml11'
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeydom committed Feb 12, 2023
2 parents dc61ef6 + 999f86c commit 16a74aa
Show file tree
Hide file tree
Showing 13 changed files with 633 additions and 450 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "submodules/cpptoml"]
path = submodules/cpptoml
url = https://github.com/skystrife/cpptoml.git
[submodule "submodules/toml11"]
path = submodules/toml11
url = git@github.com:ToruNiina/toml11.git
176 changes: 111 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ObjectiveTOML

ObjectiveTOML is a clean and nice Objective-C API to read and write [TOML](https://github.com/toml-lang/toml) files. It is utilizing [cpptoml](https://github.com/skystrife/cpptoml) and therefore on par with its TOML compliance. At time of writing this is [TOML 0.5.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md)
ObjectiveTOML is a clean and nice Objective-C API to read and write [TOML](https://github.com/toml-lang/toml) files. It is utilizing [toml11](https://github.com/ToruNiina/toml11) and therefore on par with its TOML compliance. At time of writing this is [TOML 1.0.0](https://toml.io/en/v1.0.0)

The main target is a small command line utility `tomlutil` to convert between TOML, JSON and the xml and binary plist format on macOS. To use the API in your app it should be enough to snapshot the .h and .mm files of the project to your project.
The main target is a small command line utility `tomlutil` to convert between TOML, JSON and the xml and binary plist format on macOS.

The API is aligned with `NSJSONSerialization`:

Expand All @@ -19,97 +19,140 @@ NSDictionary <NSString *, id>* tomlObject =
The `tomlutil` has nice parsing error reporting (if you only want this, you can use the `-lint` option:
```
$> ./tomlutil ObjectiveTOML/toml-examples/example-v0.4.0.toml
$> ./tomlutil -lint toml-examples/wrong.toml
🚫 Input TOML could not be parsed
Failed to parse value type at line 32
31: [x.y.z.w] # for this to work
> 32: unsupported =
33:
[error] toml::parse_key_value_pair: invalid format for key
--> toml-examples/wrong.toml
|
14 | asdfpoin1!@ j= ;alskjfasdf
| ^--- invalid character in key
|
Hint: Did you forget '.' to separate dotted-key?
Hint: Allowed characters for bare key are [0-9a-zA-Z_-].
```
Current usage output:
```
tomlutil v1.1.0 (cpptoml v0.1.1)
tomlutil v2.0.0 (toml11 v3.7.1)

Usage: tomlutil [-f json|xml1|binary1|toml] file [outputfile]

A file of '-' reads from stdin. Can read json, plists and toml. Output defaults to stdout.
-f format Output format. One of json, xml, binary1, toml. Defaults to toml.
-lint Just lint with cpptoml, no output.
-f format Output format. One of json, xml1, binary1, toml. Defaults to toml.
-lint Just lint with toml11, no output.
```
Simple conversion of the Mojave News.app plist to TOML:
```toml
$ ./tomlutil /Applications/News.app/Contents/Info.plist
BuildMachineOSBuild = "17A405001"
CFBundleDevelopmentRegion = "en"
CFBundleDisplayName = "News"
CFBundleExecutable = "News"
CFBundleHelpBookFolder = "News.help"
$> ./tomlutil /System/Applications/News.app/Contents/Info.plist
SBAppUsesLocalNotifications = true
DTSDKBuild = "22D40"
UILaunchStoryboardName = "LaunchScreen"
CFBundleHelpBookName = "com.apple.News.help"
CFBundleIconFile = "AppIcon_macOS.icns"
CFBundleIconName = "AppIcon"
CFBundleIdentifier = "com.apple.news"
CFBundleInfoDictionaryVersion = "6.0"
NSSupportsSuddenTermination = true
DTPlatformVersion = "13.2"
UIViewGroupOpacity = false
CFBundleDisplayName = "News"
CFBundleName = "News"
HPDHelpProjectIdentifier = "news"
UIDeviceFamily = [6]
CFBundlePackageType = "APPL"
CFBundleShortVersionString = "4.0"
UIRequiredDeviceCapabilities = ["armv7"]
CFBundleSignature = "????"
CFBundleSupportedPlatforms = ["MacOSX"]
CFBundleVersion = "1637.9"
DTCompiler = "com.apple.compilers.llvm.clang.1_0"
DTPlatformBuild = "10L213p"
DTPlatformName = "macosx"
DTPlatformVersion = "10.14"
DTSDKBuild = "18A371"
DTSDKName = "macosx10.14internal"
DTXcode = "1000"
DTXcodeBuild = "10L213p"
HPDHelpProjectIdentifier = "news"
LSCounterpartIdentifiers = ["com.apple.nanonews"]
LSMinimumSystemVersion = "10.14"
LSSupportedRegions = ["US", "GB", "AU"]
UIMenuBarItemTitleQuit = "Quit News"
CFBundleVersion = "3270.0.1"
LSSupportedRegions = ["US","GB","AU","CA"]
NSLocationDefaultAccuracyReduced = true
UIMenuBarItemTitleHelp = "News Help"
NSLocationUsageDescription = """
Get top local news and weather, and locally relevant search results an\
d ads.\
"""
UIMenuBarItemTitleAbout = "About News"
UIMenuBarItemTitleHide = "Hide News"
NSCalendarsUsageDescription = "This will let you add events from News to your calendar."
NSContactsUsageDescription = ""
NSHumanReadableCopyright = "Copyright © 2018 Apple. All rights reserved."
NSLocationWhenInUseUsageDescription = "Your location is used to deliver locally relevant information such as search results and weather."
CFBundleSupportedPlatforms = ["MacOSX"]
NSLocationWhenInUseUsageDescription = """
Get top local news and weather, and locally relevant search r\
esults and ads.\
"""
CFBundleInfoDictionaryVersion = "6.0"
LSMinimumSystemVersion = "13.2"
CFBundleIdentifier = "com.apple.news"
NSHumanReadableCopyright = "Copyright © 2022 Apple Inc. All rights reserved."
NSPhotoLibraryAddUsageDescription = ""
NSPhotoLibraryUsageDescription = ""
NSUserActivityTypes = ["com.apple.news.articleViewing", "com.apple.news.feedBrowsing", "com.apple.news.forYou", "com.apple.news.saved", "com.apple.news.history"]
SBAppUsesLocalNotifications = true
UIWhitePointAdaptivityStyle = "UIWhitePointAdaptivityStyleReading"
NSContactsUsageDescription = ""
NSSupportsAutomaticTermination = true
CFBundleShortVersionString = "8.2.1"
CFBundleIconFile = "AppIcon"
CTIgnoreUserFonts = true
UIAppFonts = []
UIApplicationShortcutWidget = "com.apple.news.widget"
UIBackgroundModes = ["audio", "fetch", "remote-notification"]
UIDeviceFamily = [1, 2]
UILaunchStoryboardName = "LaunchScreen"
UIMainStoryboardFile = "Main"
UIMenuBarItemTitleAbout = "About News"
UIMenuBarItemTitleHelp = "News Help"
UIMenuBarItemTitleHide = "Hide News"
UIMenuBarItemTitleQuit = "Quit News"
UIRequiredDeviceCapabilities = ["armv7"]
UIStatusBarHidden = false
UISupportedInterfaceOrientations = ["UIInterfaceOrientationPortrait", "UIInterfaceOrientationLandscapeLeft", "UIInterfaceOrientationLandscapeRight"]
"UISupportedInterfaceOrientations~ipad" = ["UIInterfaceOrientationPortrait", "UIInterfaceOrientationPortraitUpsideDown", "UIInterfaceOrientationLandscapeLeft", "UIInterfaceOrientationLandscapeRight"]
UIUserInterfaceStyle = "Automatic"
DTXcodeBuild = "14A6270d"
CFBundleExecutable = "News"
DTCompiler = "com.apple.compilers.llvm.clang.1_0"
CFBundleIconName = "AppIcon"
UIStatusBarHidden = false
"UISupportedInterfaceOrientations~ipad" = [
"UIInterfaceOrientationPortrait",
"UIInterfaceOrientationPortraitUpsideDown",
"UIInterfaceOrientationLandscapeLeft",
"UIInterfaceOrientationLandscapeRight",
]
BuildMachineOSBuild = "20A241133"
UIViewControllerBasedStatusBarAppearance = true
UIBackgroundModes = ["audio","fetch","remote-notification"]
NSAccentColorName = "NewsAccentColor"
UIViewEdgeAntialiasing = false
UIViewGroupOpacity = false
UIWhitePointAdaptivityStyle = "UIWhitePointAdaptivityStyleReading"
DTPlatformName = "macosx"
SBMatchingApplicationGenres = [
"News","Reference","Entertainment","Productivity","Education",
"Business",
]
NSUserActivityTypes = [
"TagIntent","TodayIntent","com.apple.news.articleViewing",
"com.apple.news.feedBrowsing","com.apple.news.feedBackCatalog",
"com.apple.news.forYou","com.apple.news.history","com.apple.news.saved",
"com.apple.news.magazineSections","com.apple.news.link",
]
UIApplicationShortcutWidget = "com.apple.news.widget"
CFBundleDevelopmentRegion = "en"
UISupportedInterfaceOrientations = ["UIInterfaceOrientationPortrait"]
CFBundleHelpBookFolder = "News.help"
BGTaskSchedulerPermittedIdentifiers = ["com.apple.news.backgroundFetchManager"]
_LSSupportsRemoval = true
[CFBundleIcons]
["CFBundleIcons~ipad"]
[[CFBundleURLTypes]]
CFBundleTypeRole = "Editor"
CFBundleURLName = "com.apple.NewsCustomScheme"
CFBundleURLSchemes = ["applenews", "applenewss", "feed"]
DTSDKName = "macosx13.2.internal"
DTPlatformBuild = "22D40"
NSPhotoLibraryUsageDescription = ""
DTXcode = "1400"
LSCounterpartIdentifiers = ["com.apple.nanonews"]
[[UIApplicationShortcutItems]]
UIApplicationShortcutItemIconFile = "ios_for_you_icon_large"
UIApplicationShortcutItemTitle = "ApplicationShortcutItemForYou"
UIApplicationShortcutItemType = "com.apple.news.openforyou"
UIApplicationShortcutItemTitle = "ApplicationShortcutItemForYou"
UIApplicationShortcutItemIconFile = "ios_for_you_icon_large"
UIApplicationShortcutItemType = "com.apple.news.openforyou"
[UNUserNotificationCenter]
UNSuppressUserAuthorizationPrompt = false
[UIApplicationSceneManifest]
UIApplicationSupportsMultipleScenes = "1"
[UIApplicationSceneManifest.UISceneConfigurations]
[[UIApplicationSceneManifest.UISceneConfigurations.UIWindowSceneSessionRoleApplication]]
UISceneConfigurationName = "Default Configuration"
UISceneDelegateClassName = "NewsUI2.SceneDelegate"
UISceneClassName = "TeaUI.WindowScene"
[[CFBundleURLTypes]]
CFBundleURLSchemes = ["applenews","applenewss"]
CFBundleURLName = "com.apple.NewsCustomScheme"
CFBundleTypeRole = "Editor"
```

Full header:
Expand Down Expand Up @@ -150,6 +193,9 @@ Full header:
## Changelog
* v2.0.0
* switched to [toml11] (https://github.com/ToruNiina/toml11
* v1.1.0
* Updated to cpptoml v0.1.1
* Added more arguments, help and error reporting to the `tomlutil`
Expand Down
1 change: 0 additions & 1 deletion submodules/cpptoml
Submodule cpptoml deleted from fededa
1 change: 1 addition & 0 deletions submodules/toml11
Submodule toml11 added at dcfe39
18 changes: 18 additions & 0 deletions toml-examples/wrong.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
################################################################################
## Comment

# Speak your mind with the hash symbol. They go from the symbol to the end of
# the line.


################################################################################
## Table

# Tables (also known as hash tables or dictionaries) are collections of
# key/value pairs. They appear in square brackets on a line by themselves.

asdfpoin1!@ j= ;alskjfasdf

[table]

key = "value" # Yeah, you can do this.
Loading

0 comments on commit 16a74aa

Please sign in to comment.