Updated the generated docs.
|
@ -1,4 +1,4 @@
|
||||||
# Sphinx build info version 1
|
# Sphinx build info version 1
|
||||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||||
config: 932028a19a10a213bb2bc3e91bc492de
|
config: 433cb5227210ca9af80d745da3915442
|
||||||
tags: fbb0d17656682115ca4d033fb2f83ba1
|
tags: fbb0d17656682115ca4d033fb2f83ba1
|
||||||
|
|
|
@ -77,7 +77,7 @@ into the file:
|
||||||
.. code-block:: d
|
.. code-block:: d
|
||||||
|
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import yaml;
|
import dyaml.all;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -100,8 +100,8 @@ into the file:
|
||||||
Explanation of the code
|
Explanation of the code
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
First, we import the *yaml* module. This is the only D:YAML module you need to
|
First, we import the *dyaml.all* module. This is the only D:YAML module you
|
||||||
import - it automatically imports all needed modules.
|
need to import - it automatically imports all needed modules.
|
||||||
|
|
||||||
Next we load the file using the *Loader.load()* method. *Loader* is a struct
|
Next we load the file using the *Loader.load()* method. *Loader* is a struct
|
||||||
used for parsing YAML documents. The *load()* method loads the file as
|
used for parsing YAML documents. The *load()* method loads the file as
|
||||||
|
@ -147,22 +147,23 @@ Compiling
|
||||||
|
|
||||||
To compile your project, DMD needs to know which directories contain the
|
To compile your project, DMD needs to know which directories contain the
|
||||||
imported modules and the library. You also need to tell it to link with D:YAML.
|
imported modules and the library. You also need to tell it to link with D:YAML.
|
||||||
The import directory should be the D:YAML package directory. You can specify it
|
The import directory should be the ``source`` subdirectory of the D:YAML
|
||||||
using the ``-I`` option of DMD. The library directory should point to the
|
directory. You can specify it using the ``-I`` option of DMD. The library
|
||||||
compiled library. On Unix/Linux you can specify it using the ``-L-L`` option,
|
directory should point to the compiled library. On Unix/Linux you can specify
|
||||||
and link with D:YAML using the ``-L-l`` option. On Windows, the import directory
|
it using the ``-L-L`` option, and link with D:YAML using the ``-L-l`` option.
|
||||||
is used as the library directory. To link with the library on Windows, just add
|
On Windows, the import directory is used as the library directory. To link with
|
||||||
the path to it relative to the current directory.
|
the library on Windows, just add the path to it relative to the current
|
||||||
|
directory.
|
||||||
|
|
||||||
For example, if you extracted and compiled D:YAML in ``/home/xxx/dyaml``, your
|
For example, if you extracted and compiled D:YAML in ``/home/xxx/dyaml``, your
|
||||||
project is in ``/home/xxx/dyaml-project``, and you are currently in that
|
project is in ``/home/xxx/dyaml-project``, and you are currently in that
|
||||||
directory, compile the project with the following command on Unix/Linux::
|
directory, compile the project with the following command on Unix/Linux::
|
||||||
|
|
||||||
dmd -I../dyaml -L-L../dyaml -L-ldyaml main.d
|
dmd -I../dyaml/source -L-L../dyaml -L-ldyaml main.d
|
||||||
|
|
||||||
And the following on Windows::
|
And the following on Windows::
|
||||||
|
|
||||||
dmd -I../dyaml ../dyaml/libdyaml.lib main.d
|
dmd -I../dyaml/source ../dyaml/libdyaml.lib main.d
|
||||||
|
|
||||||
This will produce an executable called ``main`` or ``main.exe`` in your
|
This will produce an executable called ``main`` or ``main.exe`` in your
|
||||||
directory. When you run it, it should produce the following output::
|
directory. When you run it, it should produce the following output::
|
||||||
|
|
BIN
doc/html/_static/ajax-loader.gif
Normal file
After Width: | Height: | Size: 673 B |
|
@ -79,6 +79,14 @@ div.sphinxsidebar input {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.sphinxsidebar #searchbox input[type="text"] {
|
||||||
|
width: 170px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sphinxsidebar #searchbox input[type="submit"] {
|
||||||
|
width: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +244,6 @@ img.align-center, .figure.align-center, object.align-center {
|
||||||
}
|
}
|
||||||
|
|
||||||
.align-center {
|
.align-center {
|
||||||
clear: both;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,6 +447,11 @@ dl.glossary dt {
|
||||||
font-style: oblique;
|
font-style: oblique;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abbr, acronym {
|
||||||
|
border-bottom: dotted 1px;
|
||||||
|
cursor: help;
|
||||||
|
}
|
||||||
|
|
||||||
/* -- code displays --------------------------------------------------------- */
|
/* -- code displays --------------------------------------------------------- */
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
|
|
BIN
doc/html/_static/comment-bright.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
doc/html/_static/comment-close.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
doc/html/_static/comment.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
|
@ -2,7 +2,7 @@
|
||||||
* doctools.js
|
* doctools.js
|
||||||
* ~~~~~~~~~~~
|
* ~~~~~~~~~~~
|
||||||
*
|
*
|
||||||
* Sphinx JavaScript utilties for all documentation.
|
* Sphinx JavaScript utilities for all documentation.
|
||||||
*
|
*
|
||||||
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||||
* :license: BSD, see LICENSE for details.
|
* :license: BSD, see LICENSE for details.
|
||||||
|
@ -185,9 +185,9 @@ var Documentation = {
|
||||||
body.highlightText(this.toLowerCase(), 'highlighted');
|
body.highlightText(this.toLowerCase(), 'highlighted');
|
||||||
});
|
});
|
||||||
}, 10);
|
}, 10);
|
||||||
$('<li class="highlight-link"><a href="javascript:Documentation.' +
|
$('<p class="highlight-link"><a href="javascript:Documentation.' +
|
||||||
'hideSearchWords()">' + _('Hide Search Matches') + '</a></li>')
|
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
|
||||||
.appendTo($('.sidebar .this-page-menu'));
|
.appendTo($('#searchbox'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ var Documentation = {
|
||||||
* helper function to hide the search marks again
|
* helper function to hide the search marks again
|
||||||
*/
|
*/
|
||||||
hideSearchWords : function() {
|
hideSearchWords : function() {
|
||||||
$('.sidebar .this-page-menu li.highlight-link').fadeOut(300);
|
$('#searchbox .highlight-link').fadeOut(300);
|
||||||
$('span.highlighted').removeClass('highlighted');
|
$('span.highlighted').removeClass('highlighted');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
BIN
doc/html/_static/down-pressed.png
Normal file
After Width: | Height: | Size: 368 B |
BIN
doc/html/_static/down.png
Normal file
After Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 312 B After Width: | Height: | Size: 392 B |
4331
doc/html/_static/jquery.js
vendored
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 199 B |
|
@ -13,11 +13,11 @@
|
||||||
.highlight .gr { color: #FF0000 } /* Generic.Error */
|
.highlight .gr { color: #FF0000 } /* Generic.Error */
|
||||||
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||||
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
||||||
.highlight .go { color: #303030 } /* Generic.Output */
|
.highlight .go { color: #333333 } /* Generic.Output */
|
||||||
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
|
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
|
||||||
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
||||||
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||||
.highlight .gt { color: #0040D0 } /* Generic.Traceback */
|
.highlight .gt { color: #0044DD } /* Generic.Traceback */
|
||||||
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
|
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
|
||||||
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
||||||
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
|
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* searchtools.js
|
* searchtools.js_t
|
||||||
* ~~~~~~~~~~~~~~
|
* ~~~~~~~~~~~~~~~~
|
||||||
*
|
*
|
||||||
* Sphinx JavaScript utilties for the full-text search.
|
* Sphinx JavaScript utilties for the full-text search.
|
||||||
*
|
*
|
||||||
|
@ -36,10 +36,11 @@ jQuery.makeSearchSummary = function(text, keywords, hlwords) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Porter Stemmer
|
* Porter Stemmer
|
||||||
*/
|
*/
|
||||||
var PorterStemmer = function() {
|
var Stemmer = function() {
|
||||||
|
|
||||||
var step2list = {
|
var step2list = {
|
||||||
ational: 'ate',
|
ational: 'ate',
|
||||||
|
@ -238,8 +239,13 @@ var Search = {
|
||||||
},
|
},
|
||||||
|
|
||||||
loadIndex : function(url) {
|
loadIndex : function(url) {
|
||||||
$.ajax({type: "GET", url: url, data: null, success: null,
|
$.ajax({type: "GET", url: url, data: null,
|
||||||
dataType: "script", cache: true});
|
dataType: "script", cache: true,
|
||||||
|
complete: function(jqxhr, textstatus) {
|
||||||
|
if (textstatus != "success") {
|
||||||
|
document.getElementById("searchindexloader").src = url;
|
||||||
|
}
|
||||||
|
}});
|
||||||
},
|
},
|
||||||
|
|
||||||
setIndex : function(index) {
|
setIndex : function(index) {
|
||||||
|
@ -300,20 +306,20 @@ var Search = {
|
||||||
},
|
},
|
||||||
|
|
||||||
query : function(query) {
|
query : function(query) {
|
||||||
var stopwords = ['and', 'then', 'into', 'it', 'as', 'are', 'in',
|
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
|
||||||
'if', 'for', 'no', 'there', 'their', 'was', 'is',
|
|
||||||
'be', 'to', 'that', 'but', 'they', 'not', 'such',
|
|
||||||
'with', 'by', 'a', 'on', 'these', 'of', 'will',
|
|
||||||
'this', 'near', 'the', 'or', 'at'];
|
|
||||||
|
|
||||||
// stem the searchterms and add them to the correct list
|
// Stem the searchterms and add them to the correct list
|
||||||
var stemmer = new PorterStemmer();
|
var stemmer = new Stemmer();
|
||||||
var searchterms = [];
|
var searchterms = [];
|
||||||
var excluded = [];
|
var excluded = [];
|
||||||
var hlterms = [];
|
var hlterms = [];
|
||||||
var tmp = query.split(/\s+/);
|
var tmp = query.split(/\s+/);
|
||||||
var object = (tmp.length == 1) ? tmp[0].toLowerCase() : null;
|
var objectterms = [];
|
||||||
for (var i = 0; i < tmp.length; i++) {
|
for (var i = 0; i < tmp.length; i++) {
|
||||||
|
if (tmp[i] != "") {
|
||||||
|
objectterms.push(tmp[i].toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
if ($u.indexOf(stopwords, tmp[i]) != -1 || tmp[i].match(/^\d+$/) ||
|
if ($u.indexOf(stopwords, tmp[i]) != -1 || tmp[i].match(/^\d+$/) ||
|
||||||
tmp[i] == "") {
|
tmp[i] == "") {
|
||||||
// skip this "word"
|
// skip this "word"
|
||||||
|
@ -344,9 +350,6 @@ var Search = {
|
||||||
var filenames = this._index.filenames;
|
var filenames = this._index.filenames;
|
||||||
var titles = this._index.titles;
|
var titles = this._index.titles;
|
||||||
var terms = this._index.terms;
|
var terms = this._index.terms;
|
||||||
var objects = this._index.objects;
|
|
||||||
var objtypes = this._index.objtypes;
|
|
||||||
var objnames = this._index.objnames;
|
|
||||||
var fileMap = {};
|
var fileMap = {};
|
||||||
var files = null;
|
var files = null;
|
||||||
// different result priorities
|
// different result priorities
|
||||||
|
@ -357,40 +360,19 @@ var Search = {
|
||||||
$('#search-progress').empty();
|
$('#search-progress').empty();
|
||||||
|
|
||||||
// lookup as object
|
// lookup as object
|
||||||
if (object != null) {
|
for (var i = 0; i < objectterms.length; i++) {
|
||||||
for (var prefix in objects) {
|
var others = [].concat(objectterms.slice(0,i),
|
||||||
for (var name in objects[prefix]) {
|
objectterms.slice(i+1, objectterms.length))
|
||||||
var fullname = (prefix ? prefix + '.' : '') + name;
|
var results = this.performObjectSearch(objectterms[i], others);
|
||||||
if (fullname.toLowerCase().indexOf(object) > -1) {
|
// Assume first word is most likely to be the object,
|
||||||
match = objects[prefix][name];
|
// other words more likely to be in description.
|
||||||
descr = objnames[match[1]] + _(', in ') + titles[match[0]];
|
// Therefore put matches for earlier words first.
|
||||||
// XXX the generated anchors are not generally correct
|
// (Results are eventually used in reverse order).
|
||||||
// XXX there may be custom prefixes
|
objectResults = results[0].concat(objectResults);
|
||||||
result = [filenames[match[0]], fullname, '#'+fullname, descr];
|
importantResults = results[1].concat(importantResults);
|
||||||
switch (match[2]) {
|
unimportantResults = results[2].concat(unimportantResults);
|
||||||
case 1: objectResults.push(result); break;
|
|
||||||
case 0: importantResults.push(result); break;
|
|
||||||
case 2: unimportantResults.push(result); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort results descending
|
|
||||||
objectResults.sort(function(a, b) {
|
|
||||||
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
importantResults.sort(function(a, b) {
|
|
||||||
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
unimportantResults.sort(function(a, b) {
|
|
||||||
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// perform the search on the required terms
|
// perform the search on the required terms
|
||||||
for (var i = 0; i < searchterms.length; i++) {
|
for (var i = 0; i < searchterms.length; i++) {
|
||||||
var word = searchterms[i];
|
var word = searchterms[i];
|
||||||
|
@ -480,16 +462,18 @@ var Search = {
|
||||||
displayNextItem();
|
displayNextItem();
|
||||||
});
|
});
|
||||||
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
|
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
|
||||||
$.get(DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' +
|
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt',
|
||||||
item[0] + '.txt', function(data) {
|
dataType: "text",
|
||||||
if (data != '') {
|
complete: function(jqxhr, textstatus) {
|
||||||
listItem.append($.makeSearchSummary(data, searchterms, hlterms));
|
var data = jqxhr.responseText;
|
||||||
Search.output.append(listItem);
|
if (data !== '') {
|
||||||
}
|
listItem.append($.makeSearchSummary(data, searchterms, hlterms));
|
||||||
listItem.slideDown(5, function() {
|
}
|
||||||
displayNextItem();
|
Search.output.append(listItem);
|
||||||
});
|
listItem.slideDown(5, function() {
|
||||||
}, "text");
|
displayNextItem();
|
||||||
|
});
|
||||||
|
}});
|
||||||
} else {
|
} else {
|
||||||
// no source available, just display title
|
// no source available, just display title
|
||||||
Search.output.append(listItem);
|
Search.output.append(listItem);
|
||||||
|
@ -510,6 +494,71 @@ var Search = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayNextItem();
|
displayNextItem();
|
||||||
|
},
|
||||||
|
|
||||||
|
performObjectSearch : function(object, otherterms) {
|
||||||
|
var filenames = this._index.filenames;
|
||||||
|
var objects = this._index.objects;
|
||||||
|
var objnames = this._index.objnames;
|
||||||
|
var titles = this._index.titles;
|
||||||
|
|
||||||
|
var importantResults = [];
|
||||||
|
var objectResults = [];
|
||||||
|
var unimportantResults = [];
|
||||||
|
|
||||||
|
for (var prefix in objects) {
|
||||||
|
for (var name in objects[prefix]) {
|
||||||
|
var fullname = (prefix ? prefix + '.' : '') + name;
|
||||||
|
if (fullname.toLowerCase().indexOf(object) > -1) {
|
||||||
|
var match = objects[prefix][name];
|
||||||
|
var objname = objnames[match[1]][2];
|
||||||
|
var title = titles[match[0]];
|
||||||
|
// If more than one term searched for, we require other words to be
|
||||||
|
// found in the name/title/description
|
||||||
|
if (otherterms.length > 0) {
|
||||||
|
var haystack = (prefix + ' ' + name + ' ' +
|
||||||
|
objname + ' ' + title).toLowerCase();
|
||||||
|
var allfound = true;
|
||||||
|
for (var i = 0; i < otherterms.length; i++) {
|
||||||
|
if (haystack.indexOf(otherterms[i]) == -1) {
|
||||||
|
allfound = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!allfound) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var descr = objname + _(', in ') + title;
|
||||||
|
anchor = match[3];
|
||||||
|
if (anchor == '')
|
||||||
|
anchor = fullname;
|
||||||
|
else if (anchor == '-')
|
||||||
|
anchor = objnames[match[1]][1] + '-' + fullname;
|
||||||
|
result = [filenames[match[0]], fullname, '#'+anchor, descr];
|
||||||
|
switch (match[2]) {
|
||||||
|
case 1: objectResults.push(result); break;
|
||||||
|
case 0: importantResults.push(result); break;
|
||||||
|
case 2: unimportantResults.push(result); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort results descending
|
||||||
|
objectResults.sort(function(a, b) {
|
||||||
|
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
importantResults.sort(function(a, b) {
|
||||||
|
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
unimportantResults.sort(function(a, b) {
|
||||||
|
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
return [importantResults, objectResults, unimportantResults]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ $(function() {
|
||||||
var sidebar = $('.sphinxsidebar');
|
var sidebar = $('.sphinxsidebar');
|
||||||
var sidebarwrapper = $('.sphinxsidebarwrapper');
|
var sidebarwrapper = $('.sphinxsidebarwrapper');
|
||||||
|
|
||||||
|
// for some reason, the document has no sidebar; do not run into errors
|
||||||
|
if (!sidebar.length) return;
|
||||||
|
|
||||||
// original margin-left of the bodywrapper and width of the sidebar
|
// original margin-left of the bodywrapper and width of the sidebar
|
||||||
// with the sidebar expanded
|
// with the sidebar expanded
|
||||||
var bw_margin_expanded = bodywrapper.css('margin-left');
|
var bw_margin_expanded = bodywrapper.css('margin-left');
|
||||||
|
|
BIN
doc/html/_static/up-pressed.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
doc/html/_static/up.png
Normal file
After Width: | Height: | Size: 363 B |
808
doc/html/_static/websupport.js
Normal file
|
@ -0,0 +1,808 @@
|
||||||
|
/*
|
||||||
|
* websupport.js
|
||||||
|
* ~~~~~~~~~~~~~
|
||||||
|
*
|
||||||
|
* sphinx.websupport utilties for all documentation.
|
||||||
|
*
|
||||||
|
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||||
|
* :license: BSD, see LICENSE for details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
$.fn.autogrow = function() {
|
||||||
|
return this.each(function() {
|
||||||
|
var textarea = this;
|
||||||
|
|
||||||
|
$.fn.autogrow.resize(textarea);
|
||||||
|
|
||||||
|
$(textarea)
|
||||||
|
.focus(function() {
|
||||||
|
textarea.interval = setInterval(function() {
|
||||||
|
$.fn.autogrow.resize(textarea);
|
||||||
|
}, 500);
|
||||||
|
})
|
||||||
|
.blur(function() {
|
||||||
|
clearInterval(textarea.interval);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.autogrow.resize = function(textarea) {
|
||||||
|
var lineHeight = parseInt($(textarea).css('line-height'), 10);
|
||||||
|
var lines = textarea.value.split('\n');
|
||||||
|
var columns = textarea.cols;
|
||||||
|
var lineCount = 0;
|
||||||
|
$.each(lines, function() {
|
||||||
|
lineCount += Math.ceil(this.length / columns) || 1;
|
||||||
|
});
|
||||||
|
var height = lineHeight * (lineCount + 1);
|
||||||
|
$(textarea).css('height', height);
|
||||||
|
};
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
var comp, by;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
initEvents();
|
||||||
|
initComparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
function initEvents() {
|
||||||
|
$('a.comment-close').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
hide($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.vote').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
handleVote($(this));
|
||||||
|
});
|
||||||
|
$('a.reply').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
openReply($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.close-reply').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
closeReply($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.sort-option').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
handleReSort($(this));
|
||||||
|
});
|
||||||
|
$('a.show-proposal').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
showProposal($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.hide-proposal').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
hideProposal($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.show-propose-change').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
showProposeChange($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.hide-propose-change').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
hideProposeChange($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.accept-comment').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
acceptComment($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.delete-comment').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
deleteComment($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
$('a.comment-markup').live("click", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
toggleCommentMarkupBox($(this).attr('id').substring(2));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set comp, which is a comparator function used for sorting and
|
||||||
|
* inserting comments into the list.
|
||||||
|
*/
|
||||||
|
function setComparator() {
|
||||||
|
// If the first three letters are "asc", sort in ascending order
|
||||||
|
// and remove the prefix.
|
||||||
|
if (by.substring(0,3) == 'asc') {
|
||||||
|
var i = by.substring(3);
|
||||||
|
comp = function(a, b) { return a[i] - b[i]; };
|
||||||
|
} else {
|
||||||
|
// Otherwise sort in descending order.
|
||||||
|
comp = function(a, b) { return b[by] - a[by]; };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset link styles and format the selected sort option.
|
||||||
|
$('a.sel').attr('href', '#').removeClass('sel');
|
||||||
|
$('a.by' + by).removeAttr('href').addClass('sel');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a comp function. If the user has preferences stored in
|
||||||
|
* the sortBy cookie, use those, otherwise use the default.
|
||||||
|
*/
|
||||||
|
function initComparator() {
|
||||||
|
by = 'rating'; // Default to sort by rating.
|
||||||
|
// If the sortBy cookie is set, use that instead.
|
||||||
|
if (document.cookie.length > 0) {
|
||||||
|
var start = document.cookie.indexOf('sortBy=');
|
||||||
|
if (start != -1) {
|
||||||
|
start = start + 7;
|
||||||
|
var end = document.cookie.indexOf(";", start);
|
||||||
|
if (end == -1) {
|
||||||
|
end = document.cookie.length;
|
||||||
|
by = unescape(document.cookie.substring(start, end));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setComparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a comment div.
|
||||||
|
*/
|
||||||
|
function show(id) {
|
||||||
|
$('#ao' + id).hide();
|
||||||
|
$('#ah' + id).show();
|
||||||
|
var context = $.extend({id: id}, opts);
|
||||||
|
var popup = $(renderTemplate(popupTemplate, context)).hide();
|
||||||
|
popup.find('textarea[name="proposal"]').hide();
|
||||||
|
popup.find('a.by' + by).addClass('sel');
|
||||||
|
var form = popup.find('#cf' + id);
|
||||||
|
form.submit(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
addComment(form);
|
||||||
|
});
|
||||||
|
$('#s' + id).after(popup);
|
||||||
|
popup.slideDown('fast', function() {
|
||||||
|
getComments(id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide a comment div.
|
||||||
|
*/
|
||||||
|
function hide(id) {
|
||||||
|
$('#ah' + id).hide();
|
||||||
|
$('#ao' + id).show();
|
||||||
|
var div = $('#sc' + id);
|
||||||
|
div.slideUp('fast', function() {
|
||||||
|
div.remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an ajax request to get comments for a node
|
||||||
|
* and insert the comments into the comments tree.
|
||||||
|
*/
|
||||||
|
function getComments(id) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: opts.getCommentsURL,
|
||||||
|
data: {node: id},
|
||||||
|
success: function(data, textStatus, request) {
|
||||||
|
var ul = $('#cl' + id);
|
||||||
|
var speed = 100;
|
||||||
|
$('#cf' + id)
|
||||||
|
.find('textarea[name="proposal"]')
|
||||||
|
.data('source', data.source);
|
||||||
|
|
||||||
|
if (data.comments.length === 0) {
|
||||||
|
ul.html('<li>No comments yet.</li>');
|
||||||
|
ul.data('empty', true);
|
||||||
|
} else {
|
||||||
|
// If there are comments, sort them and put them in the list.
|
||||||
|
var comments = sortComments(data.comments);
|
||||||
|
speed = data.comments.length * 100;
|
||||||
|
appendComments(comments, ul);
|
||||||
|
ul.data('empty', false);
|
||||||
|
}
|
||||||
|
$('#cn' + id).slideUp(speed + 200);
|
||||||
|
ul.slideDown(speed);
|
||||||
|
},
|
||||||
|
error: function(request, textStatus, error) {
|
||||||
|
showError('Oops, there was a problem retrieving the comments.');
|
||||||
|
},
|
||||||
|
dataType: 'json'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a comment via ajax and insert the comment into the comment tree.
|
||||||
|
*/
|
||||||
|
function addComment(form) {
|
||||||
|
var node_id = form.find('input[name="node"]').val();
|
||||||
|
var parent_id = form.find('input[name="parent"]').val();
|
||||||
|
var text = form.find('textarea[name="comment"]').val();
|
||||||
|
var proposal = form.find('textarea[name="proposal"]').val();
|
||||||
|
|
||||||
|
if (text == '') {
|
||||||
|
showError('Please enter a comment.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable the form that is being submitted.
|
||||||
|
form.find('textarea,input').attr('disabled', 'disabled');
|
||||||
|
|
||||||
|
// Send the comment to the server.
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: opts.addCommentURL,
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
node: node_id,
|
||||||
|
parent: parent_id,
|
||||||
|
text: text,
|
||||||
|
proposal: proposal
|
||||||
|
},
|
||||||
|
success: function(data, textStatus, error) {
|
||||||
|
// Reset the form.
|
||||||
|
if (node_id) {
|
||||||
|
hideProposeChange(node_id);
|
||||||
|
}
|
||||||
|
form.find('textarea')
|
||||||
|
.val('')
|
||||||
|
.add(form.find('input'))
|
||||||
|
.removeAttr('disabled');
|
||||||
|
var ul = $('#cl' + (node_id || parent_id));
|
||||||
|
if (ul.data('empty')) {
|
||||||
|
$(ul).empty();
|
||||||
|
ul.data('empty', false);
|
||||||
|
}
|
||||||
|
insertComment(data.comment);
|
||||||
|
var ao = $('#ao' + node_id);
|
||||||
|
ao.find('img').attr({'src': opts.commentBrightImage});
|
||||||
|
if (node_id) {
|
||||||
|
// if this was a "root" comment, remove the commenting box
|
||||||
|
// (the user can get it back by reopening the comment popup)
|
||||||
|
$('#ca' + node_id).slideUp();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(request, textStatus, error) {
|
||||||
|
form.find('textarea,input').removeAttr('disabled');
|
||||||
|
showError('Oops, there was a problem adding the comment.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively append comments to the main comment list and children
|
||||||
|
* lists, creating the comment tree.
|
||||||
|
*/
|
||||||
|
function appendComments(comments, ul) {
|
||||||
|
$.each(comments, function() {
|
||||||
|
var div = createCommentDiv(this);
|
||||||
|
ul.append($(document.createElement('li')).html(div));
|
||||||
|
appendComments(this.children, div.find('ul.comment-children'));
|
||||||
|
// To avoid stagnating data, don't store the comments children in data.
|
||||||
|
this.children = null;
|
||||||
|
div.data('comment', this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After adding a new comment, it must be inserted in the correct
|
||||||
|
* location in the comment tree.
|
||||||
|
*/
|
||||||
|
function insertComment(comment) {
|
||||||
|
var div = createCommentDiv(comment);
|
||||||
|
|
||||||
|
// To avoid stagnating data, don't store the comments children in data.
|
||||||
|
comment.children = null;
|
||||||
|
div.data('comment', comment);
|
||||||
|
|
||||||
|
var ul = $('#cl' + (comment.node || comment.parent));
|
||||||
|
var siblings = getChildren(ul);
|
||||||
|
|
||||||
|
var li = $(document.createElement('li'));
|
||||||
|
li.hide();
|
||||||
|
|
||||||
|
// Determine where in the parents children list to insert this comment.
|
||||||
|
for(i=0; i < siblings.length; i++) {
|
||||||
|
if (comp(comment, siblings[i]) <= 0) {
|
||||||
|
$('#cd' + siblings[i].id)
|
||||||
|
.parent()
|
||||||
|
.before(li.html(div));
|
||||||
|
li.slideDown('fast');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we get here, this comment rates lower than all the others,
|
||||||
|
// or it is the only comment in the list.
|
||||||
|
ul.append(li.html(div));
|
||||||
|
li.slideDown('fast');
|
||||||
|
}
|
||||||
|
|
||||||
|
function acceptComment(id) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: opts.acceptCommentURL,
|
||||||
|
data: {id: id},
|
||||||
|
success: function(data, textStatus, request) {
|
||||||
|
$('#cm' + id).fadeOut('fast');
|
||||||
|
$('#cd' + id).removeClass('moderate');
|
||||||
|
},
|
||||||
|
error: function(request, textStatus, error) {
|
||||||
|
showError('Oops, there was a problem accepting the comment.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteComment(id) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: opts.deleteCommentURL,
|
||||||
|
data: {id: id},
|
||||||
|
success: function(data, textStatus, request) {
|
||||||
|
var div = $('#cd' + id);
|
||||||
|
if (data == 'delete') {
|
||||||
|
// Moderator mode: remove the comment and all children immediately
|
||||||
|
div.slideUp('fast', function() {
|
||||||
|
div.remove();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// User mode: only mark the comment as deleted
|
||||||
|
div
|
||||||
|
.find('span.user-id:first')
|
||||||
|
.text('[deleted]').end()
|
||||||
|
.find('div.comment-text:first')
|
||||||
|
.text('[deleted]').end()
|
||||||
|
.find('#cm' + id + ', #dc' + id + ', #ac' + id + ', #rc' + id +
|
||||||
|
', #sp' + id + ', #hp' + id + ', #cr' + id + ', #rl' + id)
|
||||||
|
.remove();
|
||||||
|
var comment = div.data('comment');
|
||||||
|
comment.username = '[deleted]';
|
||||||
|
comment.text = '[deleted]';
|
||||||
|
div.data('comment', comment);
|
||||||
|
},
|
||||||
|
error: function(request, textStatus, error) {
|
||||||
|
showError('Oops, there was a problem deleting the comment.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showProposal(id) {
|
||||||
|
$('#sp' + id).hide();
|
||||||
|
$('#hp' + id).show();
|
||||||
|
$('#pr' + id).slideDown('fast');
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideProposal(id) {
|
||||||
|
$('#hp' + id).hide();
|
||||||
|
$('#sp' + id).show();
|
||||||
|
$('#pr' + id).slideUp('fast');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showProposeChange(id) {
|
||||||
|
$('#pc' + id).hide();
|
||||||
|
$('#hc' + id).show();
|
||||||
|
var textarea = $('#pt' + id);
|
||||||
|
textarea.val(textarea.data('source'));
|
||||||
|
$.fn.autogrow.resize(textarea[0]);
|
||||||
|
textarea.slideDown('fast');
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideProposeChange(id) {
|
||||||
|
$('#hc' + id).hide();
|
||||||
|
$('#pc' + id).show();
|
||||||
|
var textarea = $('#pt' + id);
|
||||||
|
textarea.val('').removeAttr('disabled');
|
||||||
|
textarea.slideUp('fast');
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCommentMarkupBox(id) {
|
||||||
|
$('#mb' + id).toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Handle when the user clicks on a sort by link. */
|
||||||
|
function handleReSort(link) {
|
||||||
|
var classes = link.attr('class').split(/\s+/);
|
||||||
|
for (var i=0; i<classes.length; i++) {
|
||||||
|
if (classes[i] != 'sort-option') {
|
||||||
|
by = classes[i].substring(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setComparator();
|
||||||
|
// Save/update the sortBy cookie.
|
||||||
|
var expiration = new Date();
|
||||||
|
expiration.setDate(expiration.getDate() + 365);
|
||||||
|
document.cookie= 'sortBy=' + escape(by) +
|
||||||
|
';expires=' + expiration.toUTCString();
|
||||||
|
$('ul.comment-ul').each(function(index, ul) {
|
||||||
|
var comments = getChildren($(ul), true);
|
||||||
|
comments = sortComments(comments);
|
||||||
|
appendComments(comments, $(ul).empty());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to process a vote when a user clicks an arrow.
|
||||||
|
*/
|
||||||
|
function handleVote(link) {
|
||||||
|
if (!opts.voting) {
|
||||||
|
showError("You'll need to login to vote.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var id = link.attr('id');
|
||||||
|
if (!id) {
|
||||||
|
// Didn't click on one of the voting arrows.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If it is an unvote, the new vote value is 0,
|
||||||
|
// Otherwise it's 1 for an upvote, or -1 for a downvote.
|
||||||
|
var value = 0;
|
||||||
|
if (id.charAt(1) != 'u') {
|
||||||
|
value = id.charAt(0) == 'u' ? 1 : -1;
|
||||||
|
}
|
||||||
|
// The data to be sent to the server.
|
||||||
|
var d = {
|
||||||
|
comment_id: id.substring(2),
|
||||||
|
value: value
|
||||||
|
};
|
||||||
|
|
||||||
|
// Swap the vote and unvote links.
|
||||||
|
link.hide();
|
||||||
|
$('#' + id.charAt(0) + (id.charAt(1) == 'u' ? 'v' : 'u') + d.comment_id)
|
||||||
|
.show();
|
||||||
|
|
||||||
|
// The div the comment is displayed in.
|
||||||
|
var div = $('div#cd' + d.comment_id);
|
||||||
|
var data = div.data('comment');
|
||||||
|
|
||||||
|
// If this is not an unvote, and the other vote arrow has
|
||||||
|
// already been pressed, unpress it.
|
||||||
|
if ((d.value !== 0) && (data.vote === d.value * -1)) {
|
||||||
|
$('#' + (d.value == 1 ? 'd' : 'u') + 'u' + d.comment_id).hide();
|
||||||
|
$('#' + (d.value == 1 ? 'd' : 'u') + 'v' + d.comment_id).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the comments rating in the local data.
|
||||||
|
data.rating += (data.vote === 0) ? d.value : (d.value - data.vote);
|
||||||
|
data.vote = d.value;
|
||||||
|
div.data('comment', data);
|
||||||
|
|
||||||
|
// Change the rating text.
|
||||||
|
div.find('.rating:first')
|
||||||
|
.text(data.rating + ' point' + (data.rating == 1 ? '' : 's'));
|
||||||
|
|
||||||
|
// Send the vote information to the server.
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: opts.processVoteURL,
|
||||||
|
data: d,
|
||||||
|
error: function(request, textStatus, error) {
|
||||||
|
showError('Oops, there was a problem casting that vote.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a reply form used to reply to an existing comment.
|
||||||
|
*/
|
||||||
|
function openReply(id) {
|
||||||
|
// Swap out the reply link for the hide link
|
||||||
|
$('#rl' + id).hide();
|
||||||
|
$('#cr' + id).show();
|
||||||
|
|
||||||
|
// Add the reply li to the children ul.
|
||||||
|
var div = $(renderTemplate(replyTemplate, {id: id})).hide();
|
||||||
|
$('#cl' + id)
|
||||||
|
.prepend(div)
|
||||||
|
// Setup the submit handler for the reply form.
|
||||||
|
.find('#rf' + id)
|
||||||
|
.submit(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
addComment($('#rf' + id));
|
||||||
|
closeReply(id);
|
||||||
|
})
|
||||||
|
.find('input[type=button]')
|
||||||
|
.click(function() {
|
||||||
|
closeReply(id);
|
||||||
|
});
|
||||||
|
div.slideDown('fast', function() {
|
||||||
|
$('#rf' + id).find('textarea').focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the reply form opened with openReply.
|
||||||
|
*/
|
||||||
|
function closeReply(id) {
|
||||||
|
// Remove the reply div from the DOM.
|
||||||
|
$('#rd' + id).slideUp('fast', function() {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Swap out the hide link for the reply link
|
||||||
|
$('#cr' + id).hide();
|
||||||
|
$('#rl' + id).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively sort a tree of comments using the comp comparator.
|
||||||
|
*/
|
||||||
|
function sortComments(comments) {
|
||||||
|
comments.sort(comp);
|
||||||
|
$.each(comments, function() {
|
||||||
|
this.children = sortComments(this.children);
|
||||||
|
});
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the children comments from a ul. If recursive is true,
|
||||||
|
* recursively include childrens' children.
|
||||||
|
*/
|
||||||
|
function getChildren(ul, recursive) {
|
||||||
|
var children = [];
|
||||||
|
ul.children().children("[id^='cd']")
|
||||||
|
.each(function() {
|
||||||
|
var comment = $(this).data('comment');
|
||||||
|
if (recursive)
|
||||||
|
comment.children = getChildren($(this).find('#cl' + comment.id), true);
|
||||||
|
children.push(comment);
|
||||||
|
});
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a div to display a comment in. */
|
||||||
|
function createCommentDiv(comment) {
|
||||||
|
if (!comment.displayed && !opts.moderator) {
|
||||||
|
return $('<div class="moderate">Thank you! Your comment will show up '
|
||||||
|
+ 'once it is has been approved by a moderator.</div>');
|
||||||
|
}
|
||||||
|
// Prettify the comment rating.
|
||||||
|
comment.pretty_rating = comment.rating + ' point' +
|
||||||
|
(comment.rating == 1 ? '' : 's');
|
||||||
|
// Make a class (for displaying not yet moderated comments differently)
|
||||||
|
comment.css_class = comment.displayed ? '' : ' moderate';
|
||||||
|
// Create a div for this comment.
|
||||||
|
var context = $.extend({}, opts, comment);
|
||||||
|
var div = $(renderTemplate(commentTemplate, context));
|
||||||
|
|
||||||
|
// If the user has voted on this comment, highlight the correct arrow.
|
||||||
|
if (comment.vote) {
|
||||||
|
var direction = (comment.vote == 1) ? 'u' : 'd';
|
||||||
|
div.find('#' + direction + 'v' + comment.id).hide();
|
||||||
|
div.find('#' + direction + 'u' + comment.id).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.moderator || comment.text != '[deleted]') {
|
||||||
|
div.find('a.reply').show();
|
||||||
|
if (comment.proposal_diff)
|
||||||
|
div.find('#sp' + comment.id).show();
|
||||||
|
if (opts.moderator && !comment.displayed)
|
||||||
|
div.find('#cm' + comment.id).show();
|
||||||
|
if (opts.moderator || (opts.username == comment.username))
|
||||||
|
div.find('#dc' + comment.id).show();
|
||||||
|
}
|
||||||
|
return div;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple template renderer. Placeholders such as <%id%> are replaced
|
||||||
|
* by context['id'] with items being escaped. Placeholders such as <#id#>
|
||||||
|
* are not escaped.
|
||||||
|
*/
|
||||||
|
function renderTemplate(template, context) {
|
||||||
|
var esc = $(document.createElement('div'));
|
||||||
|
|
||||||
|
function handle(ph, escape) {
|
||||||
|
var cur = context;
|
||||||
|
$.each(ph.split('.'), function() {
|
||||||
|
cur = cur[this];
|
||||||
|
});
|
||||||
|
return escape ? esc.text(cur || "").html() : cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
|
||||||
|
return handle(arguments[2], arguments[1] == '%' ? true : false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Flash an error message briefly. */
|
||||||
|
function showError(message) {
|
||||||
|
$(document.createElement('div')).attr({'class': 'popup-error'})
|
||||||
|
.append($(document.createElement('div'))
|
||||||
|
.attr({'class': 'error-message'}).text(message))
|
||||||
|
.appendTo('body')
|
||||||
|
.fadeIn("slow")
|
||||||
|
.delay(2000)
|
||||||
|
.fadeOut("slow");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add a link the user uses to open the comments popup. */
|
||||||
|
$.fn.comment = function() {
|
||||||
|
return this.each(function() {
|
||||||
|
var id = $(this).attr('id').substring(1);
|
||||||
|
var count = COMMENT_METADATA[id];
|
||||||
|
var title = count + ' comment' + (count == 1 ? '' : 's');
|
||||||
|
var image = count > 0 ? opts.commentBrightImage : opts.commentImage;
|
||||||
|
var addcls = count == 0 ? ' nocomment' : '';
|
||||||
|
$(this)
|
||||||
|
.append(
|
||||||
|
$(document.createElement('a')).attr({
|
||||||
|
href: '#',
|
||||||
|
'class': 'sphinx-comment-open' + addcls,
|
||||||
|
id: 'ao' + id
|
||||||
|
})
|
||||||
|
.append($(document.createElement('img')).attr({
|
||||||
|
src: image,
|
||||||
|
alt: 'comment',
|
||||||
|
title: title
|
||||||
|
}))
|
||||||
|
.click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
show($(this).attr('id').substring(2));
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.append(
|
||||||
|
$(document.createElement('a')).attr({
|
||||||
|
href: '#',
|
||||||
|
'class': 'sphinx-comment-close hidden',
|
||||||
|
id: 'ah' + id
|
||||||
|
})
|
||||||
|
.append($(document.createElement('img')).attr({
|
||||||
|
src: opts.closeCommentImage,
|
||||||
|
alt: 'close',
|
||||||
|
title: 'close'
|
||||||
|
}))
|
||||||
|
.click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
hide($(this).attr('id').substring(2));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var opts = {
|
||||||
|
processVoteURL: '/_process_vote',
|
||||||
|
addCommentURL: '/_add_comment',
|
||||||
|
getCommentsURL: '/_get_comments',
|
||||||
|
acceptCommentURL: '/_accept_comment',
|
||||||
|
deleteCommentURL: '/_delete_comment',
|
||||||
|
commentImage: '/static/_static/comment.png',
|
||||||
|
closeCommentImage: '/static/_static/comment-close.png',
|
||||||
|
loadingImage: '/static/_static/ajax-loader.gif',
|
||||||
|
commentBrightImage: '/static/_static/comment-bright.png',
|
||||||
|
upArrow: '/static/_static/up.png',
|
||||||
|
downArrow: '/static/_static/down.png',
|
||||||
|
upArrowPressed: '/static/_static/up-pressed.png',
|
||||||
|
downArrowPressed: '/static/_static/down-pressed.png',
|
||||||
|
voting: false,
|
||||||
|
moderator: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof COMMENT_OPTIONS != "undefined") {
|
||||||
|
opts = jQuery.extend(opts, COMMENT_OPTIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
var popupTemplate = '\
|
||||||
|
<div class="sphinx-comments" id="sc<%id%>">\
|
||||||
|
<p class="sort-options">\
|
||||||
|
Sort by:\
|
||||||
|
<a href="#" class="sort-option byrating">best rated</a>\
|
||||||
|
<a href="#" class="sort-option byascage">newest</a>\
|
||||||
|
<a href="#" class="sort-option byage">oldest</a>\
|
||||||
|
</p>\
|
||||||
|
<div class="comment-header">Comments</div>\
|
||||||
|
<div class="comment-loading" id="cn<%id%>">\
|
||||||
|
loading comments... <img src="<%loadingImage%>" alt="" /></div>\
|
||||||
|
<ul id="cl<%id%>" class="comment-ul"></ul>\
|
||||||
|
<div id="ca<%id%>">\
|
||||||
|
<p class="add-a-comment">Add a comment\
|
||||||
|
(<a href="#" class="comment-markup" id="ab<%id%>">markup</a>):</p>\
|
||||||
|
<div class="comment-markup-box" id="mb<%id%>">\
|
||||||
|
reStructured text markup: <i>*emph*</i>, <b>**strong**</b>, \
|
||||||
|
<tt>``code``</tt>, \
|
||||||
|
code blocks: <tt>::</tt> and an indented block after blank line</div>\
|
||||||
|
<form method="post" id="cf<%id%>" class="comment-form" action="">\
|
||||||
|
<textarea name="comment" cols="80"></textarea>\
|
||||||
|
<p class="propose-button">\
|
||||||
|
<a href="#" id="pc<%id%>" class="show-propose-change">\
|
||||||
|
Propose a change ▹\
|
||||||
|
</a>\
|
||||||
|
<a href="#" id="hc<%id%>" class="hide-propose-change">\
|
||||||
|
Propose a change ▿\
|
||||||
|
</a>\
|
||||||
|
</p>\
|
||||||
|
<textarea name="proposal" id="pt<%id%>" cols="80"\
|
||||||
|
spellcheck="false"></textarea>\
|
||||||
|
<input type="submit" value="Add comment" />\
|
||||||
|
<input type="hidden" name="node" value="<%id%>" />\
|
||||||
|
<input type="hidden" name="parent" value="" />\
|
||||||
|
</form>\
|
||||||
|
</div>\
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
var commentTemplate = '\
|
||||||
|
<div id="cd<%id%>" class="sphinx-comment<%css_class%>">\
|
||||||
|
<div class="vote">\
|
||||||
|
<div class="arrow">\
|
||||||
|
<a href="#" id="uv<%id%>" class="vote" title="vote up">\
|
||||||
|
<img src="<%upArrow%>" />\
|
||||||
|
</a>\
|
||||||
|
<a href="#" id="uu<%id%>" class="un vote" title="vote up">\
|
||||||
|
<img src="<%upArrowPressed%>" />\
|
||||||
|
</a>\
|
||||||
|
</div>\
|
||||||
|
<div class="arrow">\
|
||||||
|
<a href="#" id="dv<%id%>" class="vote" title="vote down">\
|
||||||
|
<img src="<%downArrow%>" id="da<%id%>" />\
|
||||||
|
</a>\
|
||||||
|
<a href="#" id="du<%id%>" class="un vote" title="vote down">\
|
||||||
|
<img src="<%downArrowPressed%>" />\
|
||||||
|
</a>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="comment-content">\
|
||||||
|
<p class="tagline comment">\
|
||||||
|
<span class="user-id"><%username%></span>\
|
||||||
|
<span class="rating"><%pretty_rating%></span>\
|
||||||
|
<span class="delta"><%time.delta%></span>\
|
||||||
|
</p>\
|
||||||
|
<div class="comment-text comment"><#text#></div>\
|
||||||
|
<p class="comment-opts comment">\
|
||||||
|
<a href="#" class="reply hidden" id="rl<%id%>">reply ▹</a>\
|
||||||
|
<a href="#" class="close-reply" id="cr<%id%>">reply ▿</a>\
|
||||||
|
<a href="#" id="sp<%id%>" class="show-proposal">proposal ▹</a>\
|
||||||
|
<a href="#" id="hp<%id%>" class="hide-proposal">proposal ▿</a>\
|
||||||
|
<a href="#" id="dc<%id%>" class="delete-comment hidden">delete</a>\
|
||||||
|
<span id="cm<%id%>" class="moderation hidden">\
|
||||||
|
<a href="#" id="ac<%id%>" class="accept-comment">accept</a>\
|
||||||
|
</span>\
|
||||||
|
</p>\
|
||||||
|
<pre class="proposal" id="pr<%id%>">\
|
||||||
|
<#proposal_diff#>\
|
||||||
|
</pre>\
|
||||||
|
<ul class="comment-children" id="cl<%id%>"></ul>\
|
||||||
|
</div>\
|
||||||
|
<div class="clearleft"></div>\
|
||||||
|
</div>\
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
var replyTemplate = '\
|
||||||
|
<li>\
|
||||||
|
<div class="reply-div" id="rd<%id%>">\
|
||||||
|
<form id="rf<%id%>">\
|
||||||
|
<textarea name="comment" cols="80"></textarea>\
|
||||||
|
<input type="submit" value="Add reply" />\
|
||||||
|
<input type="button" value="Cancel" />\
|
||||||
|
<input type="hidden" name="parent" value="<%id%>" />\
|
||||||
|
<input type="hidden" name="node" value="" />\
|
||||||
|
</form>\
|
||||||
|
</div>\
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
init();
|
||||||
|
});
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
// add comment anchors for all paragraphs that are commentable
|
||||||
|
$('.sphinx-has-comment').comment();
|
||||||
|
|
||||||
|
// highlight search words in search results
|
||||||
|
$("div.context").each(function() {
|
||||||
|
var params = $.getQueryParameters();
|
||||||
|
var terms = (params.q) ? params.q[0].split(/\s+/) : [];
|
||||||
|
var result = $(this);
|
||||||
|
$.each(terms, function() {
|
||||||
|
result.highlightText(this.toLowerCase(), 'highlighted');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// directly open comment window if requested
|
||||||
|
var anchor = document.location.hash;
|
||||||
|
if (anchor.substring(0, 9) == '#comment-') {
|
||||||
|
$('#ao' + anchor.substring(9)).click();
|
||||||
|
document.location.hash = '#s' + anchor.substring(9);
|
||||||
|
}
|
||||||
|
});
|
|
@ -44,13 +44,13 @@
|
||||||
nodes. This can be used to implement custom data types. A tutorial can be
|
nodes. This can be used to implement custom data types. A tutorial can be
|
||||||
found <a href="../tutorials/custom_types.html">here</a>.</p>
|
found <a href="../tutorials/custom_types.html">here</a>.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">class <a name="ConstructorException"></a><span class="ddoc_psymbol">ConstructorException</span>: dyaml.exception.YAMLException;
|
<dl><dt class="d_decl"><a name="ConstructorException"></a>class <a name="ConstructorException"></a><span class="ddoc_psymbol">ConstructorException</span>: dyaml.exception.YAMLException;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Exception thrown at constructor errors.
|
<dd><p>Exception thrown at constructor errors.
|
||||||
</p>
|
</p>
|
||||||
<p>Can be thrown by custom constructor functions.</p>
|
<p>Can be thrown by custom constructor functions.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(string <b>msg</b>, Mark <b>start</b>, Mark <b>end</b>, string <b>file</b> = __FILE__, int <b>line</b> = __LINE__);
|
<dl><dt class="d_decl"><a name="ConstructorException.this"></a>@safe this(string <b>msg</b>, Mark <b>start</b>, Mark <b>end</b>, string <b>file</b> = __FILE__, int <b>line</b> = __LINE__);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a ConstructorException.
|
<dd><p>Construct a ConstructorException.
|
||||||
</p>
|
</p>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">class <a name="Constructor"></a><span class="ddoc_psymbol">Constructor</span>;
|
<dt class="d_decl"><a name="Constructor"></a>class <a name="Constructor"></a><span class="ddoc_psymbol">Constructor</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Constructs YAML values.
|
<dd><p>Constructs YAML values.
|
||||||
</p>
|
</p>
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
If a tag is detected with no known constructor function, it is considered an error.</p>
|
If a tag is detected with no known constructor function, it is considered an error.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(const(bool) <b>defaultConstructors</b> = true);
|
<dl><dt class="d_decl"><a name="Constructor.this"></a>nothrow @safe this(const Flag!"useDefaultConstructors" <b>defaultConstructors</b> = Yes.useDefaultConstructors);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Constructor.
|
<dd><p>Construct a Constructor.
|
||||||
</p>
|
</p>
|
||||||
|
@ -92,23 +92,23 @@
|
||||||
<b>defaultConstructors</b> to disable constructor functions for these.
|
<b>defaultConstructors</b> to disable constructor functions for these.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>const(bool) <b>defaultConstructors</b></td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>Flag!"useDefaultConstructors" <b>defaultConstructors</b></td>
|
||||||
<td valign=top>Use constructors for default YAML tags?</td></tr>
|
<td valign=top>Use constructors for default YAML tags?</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="addConstructorScalar"></a><span class="ddoc_psymbol">addConstructorScalar</span>(T)(in string <b>tag</b>, T function(ref Node) <b>ctor</b>);
|
<dt class="d_decl"><a name="Constructor.addConstructorScalar"></a>nothrow @safe void <a name="addConstructorScalar"></a><span class="ddoc_psymbol">addConstructorScalar</span>(T)(const string <b>tag</b>, T function(ref Node) <b>ctor</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Add a constructor function from scalar.
|
<dd><p>Add a constructor function from scalar.
|
||||||
</p>
|
</p>
|
||||||
<p>The function must take a reference to Node to construct from.
|
<p>The function must take a reference to <span class="d_inlinecode">Node</span> to construct from.
|
||||||
The node contains a string for scalars, Node[] for sequences and
|
The node contains a string for scalars, for sequences and
|
||||||
Node.Pair[] for mappings.
|
for mappings.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
Any exception thrown by this function will be caught by D:YAML and
|
Any exception thrown by this function will be caught by D:YAML and
|
||||||
its message will be added to a YAMLException that will also tell the
|
its message will be added to a that will also tell
|
||||||
user which type failed to construct, and position in the file.
|
the user which type failed to construct, and position in the file.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
@ -129,53 +129,53 @@
|
||||||
values - it is not const for compatibility reasons.
|
values - it is not const for compatibility reasons.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>tag</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string tag</td>
|
||||||
<td valign=top>Tag for the function to handle.</td></tr>
|
<td valign=top>Tag for the function to handle.</td></tr>
|
||||||
<tr><td valign=top>ctor</td>
|
<tr><td valign=top>T function(ref Node) ctor</td>
|
||||||
<td valign=top>Constructor function.</td></tr>
|
<td valign=top>Constructor function.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<p><b>Example:</b><br>
|
<p><b>Example:</b><br>
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.string;
|
<pre class="d_code"><span class="d_keyword">import</span> std.string;
|
||||||
|
|
||||||
<span class="d_keyword">import</span> yaml;
|
<span class="d_keyword">import</span> dyaml.all;
|
||||||
|
|
||||||
<span class="d_keyword">struct</span> MyStruct
|
<span class="d_keyword">struct</span> MyStruct
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MyStruct constructMyStructScalar(<span class="d_keyword">ref</span> Node node)
|
MyStruct constructMyStructScalar(<span class="d_keyword">ref</span> Node node)
|
||||||
{
|
{
|
||||||
<span class="d_comment">//Guaranteed to be string as we construct from scalar.
|
<span class="d_comment">//Guaranteed to be string as we construct from scalar.
|
||||||
</span> <span class="d_comment">//!mystruct x:y:z
|
</span> <span class="d_comment">//!mystruct x:y:z
|
||||||
</span> <span class="d_keyword">auto</span> parts = node.as!string().split(<span class="d_string">":"</span>);
|
</span> <span class="d_keyword">auto</span> parts = node.as!string().split(<span class="d_string">":"</span>);
|
||||||
<span class="d_comment">//If this throws, the D:YAML will handle it and throw a YAMLException.
|
<span class="d_comment">//If this throws, the D:YAML will handle it and throw a YAMLException.
|
||||||
</span> <span class="d_keyword">return</span> MyStruct(to!<span class="d_keyword">int</span>(parts[0]), to!<span class="d_keyword">int</span>(parts[1]), to!<span class="d_keyword">int</span>(parts[2]));
|
</span> <span class="d_keyword">return</span> MyStruct(to!<span class="d_keyword">int</span>(parts[0]), to!<span class="d_keyword">int</span>(parts[1]), to!<span class="d_keyword">int</span>(parts[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_keyword">void</span> main()
|
<span class="d_keyword">void</span> main()
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.yaml"</span>);
|
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.yaml"</span>);
|
||||||
<span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor;
|
<span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor;
|
||||||
constructor.<span class="d_psymbol">addConstructorScalar</span>(<span class="d_string">"!mystruct"</span>, &constructMyStructScalar);
|
constructor.<span class="d_psymbol">addConstructorScalar</span>(<span class="d_string">"!mystruct"</span>, &constructMyStructScalar);
|
||||||
loader.constructor = constructor;
|
loader.constructor = constructor;
|
||||||
Node node = loader.load();
|
Node node = loader.load();
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="addConstructorSequence"></a><span class="ddoc_psymbol">addConstructorSequence</span>(T)(in string <b>tag</b>, T function(ref Node) <b>ctor</b>);
|
<dt class="d_decl"><a name="Constructor.addConstructorSequence"></a>nothrow @safe void <a name="addConstructorSequence"></a><span class="ddoc_psymbol">addConstructorSequence</span>(T)(const string <b>tag</b>, T function(ref Node) <b>ctor</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Add a constructor function from sequence.
|
<dd><p>Add a constructor function from sequence.
|
||||||
</p>
|
</p>
|
||||||
|
@ -183,45 +183,45 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p><b>Example:</b><br>
|
<p><b>Example:</b><br>
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.string;
|
<pre class="d_code"><span class="d_keyword">import</span> std.string;
|
||||||
|
|
||||||
<span class="d_keyword">import</span> yaml;
|
<span class="d_keyword">import</span> dyaml.all;
|
||||||
|
|
||||||
<span class="d_keyword">struct</span> MyStruct
|
<span class="d_keyword">struct</span> MyStruct
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MyStruct constructMyStructSequence(<span class="d_keyword">ref</span> Node node)
|
MyStruct constructMyStructSequence(<span class="d_keyword">ref</span> Node node)
|
||||||
{
|
{
|
||||||
<span class="d_comment">//node is guaranteed to be sequence.
|
<span class="d_comment">//node is guaranteed to be sequence.
|
||||||
</span> <span class="d_comment">//!mystruct [x, y, z]
|
</span> <span class="d_comment">//!mystruct [x, y, z]
|
||||||
</span> <span class="d_keyword">return</span> MyStruct(node[0].as!<span class="d_keyword">int</span>, node[1].as!<span class="d_keyword">int</span>, node[2].as!<span class="d_keyword">int</span>);
|
</span> <span class="d_keyword">return</span> MyStruct(node[0].as!<span class="d_keyword">int</span>, node[1].as!<span class="d_keyword">int</span>, node[2].as!<span class="d_keyword">int</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_keyword">void</span> main()
|
<span class="d_keyword">void</span> main()
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.yaml"</span>);
|
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.yaml"</span>);
|
||||||
<span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor;
|
<span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor;
|
||||||
constructor.<span class="d_psymbol">addConstructorSequence</span>(<span class="d_string">"!mystruct"</span>, &constructMyStructSequence);
|
constructor.<span class="d_psymbol">addConstructorSequence</span>(<span class="d_string">"!mystruct"</span>, &constructMyStructSequence);
|
||||||
loader.constructor = constructor;
|
loader.constructor = constructor;
|
||||||
Node node = loader.load();
|
Node node = loader.load();
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="addConstructorMapping"></a><span class="ddoc_psymbol">addConstructorMapping</span>(T)(in string <b>tag</b>, T function(ref Node) <b>ctor</b>);
|
<dt class="d_decl"><a name="Constructor.addConstructorMapping"></a>nothrow @safe void <a name="addConstructorMapping"></a><span class="ddoc_psymbol">addConstructorMapping</span>(T)(const string <b>tag</b>, T function(ref Node) <b>ctor</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Add a constructor function from a mapping.
|
<dd><p>Add a constructor function from a mapping.
|
||||||
</p>
|
</p>
|
||||||
|
@ -229,112 +229,112 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p><b>Example:</b><br>
|
<p><b>Example:</b><br>
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.string;
|
<pre class="d_code"><span class="d_keyword">import</span> std.string;
|
||||||
|
|
||||||
<span class="d_keyword">import</span> yaml;
|
<span class="d_keyword">import</span> dyaml.all;
|
||||||
|
|
||||||
<span class="d_keyword">struct</span> MyStruct
|
<span class="d_keyword">struct</span> MyStruct
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MyStruct constructMyStructMapping(<span class="d_keyword">ref</span> Node node)
|
MyStruct constructMyStructMapping(<span class="d_keyword">ref</span> Node node)
|
||||||
{
|
{
|
||||||
<span class="d_comment">//node is guaranteed to be mapping.
|
<span class="d_comment">//node is guaranteed to be mapping.
|
||||||
</span> <span class="d_comment">//!mystruct {"x": x, "y": y, "z": z}
|
</span> <span class="d_comment">//!mystruct {"x": x, "y": y, "z": z}
|
||||||
</span> <span class="d_keyword">return</span> MyStruct(node[<span class="d_string">"x"</span>].as!<span class="d_keyword">int</span>, node[<span class="d_string">"y"</span>].as!<span class="d_keyword">int</span>, node[<span class="d_string">"z"</span>].as!<span class="d_keyword">int</span>);
|
</span> <span class="d_keyword">return</span> MyStruct(node[<span class="d_string">"x"</span>].as!<span class="d_keyword">int</span>, node[<span class="d_string">"y"</span>].as!<span class="d_keyword">int</span>, node[<span class="d_string">"z"</span>].as!<span class="d_keyword">int</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_keyword">void</span> main()
|
<span class="d_keyword">void</span> main()
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.yaml"</span>);
|
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.yaml"</span>);
|
||||||
<span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor;
|
<span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor;
|
||||||
constructor.<span class="d_psymbol">addConstructorMapping</span>(<span class="d_string">"!mystruct"</span>, &constructMyStructMapping);
|
constructor.<span class="d_psymbol">addConstructorMapping</span>(<span class="d_string">"!mystruct"</span>, &constructMyStructMapping);
|
||||||
loader.constructor = constructor;
|
loader.constructor = constructor;
|
||||||
Node node = loader.load();
|
Node node = loader.load();
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">YAMLNull <a name="constructNull"></a><span class="ddoc_psymbol">constructNull</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructNull"></a>YAMLNull <a name="constructNull"></a><span class="ddoc_psymbol">constructNull</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a null node.</p>
|
<dd><p>Construct a null node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">YAMLMerge <a name="constructMerge"></a><span class="ddoc_psymbol">constructMerge</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructMerge"></a>YAMLMerge <a name="constructMerge"></a><span class="ddoc_psymbol">constructMerge</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a merge node - a node that merges another node into a mapping.</p>
|
<dd><p>Construct a merge node - a node that merges another node into a mapping.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">bool <a name="constructBool"></a><span class="ddoc_psymbol">constructBool</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructBool"></a>bool <a name="constructBool"></a><span class="ddoc_psymbol">constructBool</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a boolean node.</p>
|
<dd><p>Construct a boolean node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">long <a name="constructLong"></a><span class="ddoc_psymbol">constructLong</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructLong"></a>long <a name="constructLong"></a><span class="ddoc_psymbol">constructLong</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct an integer (long) node.</p>
|
<dd><p>Construct an integer (long) node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">real <a name="constructReal"></a><span class="ddoc_psymbol">constructReal</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructReal"></a>real <a name="constructReal"></a><span class="ddoc_psymbol">constructReal</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a floating point (real) node.</p>
|
<dd><p>Construct a floating point (real) node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">ubyte[] <a name="constructBinary"></a><span class="ddoc_psymbol">constructBinary</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructBinary"></a>ubyte[] <a name="constructBinary"></a><span class="ddoc_psymbol">constructBinary</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a binary (base64) node.</p>
|
<dd><p>Construct a binary (base64) node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">SysTime <a name="constructTimestamp"></a><span class="ddoc_psymbol">constructTimestamp</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructTimestamp"></a>SysTime <a name="constructTimestamp"></a><span class="ddoc_psymbol">constructTimestamp</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a timestamp (SysTime) node.</p>
|
<dd><p>Construct a timestamp (SysTime) node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">string <a name="constructString"></a><span class="ddoc_psymbol">constructString</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructString"></a>string <a name="constructString"></a><span class="ddoc_psymbol">constructString</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a string node.</p>
|
<dd><p>Construct a string node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Pair[] <a name="getPairs"></a><span class="ddoc_psymbol">getPairs</span>(string <b>type</b>, Node[] <b>nodes</b>);
|
<dt class="d_decl"><a name="getPairs"></a>Node.Pair[] <a name="getPairs"></a><span class="ddoc_psymbol">getPairs</span>(string <b>type</b>, Node[] <b>nodes</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Convert a sequence of single-element mappings into a sequence of pairs.</p>
|
<dd><p>Convert a sequence of single-element mappings into a sequence of pairs.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Pair[] <a name="constructOrderedMap"></a><span class="ddoc_psymbol">constructOrderedMap</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructOrderedMap"></a>Node.Pair[] <a name="constructOrderedMap"></a><span class="ddoc_psymbol">constructOrderedMap</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct an ordered map (ordered sequence of key:value pairs without duplicates) node.</p>
|
<dd><p>Construct an ordered map (ordered sequence of key:value pairs without duplicates) node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Pair[] <a name="constructPairs"></a><span class="ddoc_psymbol">constructPairs</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructPairs"></a>Node.Pair[] <a name="constructPairs"></a><span class="ddoc_psymbol">constructPairs</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a pairs (ordered sequence of key: value pairs allowing duplicates) node.</p>
|
<dd><p>Construct a pairs (ordered sequence of key: value pairs allowing duplicates) node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node[] <a name="constructSet"></a><span class="ddoc_psymbol">constructSet</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructSet"></a>Node[] <a name="constructSet"></a><span class="ddoc_psymbol">constructSet</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a set node.</p>
|
<dd><p>Construct a set node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node[] <a name="constructSequence"></a><span class="ddoc_psymbol">constructSequence</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructSequence"></a>Node[] <a name="constructSequence"></a><span class="ddoc_psymbol">constructSequence</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a sequence (array) node.</p>
|
<dd><p>Construct a sequence (array) node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Pair[] <a name="constructMap"></a><span class="ddoc_psymbol">constructMap</span>(ref Node <b>node</b>);
|
<dt class="d_decl"><a name="constructMap"></a>Node.Pair[] <a name="constructMap"></a><span class="ddoc_psymbol">constructMap</span>(ref Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct an unordered map (unordered set of key:value pairs without duplicates) node.</p>
|
<dd><p>Construct an unordered map (unordered set of key:value pairs without duplicates) node.</p>
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
</p>
|
</p>
|
||||||
<p>Code based on <a href="http://www.pyyaml.org">PyYAML</a>.</p>
|
<p>Code based on <a href="http://www.pyyaml.org">PyYAML</a>.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">struct <a name="Dumper"></a><span class="ddoc_psymbol">Dumper</span>;
|
<dl><dt class="d_decl"><a name="Dumper"></a>struct <a name="Dumper"></a><span class="ddoc_psymbol">Dumper</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Dumps YAML documents to files or streams.
|
<dd><p>Dumps YAML documents to files or streams.
|
||||||
</p>
|
</p>
|
||||||
|
@ -56,43 +56,46 @@
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Examples:</b><div class="pbr">Write to a file:
|
<b>Examples:</b><div class="pbr">Write to a file:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> node = Node([1, 2, 3, 4, 5]);
|
<pre class="d_code"><span class="d_keyword">auto</span> node = Node([1, 2, 3, 4, 5]);
|
||||||
<span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>).dump(node);
|
<span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>).dump(node);
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Write multiple YAML documents to a file:
|
Write multiple YAML documents to a file:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> node1 = Node([1, 2, 3, 4, 5]);
|
<pre class="d_code"><span class="d_keyword">auto</span> node1 = Node([1, 2, 3, 4, 5]);
|
||||||
<span class="d_keyword">auto</span> node2 = Node(<span class="d_string">"This document contains only one string"</span>);
|
<span class="d_keyword">auto</span> node2 = Node(<span class="d_string">"This document contains only one string"</span>);
|
||||||
<span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>).dump(node1, node2);
|
<span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>).dump(node1, node2);
|
||||||
|
|
||||||
<span class="d_comment">//Or with an array:
|
<span class="d_comment">//Or with an array:
|
||||||
</span> <span class="d_comment">//Dumper("file.yaml").dump([node1, node2]);
|
</span><span class="d_comment">//Dumper("file.yaml").dump([node1, node2]);
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Write to memory:
|
Write to memory:
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.stream;
|
<pre class="d_code"><span class="d_keyword">import</span> std.stream;
|
||||||
<span class="d_keyword">auto</span> stream = <span class="d_keyword">new</span> MemoryStream();
|
<span class="d_keyword">auto</span> stream = <span class="d_keyword">new</span> MemoryStream();
|
||||||
<span class="d_keyword">auto</span> node = Node([1, 2, 3, 4, 5]);
|
<span class="d_keyword">auto</span> node = Node([1, 2, 3, 4, 5]);
|
||||||
<span class="d_psymbol">Dumper</span>(stream).dump(node);
|
<span class="d_psymbol">Dumper</span>(stream).dump(node);
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Use a custom representer/resolver to support custom data types and/or implicit tags:
|
Use a custom representer/resolver to support custom data types and/or implicit tags:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> node = Node([1, 2, 3, 4, 5]);
|
<pre class="d_code"><span class="d_keyword">auto</span> node = Node([1, 2, 3, 4, 5]);
|
||||||
<span class="d_keyword">auto</span> representer = <span class="d_keyword">new</span> Representer();
|
<span class="d_keyword">auto</span> representer = <span class="d_keyword">new</span> Representer();
|
||||||
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
|
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
|
||||||
|
|
||||||
<span class="d_comment">//Add representer functions / resolver expressions here...
|
<span class="d_comment">//Add representer functions / resolver expressions here...
|
||||||
</span>
|
</span>
|
||||||
<span class="d_keyword">auto</span> dumper = <span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>);
|
<span class="d_keyword">auto</span> dumper = <span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>);
|
||||||
dumper.representer = representer;
|
dumper.representer = representer;
|
||||||
dumper.resolver = resolver;
|
dumper.resolver = resolver;
|
||||||
dumper.dump(node);
|
dumper.dump(node);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(string <b>filename</b>);
|
<dl><dt class="d_decl"><a name="Dumper.this"></a>@trusted this(string <b>filename</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Dumper writing to a file.
|
<dd><p>Construct a Dumper writing to a file.
|
||||||
</p>
|
</p>
|
||||||
|
@ -102,67 +105,67 @@
|
||||||
<b>Throws:</b><div class="pbr">YAMLException if the file can not be dumped to (e.g. cannot be opened).</div>
|
<b>Throws:</b><div class="pbr">YAMLException if the file can not be dumped to (e.g. cannot be opened).</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">this(Stream <b>stream</b>);
|
<dt class="d_decl"><a name="Dumper.this"></a>@safe this(Stream <b>stream</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Dumper writing to a stream. This is useful to e.g. write to memory.</p>
|
<dd><p>Construct a Dumper writing to a stream. This is useful to e.g. write to memory.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="name"></a><span class="ddoc_psymbol">name</span>(string <a name="name"></a><span class="ddoc_psymbol">name</span>);
|
<dt class="d_decl"><a name="Dumper.name"></a>pure nothrow @property @safe void <a name="name"></a><span class="ddoc_psymbol">name</span>(string <a name="name"></a><span class="ddoc_psymbol">name</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set stream name. Used in debugging messages.</p>
|
<dd><p>Set stream name. Used in debugging messages.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>(Resolver <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>);
|
<dt class="d_decl"><a name="Dumper.resolver"></a>@property @trusted void <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>(Resolver <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Specify custom Resolver to use.</p>
|
<dd><p>Specify custom Resolver to use.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="representer"></a><span class="ddoc_psymbol">representer</span>(Representer <a name="representer"></a><span class="ddoc_psymbol">representer</span>);
|
<dt class="d_decl"><a name="Dumper.representer"></a>@property @trusted void <a name="representer"></a><span class="ddoc_psymbol">representer</span>(Representer <a name="representer"></a><span class="ddoc_psymbol">representer</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Specify custom Representer to use.</p>
|
<dd><p>Specify custom Representer to use.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="canonical"></a><span class="ddoc_psymbol">canonical</span>(bool <a name="canonical"></a><span class="ddoc_psymbol">canonical</span>);
|
<dt class="d_decl"><a name="Dumper.canonical"></a>pure nothrow @property @safe void <a name="canonical"></a><span class="ddoc_psymbol">canonical</span>(bool <a name="canonical"></a><span class="ddoc_psymbol">canonical</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Write scalars in canonical form?</p>
|
<dd><p>Write scalars in canonical form?</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="indent"></a><span class="ddoc_psymbol">indent</span>(uint <a name="indent"></a><span class="ddoc_psymbol">indent</span>);
|
<dt class="d_decl"><a name="Dumper.indent"></a>pure nothrow @property @safe void <a name="indent"></a><span class="ddoc_psymbol">indent</span>(uint <a name="indent"></a><span class="ddoc_psymbol">indent</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set indentation width. 2 by default. Must not be zero.</p>
|
<dd><p>Set indentation width. 2 by default. Must not be zero.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="textWidth"></a><span class="ddoc_psymbol">textWidth</span>(uint <b>width</b>);
|
<dt class="d_decl"><a name="Dumper.textWidth"></a>pure nothrow @property @safe void <a name="textWidth"></a><span class="ddoc_psymbol">textWidth</span>(uint <b>width</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set preferred text width.</p>
|
<dd><p>Set preferred text width.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="lineBreak"></a><span class="ddoc_psymbol">lineBreak</span>(LineBreak <a name="lineBreak"></a><span class="ddoc_psymbol">lineBreak</span>);
|
<dt class="d_decl"><a name="Dumper.lineBreak"></a>pure nothrow @property @safe void <a name="lineBreak"></a><span class="ddoc_psymbol">lineBreak</span>(LineBreak <a name="lineBreak"></a><span class="ddoc_psymbol">lineBreak</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set line break to use. Unix by default.</p>
|
<dd><p>Set line break to use. Unix by default.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="encoding"></a><span class="ddoc_psymbol">encoding</span>(Encoding <a name="encoding"></a><span class="ddoc_psymbol">encoding</span>);
|
<dt class="d_decl"><a name="Dumper.encoding"></a>pure nothrow @property @safe void <a name="encoding"></a><span class="ddoc_psymbol">encoding</span>(Encoding <a name="encoding"></a><span class="ddoc_psymbol">encoding</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set character encoding to use. UTF-8 by default.</p>
|
<dd><p>Set character encoding to use. UTF-8 by default.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="explicitStart"></a><span class="ddoc_psymbol">explicitStart</span>(bool <b>explicit</b>);
|
<dt class="d_decl"><a name="Dumper.explicitStart"></a>pure nothrow @property @safe void <a name="explicitStart"></a><span class="ddoc_psymbol">explicitStart</span>(bool <b>explicit</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Always explicitly write document start?</p>
|
<dd><p>Always explicitly write document start?</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="explicitEnd"></a><span class="ddoc_psymbol">explicitEnd</span>(bool <b>explicit</b>);
|
<dt class="d_decl"><a name="Dumper.explicitEnd"></a>pure nothrow @property @safe void <a name="explicitEnd"></a><span class="ddoc_psymbol">explicitEnd</span>(bool <b>explicit</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Always explicitly write document end?</p>
|
<dd><p>Always explicitly write document end?</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="YAMLVersion"></a><span class="ddoc_psymbol">YAMLVersion</span>(string <a name="YAMLVersion"></a><span class="ddoc_psymbol">YAMLVersion</span>);
|
<dt class="d_decl"><a name="Dumper.YAMLVersion"></a>pure nothrow @property @safe void <a name="YAMLVersion"></a><span class="ddoc_psymbol">YAMLVersion</span>(string <a name="YAMLVersion"></a><span class="ddoc_psymbol">YAMLVersion</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Specify YAML version string. "1.1" by default.</p>
|
<dd><p>Specify YAML version string. "1.1" by default.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="tagDirectives"></a><span class="ddoc_psymbol">tagDirectives</span>(string[string] <b>tags</b>);
|
<dt class="d_decl"><a name="Dumper.tagDirectives"></a>pure @property @trusted void <a name="tagDirectives"></a><span class="ddoc_psymbol">tagDirectives</span>(string[string] <b>tags</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Specify tag directives.
|
<dd><p>Specify tag directives.
|
||||||
</p>
|
</p>
|
||||||
|
@ -189,18 +192,18 @@
|
||||||
<td valign=top>Tag directives (keys are handles, values are prefixes).</td></tr>
|
<td valign=top>Tag directives (keys are handles, values are prefixes).</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<p><b>Example:</b><br>
|
<p><b>Example:</b><br>
|
||||||
<pre class="d_code"> Dumper dumper = Dumper(<span class="d_string">"file.yaml"</span>);
|
<pre class="d_code">Dumper dumper = Dumper(<span class="d_string">"file.yaml"</span>);
|
||||||
string[string] directives;
|
string[string] directives;
|
||||||
directives[<span class="d_string">"!short!"</span>] = <span class="d_string">"tag:long.org,2011:"</span>;
|
directives[<span class="d_string">"!short!"</span>] = <span class="d_string">"tag:long.org,2011:"</span>;
|
||||||
<span class="d_comment">//This will emit tags starting with "tag:long.org,2011"
|
<span class="d_comment">//This will emit tags starting with "tag:long.org,2011"
|
||||||
</span> <span class="d_comment">//with a "!short!" prefix instead.
|
</span><span class="d_comment">//with a "!short!" prefix instead.
|
||||||
</span> dumper.<span class="d_psymbol">tagDirectives</span>(directives);
|
</span>dumper.<span class="d_psymbol">tagDirectives</span>(directives);
|
||||||
dumper.dump(Node(<span class="d_string">"foo"</span>));
|
dumper.dump(Node(<span class="d_string">"foo"</span>));
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="dump"></a><span class="ddoc_psymbol">dump</span>(Node[] <b>documents</b>...);
|
<dt class="d_decl"><a name="Dumper.dump"></a>@trusted void <a name="dump"></a><span class="ddoc_psymbol">dump</span>(Node[] <b>documents</b>...);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Dump one or more YAML documents to the file/stream.
|
<dd><p>Dump one or more YAML documents to the file/stream.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -41,19 +41,19 @@
|
||||||
<h1>dyaml.encoding</h1>
|
<h1>dyaml.encoding</h1>
|
||||||
<!-- Generated by Ddoc from dyaml/encoding.d -->
|
<!-- Generated by Ddoc from dyaml/encoding.d -->
|
||||||
<br>
|
<br>
|
||||||
<dl><dt class="d_decl">enum <a name="Encoding"></a><span class="ddoc_psymbol">Encoding</span>;
|
<dl><dt class="d_decl"><a name="Encoding"></a>enum <a name="Encoding"></a><span class="ddoc_psymbol">Encoding</span>: ubyte;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Text encodings supported by D:YAML.</p>
|
<dd><p>Text encodings supported by D:YAML.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl"><a name="UTF_8"></a><span class="ddoc_psymbol">UTF_8</span></dt>
|
<dl><dt class="d_decl"><a name="Encoding.UTF_8"></a><a name="UTF_8"></a><span class="ddoc_psymbol">UTF_8</span></dt>
|
||||||
<dd><p>Unicode UTF-8</p>
|
<dd><p>Unicode UTF-8</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="UTF_16"></a><span class="ddoc_psymbol">UTF_16</span></dt>
|
<dt class="d_decl"><a name="Encoding.UTF_16"></a><a name="UTF_16"></a><span class="ddoc_psymbol">UTF_16</span></dt>
|
||||||
<dd><p>Unicode UTF-16</p>
|
<dd><p>Unicode UTF-16</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="UTF_32"></a><span class="ddoc_psymbol">UTF_32</span></dt>
|
<dt class="d_decl"><a name="Encoding.UTF_32"></a><a name="UTF_32"></a><span class="ddoc_psymbol">UTF_32</span></dt>
|
||||||
<dd><p>Unicode UTF-32</p>
|
<dd><p>Unicode UTF-32</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
|
|
|
@ -42,27 +42,27 @@
|
||||||
<!-- Generated by Ddoc from dyaml/exception.d -->
|
<!-- Generated by Ddoc from dyaml/exception.d -->
|
||||||
<p>Exceptions thrown by D:YAML and exception related code.</p>
|
<p>Exceptions thrown by D:YAML and exception related code.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">class <a name="YAMLException"></a><span class="ddoc_psymbol">YAMLException</span>: object.Exception;
|
<dl><dt class="d_decl"><a name="YAMLException"></a>class <a name="YAMLException"></a><span class="ddoc_psymbol">YAMLException</span>: object.Exception;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Base class for all exceptions thrown by D:YAML.</p>
|
<dd><p>Base class for all exceptions thrown by D:YAML.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(string <b>msg</b>, string <b>file</b> = __FILE__, int <b>line</b> = __LINE__);
|
<dl><dt class="d_decl"><a name="YAMLException.this"></a>pure nothrow @trusted this(string <b>msg</b>, string <b>file</b> = __FILE__, int <b>line</b> = __LINE__);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a YAMLException with specified message and position where it was thrown.</p>
|
<dd><p>Construct a YAMLException with specified message and position where it was thrown.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">struct <a name="Mark"></a><span class="ddoc_psymbol">Mark</span>;
|
<dt class="d_decl"><a name="Mark"></a>struct <a name="Mark"></a><span class="ddoc_psymbol">Mark</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Position in a YAML stream, used for error messages.</p>
|
<dd><p>Position in a YAML stream, used for error messages.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(const(uint) <b>line</b>, const(uint) <b>column</b>);
|
<dl><dt class="d_decl"><a name="Mark.this"></a>pure nothrow @safe this(const uint <b>line</b>, const uint <b>column</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Mark with specified <b>line</b> and <b>column</b> in the file.</p>
|
<dd><p>Construct a Mark with specified <b>line</b> and <b>column</b> in the file.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const string <a name="toString"></a><span class="ddoc_psymbol">toString</span>();
|
<dt class="d_decl"><a name="Mark.toString"></a>const pure @trusted string <a name="toString"></a><span class="ddoc_psymbol">toString</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Get a string representation of the mark.</p>
|
<dd><p>Get a string representation of the mark.</p>
|
||||||
|
|
||||||
|
|
|
@ -41,19 +41,19 @@
|
||||||
<h1>dyaml.linebreak</h1>
|
<h1>dyaml.linebreak</h1>
|
||||||
<!-- Generated by Ddoc from dyaml/linebreak.d -->
|
<!-- Generated by Ddoc from dyaml/linebreak.d -->
|
||||||
<br>
|
<br>
|
||||||
<dl><dt class="d_decl">enum <a name="LineBreak"></a><span class="ddoc_psymbol">LineBreak</span>;
|
<dl><dt class="d_decl"><a name="LineBreak"></a>enum <a name="LineBreak"></a><span class="ddoc_psymbol">LineBreak</span>: int;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Enumerates platform specific line breaks.</p>
|
<dd><p>Enumerates platform specific line breaks.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl"><a name="Unix"></a><span class="ddoc_psymbol">Unix</span></dt>
|
<dl><dt class="d_decl"><a name="LineBreak.Unix"></a><a name="Unix"></a><span class="ddoc_psymbol">Unix</span></dt>
|
||||||
<dd><p><a name="Unix"></a><span class="ddoc_psymbol">Unix</span> line break ("\n").</p>
|
<dd><p><a name="Unix"></a><span class="ddoc_psymbol">Unix</span> line break ("\n").</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="Windows"></a><span class="ddoc_psymbol">Windows</span></dt>
|
<dt class="d_decl"><a name="LineBreak.Windows"></a><a name="Windows"></a><span class="ddoc_psymbol">Windows</span></dt>
|
||||||
<dd><p><a name="Windows"></a><span class="ddoc_psymbol">Windows</span> line break ("\r\n").</p>
|
<dd><p><a name="Windows"></a><span class="ddoc_psymbol">Windows</span> line break ("\r\n").</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="Macintosh"></a><span class="ddoc_psymbol">Macintosh</span></dt>
|
<dt class="d_decl"><a name="LineBreak.Macintosh"></a><a name="Macintosh"></a><span class="ddoc_psymbol">Macintosh</span></dt>
|
||||||
<dd><p><a name="Macintosh"></a><span class="ddoc_psymbol">Macintosh</span> line break ("\r").</p>
|
<dd><p><a name="Macintosh"></a><span class="ddoc_psymbol">Macintosh</span> line break ("\r").</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<!-- Generated by Ddoc from dyaml/loader.d -->
|
<!-- Generated by Ddoc from dyaml/loader.d -->
|
||||||
<p>Class used to load YAML documents.</p>
|
<p>Class used to load YAML documents.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">struct <a name="Loader"></a><span class="ddoc_psymbol">Loader</span>;
|
<dl><dt class="d_decl"><a name="Loader"></a>struct <a name="Loader"></a><span class="ddoc_psymbol">Loader</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Loads YAML documents from files or streams.
|
<dd><p>Loads YAML documents from files or streams.
|
||||||
</p>
|
</p>
|
||||||
|
@ -51,54 +51,58 @@
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Examples:</b><div class="pbr">Load single YAML document from a file:
|
<b>Examples:</b><div class="pbr">Load single YAML document from a file:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> rootNode = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>).load();
|
<pre class="d_code"><span class="d_keyword">auto</span> rootNode = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>).load();
|
||||||
...
|
...
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Load all YAML documents from a file:
|
Load all YAML documents from a file:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> nodes = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>).loadAll();
|
<pre class="d_code"><span class="d_keyword">auto</span> nodes = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>).loadAll();
|
||||||
...
|
...
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Iterate over YAML documents in a file, lazily loading them:
|
Iterate over YAML documents in a file, lazily loading them:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> loader = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>);
|
<pre class="d_code"><span class="d_keyword">auto</span> loader = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>);
|
||||||
|
|
||||||
<span class="d_keyword">foreach</span>(<span class="d_keyword">ref</span> node; loader)
|
<span class="d_keyword">foreach</span>(<span class="d_keyword">ref</span> node; loader)
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Load YAML from memory:
|
Load YAML from memory:
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.stream;
|
<pre class="d_code"><span class="d_keyword">import</span> std.stream;
|
||||||
<span class="d_keyword">import</span> std.stdio;
|
<span class="d_keyword">import</span> std.stdio;
|
||||||
|
|
||||||
string yaml_input = <span class="d_string">"red: '#ff0000'\n"</span>
|
string yaml_input = <span class="d_string">"red: '#ff0000'\n"</span>
|
||||||
<span class="d_string">"green: '#00ff00'\n"</span>
|
<span class="d_string">"green: '#00ff00'\n"</span>
|
||||||
<span class="d_string">"blue: '#0000ff'"</span>;
|
<span class="d_string">"blue: '#0000ff'"</span>;
|
||||||
|
|
||||||
<span class="d_keyword">auto</span> colors = <span class="d_psymbol">Loader</span>(<span class="d_keyword">new</span> MemoryStream(<span class="d_keyword">cast</span>(<span class="d_keyword">char</span>[])yaml_input)).load();
|
<span class="d_keyword">auto</span> colors = <span class="d_psymbol">Loader</span>.fromString(yaml_input).load();
|
||||||
|
|
||||||
<span class="d_keyword">foreach</span>(string color, string value; colors)
|
<span class="d_keyword">foreach</span>(string color, string value; colors)
|
||||||
{
|
{
|
||||||
writeln(color, <span class="d_string">" is "</span>, value, <span class="d_string">" in HTML/CSS"</span>);
|
writeln(color, <span class="d_string">" is "</span>, value, <span class="d_string">" in HTML/CSS"</span>);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Use a custom constructor/resolver to support custom data types and/or implicit tags:
|
Use a custom constructor/resolver to support custom data types and/or implicit tags:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor();
|
<pre class="d_code"><span class="d_keyword">auto</span> constructor = <span class="d_keyword">new</span> Constructor();
|
||||||
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
|
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
|
||||||
|
|
||||||
<span class="d_comment">//Add constructor functions / resolver expressions here...
|
<span class="d_comment">//Add constructor functions / resolver expressions here...
|
||||||
</span>
|
</span>
|
||||||
<span class="d_keyword">auto</span> loader = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>);
|
<span class="d_keyword">auto</span> loader = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>);
|
||||||
loader.constructor = constructor;
|
loader.constructor = constructor;
|
||||||
loader.resolver = resolver;
|
loader.resolver = resolver;
|
||||||
<span class="d_keyword">auto</span> rootNode = loader.load(node);
|
<span class="d_keyword">auto</span> rootNode = loader.load(node);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(string <b>filename</b>);
|
<dl><dt class="d_decl"><a name="Loader.this"></a>@trusted this(string <b>filename</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Loader to load YAML from a file.
|
<dd><p>Construct a Loader to load YAML from a file.
|
||||||
</p>
|
</p>
|
||||||
|
@ -108,7 +112,17 @@
|
||||||
<b>Throws:</b><div class="pbr">YAMLException if the file could not be opened or read.</div>
|
<b>Throws:</b><div class="pbr">YAMLException if the file could not be opened or read.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">this(Stream <b>stream</b>);
|
<dt class="d_decl"><a name="Loader.fromString"></a>static Loader <a name="fromString"></a><span class="ddoc_psymbol">fromString</span>(string <b>data</b>);
|
||||||
|
</dt>
|
||||||
|
<dd><p>Construct a Loader to load YAML from a string.
|
||||||
|
</p>
|
||||||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>data</b></td>
|
||||||
|
<td valign=top>String to load YAML from.</td></tr>
|
||||||
|
</table></div>
|
||||||
|
<b>Returns:</b><div class="pbr">Loader loading YAML from given string.</div>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Loader.this"></a>@safe this(Stream <b>stream</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Loader to load YAML from a stream.
|
<dd><p>Construct a Loader to load YAML from a stream.
|
||||||
</p>
|
</p>
|
||||||
|
@ -118,22 +132,22 @@
|
||||||
<b>Throws:</b><div class="pbr">YAMLException if <b>stream</b> could not be read.</div>
|
<b>Throws:</b><div class="pbr">YAMLException if <b>stream</b> could not be read.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="name"></a><span class="ddoc_psymbol">name</span>(string <a name="name"></a><span class="ddoc_psymbol">name</span>);
|
<dt class="d_decl"><a name="Loader.name"></a>pure nothrow @property @safe void <a name="name"></a><span class="ddoc_psymbol">name</span>(string <a name="name"></a><span class="ddoc_psymbol">name</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set stream name. Used in debugging messages.</p>
|
<dd><p>Set stream name. Used in debugging messages.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>(Resolver <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>);
|
<dt class="d_decl"><a name="Loader.resolver"></a>pure nothrow @property @safe void <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>(Resolver <a name="resolver"></a><span class="ddoc_psymbol">resolver</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Specify custom Resolver to use.</p>
|
<dd><p>Specify custom Resolver to use.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="constructor"></a><span class="ddoc_psymbol">constructor</span>(Constructor <a name="constructor"></a><span class="ddoc_psymbol">constructor</span>);
|
<dt class="d_decl"><a name="Loader.constructor"></a>pure nothrow @property @safe void <a name="constructor"></a><span class="ddoc_psymbol">constructor</span>(Constructor <a name="constructor"></a><span class="ddoc_psymbol">constructor</span>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Specify custom Constructor to use.</p>
|
<dd><p>Specify custom Constructor to use.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="load"></a><span class="ddoc_psymbol">load</span>();
|
<dt class="d_decl"><a name="Loader.load"></a>@safe Node <a name="load"></a><span class="ddoc_psymbol">load</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Load single YAML document.
|
<dd><p>Load single YAML document.
|
||||||
</p>
|
</p>
|
||||||
|
@ -150,7 +164,7 @@
|
||||||
or on a YAML parsing error.</div>
|
or on a YAML parsing error.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node[] <a name="loadAll"></a><span class="ddoc_psymbol">loadAll</span>();
|
<dt class="d_decl"><a name="Loader.loadAll"></a>@safe Node[] <a name="loadAll"></a><span class="ddoc_psymbol">loadAll</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Load all YAML documents.
|
<dd><p>Load all YAML documents.
|
||||||
</p>
|
</p>
|
||||||
|
@ -169,7 +183,7 @@
|
||||||
<b>Throws:</b><div class="pbr">YAMLException on a parsing error.</div>
|
<b>Throws:</b><div class="pbr">YAMLException on a parsing error.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">int <a name="opApply"></a><span class="ddoc_psymbol">opApply</span>(int delegate(ref Node) <b>dg</b>);
|
<dt class="d_decl"><a name="Loader.opApply"></a>@trusted int <a name="opApply"></a><span class="ddoc_psymbol">opApply</span>(int delegate(ref Node) <b>dg</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Foreach over YAML documents.
|
<dd><p>Foreach over YAML documents.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -43,23 +43,23 @@
|
||||||
<p>Node of a YAML document. Used to read YAML data once it's loaded,
|
<p>Node of a YAML document. Used to read YAML data once it's loaded,
|
||||||
and to prepare data to emit.</p>
|
and to prepare data to emit.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">class <a name="NodeException"></a><span class="ddoc_psymbol">NodeException</span>: dyaml.exception.YAMLException;
|
<dl><dt class="d_decl"><a name="NodeException"></a>class <a name="NodeException"></a><span class="ddoc_psymbol">NodeException</span>: dyaml.exception.YAMLException;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Exception thrown at node related errors.</p>
|
<dd><p>Exception thrown at node related errors.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">struct <a name="YAMLNull"></a><span class="ddoc_psymbol">YAMLNull</span>;
|
<dt class="d_decl"><a name="YAMLNull"></a>struct <a name="YAMLNull"></a><span class="ddoc_psymbol">YAMLNull</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Null YAML type. Used in nodes with null values.</p>
|
<dd><p>Null YAML type. Used in nodes with null values.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">const string <a name="toString"></a><span class="ddoc_psymbol">toString</span>();
|
<dl><dt class="d_decl"><a name="YAMLNull.toString"></a>const pure nothrow @safe string <a name="toString"></a><span class="ddoc_psymbol">toString</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Used for string conversion.</p>
|
<dd><p>Used for string conversion.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">struct <a name="Node"></a><span class="ddoc_psymbol">Node</span>;
|
<dt class="d_decl"><a name="Node"></a>struct <a name="Node"></a><span class="ddoc_psymbol">Node</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>YAML node.
|
<dd><p>YAML node.
|
||||||
</p>
|
</p>
|
||||||
|
@ -67,39 +67,50 @@
|
||||||
sequence or mapping of nodes. You can get data from a <a name="Node"></a><span class="ddoc_psymbol">Node</span> directly or
|
sequence or mapping of nodes. You can get data from a <a name="Node"></a><span class="ddoc_psymbol">Node</span> directly or
|
||||||
iterate over it if it's a collection.</p>
|
iterate over it if it's a collection.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">struct <a name="Pair"></a><span class="ddoc_psymbol">Pair</span>;
|
<dl><dt class="d_decl"><a name="Node.Pair"></a>struct <a name="Pair"></a><span class="ddoc_psymbol">Pair</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Key-value pair of YAML nodes, used in mappings.</p>
|
<dd><p>Key-value pair of YAML nodes, used in mappings.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">Node <a name="key"></a><span class="ddoc_psymbol">key</span>;
|
<dl><dt class="d_decl"><a name="Node.Pair.key"></a>Node <a name="key"></a><span class="ddoc_psymbol">key</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Key node.</p>
|
<dd><p>Key node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="value"></a><span class="ddoc_psymbol">value</span>;
|
<dt class="d_decl"><a name="Node.Pair.value"></a>Node <a name="value"></a><span class="ddoc_psymbol">value</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Value node.</p>
|
<dd><p>Value node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">this(K, V)(K <b>key</b>, V <b>value</b>);
|
<dt class="d_decl"><a name="Node.Pair.this"></a>@safe this(K, V)(K <b>key</b>, V <b>value</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Pair from two values. Will be converted to Nodes if needed.</p>
|
<dd><p>Construct a Pair from two values. Will be converted to Nodes if needed.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const bool <a name="opEquals"></a><span class="ddoc_psymbol">opEquals</span>(ref const Pair <b>rhs</b>);
|
<dt class="d_decl"><a name="Node.Pair.opEquals"></a>const @safe bool <a name="opEquals"></a><span class="ddoc_psymbol">opEquals</span>(ref const Pair <b>rhs</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Equality test with another Pair.</p>
|
<dd><p>Equality test with another Pair.</p>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.Pair.opAssign"></a>nothrow @safe void <a name="opAssign"></a><span class="ddoc_psymbol">opAssign</span>(Pair <b>rhs</b>);
|
||||||
|
</dt>
|
||||||
|
<dd><p>Assignment (shallow copy) by value.</p>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.Pair.opAssign"></a>nothrow @safe void <a name="opAssign"></a><span class="ddoc_psymbol">opAssign</span>(ref Pair <b>rhs</b>);
|
||||||
|
</dt>
|
||||||
|
<dd><p>Assignment (shallow copy) by reference.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">this(T)(T <b>value</b>, in string <b>tag</b> = null);
|
<dt class="d_decl"><a name="Node.this"></a>@trusted this(T)(T <b>value</b>, const string <b>tag</b> = null) if (isSomeString!T || !isArray!T && !isAssociativeArray!T);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Node from a value.
|
<dd><p>Construct a Node from a value.
|
||||||
</p>
|
</p>
|
||||||
<p>Any type except of Node can be stored in a Node, but default YAML
|
<p>Any type except for Node can be stored in a Node, but default YAML
|
||||||
types (integers, floats, strings, timestamps, etc.) will be stored
|
types (integers, floats, strings, timestamps, etc.) will be stored
|
||||||
more efficiently.
|
more efficiently. To create a node representing a <b>null</b> value,
|
||||||
|
construct it from YAMLNull.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
@ -109,9 +120,9 @@
|
||||||
otherwise emitting will fail.
|
otherwise emitting will fail.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>value</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T value</td>
|
||||||
<td valign=top>Value to store in the node.</td></tr>
|
<td valign=top>Value to store in the node.</td></tr>
|
||||||
<tr><td valign=top>tag</td>
|
<tr><td valign=top>string tag</td>
|
||||||
<td valign=top>Overrides tag of the node when emitted, regardless
|
<td valign=top>Overrides tag of the node when emitted, regardless
|
||||||
of tag determined by Representer. Representer uses
|
of tag determined by Representer. Representer uses
|
||||||
this to determine YAML data type when a D data type
|
this to determine YAML data type when a D data type
|
||||||
|
@ -121,7 +132,7 @@
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">this(T)(T[] <b>array</b>, in string <b>tag</b> = null);
|
<dt class="d_decl"><a name="Node.this"></a>@safe this(T)(T[] <b>array</b>, const string <b>tag</b> = null) if (!isSomeString!(T[]));
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a node from an array.
|
<dd><p>Construct a node from an array.
|
||||||
</p>
|
</p>
|
||||||
|
@ -130,9 +141,9 @@
|
||||||
those nodes are stored.
|
those nodes are stored.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>array</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T[] array</td>
|
||||||
<td valign=top>Values to store in the node.</td></tr>
|
<td valign=top>Values to store in the node.</td></tr>
|
||||||
<tr><td valign=top>tag</td>
|
<tr><td valign=top>string tag</td>
|
||||||
<td valign=top>Overrides tag of the node when emitted, regardless
|
<td valign=top>Overrides tag of the node when emitted, regardless
|
||||||
of tag determined by Representer. Representer uses
|
of tag determined by Representer. Representer uses
|
||||||
this to determine YAML data type when a D data type
|
this to determine YAML data type when a D data type
|
||||||
|
@ -143,15 +154,15 @@
|
||||||
must be in full form, e.g. "tag:yaml.org,2002:set",
|
must be in full form, e.g. "tag:yaml.org,2002:set",
|
||||||
not a shortcut, like "!!set".</td></tr>
|
not a shortcut, like "!!set".</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Examples:</b><div class="pbr"><pre class="d_code"> <span class="d_comment">//Will be emitted as a sequence (default for arrays)
|
<b>Examples:</b><div class="pbr"><pre class="d_code"><span class="d_comment">//Will be emitted as a sequence (default for arrays)
|
||||||
</span> <span class="d_keyword">auto</span> seq = Node([1, 2, 3, 4, 5]);
|
</span><span class="d_keyword">auto</span> seq = Node([1, 2, 3, 4, 5]);
|
||||||
<span class="d_comment">//Will be emitted as a set (overriden tag)
|
<span class="d_comment">//Will be emitted as a set (overriden tag)
|
||||||
</span> <span class="d_keyword">auto</span> set = Node([1, 2, 3, 4, 5], <span class="d_string">"tag:yaml.org,2002:set"</span>);
|
</span><span class="d_keyword">auto</span> set = Node([1, 2, 3, 4, 5], <span class="d_string">"tag:yaml.org,2002:set"</span>);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">this(K, V)(V[K] <b>array</b>, in string <b>tag</b> = null);
|
<dt class="d_decl"><a name="Node.this"></a>@safe this(K, V)(V[K] <b>array</b>, const string <b>tag</b> = null);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a node from an associative array.
|
<dd><p>Construct a node from an associative array.
|
||||||
</p>
|
</p>
|
||||||
|
@ -159,9 +170,9 @@
|
||||||
Otherwise they are converted to nodes and then stored.
|
Otherwise they are converted to nodes and then stored.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>array</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>V[K] array</td>
|
||||||
<td valign=top>Values to store in the node.</td></tr>
|
<td valign=top>Values to store in the node.</td></tr>
|
||||||
<tr><td valign=top>tag</td>
|
<tr><td valign=top>string tag</td>
|
||||||
<td valign=top>Overrides tag of the node when emitted, regardless
|
<td valign=top>Overrides tag of the node when emitted, regardless
|
||||||
of tag determined by Representer. Representer uses
|
of tag determined by Representer. Representer uses
|
||||||
this to determine YAML data type when a D data type
|
this to determine YAML data type when a D data type
|
||||||
|
@ -173,17 +184,17 @@
|
||||||
in full form, e.g. "tag:yaml.org,2002:omap", not a
|
in full form, e.g. "tag:yaml.org,2002:omap", not a
|
||||||
shortcut, like "!!omap".</td></tr>
|
shortcut, like "!!omap".</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Examples:</b><div class="pbr"><pre class="d_code"> <span class="d_comment">//Will be emitted as an unordered mapping (default for mappings)
|
<b>Examples:</b><div class="pbr"><pre class="d_code"><span class="d_comment">//Will be emitted as an unordered mapping (default for mappings)
|
||||||
</span> <span class="d_keyword">auto</span> map = Node([1 : <span class="d_string">"a"</span>, 2 : <span class="d_string">"b"</span>]);
|
</span><span class="d_keyword">auto</span> map = Node([1 : <span class="d_string">"a"</span>, 2 : <span class="d_string">"b"</span>]);
|
||||||
<span class="d_comment">//Will be emitted as an ordered map (overriden tag)
|
<span class="d_comment">//Will be emitted as an ordered map (overriden tag)
|
||||||
</span> <span class="d_keyword">auto</span> omap = Node([1 : <span class="d_string">"a"</span>, 2 : <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:omap"</span>);
|
</span><span class="d_keyword">auto</span> omap = Node([1 : <span class="d_string">"a"</span>, 2 : <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:omap"</span>);
|
||||||
<span class="d_comment">//Will be emitted as pairs (overriden tag)
|
<span class="d_comment">//Will be emitted as pairs (overriden tag)
|
||||||
</span> <span class="d_keyword">auto</span> pairs = Node([1 : <span class="d_string">"a"</span>, 2 : <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:pairs"</span>);
|
</span><span class="d_keyword">auto</span> pairs = Node([1 : <span class="d_string">"a"</span>, 2 : <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:pairs"</span>);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">this(K, V)(K[] <b>keys</b>, V[] <b>values</b>, in string <b>tag</b> = null);
|
<dt class="d_decl"><a name="Node.this"></a>@safe this(K, V)(K[] <b>keys</b>, V[] <b>values</b>, const string <b>tag</b> = null) if (!(isSomeString!(K[]) || isSomeString!(V[])));
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a node from arrays of keys and values.
|
<dd><p>Construct a node from arrays of keys and values.
|
||||||
</p>
|
</p>
|
||||||
|
@ -203,11 +214,11 @@
|
||||||
Otherwise they are converted to nodes and then stored.
|
Otherwise they are converted to nodes and then stored.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>keys</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>K[] keys</td>
|
||||||
<td valign=top>Keys of the mapping, from first to last pair.</td></tr>
|
<td valign=top>Keys of the mapping, from first to last pair.</td></tr>
|
||||||
<tr><td valign=top>values</td>
|
<tr><td valign=top>V[] values</td>
|
||||||
<td valign=top>Values of the mapping, from first to last pair.</td></tr>
|
<td valign=top>Values of the mapping, from first to last pair.</td></tr>
|
||||||
<tr><td valign=top>tag</td>
|
<tr><td valign=top>string tag</td>
|
||||||
<td valign=top>Overrides tag of the node when emitted, regardless
|
<td valign=top>Overrides tag of the node when emitted, regardless
|
||||||
of tag determined by Representer. Representer uses
|
of tag determined by Representer. Representer uses
|
||||||
this to determine YAML data type when a D data type
|
this to determine YAML data type when a D data type
|
||||||
|
@ -219,47 +230,52 @@
|
||||||
in full form, e.g. "tag:yaml.org,2002:omap", not a
|
in full form, e.g. "tag:yaml.org,2002:omap", not a
|
||||||
shortcut, like "!!omap".</td></tr>
|
shortcut, like "!!omap".</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Examples:</b><div class="pbr"><pre class="d_code"> <span class="d_comment">//Will be emitted as an unordered mapping (default for mappings)
|
<b>Examples:</b><div class="pbr"><pre class="d_code"><span class="d_comment">//Will be emitted as an unordered mapping (default for mappings)
|
||||||
</span> <span class="d_keyword">auto</span> map = Node([1, 2], [<span class="d_string">"a"</span>, <span class="d_string">"b"</span>]);
|
</span><span class="d_keyword">auto</span> map = Node([1, 2], [<span class="d_string">"a"</span>, <span class="d_string">"b"</span>]);
|
||||||
<span class="d_comment">//Will be emitted as an ordered map (overriden tag)
|
<span class="d_comment">//Will be emitted as an ordered map (overriden tag)
|
||||||
</span> <span class="d_keyword">auto</span> omap = Node([1, 2], [<span class="d_string">"a"</span>, <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:omap"</span>);
|
</span><span class="d_keyword">auto</span> omap = Node([1, 2], [<span class="d_string">"a"</span>, <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:omap"</span>);
|
||||||
<span class="d_comment">//Will be emitted as pairs (overriden tag)
|
<span class="d_comment">//Will be emitted as pairs (overriden tag)
|
||||||
</span> <span class="d_keyword">auto</span> pairs = Node([1, 2], [<span class="d_string">"a"</span>, <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:pairs"</span>);
|
</span><span class="d_keyword">auto</span> pairs = Node([1, 2], [<span class="d_string">"a"</span>, <span class="d_string">"b"</span>], <span class="d_string">"tag:yaml.org,2002:pairs"</span>);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const @property bool <a name="isValid"></a><span class="ddoc_psymbol">isValid</span>();
|
<dt class="d_decl"><a name="Node.isValid"></a>const pure nothrow @property @safe bool <a name="isValid"></a><span class="ddoc_psymbol">isValid</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Is this node valid (initialized)? </p>
|
<dd><p>Is this node valid (initialized)? </p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const @property bool <a name="isScalar"></a><span class="ddoc_psymbol">isScalar</span>();
|
<dt class="d_decl"><a name="Node.isScalar"></a>const nothrow @property @safe bool <a name="isScalar"></a><span class="ddoc_psymbol">isScalar</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Is this node a scalar value?</p>
|
<dd><p>Is this node a scalar value?</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const @property bool <a name="isSequence"></a><span class="ddoc_psymbol">isSequence</span>();
|
<dt class="d_decl"><a name="Node.isSequence"></a>const nothrow @property @safe bool <a name="isSequence"></a><span class="ddoc_psymbol">isSequence</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Is this node a sequence?</p>
|
<dd><p>Is this node a sequence?</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const @property bool <a name="isMapping"></a><span class="ddoc_psymbol">isMapping</span>();
|
<dt class="d_decl"><a name="Node.isMapping"></a>const nothrow @property @safe bool <a name="isMapping"></a><span class="ddoc_psymbol">isMapping</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Is this node a mapping?</p>
|
<dd><p>Is this node a mapping?</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const @property bool <a name="isUserType"></a><span class="ddoc_psymbol">isUserType</span>();
|
<dt class="d_decl"><a name="Node.isUserType"></a>const nothrow @property @safe bool <a name="isUserType"></a><span class="ddoc_psymbol">isUserType</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Is this node a user defined type?</p>
|
<dd><p>Is this node a user defined type?</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const @property string <a name="tag"></a><span class="ddoc_psymbol">tag</span>();
|
<dt class="d_decl"><a name="Node.isNull"></a>const nothrow @property @safe bool <a name="isNull"></a><span class="ddoc_psymbol">isNull</span>();
|
||||||
|
</dt>
|
||||||
|
<dd><p>Is this node <b>null</b>?</p>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.tag"></a>const nothrow @property @safe string <a name="tag"></a><span class="ddoc_psymbol">tag</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Return <a name="tag"></a><span class="ddoc_psymbol">tag</span> of the node.</p>
|
<dd><p>Return <a name="tag"></a><span class="ddoc_psymbol">tag</span> of the node.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const bool <a name="opEquals"></a><span class="ddoc_psymbol">opEquals</span>(T)(ref const T <b>rhs</b>);
|
<dt class="d_decl"><a name="Node.opEquals"></a>const @safe bool <a name="opEquals"></a><span class="ddoc_psymbol">opEquals</span>(T)(auto ref const T <b>rhs</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Equality test.
|
<dd><p>Equality test.
|
||||||
</p>
|
</p>
|
||||||
|
@ -267,34 +283,40 @@
|
||||||
This might be quite expensive if testing entire documents.
|
This might be quite expensive if testing entire documents.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
If T is not Node, convert the node to T and test equality with that.
|
If T is not Node, get a value if type T from the node and test
|
||||||
|
equality with that.
|
||||||
|
<br>
|
||||||
|
|
||||||
|
To test equality with a <b>null</b> YAML value, use YAMLNull.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Examples:</b><div class="pbr"><pre class="d_code"> <span class="d_keyword">auto</span> node = Node(42);
|
<b>Examples:</b><div class="pbr"><pre class="d_code"><span class="d_keyword">auto</span> node = Node(42);
|
||||||
|
|
||||||
<span class="d_keyword">assert</span>(node == 42);
|
<span class="d_keyword">assert</span>(node == 42);
|
||||||
<span class="d_keyword">assert</span>(node == <span class="d_string">"42"</span>);
|
<span class="d_keyword">assert</span>(node != <span class="d_string">"42"</span>);
|
||||||
<span class="d_keyword">assert</span>(node != <span class="d_string">"43"</span>);
|
<span class="d_keyword">assert</span>(node != <span class="d_string">"43"</span>);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>rhs</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T rhs</td>
|
||||||
<td valign=top>Variable to test equality with.</td></tr>
|
<td valign=top>Variable to test equality with.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Returns:</b><div class="pbr"><b>true</b> if equal, <b>false</b> otherwise.</div>
|
<b>Returns:</b><div class="pbr"><b>true</b> if equal, <b>false</b> otherwise.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">alias <a name="as"></a><span class="ddoc_psymbol">as</span>;
|
<dt class="d_decl"><a name="Node.as"></a>alias <a name="as"></a><span class="ddoc_psymbol">as</span> = get(T, Flag stringConversion = Yes.stringConversion)() if (!is(T == const));
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Shortcut for get().</p>
|
<dd><p>Shortcut for get().</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">T <a name="get"></a><span class="ddoc_psymbol">get</span>(T)();
|
<dt class="d_decl"><a name="Node.get"></a>@trusted T <a name="get"></a><span class="ddoc_psymbol">get</span>(T, Flag!"stringConversion" stringConversion = Yes.stringConversion)() if (!is(T == const));
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Get the value of the node as specified type.
|
<dd><p>Get the value of the node as specified type.
|
||||||
</p>
|
</p>
|
||||||
<p>If the specifed type does not match type in the node,
|
<p>If the specifed type does not match type in the node,
|
||||||
conversion is attempted.
|
conversion is attempted. The stringConversion template
|
||||||
|
parameter can be used to disable conversion from non-string
|
||||||
|
types to strings.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
Numeric values are range checked, throwing if out of range of
|
Numeric values are range checked, throwing if out of range of
|
||||||
|
@ -305,6 +327,10 @@
|
||||||
Binary values are decoded and stored as ubyte[].
|
Binary values are decoded and stored as ubyte[].
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
To <a name="get"></a><span class="ddoc_psymbol">get</span> a <b>null</b> value, use <a name="get"></a><span class="ddoc_psymbol">get</span>!YAMLNull . This is to
|
||||||
|
prevent getting <b>null</b> values for types such as strings or classes.
|
||||||
|
<br>
|
||||||
|
|
||||||
<br><b>Mapping default values:</b>
|
<br><b>Mapping default values:</b>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
@ -318,11 +344,11 @@
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Examples:</b><div class="pbr">Automatic type conversion:
|
<b>Examples:</b><div class="pbr">Automatic type conversion:
|
||||||
<pre class="d_code"> <span class="d_keyword">auto</span> node = Node(42);
|
<pre class="d_code"><span class="d_keyword">auto</span> node = Node(42);
|
||||||
|
|
||||||
<span class="d_keyword">assert</span>(node.as!<span class="d_keyword">int</span> == 42);
|
<span class="d_keyword">assert</span>(node.as!<span class="d_keyword">int</span> == 42);
|
||||||
<span class="d_keyword">assert</span>(node.as!string == <span class="d_string">"42"</span>);
|
<span class="d_keyword">assert</span>(node.as!string == <span class="d_string">"42"</span>);
|
||||||
<span class="d_keyword">assert</span>(node.as!<span class="d_keyword">double</span> == 42.0);
|
<span class="d_keyword">assert</span>(node.as!<span class="d_keyword">double</span> == 42.0);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -333,7 +359,12 @@
|
||||||
the value is out of range of requested type.</div>
|
the value is out of range of requested type.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const @property size_t <a name="length"></a><span class="ddoc_psymbol">length</span>();
|
<dt class="d_decl"><a name="Node.get"></a>const @trusted T <a name="get"></a><span class="ddoc_psymbol">get</span>(T, Flag!"stringConversion" stringConversion = Yes.stringConversion)() if (is(T == const));
|
||||||
|
</dt>
|
||||||
|
<dd><p>Ditto.</p>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.length"></a>const @property @safe size_t <a name="length"></a><span class="ddoc_psymbol">length</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>If this is a collection, return its length.
|
<dd><p>If this is a collection, return its length.
|
||||||
</p>
|
</p>
|
||||||
|
@ -346,7 +377,7 @@
|
||||||
<b>Throws:</b><div class="pbr">NodeException if this is not a sequence nor a mapping.</div>
|
<b>Throws:</b><div class="pbr">NodeException if this is not a sequence nor a mapping.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="opIndex"></a><span class="ddoc_psymbol">opIndex</span>(T)(T <b>index</b>);
|
<dt class="d_decl"><a name="Node.opIndex"></a>@trusted Node <a name="opIndex"></a><span class="ddoc_psymbol">opIndex</span>(T)(T <b>index</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Get the element at specified index.
|
<dd><p>Get the element at specified index.
|
||||||
</p>
|
</p>
|
||||||
|
@ -356,11 +387,13 @@
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
If the node is a mapping, return the value corresponding to the first
|
If the node is a mapping, return the value corresponding to the first
|
||||||
key equal to index, even after conversion. I.e; node["12"] will
|
key equal to index.
|
||||||
return value of the first key that equals "12", even if it's an integer.
|
<br>
|
||||||
|
|
||||||
|
To get element at a <b>null</b> index, use YAMLNull for index.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>index</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T index</td>
|
||||||
<td valign=top>Index to use.</td></tr>
|
<td valign=top>Index to use.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Returns:</b><div class="pbr">Value corresponding to the index.
|
<b>Returns:</b><div class="pbr">Value corresponding to the index.
|
||||||
|
@ -371,7 +404,57 @@
|
||||||
not a collection.</div>
|
not a collection.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="opIndexAssign"></a><span class="ddoc_psymbol">opIndexAssign</span>(K, V)(V <b>value</b>, K <b>index</b>);
|
<dt class="d_decl"><a name="Node.contains"></a>const @safe bool <a name="contains"></a><span class="ddoc_psymbol">contains</span>(T)(T <b>rhs</b>);
|
||||||
|
</dt>
|
||||||
|
<dd><p>Determine if a collection <a name="contains"></a><span class="ddoc_psymbol">contains</span> specified value.
|
||||||
|
</p>
|
||||||
|
<p>If the node is a sequence, check if it <a name="contains"></a><span class="ddoc_psymbol">contains</span> the specified value.
|
||||||
|
If it's a mapping, check if it has a value that matches specified value.
|
||||||
|
<br>
|
||||||
|
|
||||||
|
To check for a <b>null</b> value, use YAMLNull for rhs.
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T rhs</td>
|
||||||
|
<td valign=top>Item to look for.</td></tr>
|
||||||
|
</table></div>
|
||||||
|
<b>Returns:</b><div class="pbr"><b>true</b> if rhs was found, <b>false</b> otherwise.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection.</div>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.containsKey"></a>const @safe bool <a name="containsKey"></a><span class="ddoc_psymbol">containsKey</span>(T)(T <b>rhs</b>);
|
||||||
|
</dt>
|
||||||
|
<dd><p>Determine if a collection contains specified key.
|
||||||
|
</p>
|
||||||
|
<p>If the node is a mapping, check if it has a key
|
||||||
|
that matches specified key.
|
||||||
|
<br>
|
||||||
|
|
||||||
|
To check for a <b>null</b> key, use YAMLNull for rhs.
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T rhs</td>
|
||||||
|
<td valign=top>Item to look for.</td></tr>
|
||||||
|
</table></div>
|
||||||
|
<b>Returns:</b><div class="pbr"><b>true</b> if rhs was found, <b>false</b> otherwise.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<b>Throws:</b><div class="pbr">NodeException if the node is not a mapping.</div>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.opAssign"></a>nothrow @safe void <a name="opAssign"></a><span class="ddoc_psymbol">opAssign</span>(Node <b>rhs</b>);
|
||||||
|
</dt>
|
||||||
|
<dd><p>Assignment (shallow copy) by value.</p>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.opAssign"></a>nothrow @trusted void <a name="opAssign"></a><span class="ddoc_psymbol">opAssign</span>(ref Node <b>rhs</b>);
|
||||||
|
</dt>
|
||||||
|
<dd><p>Assignment (shallow copy) by reference.</p>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.opIndexAssign"></a>@safe void <a name="opIndexAssign"></a><span class="ddoc_psymbol">opIndexAssign</span>(K, V)(V <b>value</b>, K <b>index</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set element at specified index in a collection.
|
<dd><p>Set element at specified index in a collection.
|
||||||
</p>
|
</p>
|
||||||
|
@ -389,16 +472,19 @@
|
||||||
pair is added to the mapping. In sequences the index must be in
|
pair is added to the mapping. In sequences the index must be in
|
||||||
range. This ensures behavior siilar to D arrays and associative
|
range. This ensures behavior siilar to D arrays and associative
|
||||||
arrays.
|
arrays.
|
||||||
|
<br>
|
||||||
|
|
||||||
|
To set element at a <b>null</b> index, use YAMLNull for index.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>index</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>K index</td>
|
||||||
<td valign=top>Index of the value to set.</td></tr>
|
<td valign=top>Index of the value to set.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection, index is out
|
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection, index is out
|
||||||
of range or if a non-integral index is used on a sequence node.</div>
|
of range or if a non-integral index is used on a sequence node.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">int <a name="opApply"></a><span class="ddoc_psymbol">opApply</span>(T)(int delegate(ref T) <b>dg</b>);
|
<dt class="d_decl"><a name="Node.opApply"></a>@trusted int <a name="opApply"></a><span class="ddoc_psymbol">opApply</span>(T)(int delegate(ref T) <b>dg</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Foreach over a sequence, getting each element as T.
|
<dd><p>Foreach over a sequence, getting each element as T.
|
||||||
</p>
|
</p>
|
||||||
|
@ -410,7 +496,7 @@
|
||||||
element could not be converted to specified type.</div>
|
element could not be converted to specified type.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">int <a name="opApply"></a><span class="ddoc_psymbol">opApply</span>(K, V)(int delegate(ref K, ref V) <b>dg</b>);
|
<dt class="d_decl"><a name="Node.opApply"></a>@trusted int <a name="opApply"></a><span class="ddoc_psymbol">opApply</span>(K, V)(int delegate(ref K, ref V) <b>dg</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Foreach over a mapping, getting each key/value as K/V.
|
<dd><p>Foreach over a mapping, getting each key/value as K/V.
|
||||||
</p>
|
</p>
|
||||||
|
@ -422,7 +508,7 @@
|
||||||
element could not be converted to specified type.</div>
|
element could not be converted to specified type.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="add"></a><span class="ddoc_psymbol">add</span>(T)(T <b>value</b>);
|
<dt class="d_decl"><a name="Node.add"></a>@safe void <a name="add"></a><span class="ddoc_psymbol">add</span>(T)(T <b>value</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Add an element to a sequence.
|
<dd><p>Add an element to a sequence.
|
||||||
</p>
|
</p>
|
||||||
|
@ -439,12 +525,12 @@
|
||||||
emitted.</p>
|
emitted.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>value</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T value</td>
|
||||||
<td valign=top>Value to add to the sequence.</td></tr>
|
<td valign=top>Value to add to the sequence.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="add"></a><span class="ddoc_psymbol">add</span>(K, V)(K <b>key</b>, V <b>value</b>);
|
<dt class="d_decl"><a name="Node.add"></a>@safe void <a name="add"></a><span class="ddoc_psymbol">add</span>(K, V)(K <b>key</b>, V <b>value</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Add a key-value pair to a mapping.
|
<dd><p>Add a key-value pair to a mapping.
|
||||||
</p>
|
</p>
|
||||||
|
@ -461,33 +547,54 @@
|
||||||
<b>invalid</b> YAML with "!!map" and "!!omap" tags.</p>
|
<b>invalid</b> YAML with "!!map" and "!!omap" tags.</p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>key</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>K key</td>
|
||||||
<td valign=top>Key to add.</td></tr>
|
<td valign=top>Key to add.</td></tr>
|
||||||
<tr><td valign=top>value</td>
|
<tr><td valign=top>V value</td>
|
||||||
<td valign=top>Value to add.</td></tr>
|
<td valign=top>Value to add.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="remove"></a><span class="ddoc_psymbol">remove</span>(T)(T <b>value</b>);
|
<dt class="d_decl"><a name="Node.opBinaryRight"></a>@trusted Node* <a name="opBinaryRight"></a><span class="ddoc_psymbol">opBinaryRight</span>(string op, K)(K <b>key</b>) if (op == "in");
|
||||||
|
</dt>
|
||||||
|
<dd><p>Determine whether a key is in a mapping, and access its value.
|
||||||
|
</p>
|
||||||
|
<p>This method can only be called on mapping nodes.
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>K key</td>
|
||||||
|
<td valign=top>Key to search for.</td></tr>
|
||||||
|
</table></div>
|
||||||
|
<b>Returns:</b><div class="pbr">A pointer to the value (as a Node) corresponding to key,
|
||||||
|
or <b>null</b> if not found.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p><b>Note:</b><br>
|
||||||
|
Any modification to the node can invalidate the returned
|
||||||
|
pointer.
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<b>See Also:</b><div class="pbr">contains</div>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt class="d_decl"><a name="Node.remove"></a>@trusted void <a name="remove"></a><span class="ddoc_psymbol">remove</span>(T)(T <b>rhs</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Remove first (if any) occurence of a value in a collection.
|
<dd><p>Remove first (if any) occurence of a value in a collection.
|
||||||
</p>
|
</p>
|
||||||
<p>This method can only be called on collection nodes.
|
<p>This method can only be called on collection nodes.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
If the node is a sequence, the first node matching value (including
|
If the node is a sequence, the first node matching value is removed.
|
||||||
conversion, so e.g. "42" matches 42) is removed.
|
|
||||||
If the node is a mapping, the first key-value pair where value
|
If the node is a mapping, the first key-value pair where value
|
||||||
matches specified value is removed.
|
matches specified value is removed.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>value</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T rhs</td>
|
||||||
<td valign=top>Value to remove.</td></tr>
|
<td valign=top>Value to remove.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection.</div>
|
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="removeAt"></a><span class="ddoc_psymbol">removeAt</span>(T)(T <b>index</b>);
|
<dt class="d_decl"><a name="Node.removeAt"></a>@trusted void <a name="removeAt"></a><span class="ddoc_psymbol">removeAt</span>(T)(T <b>index</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Remove element at the specified index of a collection.
|
<dd><p>Remove element at the specified index of a collection.
|
||||||
</p>
|
</p>
|
||||||
|
@ -498,7 +605,7 @@
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
If the node is a mapping, remove the first key-value pair where
|
If the node is a mapping, remove the first key-value pair where
|
||||||
key matches index (including conversion, so e.g. "42" matches 42).
|
key matches index.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
If the node is a mapping and no key matches index, nothing is removed
|
If the node is a mapping and no key matches index, nothing is removed
|
||||||
|
@ -506,14 +613,14 @@
|
||||||
and associative arrays.
|
and associative arrays.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>index</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>T index</td>
|
||||||
<td valign=top>Index to remove at.</td></tr>
|
<td valign=top>Index to remove at.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection, index is out
|
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection, index is out
|
||||||
of range or if a non-integral index is used on a sequence node.</div>
|
of range or if a non-integral index is used on a sequence node.</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">const const int <a name="opCmp"></a><span class="ddoc_psymbol">opCmp</span>(ref const Node <b>node</b>);
|
<dt class="d_decl"><a name="Node.opCmp"></a>const @safe int <a name="opCmp"></a><span class="ddoc_psymbol">opCmp</span>(ref const Node <b>node</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Compare with another node.</p>
|
<dd><p>Compare with another node.</p>
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,12 @@
|
||||||
</p>
|
</p>
|
||||||
<p>Code based on <a href="http://www.pyyaml.org">PyYAML</a>.</p>
|
<p>Code based on <a href="http://www.pyyaml.org">PyYAML</a>.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">class <a name="RepresenterException"></a><span class="ddoc_psymbol">RepresenterException</span>: dyaml.exception.YAMLException;
|
<dl><dt class="d_decl"><a name="RepresenterException"></a>class <a name="RepresenterException"></a><span class="ddoc_psymbol">RepresenterException</span>: dyaml.exception.YAMLException;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Exception thrown on Representer errors.</p>
|
<dd><p>Exception thrown on Representer errors.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">class <a name="Representer"></a><span class="ddoc_psymbol">Representer</span>;
|
<dt class="d_decl"><a name="Representer"></a>class <a name="Representer"></a><span class="ddoc_psymbol">Representer</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represents YAML nodes as scalar, sequence and mapping nodes ready for output.
|
<dd><p>Represents YAML nodes as scalar, sequence and mapping nodes ready for output.
|
||||||
</p>
|
</p>
|
||||||
|
@ -59,11 +59,11 @@
|
||||||
|
|
||||||
It can also override default node formatting styles for output.</p>
|
It can also override default node formatting styles for output.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(bool <b>useDefaultRepresenters</b> = true);
|
<dl><dt class="d_decl"><a name="Representer.this"></a>pure @safe this(const Flag!"<b>useDefaultRepresenters</b>" <b>useDefaultRepresenters</b> = Yes.<b>useDefaultRepresenters</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Representer.
|
<dd><p>Construct a Representer.
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>bool <b>useDefaultRepresenters</b></td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>Flag!"<b>useDefaultRepresenters</b>" <b>useDefaultRepresenters</b></td>
|
||||||
<td valign=top>Use default representer functions
|
<td valign=top>Use default representer functions
|
||||||
for default YAML types? This can be
|
for default YAML types? This can be
|
||||||
disabled to use custom representer
|
disabled to use custom representer
|
||||||
|
@ -71,17 +71,17 @@
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="defaultScalarStyle"></a><span class="ddoc_psymbol">defaultScalarStyle</span>(ScalarStyle <b>style</b>);
|
<dt class="d_decl"><a name="Representer.defaultScalarStyle"></a>pure nothrow @property @safe void <a name="defaultScalarStyle"></a><span class="ddoc_psymbol">defaultScalarStyle</span>(ScalarStyle <b>style</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set default style for scalars. If <b>style</b> is <span class="d_inlinecode">ScalarStyle.Invalid</span>, the style is chosen automatically.</p>
|
<dd><p>Set default style for scalars. If <b>style</b> is <span class="d_inlinecode">ScalarStyle.Invalid</span>, the style is chosen automatically.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">@property void <a name="defaultCollectionStyle"></a><span class="ddoc_psymbol">defaultCollectionStyle</span>(CollectionStyle <b>style</b>);
|
<dt class="d_decl"><a name="Representer.defaultCollectionStyle"></a>pure nothrow @property @safe void <a name="defaultCollectionStyle"></a><span class="ddoc_psymbol">defaultCollectionStyle</span>(CollectionStyle <b>style</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Set default style for collections. If <b>style</b> is <span class="d_inlinecode">CollectionStyle.Invalid</span>, the style is chosen automatically. </p>
|
<dd><p>Set default style for collections. If <b>style</b> is <span class="d_inlinecode">CollectionStyle.Invalid</span>, the style is chosen automatically. </p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="addRepresenter"></a><span class="ddoc_psymbol">addRepresenter</span>(T)(Node function(ref Node, Representer) <b>representer</b>);
|
<dt class="d_decl"><a name="Representer.addRepresenter"></a>pure @trusted void <a name="addRepresenter"></a><span class="ddoc_psymbol">addRepresenter</span>(T)(Node function(ref Node, Representer) <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Add a function to represent nodes with a specific data type.
|
<dd><p>Add a function to represent nodes with a specific data type.
|
||||||
</p>
|
</p>
|
||||||
|
@ -107,108 +107,109 @@
|
||||||
values - it is not const for compatibility reasons.
|
values - it is not const for compatibility reasons.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>representer</td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>Node function(ref Node, Representer) representer</td>
|
||||||
<td valign=top>Representer function to add.</td></tr>
|
<td valign=top>Representer function to add.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Examples:</b><div class="pbr">Representing a simple struct:
|
<b>Examples:</b><div class="pbr">Representing a simple struct:
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.string;
|
<pre class="d_code"><span class="d_keyword">import</span> std.string;
|
||||||
|
|
||||||
<span class="d_keyword">import</span> yaml;
|
<span class="d_keyword">import</span> dyaml.all;
|
||||||
|
|
||||||
<span class="d_keyword">struct</span> MyStruct
|
<span class="d_keyword">struct</span> MyStruct
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
||||||
{
|
{
|
||||||
<span class="d_comment">//The node is guaranteed to be MyStruct as we add representer for MyStruct.
|
<span class="d_comment">//The node is guaranteed to be MyStruct as we add representer for MyStruct.
|
||||||
</span> <span class="d_keyword">auto</span> value = node.as!MyStruct;
|
</span> <span class="d_keyword">auto</span> value = node.as!MyStruct;
|
||||||
<span class="d_comment">//Using custom scalar format, x:y:z.
|
<span class="d_comment">//Using custom scalar format, x:y:z.
|
||||||
</span> <span class="d_keyword">auto</span> scalar = format(value.x, <span class="d_string">":"</span>, value.y, <span class="d_string">":"</span>, value.z);
|
</span> <span class="d_keyword">auto</span> scalar = format(<span class="d_string">"%s:%s:%s"</span>, value.x, value.y, value.z);
|
||||||
<span class="d_comment">//Representing as a scalar, with custom tag to specify this data type.
|
<span class="d_comment">//Representing as a scalar, with custom tag to specify this data type.
|
||||||
</span> <span class="d_keyword">return</span> representer.representScalar(<span class="d_string">"!mystruct.tag"</span>, scalar);
|
</span> <span class="d_keyword">return</span> representer.representScalar(<span class="d_string">"!mystruct.tag"</span>, scalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_keyword">void</span> main()
|
<span class="d_keyword">void</span> main()
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> dumper = Dumper(<span class="d_string">"file.yaml"</span>);
|
<span class="d_keyword">auto</span> dumper = Dumper(<span class="d_string">"file.yaml"</span>);
|
||||||
<span class="d_keyword">auto</span> representer = <span class="d_keyword">new</span> Representer;
|
<span class="d_keyword">auto</span> representer = <span class="d_keyword">new</span> Representer;
|
||||||
representer.<span class="d_psymbol">addRepresenter</span>!MyStruct(&representMyStruct);
|
representer.<span class="d_psymbol">addRepresenter</span>!MyStruct(&representMyStruct);
|
||||||
dumper.representer = representer;
|
dumper.representer = representer;
|
||||||
dumper.dump(Node(MyStruct(1,2,3)));
|
dumper.dump(Node(MyStruct(1,2,3)));
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
Representing a class:
|
Representing a class:
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.string;
|
<pre class="d_code"><span class="d_keyword">import</span> std.string;
|
||||||
|
|
||||||
<span class="d_keyword">import</span> yaml;
|
<span class="d_keyword">import</span> dyaml.all;
|
||||||
|
|
||||||
<span class="d_keyword">class</span> MyClass
|
<span class="d_keyword">class</span> MyClass
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_keyword">this</span>(<span class="d_keyword">int</span> x, <span class="d_keyword">int</span> y, <span class="d_keyword">int</span> z)
|
<span class="d_keyword">this</span>(<span class="d_keyword">int</span> x, <span class="d_keyword">int</span> y, <span class="d_keyword">int</span> z)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">this</span>.x = x;
|
<span class="d_keyword">this</span>.x = x;
|
||||||
<span class="d_keyword">this</span>.y = y;
|
<span class="d_keyword">this</span>.y = y;
|
||||||
<span class="d_keyword">this</span>.z = z;
|
<span class="d_keyword">this</span>.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">override</span> <span class="d_keyword">int</span> opCmp(Object o)
|
</span> <span class="d_keyword">override</span> <span class="d_keyword">int</span> opCmp(Object o)
|
||||||
{
|
{
|
||||||
MyClass s = <span class="d_keyword">cast</span>(MyClass)o;
|
MyClass s = <span class="d_keyword">cast</span>(MyClass)o;
|
||||||
<span class="d_keyword">if</span>(s <span class="d_keyword">is</span> <span class="d_keyword">null</span>){<span class="d_keyword">return</span> -1;}
|
<span class="d_keyword">if</span>(s <span class="d_keyword">is</span> <span class="d_keyword">null</span>){<span class="d_keyword">return</span> -1;}
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_comment">///Useful for Node.as!string .
|
<span class="d_comment">///Useful for Node.as!string .
|
||||||
</span> <span class="d_keyword">override</span> string toString()
|
</span> <span class="d_keyword">override</span> string toString()
|
||||||
{
|
{
|
||||||
<span class="d_keyword">return</span> format(<span class="d_string">"MyClass("), x, <span class="d_string">", "</span>, y, <span class="d_string">", "</span>, z, <span class="d_string">"</span>"</span>);
|
<span class="d_keyword">return</span> format(<span class="d_string">"MyClass(%s, %s, %s)"</span>, x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_comment">//Same as representMyStruct.
|
<span class="d_comment">//Same as representMyStruct.
|
||||||
</span> Node representMyClass(<span class="d_keyword">ref</span> Node node, Representer representer)
|
</span>Node representMyClass(<span class="d_keyword">ref</span> Node node, Representer representer)
|
||||||
{
|
{
|
||||||
<span class="d_comment">//The node is guaranteed to be MyClass as we add representer for MyClass.
|
<span class="d_comment">//The node is guaranteed to be MyClass as we add representer for MyClass.
|
||||||
</span> <span class="d_keyword">auto</span> value = node.as!MyClass;
|
</span> <span class="d_keyword">auto</span> value = node.as!MyClass;
|
||||||
<span class="d_comment">//Using custom scalar format, x:y:z.
|
<span class="d_comment">//Using custom scalar format, x:y:z.
|
||||||
</span> <span class="d_keyword">auto</span> scalar = format(value.x, <span class="d_string">":"</span>, value.y, <span class="d_string">":"</span>, value.z);
|
</span> <span class="d_keyword">auto</span> scalar = format(<span class="d_string">"%s:%s:%s"</span>, value.x, value.y, value.z);
|
||||||
<span class="d_comment">//Representing as a scalar, with custom tag to specify this data type.
|
<span class="d_comment">//Representing as a scalar, with custom tag to specify this data type.
|
||||||
</span> <span class="d_keyword">return</span> representer.representScalar(<span class="d_string">"!myclass.tag"</span>, scalar);
|
</span> <span class="d_keyword">return</span> representer.representScalar(<span class="d_string">"!myclass.tag"</span>, scalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="d_keyword">void</span> main()
|
<span class="d_keyword">void</span> main()
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> dumper = Dumper(<span class="d_string">"file.yaml"</span>);
|
<span class="d_keyword">auto</span> dumper = Dumper(<span class="d_string">"file.yaml"</span>);
|
||||||
<span class="d_keyword">auto</span> representer = <span class="d_keyword">new</span> Representer;
|
<span class="d_keyword">auto</span> representer = <span class="d_keyword">new</span> Representer;
|
||||||
representer.<span class="d_psymbol">addRepresenter</span>!MyClass(&representMyClass);
|
representer.<span class="d_psymbol">addRepresenter</span>!MyClass(&representMyClass);
|
||||||
dumper.representer = representer;
|
dumper.representer = representer;
|
||||||
dumper.dump(Node(<span class="d_keyword">new</span> MyClass(1,2,3)));
|
dumper.dump(Node(<span class="d_keyword">new</span> MyClass(1,2,3)));
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representScalar"></a><span class="ddoc_psymbol">representScalar</span>(string <b>tag</b>, string <b>scalar</b>, ScalarStyle <b>style</b> = (ScalarStyle).Invalid);
|
<dt class="d_decl"><a name="Representer.representScalar"></a>@safe Node <a name="representScalar"></a><span class="ddoc_psymbol">representScalar</span>(string <b>tag</b>, string <b>scalar</b>, ScalarStyle <b>style</b> = ScalarStyle.Invalid);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a scalar with specified tag.
|
<dd><p>Represent a scalar with specified tag.
|
||||||
</p>
|
</p>
|
||||||
|
@ -227,32 +228,32 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p><b>Example:</b><br>
|
<p><b>Example:</b><br>
|
||||||
<pre class="d_code"> <span class="d_keyword">struct</span> MyStruct
|
<pre class="d_code"><span class="d_keyword">struct</span> MyStruct
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> value = node.as!MyStruct;
|
<span class="d_keyword">auto</span> value = node.as!MyStruct;
|
||||||
<span class="d_keyword">auto</span> <span class="d_param">scalar</span> = format(value.x, <span class="d_string">":"</span>, value.y, <span class="d_string">":"</span>, value.z);
|
<span class="d_keyword">auto</span> <span class="d_param">scalar</span> = format(<span class="d_string">"%s:%s:%s"</span>, value.x, value.y, value.z);
|
||||||
<span class="d_keyword">return</span> representer.<span class="d_psymbol">representScalar</span>(<span class="d_string">"!mystruct.tag"</span>, <span class="d_param">scalar</span>);
|
<span class="d_keyword">return</span> representer.<span class="d_psymbol">representScalar</span>(<span class="d_string">"!mystruct.tag"</span>, <span class="d_param">scalar</span>);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representSequence"></a><span class="ddoc_psymbol">representSequence</span>(string <b>tag</b>, Node[] <b>sequence</b>, CollectionStyle <b>style</b> = (CollectionStyle).Invalid);
|
<dt class="d_decl"><a name="Representer.representSequence"></a>@trusted Node <a name="representSequence"></a><span class="ddoc_psymbol">representSequence</span>(string <b>tag</b>, Node[] <b>sequence</b>, CollectionStyle <b>style</b> = CollectionStyle.Invalid);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a sequence with specified tag, representing children first.
|
<dd><p>Represent a sequence with specified tag, representing children first.
|
||||||
</p>
|
</p>
|
||||||
|
@ -274,34 +275,34 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p><b>Example:</b><br>
|
<p><b>Example:</b><br>
|
||||||
<pre class="d_code"> <span class="d_keyword">struct</span> MyStruct
|
<pre class="d_code"><span class="d_keyword">struct</span> MyStruct
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> value = node.as!MyStruct;
|
<span class="d_keyword">auto</span> value = node.as!MyStruct;
|
||||||
<span class="d_keyword">auto</span> nodes = [Node(value.x), Node(value.y), Node(value.z)];
|
<span class="d_keyword">auto</span> nodes = [Node(value.x), Node(value.y), Node(value.z)];
|
||||||
<span class="d_comment">//use flow style
|
<span class="d_comment">//use flow style
|
||||||
</span> <span class="d_keyword">return</span> representer.<span class="d_psymbol">representSequence</span>(<span class="d_string">"!mystruct.tag"</span>, nodes,
|
</span> <span class="d_keyword">return</span> representer.<span class="d_psymbol">representSequence</span>(<span class="d_string">"!mystruct.tag"</span>, nodes,
|
||||||
CollectionStyle.Flow);
|
CollectionStyle.Flow);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representMapping"></a><span class="ddoc_psymbol">representMapping</span>(string <b>tag</b>, Pair[] <b>pairs</b>, CollectionStyle <b>style</b> = (CollectionStyle).Invalid);
|
<dt class="d_decl"><a name="Representer.representMapping"></a>@trusted Node <a name="representMapping"></a><span class="ddoc_psymbol">representMapping</span>(string <b>tag</b>, Node.Pair[] <b>pairs</b>, CollectionStyle <b>style</b> = CollectionStyle.Invalid);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a mapping with specified tag, representing children first.
|
<dd><p>Represent a mapping with specified tag, representing children first.
|
||||||
</p>
|
</p>
|
||||||
|
@ -310,7 +311,7 @@
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>tag</b></td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>tag</b></td>
|
||||||
<td valign=top>Tag of the mapping.</td></tr>
|
<td valign=top>Tag of the mapping.</td></tr>
|
||||||
<tr><td valign=top>Pair[] <b>pairs</b></td>
|
<tr><td valign=top>Node.Pair[] <b>pairs</b></td>
|
||||||
<td valign=top>Key-value pairs of the mapping.</td></tr>
|
<td valign=top>Key-value pairs of the mapping.</td></tr>
|
||||||
<tr><td valign=top>CollectionStyle <b>style</b></td>
|
<tr><td valign=top>CollectionStyle <b>style</b></td>
|
||||||
<td valign=top>Style of the mapping. If invalid, default style will be used.
|
<td valign=top>Style of the mapping. If invalid, default style will be used.
|
||||||
|
@ -323,76 +324,76 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p><b>Example:</b><br>
|
<p><b>Example:</b><br>
|
||||||
<pre class="d_code"> <span class="d_keyword">struct</span> MyStruct
|
<pre class="d_code"><span class="d_keyword">struct</span> MyStruct
|
||||||
{
|
{
|
||||||
<span class="d_keyword">int</span> x, y, z;
|
<span class="d_keyword">int</span> x, y, z;
|
||||||
|
|
||||||
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
<span class="d_comment">//Any D:YAML type must have a custom opCmp operator.
|
||||||
</span> <span class="d_comment">//This is used for ordering in mappings.
|
</span> <span class="d_comment">//This is used for ordering in mappings.
|
||||||
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
</span> <span class="d_keyword">const</span> <span class="d_keyword">int</span> opCmp(<span class="d_keyword">ref</span> <span class="d_keyword">const</span> MyStruct s)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
<span class="d_keyword">if</span>(x != s.x){<span class="d_keyword">return</span> x - s.x;}
|
||||||
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
<span class="d_keyword">if</span>(y != s.y){<span class="d_keyword">return</span> y - s.y;}
|
||||||
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
<span class="d_keyword">if</span>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
|
||||||
<span class="d_keyword">return</span> 0;
|
<span class="d_keyword">return</span> 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
Node representMyStruct(<span class="d_keyword">ref</span> Node node, Representer representer)
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> value = node.as!MyStruct;
|
<span class="d_keyword">auto</span> value = node.as!MyStruct;
|
||||||
<span class="d_keyword">auto</span> <span class="d_param">pairs</span> = [Node.Pair(<span class="d_string">"x"</span>, value.x),
|
<span class="d_keyword">auto</span> <span class="d_param">pairs</span> = [Node.Pair(<span class="d_string">"x"</span>, value.x),
|
||||||
Node.Pair(<span class="d_string">"y"</span>, value.y),
|
Node.Pair(<span class="d_string">"y"</span>, value.y),
|
||||||
Node.Pair(<span class="d_string">"z"</span>, value.z)];
|
Node.Pair(<span class="d_string">"z"</span>, value.z)];
|
||||||
<span class="d_keyword">return</span> representer.<span class="d_psymbol">representMapping</span>(<span class="d_string">"!mystruct.tag"</span>, <span class="d_param">pairs</span>);
|
<span class="d_keyword">return</span> representer.<span class="d_psymbol">representMapping</span>(<span class="d_string">"!mystruct.tag"</span>, <span class="d_param">pairs</span>);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representNull"></a><span class="ddoc_psymbol">representNull</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representNull"></a>@safe Node <a name="representNull"></a><span class="ddoc_psymbol">representNull</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a null node as a null YAML value.</p>
|
<dd><p>Represent a null node as a null YAML value.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representString"></a><span class="ddoc_psymbol">representString</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representString"></a>@safe Node <a name="representString"></a><span class="ddoc_psymbol">representString</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a string node as a string scalar.</p>
|
<dd><p>Represent a string node as a string scalar.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representBytes"></a><span class="ddoc_psymbol">representBytes</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representBytes"></a>@system Node <a name="representBytes"></a><span class="ddoc_psymbol">representBytes</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a bytes node as a binary scalar.</p>
|
<dd><p>Represent a bytes node as a binary scalar.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representBool"></a><span class="ddoc_psymbol">representBool</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representBool"></a>@safe Node <a name="representBool"></a><span class="ddoc_psymbol">representBool</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a bool node as a bool scalar.</p>
|
<dd><p>Represent a bool node as a bool scalar.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representLong"></a><span class="ddoc_psymbol">representLong</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representLong"></a>@system Node <a name="representLong"></a><span class="ddoc_psymbol">representLong</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a long node as an integer scalar.</p>
|
<dd><p>Represent a long node as an integer scalar.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representReal"></a><span class="ddoc_psymbol">representReal</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representReal"></a>@system Node <a name="representReal"></a><span class="ddoc_psymbol">representReal</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a real node as a floating point scalar.</p>
|
<dd><p>Represent a real node as a floating point scalar.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representSysTime"></a><span class="ddoc_psymbol">representSysTime</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representSysTime"></a>@system Node <a name="representSysTime"></a><span class="ddoc_psymbol">representSysTime</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a SysTime node as a timestamp.</p>
|
<dd><p>Represent a SysTime node as a timestamp.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representNodes"></a><span class="ddoc_psymbol">representNodes</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representNodes"></a>@safe Node <a name="representNodes"></a><span class="ddoc_psymbol">representNodes</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a sequence node as sequence/set.</p>
|
<dd><p>Represent a sequence node as sequence/set.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">Node <a name="representPairs"></a><span class="ddoc_psymbol">representPairs</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
<dt class="d_decl"><a name="representPairs"></a>@system Node <a name="representPairs"></a><span class="ddoc_psymbol">representPairs</span>(ref Node <b>node</b>, Representer <b>representer</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Represent a mapping node as map/ordered map/pairs.</p>
|
<dd><p>Represent a mapping node as map/ordered map/pairs.</p>
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,13 @@
|
||||||
</p>
|
</p>
|
||||||
<p>Code based on <a href="http://www.pyyaml.org">PyYAML</a>.</p>
|
<p>Code based on <a href="http://www.pyyaml.org">PyYAML</a>.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">class <a name="Resolver"></a><span class="ddoc_psymbol">Resolver</span>;
|
<dl><dt class="d_decl"><a name="Resolver"></a>class <a name="Resolver"></a><span class="ddoc_psymbol">Resolver</span>;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Resolves YAML tags (data types).
|
<dd><p>Resolves YAML tags (data types).
|
||||||
</p>
|
</p>
|
||||||
<p>Can be used to implicitly resolve custom data types of scalar values.</p>
|
<p>Can be used to implicitly resolve custom data types of scalar values.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">this(bool <b>defaultImplicitResolvers</b> = true);
|
<dl><dt class="d_decl"><a name="Resolver.this"></a>@safe this(Flag!"useDefaultImplicitResolvers" <b>defaultImplicitResolvers</b> = Yes.useDefaultImplicitResolvers);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Construct a Resolver.
|
<dd><p>Construct a Resolver.
|
||||||
</p>
|
</p>
|
||||||
|
@ -61,12 +61,12 @@
|
||||||
you can use <b>defaultImplicitResolvers</b> to disable default resolvers.
|
you can use <b>defaultImplicitResolvers</b> to disable default resolvers.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>bool <b>defaultImplicitResolvers</b></td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>Flag!"useDefaultImplicitResolvers" <b>defaultImplicitResolvers</b></td>
|
||||||
<td valign=top>Use default YAML implicit resolvers?</td></tr>
|
<td valign=top>Use default YAML implicit resolvers?</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">void <a name="addImplicitResolver"></a><span class="ddoc_psymbol">addImplicitResolver</span>(string <b>tag</b>, Regex!(char) <b>regexp</b>, string <b>first</b>);
|
<dt class="d_decl"><a name="Resolver.addImplicitResolver"></a>pure @safe void <a name="addImplicitResolver"></a><span class="ddoc_psymbol">addImplicitResolver</span>(string <b>tag</b>, Regex!char <b>regexp</b>, string <b>first</b>);
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Add an implicit scalar resolver.
|
<dd><p>Add an implicit scalar resolver.
|
||||||
</p>
|
</p>
|
||||||
|
@ -83,44 +83,44 @@
|
||||||
</p>
|
</p>
|
||||||
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>tag</b></td>
|
<b>Parameters:</b><div class="pbr"><table class=parms><tr><td valign=top>string <b>tag</b></td>
|
||||||
<td valign=top>Tag to resolve to.</td></tr>
|
<td valign=top>Tag to resolve to.</td></tr>
|
||||||
<tr><td valign=top>Regex!(char) <b>regexp</b></td>
|
<tr><td valign=top>Regex!char <b>regexp</b></td>
|
||||||
<td valign=top>Regular expression the scalar must match to have this tag.</td></tr>
|
<td valign=top>Regular expression the scalar must match to have this tag.</td></tr>
|
||||||
<tr><td valign=top>string <b>first</b></td>
|
<tr><td valign=top>string <b>first</b></td>
|
||||||
<td valign=top>String of possible starting characters of the scalar.</td></tr>
|
<td valign=top>String of possible starting characters of the scalar.</td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
<b>Examples:</b><div class="pbr">Resolve scalars starting with 'A' to !tag :
|
<b>Examples:</b><div class="pbr">Resolve scalars starting with 'A' to !tag :
|
||||||
<pre class="d_code"> <span class="d_keyword">import</span> std.regex;
|
<pre class="d_code"><span class="d_keyword">import</span> std.regex;
|
||||||
|
|
||||||
<span class="d_keyword">import</span> yaml;
|
<span class="d_keyword">import</span> dyaml.all;
|
||||||
|
|
||||||
<span class="d_keyword">void</span> main()
|
<span class="d_keyword">void</span> main()
|
||||||
{
|
{
|
||||||
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.txt"</span>);
|
<span class="d_keyword">auto</span> loader = Loader(<span class="d_string">"file.txt"</span>);
|
||||||
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
|
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
|
||||||
resolver.<span class="d_psymbol">addImplicitResolver</span>(<span class="d_string">"!tag"</span>, std.regex.regex(<span class="d_string">"A.*"</span>), <span class="d_string">"A"</span>);
|
resolver.<span class="d_psymbol">addImplicitResolver</span>(<span class="d_string">"!tag"</span>, std.regex.regex(<span class="d_string">"A.*"</span>), <span class="d_string">"A"</span>);
|
||||||
loader.resolver = resolver;
|
loader.resolver = resolver;
|
||||||
|
|
||||||
<span class="d_comment">//Note that we have no constructor from tag "!tag", so we can't
|
<span class="d_comment">//Note that we have no constructor from tag "!tag", so we can't
|
||||||
</span> <span class="d_comment">//actually load anything that resolves to this tag.
|
</span> <span class="d_comment">//actually load anything that resolves to this tag.
|
||||||
</span> <span class="d_comment">//See Constructor API documentation and tutorial for more information.
|
</span> <span class="d_comment">//See Constructor API documentation and tutorial for more information.
|
||||||
</span>
|
</span>
|
||||||
<span class="d_keyword">auto</span> node = loader.load();
|
<span class="d_keyword">auto</span> node = loader.load();
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">package const @property Tag <a name="defaultScalarTag"></a><span class="ddoc_psymbol">defaultScalarTag</span>();
|
<dt class="d_decl"><a name="Resolver.defaultScalarTag"></a>package const pure nothrow @property @safe Tag <a name="defaultScalarTag"></a><span class="ddoc_psymbol">defaultScalarTag</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Return default scalar tag.</p>
|
<dd><p>Return default scalar tag.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">package const @property Tag <a name="defaultSequenceTag"></a><span class="ddoc_psymbol">defaultSequenceTag</span>();
|
<dt class="d_decl"><a name="Resolver.defaultSequenceTag"></a>package const pure nothrow @property @safe Tag <a name="defaultSequenceTag"></a><span class="ddoc_psymbol">defaultSequenceTag</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Return default sequence tag.</p>
|
<dd><p>Return default sequence tag.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">package const @property Tag <a name="defaultMappingTag"></a><span class="ddoc_psymbol">defaultMappingTag</span>();
|
<dt class="d_decl"><a name="Resolver.defaultMappingTag"></a>package const pure nothrow @property @safe Tag <a name="defaultMappingTag"></a><span class="ddoc_psymbol">defaultMappingTag</span>();
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Return default mapping tag.</p>
|
<dd><p>Return default mapping tag.</p>
|
||||||
|
|
||||||
|
|
|
@ -42,49 +42,49 @@
|
||||||
<!-- Generated by Ddoc from dyaml/style.d -->
|
<!-- Generated by Ddoc from dyaml/style.d -->
|
||||||
<p>YAML node formatting styles.</p>
|
<p>YAML node formatting styles.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl">enum <a name="ScalarStyle"></a><span class="ddoc_psymbol">ScalarStyle</span>;
|
<dl><dt class="d_decl"><a name="ScalarStyle"></a>enum <a name="ScalarStyle"></a><span class="ddoc_psymbol">ScalarStyle</span>: ubyte;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Scalar styles.</p>
|
<dd><p>Scalar styles.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl"><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span></dt>
|
<dl><dt class="d_decl"><a name="ScalarStyle.Invalid"></a><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span></dt>
|
||||||
<dd><p><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span> (uninitialized) style</p>
|
<dd><p><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span> (uninitialized) style</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="Literal"></a><span class="ddoc_psymbol">Literal</span></dt>
|
<dt class="d_decl"><a name="ScalarStyle.Literal"></a><a name="Literal"></a><span class="ddoc_psymbol">Literal</span></dt>
|
||||||
<dd><p>| (<a name="Literal"></a><span class="ddoc_psymbol">Literal</span> block style)</p>
|
<dd><p>| (<a name="Literal"></a><span class="ddoc_psymbol">Literal</span> block style)</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="Folded"></a><span class="ddoc_psymbol">Folded</span></dt>
|
<dt class="d_decl"><a name="ScalarStyle.Folded"></a><a name="Folded"></a><span class="ddoc_psymbol">Folded</span></dt>
|
||||||
<dd><p>> (<a name="Folded"></a><span class="ddoc_psymbol">Folded</span> block style)</p>
|
<dd><p>> (<a name="Folded"></a><span class="ddoc_psymbol">Folded</span> block style)</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="Plain"></a><span class="ddoc_psymbol">Plain</span></dt>
|
<dt class="d_decl"><a name="ScalarStyle.Plain"></a><a name="Plain"></a><span class="ddoc_psymbol">Plain</span></dt>
|
||||||
<dd><p><a name="Plain"></a><span class="ddoc_psymbol">Plain</span> scalar</p>
|
<dd><p><a name="Plain"></a><span class="ddoc_psymbol">Plain</span> scalar</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="SingleQuoted"></a><span class="ddoc_psymbol">SingleQuoted</span></dt>
|
<dt class="d_decl"><a name="ScalarStyle.SingleQuoted"></a><a name="SingleQuoted"></a><span class="ddoc_psymbol">SingleQuoted</span></dt>
|
||||||
<dd><p>Single quoted scalar</p>
|
<dd><p>Single quoted scalar</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="DoubleQuoted"></a><span class="ddoc_psymbol">DoubleQuoted</span></dt>
|
<dt class="d_decl"><a name="ScalarStyle.DoubleQuoted"></a><a name="DoubleQuoted"></a><span class="ddoc_psymbol">DoubleQuoted</span></dt>
|
||||||
<dd><p>Double quoted scalar</p>
|
<dd><p>Double quoted scalar</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl">enum <a name="CollectionStyle"></a><span class="ddoc_psymbol">CollectionStyle</span>;
|
<dt class="d_decl"><a name="CollectionStyle"></a>enum <a name="CollectionStyle"></a><span class="ddoc_psymbol">CollectionStyle</span>: ubyte;
|
||||||
</dt>
|
</dt>
|
||||||
<dd><p>Collection styles.</p>
|
<dd><p>Collection styles.</p>
|
||||||
|
|
||||||
<dl><dt class="d_decl"><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span></dt>
|
<dl><dt class="d_decl"><a name="CollectionStyle.Invalid"></a><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span></dt>
|
||||||
<dd><p><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span> (uninitialized) style </p>
|
<dd><p><a name="Invalid"></a><span class="ddoc_psymbol">Invalid</span> (uninitialized) style </p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="Block"></a><span class="ddoc_psymbol">Block</span></dt>
|
<dt class="d_decl"><a name="CollectionStyle.Block"></a><a name="Block"></a><span class="ddoc_psymbol">Block</span></dt>
|
||||||
<dd><p><a name="Block"></a><span class="ddoc_psymbol">Block</span> style.</p>
|
<dd><p><a name="Block"></a><span class="ddoc_psymbol">Block</span> style.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="d_decl"><a name="Flow"></a><span class="ddoc_psymbol">Flow</span></dt>
|
<dt class="d_decl"><a name="CollectionStyle.Flow"></a><a name="Flow"></a><span class="ddoc_psymbol">Flow</span></dt>
|
||||||
<dd><p><a name="Flow"></a><span class="ddoc_psymbol">Flow</span> style.</p>
|
<dd><p><a name="Flow"></a><span class="ddoc_psymbol">Flow</span> style.</p>
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<h1>D:YAML 0.4 API documentation</h1>
|
<h1>D:YAML 0.4 API documentation</h1>
|
||||||
<!-- Generated by Ddoc from doc/html/api/index.dd -->
|
<!-- Generated by Ddoc from ../doc/html/api/index.dd -->
|
||||||
|
|
||||||
|
|
||||||
<p>This is the complete API documentation for D:YAML. It describes all classes,
|
<p>This is the complete API documentation for D:YAML. It describes all classes,
|
||||||
|
|
|
@ -3,13 +3,16 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<title>Differences between D:YAML and the YAML specification — D:YAML v0.4 documentation</title>
|
<title>Differences between D:YAML and the YAML specification — D:YAML 0.4 documentation</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: '../',
|
URL_ROOT: '../',
|
||||||
|
@ -22,7 +25,7 @@
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||||
<link rel="top" title="D:YAML v0.4 documentation" href="../index.html" />
|
<link rel="top" title="D:YAML 0.4 documentation" href="../index.html" />
|
||||||
<link rel="prev" title="YAML syntax" href="../tutorials/yaml_syntax.html" />
|
<link rel="prev" title="YAML syntax" href="../tutorials/yaml_syntax.html" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -32,7 +35,7 @@
|
||||||
<li class="right" style="margin-right: 10px">
|
<li class="right" style="margin-right: 10px">
|
||||||
<a href="../tutorials/yaml_syntax.html" title="YAML syntax"
|
<a href="../tutorials/yaml_syntax.html" title="YAML syntax"
|
||||||
accesskey="P">previous</a></li>
|
accesskey="P">previous</a></li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -133,13 +136,13 @@ struct appears in Phobos.</p>
|
||||||
<li class="right" style="margin-right: 10px">
|
<li class="right" style="margin-right: 10px">
|
||||||
<a href="../tutorials/yaml_syntax.html" title="YAML syntax"
|
<a href="../tutorials/yaml_syntax.html" title="YAML syntax"
|
||||||
>previous</a></li>
|
>previous</a></li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
||||||
Last updated on Jan 23, 2012.
|
Last updated on Dec 17, 2013.
|
||||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -3,13 +3,16 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<title>Welcome to D:YAML documentation! — D:YAML v0.4 documentation</title>
|
<title>Welcome to D:YAML documentation! — D:YAML 0.4 documentation</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: '',
|
URL_ROOT: '',
|
||||||
|
@ -22,7 +25,7 @@
|
||||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
||||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
||||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
||||||
<link rel="top" title="D:YAML v0.4 documentation" href="#" />
|
<link rel="top" title="D:YAML 0.4 documentation" href="#" />
|
||||||
<link rel="next" title="Getting started" href="tutorials/getting_started.html" />
|
<link rel="next" title="Getting started" href="tutorials/getting_started.html" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -32,7 +35,7 @@
|
||||||
<li class="right" style="margin-right: 10px">
|
<li class="right" style="margin-right: 10px">
|
||||||
<a href="tutorials/getting_started.html" title="Getting started"
|
<a href="tutorials/getting_started.html" title="Getting started"
|
||||||
accesskey="N">next</a></li>
|
accesskey="N">next</a></li>
|
||||||
<li><a href="#">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="#">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -99,13 +102,13 @@
|
||||||
<li class="right" style="margin-right: 10px">
|
<li class="right" style="margin-right: 10px">
|
||||||
<a href="tutorials/getting_started.html" title="Getting started"
|
<a href="tutorials/getting_started.html" title="Getting started"
|
||||||
>next</a></li>
|
>next</a></li>
|
||||||
<li><a href="#">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="#">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
||||||
Last updated on Jan 23, 2012.
|
Last updated on Dec 17, 2013.
|
||||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -3,13 +3,16 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<title>Search — D:YAML v0.4 documentation</title>
|
<title>Search — D:YAML 0.4 documentation</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: '',
|
URL_ROOT: '',
|
||||||
|
@ -23,18 +26,20 @@
|
||||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
||||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
||||||
<script type="text/javascript" src="_static/searchtools.js"></script>
|
<script type="text/javascript" src="_static/searchtools.js"></script>
|
||||||
<link rel="top" title="D:YAML v0.4 documentation" href="index.html" />
|
<link rel="top" title="D:YAML 0.4 documentation" href="index.html" />
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(function() { Search.loadIndex("searchindex.js"); });
|
jQuery(function() { Search.loadIndex("searchindex.js"); });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript" id="searchindexloader"></script>
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="related">
|
<div class="related">
|
||||||
<h3>Navigation</h3>
|
<h3>Navigation</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -82,13 +87,13 @@
|
||||||
<div class="related">
|
<div class="related">
|
||||||
<h3>Navigation</h3>
|
<h3>Navigation</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
||||||
Last updated on Jan 23, 2012.
|
Last updated on Dec 17, 2013.
|
||||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -3,13 +3,16 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<title>Custom YAML data types — D:YAML v0.4 documentation</title>
|
<title>Custom YAML data types — D:YAML 0.4 documentation</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: '../',
|
URL_ROOT: '../',
|
||||||
|
@ -22,7 +25,7 @@
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||||
<link rel="top" title="D:YAML v0.4 documentation" href="../index.html" />
|
<link rel="top" title="D:YAML 0.4 documentation" href="../index.html" />
|
||||||
<link rel="next" title="YAML syntax" href="yaml_syntax.html" />
|
<link rel="next" title="YAML syntax" href="yaml_syntax.html" />
|
||||||
<link rel="prev" title="Getting started" href="getting_started.html" />
|
<link rel="prev" title="Getting started" href="getting_started.html" />
|
||||||
</head>
|
</head>
|
||||||
|
@ -36,7 +39,7 @@
|
||||||
<li class="right" >
|
<li class="right" >
|
||||||
<a href="getting_started.html" title="Getting started"
|
<a href="getting_started.html" title="Getting started"
|
||||||
accesskey="P">previous</a> |</li>
|
accesskey="P">previous</a> |</li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -369,13 +372,13 @@ directory of the D:YAML package.</p>
|
||||||
<li class="right" >
|
<li class="right" >
|
||||||
<a href="getting_started.html" title="Getting started"
|
<a href="getting_started.html" title="Getting started"
|
||||||
>previous</a> |</li>
|
>previous</a> |</li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
||||||
Last updated on Jan 23, 2012.
|
Last updated on Dec 17, 2013.
|
||||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -3,13 +3,16 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<title>Getting started — D:YAML v0.4 documentation</title>
|
<title>Getting started — D:YAML 0.4 documentation</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: '../',
|
URL_ROOT: '../',
|
||||||
|
@ -22,7 +25,7 @@
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||||
<link rel="top" title="D:YAML v0.4 documentation" href="../index.html" />
|
<link rel="top" title="D:YAML 0.4 documentation" href="../index.html" />
|
||||||
<link rel="next" title="Custom YAML data types" href="custom_types.html" />
|
<link rel="next" title="Custom YAML data types" href="custom_types.html" />
|
||||||
<link rel="prev" title="Welcome to D:YAML documentation!" href="../index.html" />
|
<link rel="prev" title="Welcome to D:YAML documentation!" href="../index.html" />
|
||||||
</head>
|
</head>
|
||||||
|
@ -36,7 +39,7 @@
|
||||||
<li class="right" >
|
<li class="right" >
|
||||||
<a href="../index.html" title="Welcome to D:YAML documentation!"
|
<a href="../index.html" title="Welcome to D:YAML documentation!"
|
||||||
accesskey="P">previous</a> |</li>
|
accesskey="P">previous</a> |</li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -103,7 +106,7 @@ To do this on Unix/Linux, use the following command:</p>
|
||||||
<p>Now we need to parse it. Create a file called <tt class="docutils literal"><span class="pre">main.d</span></tt>. Paste following code
|
<p>Now we need to parse it. Create a file called <tt class="docutils literal"><span class="pre">main.d</span></tt>. Paste following code
|
||||||
into the file:</p>
|
into the file:</p>
|
||||||
<div class="highlight-d"><div class="highlight"><pre><span class="k">import</span> <span class="n">std</span><span class="p">.</span><span class="n">stdio</span><span class="p">;</span>
|
<div class="highlight-d"><div class="highlight"><pre><span class="k">import</span> <span class="n">std</span><span class="p">.</span><span class="n">stdio</span><span class="p">;</span>
|
||||||
<span class="k">import</span> <span class="n">yaml</span><span class="p">;</span>
|
<span class="k">import</span> <span class="n">dyaml</span><span class="p">.</span><span class="n">all</span><span class="p">;</span>
|
||||||
|
|
||||||
<span class="kt">void</span> <span class="n">main</span><span class="p">()</span>
|
<span class="kt">void</span> <span class="n">main</span><span class="p">()</span>
|
||||||
<span class="p">{</span>
|
<span class="p">{</span>
|
||||||
|
@ -124,8 +127,8 @@ into the file:</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="explanation-of-the-code">
|
<div class="section" id="explanation-of-the-code">
|
||||||
<h3>Explanation of the code<a class="headerlink" href="#explanation-of-the-code" title="Permalink to this headline">¶</a></h3>
|
<h3>Explanation of the code<a class="headerlink" href="#explanation-of-the-code" title="Permalink to this headline">¶</a></h3>
|
||||||
<p>First, we import the <em>yaml</em> module. This is the only D:YAML module you need to
|
<p>First, we import the <em>dyaml.all</em> module. This is the only D:YAML module you
|
||||||
import - it automatically imports all needed modules.</p>
|
need to import - it automatically imports all needed modules.</p>
|
||||||
<p>Next we load the file using the <em>Loader.load()</em> method. <em>Loader</em> is a struct
|
<p>Next we load the file using the <em>Loader.load()</em> method. <em>Loader</em> is a struct
|
||||||
used for parsing YAML documents. The <em>load()</em> method loads the file as
|
used for parsing YAML documents. The <em>load()</em> method loads the file as
|
||||||
<strong>one</strong> YAML document, or throws <em>YAMLException</em>, D:YAML exception type, if the
|
<strong>one</strong> YAML document, or throws <em>YAMLException</em>, D:YAML exception type, if the
|
||||||
|
@ -161,19 +164,20 @@ formatted differently. Comments are not preserved, either.</p>
|
||||||
<h3>Compiling<a class="headerlink" href="#compiling" title="Permalink to this headline">¶</a></h3>
|
<h3>Compiling<a class="headerlink" href="#compiling" title="Permalink to this headline">¶</a></h3>
|
||||||
<p>To compile your project, DMD needs to know which directories contain the
|
<p>To compile your project, DMD needs to know which directories contain the
|
||||||
imported modules and the library. You also need to tell it to link with D:YAML.
|
imported modules and the library. You also need to tell it to link with D:YAML.
|
||||||
The import directory should be the D:YAML package directory. You can specify it
|
The import directory should be the <tt class="docutils literal"><span class="pre">source</span></tt> subdirectory of the D:YAML
|
||||||
using the <tt class="docutils literal"><span class="pre">-I</span></tt> option of DMD. The library directory should point to the
|
directory. You can specify it using the <tt class="docutils literal"><span class="pre">-I</span></tt> option of DMD. The library
|
||||||
compiled library. On Unix/Linux you can specify it using the <tt class="docutils literal"><span class="pre">-L-L</span></tt> option,
|
directory should point to the compiled library. On Unix/Linux you can specify
|
||||||
and link with D:YAML using the <tt class="docutils literal"><span class="pre">-L-l</span></tt> option. On Windows, the import directory
|
it using the <tt class="docutils literal"><span class="pre">-L-L</span></tt> option, and link with D:YAML using the <tt class="docutils literal"><span class="pre">-L-l</span></tt> option.
|
||||||
is used as the library directory. To link with the library on Windows, just add
|
On Windows, the import directory is used as the library directory. To link with
|
||||||
the path to it relative to the current directory.</p>
|
the library on Windows, just add the path to it relative to the current
|
||||||
|
directory.</p>
|
||||||
<p>For example, if you extracted and compiled D:YAML in <tt class="docutils literal"><span class="pre">/home/xxx/dyaml</span></tt>, your
|
<p>For example, if you extracted and compiled D:YAML in <tt class="docutils literal"><span class="pre">/home/xxx/dyaml</span></tt>, your
|
||||||
project is in <tt class="docutils literal"><span class="pre">/home/xxx/dyaml-project</span></tt>, and you are currently in that
|
project is in <tt class="docutils literal"><span class="pre">/home/xxx/dyaml-project</span></tt>, and you are currently in that
|
||||||
directory, compile the project with the following command on Unix/Linux:</p>
|
directory, compile the project with the following command on Unix/Linux:</p>
|
||||||
<div class="highlight-python"><pre>dmd -I../dyaml -L-L../dyaml -L-ldyaml main.d</pre>
|
<div class="highlight-python"><pre>dmd -I../dyaml/source -L-L../dyaml -L-ldyaml main.d</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>And the following on Windows:</p>
|
<p>And the following on Windows:</p>
|
||||||
<div class="highlight-python"><pre>dmd -I../dyaml ../dyaml/libdyaml.lib main.d</pre>
|
<div class="highlight-python"><pre>dmd -I../dyaml/source ../dyaml/libdyaml.lib main.d</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>This will produce an executable called <tt class="docutils literal"><span class="pre">main</span></tt> or <tt class="docutils literal"><span class="pre">main.exe</span></tt> in your
|
<p>This will produce an executable called <tt class="docutils literal"><span class="pre">main</span></tt> or <tt class="docutils literal"><span class="pre">main.exe</span></tt> in your
|
||||||
directory. When you run it, it should produce the following output:</p>
|
directory. When you run it, it should produce the following output:</p>
|
||||||
|
@ -231,13 +235,13 @@ example in the <tt class="docutils literal"><span class="pre">example/getting_st
|
||||||
<li class="right" >
|
<li class="right" >
|
||||||
<a href="../index.html" title="Welcome to D:YAML documentation!"
|
<a href="../index.html" title="Welcome to D:YAML documentation!"
|
||||||
>previous</a> |</li>
|
>previous</a> |</li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
||||||
Last updated on Jan 23, 2012.
|
Last updated on Dec 17, 2013.
|
||||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -3,13 +3,16 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<title>YAML syntax — D:YAML v0.4 documentation</title>
|
<title>YAML syntax — D:YAML 0.4 documentation</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var DOCUMENTATION_OPTIONS = {
|
var DOCUMENTATION_OPTIONS = {
|
||||||
URL_ROOT: '../',
|
URL_ROOT: '../',
|
||||||
|
@ -22,7 +25,7 @@
|
||||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||||
<link rel="top" title="D:YAML v0.4 documentation" href="../index.html" />
|
<link rel="top" title="D:YAML 0.4 documentation" href="../index.html" />
|
||||||
<link rel="next" title="Differences between D:YAML and the YAML specification" href="../articles/spec_differences.html" />
|
<link rel="next" title="Differences between D:YAML and the YAML specification" href="../articles/spec_differences.html" />
|
||||||
<link rel="prev" title="Custom YAML data types" href="custom_types.html" />
|
<link rel="prev" title="Custom YAML data types" href="custom_types.html" />
|
||||||
</head>
|
</head>
|
||||||
|
@ -36,7 +39,7 @@
|
||||||
<li class="right" >
|
<li class="right" >
|
||||||
<a href="custom_types.html" title="Custom YAML data types"
|
<a href="custom_types.html" title="Custom YAML data types"
|
||||||
accesskey="P">previous</a> |</li>
|
accesskey="P">previous</a> |</li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -253,36 +256,36 @@ Some of these might change in the future (especially !!map and !!set).</p>
|
||||||
<col width="42%" />
|
<col width="42%" />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead valign="bottom">
|
<thead valign="bottom">
|
||||||
<tr><th class="head">YAML tag</th>
|
<tr class="row-odd"><th class="head">YAML tag</th>
|
||||||
<th class="head">D type</th>
|
<th class="head">D type</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody valign="top">
|
<tbody valign="top">
|
||||||
<tr><td>!!null</td>
|
<tr class="row-even"><td>!!null</td>
|
||||||
<td>yaml.YAMLNull</td>
|
<td>yaml.YAMLNull</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!bool</td>
|
<tr class="row-odd"><td>!!bool</td>
|
||||||
<td>bool</td>
|
<td>bool</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!int</td>
|
<tr class="row-even"><td>!!int</td>
|
||||||
<td>long</td>
|
<td>long</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!float</td>
|
<tr class="row-odd"><td>!!float</td>
|
||||||
<td>real</td>
|
<td>real</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!binary</td>
|
<tr class="row-even"><td>!!binary</td>
|
||||||
<td>ubyte[]</td>
|
<td>ubyte[]</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!timestamp</td>
|
<tr class="row-odd"><td>!!timestamp</td>
|
||||||
<td>datetime.SysTime</td>
|
<td>datetime.SysTime</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!map, !!omap, !!pairs</td>
|
<tr class="row-even"><td>!!map, !!omap, !!pairs</td>
|
||||||
<td>Node.Pair[]</td>
|
<td>Node.Pair[]</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!seq, !!set</td>
|
<tr class="row-odd"><td>!!seq, !!set</td>
|
||||||
<td>Node[]</td>
|
<td>Node[]</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>!!str</td>
|
<tr class="row-even"><td>!!str</td>
|
||||||
<td>string</td>
|
<td>string</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -325,13 +328,13 @@ Some of these might change in the future (especially !!map and !!set).</p>
|
||||||
<li class="right" >
|
<li class="right" >
|
||||||
<a href="custom_types.html" title="Custom YAML data types"
|
<a href="custom_types.html" title="Custom YAML data types"
|
||||||
>previous</a> |</li>
|
>previous</a> |</li>
|
||||||
<li><a href="../index.html">D:YAML v0.4 documentation</a> »</li>
|
<li><a href="../index.html">D:YAML 0.4 documentation</a> »</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
||||||
Last updated on Jan 23, 2012.
|
Last updated on Dec 17, 2013.
|
||||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|