• Stars
    star
    244
  • Rank 165,885 (Top 4 %)
  • Language
    HTML
  • Created about 14 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Proper YAML support for Objective-C. Based on recommended libyaml.

YAML.framework for Objective-C

Based on C LibYAML library (http://pyyaml.org/wiki/LibYAML) by Kirill Simonov.

YAML.framework provides support for YAML (de/)serialisation similarly to standard NSPropertyListSerialization.

It's fast and compatible with iOS.

Example usage

NSInputStream *stream = [[NSInputStream alloc] initWithFileAtPath: @"yaml/items.yaml"];
// or [[NSInputStream alloc] initWithURL: ...]

// You can use objectsWithYAMLStream:options:error instead to get all YAML documents.
//
// Alternativelly object(s)WithYAMLData:options:error or object(s)WithYAMLString:options:error.
id yaml = [YAMLSerialization objectWithYAMLStream: stream
                                          options: kYAMLReadOptionStringScalars
                                            error: nil];

// Dump Objective-C object description.
printf("%s", [[yaml description] UTF8String]);

For input YAML file:

items:
  - name: Foo
  - name: Bar

Should print dump string similar to:

(
  {
    items = (
      {
        name = Foo;
      },
      {
        name = Bar;
      }
    );
  }
)

API

The following class methods are defined on YAMLSerialization class.

Reading YAML

// Returns all document objects from parsed YAML stream.
+ (NSMutableArray *) objectsWithYAMLStream: (NSInputStream *) stream
                                   options: (YAMLReadOptions) opt
                                     error: (NSError **) error;

// Returns all document objects from parsed YAML data.
+ (NSMutableArray *) objectsWithYAMLData: (NSData *) data
                                 options: (YAMLReadOptions) opt
                                   error: (NSError **) error;

// Returns all document objects from parsed YAML string.
+ (NSMutableArray *) objectsWithYAMLString: (NSString *) string
                                   options: (YAMLReadOptions) opt
                                     error: (NSError **) error;

// Returns first object from parsed YAML stream.
+ (id) objectWithYAMLStream: (NSInputStream *) stream
                    options: (YAMLReadOptions) opt
                      error: (NSError **) error;

// Returns first object from parsed YAML data.
+ (id) objectWithYAMLData: (NSData *) data
                  options: (YAMLReadOptions) opt
                    error: (NSError **) error;

// Returns first object from parsed YAML string.
+ (id) objectWithYAMLString: (NSString *) string
                    options: (YAMLReadOptions) opt
                      error: (NSError **) error;

Writing YAML

// Returns YES on success, NO otherwise.
+ (BOOL) writeObject: (id) object
        toYAMLStream: (NSOutputStream *) stream
             options: (YAMLWriteOptions) opt
               error: (NSError **) error;

// Caller is responsible for releasing returned object.
+ (NSData *) createYAMLDataWithObject: (id) object
                              options: (YAMLWriteOptions) opt
                                error: (NSError **) error NS_RETURNS_RETAINED;

// Returns autoreleased object.
+ (NSData *) YAMLDataWithObject: (id) object
                        options: (YAMLWriteOptions) opt
                          error: (NSError **) error;

// Caller is responsible for releasing returned object.
+ (NSString *) createYAMLStringWithObject: (id) object
                                  options: (YAMLWriteOptions) opt
                                    error: (NSError **) error NS_RETURNS_RETAINED;

// Returns autoreleased object.
+ (NSString *) YAMLStringWithObject: (id) object
                            options: (YAMLWriteOptions) opt
                              error: (NSError **) error;

License

YAML.framework is released under the MIT license.

Copyright (c) 2010 Mirek Rusin (YAML.framework)
              2006 Kirill Simonov (LibYAML)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

CoreWebSocket

Web Socket Server and Client Library for iOS and OSX. Follows Core Foundation API style.
C
142
star
2

node-rus-diff

JSON diff
CoffeeScript
125
star
3

node-unused-deps

Report unused npm packages in node, es6, babel or coffee project.
CoffeeScript
79
star
4

CoreJSON

Core Foundation, libyajl based JSON support.
C
49
star
5

quartzcomposer-websocket

Quartz Composer WebSocket Plug-In
Objective-C
40
star
6

CoreSQLite3

Core SQLite3 for iOS and OSX. Fast. Clean. Powerful...
C
37
star
7

rb_tree

Red-black tree C implementation
36
star
8

node-json-criteria

Criteria queries on JSON objects Mongo style
JavaScript
33
star
9

INI.framework

Ini style file read/write support with format preserving
Objective-C
25
star
10

node-json-hash

JSON hash
JavaScript
24
star
11

NSMutableDictionary-REST.framework

REST category for NSMutableDictionary - the way it should be done.
Objective-C
24
star
12

quartzcomposer-opencv

OpenCV 2.1 port for Quartz Composer
Objective-C
19
star
13

quartzcomposer-objective-c

Objective-C/C/C++ for Quartz Composer (on the fly)
Objective-C
16
star
14

quartzcomposer-exporter

Quartz Composer Movie Exporter Plug-In
Objective-C
13
star
15

quartzcomposer-vnc

Quartz Composer VNC Server Plugin
C
11
star
16

CoreOSC

Open Sound Control - iOS/OSX Framework
C
6
star
17

flovv

flovv.org engine similar to quartz composer.
C++
5
star
18

GitHub.framework

Objective-C Framework for GitHub (API v.2)
5
star
19

sqlite-amalgamation

Contains all C source code for SQLite 3.7.10 combined into a single source file .
C
4
star
20

node-pg-safe-numbers

Safe number parsing for pg and Sequelize.
JavaScript
3
star
21

CoreMono

Embed C# in your Objective-C iOS and Mac OSX projects. Yey!
C
3
star
22

oscpads

OSCpad - advanced iPad OSC controller
JavaScript
3
star
23

node-flat-flow

Tiny flow.
CoffeeScript
3
star
24

CoreTestAllocator

Core Foundation Test Allocator to spot memory leaks
C
2
star
25

node-tiny-sse

Server Sent Events (SSE) for express/connect.
CoffeeScript
2
star
26

ruby-odbc

Clone of http://www.ch-werner.de/rubyodbc + fixes
C
2
star
27

libeio

C
1
star
28

node-flovv

nodejs based flovv prototype
1
star
29

libeio-old

http://software.schmorp.de/pkg/libeio.html with some changes (autogen warnings fixed, extended attributes support)
C
1
star
30

atom-html2jade

Convert HTML to jade
CoffeeScript
1
star
31

celldb

Ruby
1
star
32

mirek.github.com

mirek.github.com
1
star
33

db-logic

Ruby on Rails database logic support
Ruby
1
star
34

atom-special-snippets

Special characters cmd-⌘, shift-⇧, opt-⌥, del-⌫, esc-⎋, etc.
CoffeeScript
1
star