ucl

package module
v0.0.0-...-3788fcf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2016 License: BSD-2-Clause Imports: 8 Imported by: 15

README

Go-UCL

Introduction

This is a parser and exporter for UCL fully implemented in Go. Refer to https://github.com/vstakhov/libucl for the UCL specification.

Currently it outputs to a map[string] interface{} after parsing. It may be improved in the future to output to a struct but in the meantime, either https://github.com/bitly/go-simplejson (simplify field access) or https://github.com/ld9999999999/go-interfacetools (copy map to struct) can be used to accomplish this task.

License

This module is BSD-licensed; by Nahanni Systems Inc.

Documentation

Overview

* Encodes an interface into UCL format

* Copyright (c) 2015 Leon Dang, Nahanni Systems Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE.

Index

Constants

View Source
const (
	WHITESPACE = iota
	TAG
	SEMICOL  // semi-colon ;
	COMMA    // ,
	COLON    // :
	EQUAL    // =
	QUOTE    // double quote string
	VQUOTE   // single quote string
	SLASH    // regex or /* */ comment
	HCOMMENT // # ...
	LCOMMENT // /* ... */
	MLSTRING // <<EOD multi-line string

	BRACEOPEN
	BRACECLOSE

	BRACKETOPEN
	BRACKETCLOSE

	LCOMMENT_CLOSING // Not a tag, just indicator of possibly '*/'
	// closing indicator
	MAYBE_MLSTRING
	MAYBE_MLSTRING2
	MLSTRING_PREP
	MLSTRING_HEADER_OK
)
View Source
const KeyOrder = "--ucl-keyorder--"

The order of the keys as they appear in the file; this allows the user to have their own order for items.

Variables

View Source
var UclExportKeyOrder bool = true

Allow to disable constructing the KeyOrder arrays

View Source
var Ucldebug bool = true
View Source
var UnexpectedEOF = errors.New("Unexpected EOF")

Functions

func Encode

func Encode(w io.Writer, v interface{}, indenter, tag, nilval string) error

Encode v as UCL. indenter = string to use as indentation tag = if v has struct components, then use tag to search for the tag's key nilval = (verbatim) string representing null value in output

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(r io.Reader) *Parser

func (*Parser) Ucl

func (p *Parser) Ucl() (map[string]interface{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL