Updated the generated docs.

This commit is contained in:
Ferdinand Majerech 2013-12-17 15:19:01 +01:00
parent 2a11c235d9
commit c1caf47a62
45 changed files with 4761 additions and 2900 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,4 +1,4 @@
# 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.
config: 932028a19a10a213bb2bc3e91bc492de
config: 433cb5227210ca9af80d745da3915442
tags: fbb0d17656682115ca4d033fb2f83ba1

View file

@ -77,7 +77,7 @@ into the file:
.. code-block:: d
import std.stdio;
import yaml;
import dyaml.all;
void main()
{
@ -100,8 +100,8 @@ into the file:
Explanation of the code
^^^^^^^^^^^^^^^^^^^^^^^
First, we import the *yaml* module. This is the only D:YAML module you need to
import - it automatically imports all needed modules.
First, we import the *dyaml.all* module. This is the only D:YAML module you
need to import - it automatically imports all needed modules.
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
@ -145,30 +145,31 @@ formatted differently. Comments are not preserved, either.
Compiling
^^^^^^^^^
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.
The import directory should be the D:YAML package directory. You can specify it
using the ``-I`` option of DMD. The library directory should point to the
compiled library. On Unix/Linux you can specify it using the ``-L-L`` option,
and link with D:YAML using the ``-L-l`` option. On Windows, the import directory
is used as the library directory. To link with the library on Windows, just add
the path to it relative to the current directory.
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.
The import directory should be the ``source`` subdirectory of the D:YAML
directory. You can specify it using the ``-I`` option of DMD. The library
directory should point to the compiled library. On Unix/Linux you can specify
it using the ``-L-L`` option, and link with D:YAML using the ``-L-l`` option.
On Windows, the import directory is used as the library directory. To link with
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
project is in ``/home/xxx/dyaml-project``, and you are currently in that
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::
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
directory. When you run it, it should produce the following output::
Hello
World
World
The answer is 42

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

View file

@ -79,6 +79,14 @@ div.sphinxsidebar input {
font-size: 1em;
}
div.sphinxsidebar #searchbox input[type="text"] {
width: 170px;
}
div.sphinxsidebar #searchbox input[type="submit"] {
width: 30px;
}
img {
border: 0;
}
@ -236,7 +244,6 @@ img.align-center, .figure.align-center, object.align-center {
}
.align-center {
clear: both;
text-align: center;
}
@ -440,6 +447,11 @@ dl.glossary dt {
font-style: oblique;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
@ -525,4 +537,4 @@ span.eqno {
#top-link {
display: none;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -2,7 +2,7 @@
* doctools.js
* ~~~~~~~~~~~
*
* Sphinx JavaScript utilties for all documentation.
* Sphinx JavaScript utilities for all documentation.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
@ -185,9 +185,9 @@ var Documentation = {
body.highlightText(this.toLowerCase(), 'highlighted');
});
}, 10);
$('<li class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></li>')
.appendTo($('.sidebar .this-page-menu'));
$('<p class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
.appendTo($('#searchbox'));
}
},
@ -213,7 +213,7 @@ var Documentation = {
* helper function to hide the search marks again
*/
hideSearchWords : function() {
$('.sidebar .this-page-menu li.highlight-link').fadeOut(300);
$('#searchbox .highlight-link').fadeOut(300);
$('span.highlighted').removeClass('highlighted');
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

BIN
doc/html/_static/down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 392 B

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 199 B

View file

@ -13,11 +13,11 @@
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.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 .gs { font-weight: bold } /* Generic.Strong */
.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 .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */

View file

@ -1,6 +1,6 @@
/*
* searchtools.js
* ~~~~~~~~~~~~~~
* searchtools.js_t
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilties for the full-text search.
*
@ -36,10 +36,11 @@ jQuery.makeSearchSummary = function(text, keywords, hlwords) {
return rv;
}
/**
* Porter Stemmer
*/
var PorterStemmer = function() {
var Stemmer = function() {
var step2list = {
ational: 'ate',
@ -238,8 +239,13 @@ var Search = {
},
loadIndex : function(url) {
$.ajax({type: "GET", url: url, data: null, success: null,
dataType: "script", cache: true});
$.ajax({type: "GET", url: url, data: null,
dataType: "script", cache: true,
complete: function(jqxhr, textstatus) {
if (textstatus != "success") {
document.getElementById("searchindexloader").src = url;
}
}});
},
setIndex : function(index) {
@ -300,20 +306,20 @@ var Search = {
},
query : function(query) {
var stopwords = ['and', 'then', 'into', 'it', 'as', 'are', 'in',
'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'];
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"];
// stem the searchterms and add them to the correct list
var stemmer = new PorterStemmer();
// Stem the searchterms and add them to the correct list
var stemmer = new Stemmer();
var searchterms = [];
var excluded = [];
var hlterms = [];
var tmp = query.split(/\s+/);
var object = (tmp.length == 1) ? tmp[0].toLowerCase() : null;
var objectterms = [];
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+$/) ||
tmp[i] == "") {
// skip this "word"
@ -344,9 +350,6 @@ var Search = {
var filenames = this._index.filenames;
var titles = this._index.titles;
var terms = this._index.terms;
var objects = this._index.objects;
var objtypes = this._index.objtypes;
var objnames = this._index.objnames;
var fileMap = {};
var files = null;
// different result priorities
@ -357,40 +360,19 @@ var Search = {
$('#search-progress').empty();
// lookup as object
if (object != null) {
for (var prefix in objects) {
for (var name in objects[prefix]) {
var fullname = (prefix ? prefix + '.' : '') + name;
if (fullname.toLowerCase().indexOf(object) > -1) {
match = objects[prefix][name];
descr = objnames[match[1]] + _(', in ') + titles[match[0]];
// XXX the generated anchors are not generally correct
// XXX there may be custom prefixes
result = [filenames[match[0]], fullname, '#'+fullname, descr];
switch (match[2]) {
case 1: objectResults.push(result); break;
case 0: importantResults.push(result); break;
case 2: unimportantResults.push(result); break;
}
}
}
}
for (var i = 0; i < objectterms.length; i++) {
var others = [].concat(objectterms.slice(0,i),
objectterms.slice(i+1, objectterms.length))
var results = this.performObjectSearch(objectterms[i], others);
// Assume first word is most likely to be the object,
// other words more likely to be in description.
// Therefore put matches for earlier words first.
// (Results are eventually used in reverse order).
objectResults = results[0].concat(objectResults);
importantResults = results[1].concat(importantResults);
unimportantResults = results[2].concat(unimportantResults);
}
// 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
for (var i = 0; i < searchterms.length; i++) {
var word = searchterms[i];
@ -480,16 +462,18 @@ var Search = {
displayNextItem();
});
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
$.get(DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' +
item[0] + '.txt', function(data) {
if (data != '') {
listItem.append($.makeSearchSummary(data, searchterms, hlterms));
Search.output.append(listItem);
}
listItem.slideDown(5, function() {
displayNextItem();
});
}, "text");
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt',
dataType: "text",
complete: function(jqxhr, textstatus) {
var data = jqxhr.responseText;
if (data !== '') {
listItem.append($.makeSearchSummary(data, searchterms, hlterms));
}
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
}});
} else {
// no source available, just display title
Search.output.append(listItem);
@ -510,9 +494,74 @@ var Search = {
}
}
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]
}
}
$(document).ready(function() {
Search.init();
});
});

View file

@ -29,6 +29,9 @@ $(function() {
var sidebar = $('.sphinxsidebar');
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
// with the sidebar expanded
var bw_margin_expanded = bodywrapper.css('margin-left');

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

BIN
doc/html/_static/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

View 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 &#9657;\
</a>\
<a href="#" id="hc<%id%>" class="hide-propose-change">\
Propose a change &#9663;\
</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 &#9657;</a>\
<a href="#" class="close-reply" id="cr<%id%>">reply &#9663;</a>\
<a href="#" id="sp<%id%>" class="show-proposal">proposal &#9657;</a>\
<a href="#" id="hp<%id%>" class="hide-proposal">proposal &#9663;</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);
}
});

View file

@ -44,13 +44,13 @@
nodes. This can be used to implement custom data types. A tutorial can be
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>
<dd><p>Exception thrown at constructor errors.
</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>
<dd><p>Construct a ConstructorException.
</p>
@ -65,7 +65,7 @@
</dd>
</dl>
</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>
<dd><p>Constructs YAML values.
</p>
@ -84,7 +84,7 @@
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>
<dd><p>Construct a Constructor.
</p>
@ -92,23 +92,23 @@
<b>defaultConstructors</b> to disable constructor functions for these.
</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>
</table></div>
</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>
<dd><p>Add a constructor function from scalar.
</p>
<p>The function must take a reference to Node to construct from.
The node contains a string for scalars, Node[] for sequences and
Node.Pair[] for mappings.
<p>The function must take a reference to <span class="d_inlinecode">Node</span> to construct from.
The node contains a string for scalars, for sequences and
for mappings.
<br>
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
user which type failed to construct, and position in the file.
its message will be added to a that will also tell
the user which type failed to construct, and position in the file.
<br>
<br>
@ -129,53 +129,53 @@
values - it is not const for compatibility reasons.
</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>
<tr><td valign=top>ctor</td>
<tr><td valign=top>T function(ref Node) ctor</td>
<td valign=top>Constructor function.</td></tr>
</table></div>
<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">int</span> x, y, z;
<span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<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_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>(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">return</span> 0;
}
}
<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_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>(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">return</span> 0;
}
}
MyStruct constructMyStructScalar(<span class="d_keyword">ref</span> Node node)
{
<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_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> <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]));
}
MyStruct constructMyStructScalar(<span class="d_keyword">ref</span> Node node)
{
<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_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> <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">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;
constructor.<span class="d_psymbol">addConstructorScalar</span>(<span class="d_string">"!mystruct"</span>, &amp;constructMyStructScalar);
loader.constructor = constructor;
Node node = loader.load();
}
<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> constructor = <span class="d_keyword">new</span> Constructor;
constructor.<span class="d_psymbol">addConstructorScalar</span>(<span class="d_string">"!mystruct"</span>, &amp;constructMyStructScalar);
loader.constructor = constructor;
Node node = loader.load();
}
</pre>
</p>
</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>
<dd><p>Add a constructor function from sequence.
</p>
@ -183,45 +183,45 @@
</div>
<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">int</span> x, y, z;
<span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<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_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>(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">return</span> 0;
}
}
<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_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>(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">return</span> 0;
}
}
MyStruct constructMyStructSequence(<span class="d_keyword">ref</span> Node node)
{
<span class="d_comment">//node is guaranteed to be sequence.
</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>);
}
MyStruct constructMyStructSequence(<span class="d_keyword">ref</span> Node node)
{
<span class="d_comment">//node is guaranteed to be sequence.
</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 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> constructor = <span class="d_keyword">new</span> Constructor;
constructor.<span class="d_psymbol">addConstructorSequence</span>(<span class="d_string">"!mystruct"</span>, &amp;constructMyStructSequence);
loader.constructor = constructor;
Node node = loader.load();
}
<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> constructor = <span class="d_keyword">new</span> Constructor;
constructor.<span class="d_psymbol">addConstructorSequence</span>(<span class="d_string">"!mystruct"</span>, &amp;constructMyStructSequence);
loader.constructor = constructor;
Node node = loader.load();
}
</pre>
</p>
</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>
<dd><p>Add a constructor function from a mapping.
</p>
@ -229,112 +229,112 @@
</div>
<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">int</span> x, y, z;
<span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<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_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>(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">return</span> 0;
}
}
<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_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>(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">return</span> 0;
}
}
MyStruct constructMyStructMapping(<span class="d_keyword">ref</span> Node node)
{
<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_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>);
}
MyStruct constructMyStructMapping(<span class="d_keyword">ref</span> Node node)
{
<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_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">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;
constructor.<span class="d_psymbol">addConstructorMapping</span>(<span class="d_string">"!mystruct"</span>, &amp;constructMyStructMapping);
loader.constructor = constructor;
Node node = loader.load();
}
<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> constructor = <span class="d_keyword">new</span> Constructor;
constructor.<span class="d_psymbol">addConstructorMapping</span>(<span class="d_string">"!mystruct"</span>, &amp;constructMyStructMapping);
loader.constructor = constructor;
Node node = loader.load();
}
</pre>
</p>
</dd>
</dl>
</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>
<dd><p>Construct a null node.</p>
</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>
<dd><p>Construct a merge node - a node that merges another node into a mapping.</p>
</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>
<dd><p>Construct a boolean node.</p>
</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>
<dd><p>Construct an integer (long) node.</p>
</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>
<dd><p>Construct a floating point (real) node.</p>
</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>
<dd><p>Construct a binary (base64) node.</p>
</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>
<dd><p>Construct a timestamp (SysTime) node.</p>
</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>
<dd><p>Construct a string node.</p>
</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>
<dd><p>Convert a sequence of single-element mappings into a sequence of pairs.</p>
</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>
<dd><p>Construct an ordered map (ordered sequence of key:value pairs without duplicates) node.</p>
</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>
<dd><p>Construct a pairs (ordered sequence of key: value pairs allowing duplicates) node.</p>
</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>
<dd><p>Construct a set node.</p>
</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>
<dd><p>Construct a sequence (array) node.</p>
</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>
<dd><p>Construct an unordered map (unordered set of key:value pairs without duplicates) node.</p>

View file

@ -44,7 +44,7 @@
</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>
<dd><p>Dumps YAML documents to files or streams.
</p>
@ -56,43 +56,46 @@
</p>
<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]);
<span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>).dump(node);
<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);
</pre>
<br>
Write multiple YAML documents to a file:
<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_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>).dump(node1, node2);
<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_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>).dump(node1, node2);
<span class="d_comment">//Or with an array:
</span> <span class="d_comment">//Dumper("file.yaml").dump([node1, node2]);
<span class="d_comment">//Or with an array:
</span><span class="d_comment">//Dumper("file.yaml").dump([node1, node2]);
</span>
</pre>
<br>
Write to memory:
<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> node = Node([1, 2, 3, 4, 5]);
<span class="d_psymbol">Dumper</span>(stream).dump(node);
<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> node = Node([1, 2, 3, 4, 5]);
<span class="d_psymbol">Dumper</span>(stream).dump(node);
</pre>
<br>
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]);
<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();
<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> 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 class="d_keyword">auto</span> dumper = <span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>);
dumper.representer = representer;
dumper.resolver = resolver;
dumper.dump(node);
<span class="d_keyword">auto</span> dumper = <span class="d_psymbol">Dumper</span>(<span class="d_string">"file.yaml"</span>);
dumper.representer = representer;
dumper.resolver = resolver;
dumper.dump(node);
</pre>
</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>
<dd><p>Construct a Dumper writing to a file.
</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>
</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>
<dd><p>Construct a Dumper writing to a stream. This is useful to e.g. write to memory.</p>
</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>
<dd><p>Set stream name. Used in debugging messages.</p>
</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>
<dd><p>Specify custom Resolver to use.</p>
</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>
<dd><p>Specify custom Representer to use.</p>
</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>
<dd><p>Write scalars in canonical form?</p>
</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>
<dd><p>Set indentation width. 2 by default. Must not be zero.</p>
</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>
<dd><p>Set preferred text width.</p>
</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>
<dd><p>Set line break to use. Unix by default.</p>
</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>
<dd><p>Set character encoding to use. UTF-8 by default.</p>
</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>
<dd><p>Always explicitly write document start?</p>
</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>
<dd><p>Always explicitly write document end?</p>
</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>
<dd><p>Specify YAML version string. "1.1" by default.</p>
</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>
<dd><p>Specify tag directives.
</p>
@ -189,18 +192,18 @@
<td valign=top>Tag directives (keys are handles, values are prefixes).</td></tr>
</table></div>
<p><b>Example:</b><br>
<pre class="d_code"> Dumper dumper = Dumper(<span class="d_string">"file.yaml"</span>);
string[string] directives;
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> <span class="d_comment">//with a "!short!" prefix instead.
</span> dumper.<span class="d_psymbol">tagDirectives</span>(directives);
dumper.dump(Node(<span class="d_string">"foo"</span>));
<pre class="d_code">Dumper dumper = Dumper(<span class="d_string">"file.yaml"</span>);
string[string] directives;
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><span class="d_comment">//with a "!short!" prefix instead.
</span>dumper.<span class="d_psymbol">tagDirectives</span>(directives);
dumper.dump(Node(<span class="d_string">"foo"</span>));
</pre>
</p>
</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>
<dd><p>Dump one or more YAML documents to the file/stream.
</p>

View file

@ -41,19 +41,19 @@
<h1>dyaml.encoding</h1>
<!-- Generated by Ddoc from dyaml/encoding.d -->
<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>
<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>
<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>
<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>

View file

@ -42,27 +42,27 @@
<!-- Generated by Ddoc from dyaml/exception.d -->
<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>
<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>
<dd><p>Construct a YAMLException with specified message and position where it was thrown.</p>
</dd>
</dl>
</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>
<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>
<dd><p>Construct a Mark with specified <b>line</b> and <b>column</b> in the file.</p>
</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>
<dd><p>Get a string representation of the mark.</p>

View file

@ -41,19 +41,19 @@
<h1>dyaml.linebreak</h1>
<!-- Generated by Ddoc from dyaml/linebreak.d -->
<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>
<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>
<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>
<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>

View file

@ -42,7 +42,7 @@
<!-- Generated by Ddoc from dyaml/loader.d -->
<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>
<dd><p>Loads YAML documents from files or streams.
</p>
@ -51,54 +51,58 @@
</p>
<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>
<br>
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>
<br>
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>
<br>
Load YAML from memory:
<pre class="d_code"> <span class="d_keyword">import</span> std.stream;
<span class="d_keyword">import</span> std.stdio;
<pre class="d_code"><span class="d_keyword">import</span> std.stream;
<span class="d_keyword">import</span> std.stdio;
string yaml_input = <span class="d_string">"red: '#ff0000'\n"</span>
<span class="d_string">"green: '#00ff00'\n"</span>
<span class="d_string">"blue: '#0000ff'"</span>;
string yaml_input = <span class="d_string">"red: '#ff0000'\n"</span>
<span class="d_string">"green: '#00ff00'\n"</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)
{
writeln(color, <span class="d_string">" is "</span>, value, <span class="d_string">" in HTML/CSS"</span>);
}
<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>);
}
</pre>
<br>
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();
<span class="d_keyword">auto</span> resolver = <span class="d_keyword">new</span> Resolver();
<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_comment">//Add constructor functions / resolver expressions here...
<span class="d_comment">//Add constructor functions / resolver expressions here...
</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.resolver = resolver;
<span class="d_keyword">auto</span> rootNode = loader.load(node);
<span class="d_keyword">auto</span> loader = <span class="d_psymbol">Loader</span>(<span class="d_string">"file.yaml"</span>);
loader.constructor = constructor;
loader.resolver = resolver;
<span class="d_keyword">auto</span> rootNode = loader.load(node);
</pre>
</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>
<dd><p>Construct a Loader to load YAML from a file.
</p>
@ -108,7 +112,17 @@
<b>Throws:</b><div class="pbr">YAMLException if the file could not be opened or read.</div>
</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>
<dd><p>Construct a Loader to load YAML from a stream.
</p>
@ -118,22 +132,22 @@
<b>Throws:</b><div class="pbr">YAMLException if <b>stream</b> could not be read.</div>
</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>
<dd><p>Set stream name. Used in debugging messages.</p>
</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>
<dd><p>Specify custom Resolver to use.</p>
</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>
<dd><p>Specify custom Constructor to use.</p>
</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>
<dd><p>Load single YAML document.
</p>
@ -150,7 +164,7 @@
or on a YAML parsing error.</div>
</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>
<dd><p>Load all YAML documents.
</p>
@ -169,7 +183,7 @@
<b>Throws:</b><div class="pbr">YAMLException on a parsing error.</div>
</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>
<dd><p>Foreach over YAML documents.
</p>

View file

@ -43,23 +43,23 @@
<p>Node of a YAML document. Used to read YAML data once it's loaded,
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>
<dd><p>Exception thrown at node related errors.</p>
</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>
<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>
<dd><p>Used for string conversion.</p>
</dd>
</dl>
</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>
<dd><p>YAML node.
</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
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>
<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>
<dd><p>Key node.</p>
</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>
<dd><p>Value node.</p>
</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>
<dd><p>Construct a Pair from two values. Will be converted to Nodes if needed.</p>
</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>
<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>
</dl>
</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 &amp;&amp; !isAssociativeArray!T);
</dt>
<dd><p>Construct a Node from a value.
</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
more efficiently.
more efficiently. To create a node representing a <b>null</b> value,
construct it from YAMLNull.
<br>
<br>
@ -109,9 +120,9 @@
otherwise emitting will fail.
</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>
<tr><td valign=top>tag</td>
<tr><td valign=top>string tag</td>
<td valign=top>Overrides tag of the node when emitted, regardless
of tag determined by Representer. Representer uses
this to determine YAML data type when a D data type
@ -121,7 +132,7 @@
</table></div>
</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>
<dd><p>Construct a node from an array.
</p>
@ -130,9 +141,9 @@
those nodes are stored.
</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>
<tr><td valign=top>tag</td>
<tr><td valign=top>string tag</td>
<td valign=top>Overrides tag of the node when emitted, regardless
of tag determined by Representer. Representer uses
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",
not a shortcut, like "!!set".</td></tr>
</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)
</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> <span class="d_keyword">auto</span> set = Node([1, 2, 3, 4, 5], <span class="d_string">"tag:yaml.org,2002:set"</span>);
<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 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>);
</pre>
</div>
</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>
<dd><p>Construct a node from an associative array.
</p>
@ -159,9 +170,9 @@
Otherwise they are converted to nodes and then stored.
</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>
<tr><td valign=top>tag</td>
<tr><td valign=top>string tag</td>
<td valign=top>Overrides tag of the node when emitted, regardless
of tag determined by Representer. Representer uses
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
shortcut, like "!!omap".</td></tr>
</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)
</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> <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> <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>);
<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 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 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>);
</pre>
</div>
</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>
<dd><p>Construct a node from arrays of keys and values.
</p>
@ -203,11 +214,11 @@
Otherwise they are converted to nodes and then stored.
</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>
<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>
<tr><td valign=top>tag</td>
<tr><td valign=top>string tag</td>
<td valign=top>Overrides tag of the node when emitted, regardless
of tag determined by Representer. Representer uses
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
shortcut, like "!!omap".</td></tr>
</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)
</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> <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> <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>);
<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 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 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>);
</pre>
</div>
</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>
<dd><p>Is this node valid (initialized)? </p>
</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>
<dd><p>Is this node a scalar value?</p>
</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>
<dd><p>Is this node a sequence?</p>
</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>
<dd><p>Is this node a mapping?</p>
</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>
<dd><p>Is this node a user defined type?</p>
</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>
<dd><p>Return <a name="tag"></a><span class="ddoc_psymbol">tag</span> of the node.</p>
</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>
<dd><p>Equality test.
</p>
@ -267,34 +283,40 @@
This might be quite expensive if testing entire documents.
<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>
<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 == <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 == 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">"43"</span>);
</pre>
</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>
</table></div>
<b>Returns:</b><div class="pbr"><b>true</b> if equal, <b>false</b> otherwise.</div>
</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>
<dd><p>Shortcut for get().</p>
</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>
<dd><p>Get the value of the node as specified type.
</p>
<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>
Numeric values are range checked, throwing if out of range of
@ -305,6 +327,10 @@
Binary values are decoded and stored as ubyte[].
<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>
@ -318,11 +344,11 @@
</p>
<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!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">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!<span class="d_keyword">double</span> == 42.0);
</pre>
</div>
@ -333,7 +359,12 @@
the value is out of range of requested type.</div>
</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>
<dd><p>If this is a collection, return its length.
</p>
@ -346,7 +377,7 @@
<b>Throws:</b><div class="pbr">NodeException if this is not a sequence nor a mapping.</div>
</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>
<dd><p>Get the element at specified index.
</p>
@ -356,11 +387,13 @@
<br>
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
return value of the first key that equals "12", even if it's an integer.
key equal to index.
<br>
To get element at a <b>null</b> index, use YAMLNull for index.
</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>
</table></div>
<b>Returns:</b><div class="pbr">Value corresponding to the index.
@ -371,7 +404,57 @@
not a collection.</div>
</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>
<dd><p>Set element at specified index in a collection.
</p>
@ -389,16 +472,19 @@
pair is added to the mapping. In sequences the index must be in
range. This ensures behavior siilar to D arrays and associative
arrays.
<br>
To set element at a <b>null</b> index, use YAMLNull for index.
</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>
</table></div>
<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>
</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>
<dd><p>Foreach over a sequence, getting each element as T.
</p>
@ -410,7 +496,7 @@
element could not be converted to specified type.</div>
</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>
<dd><p>Foreach over a mapping, getting each key/value as K/V.
</p>
@ -422,7 +508,7 @@
element could not be converted to specified type.</div>
</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>
<dd><p>Add an element to a sequence.
</p>
@ -439,12 +525,12 @@
emitted.</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>
</table></div>
</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>
<dd><p>Add a key-value pair to a mapping.
</p>
@ -461,33 +547,54 @@
<b>invalid</b> YAML with "!!map" and "!!omap" tags.</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>
<tr><td valign=top>value</td>
<tr><td valign=top>V value</td>
<td valign=top>Value to add.</td></tr>
</table></div>
</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>
<dd><p>Remove first (if any) occurence of a value in a collection.
</p>
<p>This method can only be called on collection nodes.
<br>
If the node is a sequence, the first node matching value (including
conversion, so e.g. "42" matches 42) is removed.
If the node is a sequence, the first node matching value is removed.
If the node is a mapping, the first key-value pair where value
matches specified value is removed.
</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>
</table></div>
<b>Throws:</b><div class="pbr">NodeException if the node is not a collection.</div>
</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>
<dd><p>Remove element at the specified index of a collection.
</p>
@ -498,7 +605,7 @@
<br>
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>
If the node is a mapping and no key matches index, nothing is removed
@ -506,14 +613,14 @@
and associative arrays.
</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>
</table></div>
<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>
</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>
<dd><p>Compare with another node.</p>

View file

@ -45,12 +45,12 @@
</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>
<dd><p>Exception thrown on Representer errors.</p>
</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>
<dd><p>Represents YAML nodes as scalar, sequence and mapping nodes ready for output.
</p>
@ -59,11 +59,11 @@
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>
<dd><p>Construct a Representer.
</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
for default YAML types? This can be
disabled to use custom representer
@ -71,17 +71,17 @@
</table></div>
</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>
<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>
<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>
<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>
<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>
<dd><p>Add a function to represent nodes with a specific data type.
</p>
@ -107,108 +107,109 @@
values - it is not const for compatibility reasons.
</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>
</table></div>
<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">int</span> x, y, z;
<span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<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_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>(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">return</span> 0;
}
}
<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_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>(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">return</span> 0;
}
}
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> <span class="d_keyword">auto</span> value = node.as!MyStruct;
<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 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);
}
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> <span class="d_keyword">auto</span> value = node.as!MyStruct;
<span class="d_comment">//Using custom scalar format, x:y: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> <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">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;
representer.<span class="d_psymbol">addRepresenter</span>!MyStruct(&amp;representMyStruct);
dumper.representer = representer;
dumper.dump(Node(MyStruct(1,2,3)));
}
<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> representer = <span class="d_keyword">new</span> Representer;
representer.<span class="d_psymbol">addRepresenter</span>!MyStruct(&amp;representMyStruct);
dumper.representer = representer;
dumper.dump(Node(MyStruct(1,2,3)));
}
</pre>
<br>
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">int</span> x, y, z;
<span class="d_keyword">class</span> MyClass
{
<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>.x = x;
<span class="d_keyword">this</span>.y = y;
<span class="d_keyword">this</span>.z = 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>.y = y;
<span class="d_keyword">this</span>.z = z;
}
<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_keyword">override</span> <span class="d_keyword">int</span> opCmp(Object 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>(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>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
<span class="d_keyword">return</span> 0;
}
<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_keyword">override</span> <span class="d_keyword">int</span> opCmp(Object 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>(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>(z != s.z){<span class="d_keyword">return</span> z - s.z;}
<span class="d_keyword">return</span> 0;
}
<span class="d_comment">///Useful for Node.as!string .
</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_comment">///Useful for Node.as!string .
</span> <span class="d_keyword">override</span> string toString()
{
<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> 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> <span class="d_keyword">auto</span> value = node.as!MyClass;
<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 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 class="d_comment">//Same as representMyStruct.
</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> <span class="d_keyword">auto</span> value = node.as!MyClass;
<span class="d_comment">//Using custom scalar format, x:y: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> <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">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;
representer.<span class="d_psymbol">addRepresenter</span>!MyClass(&amp;representMyClass);
dumper.representer = representer;
dumper.dump(Node(<span class="d_keyword">new</span> MyClass(1,2,3)));
}
<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> representer = <span class="d_keyword">new</span> Representer;
representer.<span class="d_psymbol">addRepresenter</span>!MyClass(&amp;representMyClass);
dumper.representer = representer;
dumper.dump(Node(<span class="d_keyword">new</span> MyClass(1,2,3)));
}
</pre>
</div>
</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>
<dd><p>Represent a scalar with specified tag.
</p>
@ -227,32 +228,32 @@
</div>
<p><b>Example:</b><br>
<pre class="d_code"> <span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<pre class="d_code"><span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<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_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>(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">return</span> 0;
}
}
<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_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>(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">return</span> 0;
}
}
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> <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">return</span> representer.<span class="d_psymbol">representScalar</span>(<span class="d_string">"!mystruct.tag"</span>, <span class="d_param">scalar</span>);
}
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> <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>);
}
</pre>
</p>
</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>
<dd><p>Represent a sequence with specified tag, representing children first.
</p>
@ -274,34 +275,34 @@
</div>
<p><b>Example:</b><br>
<pre class="d_code"> <span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<pre class="d_code"><span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<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_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>(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">return</span> 0;
}
}
<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_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>(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">return</span> 0;
}
}
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> nodes = [Node(value.x), Node(value.y), Node(value.z)];
<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,
CollectionStyle.Flow);
}
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> nodes = [Node(value.x), Node(value.y), Node(value.z)];
<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,
CollectionStyle.Flow);
}
</pre>
</p>
</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>
<dd><p>Represent a mapping with specified tag, representing children first.
</p>
@ -310,7 +311,7 @@
</p>
<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>
<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>
<tr><td valign=top>CollectionStyle <b>style</b></td>
<td valign=top>Style of the mapping. If invalid, default style will be used.
@ -323,76 +324,76 @@
</div>
<p><b>Example:</b><br>
<pre class="d_code"> <span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<pre class="d_code"><span class="d_keyword">struct</span> MyStruct
{
<span class="d_keyword">int</span> x, y, z;
<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_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>(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">return</span> 0;
}
}
<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_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>(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">return</span> 0;
}
}
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> <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">"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>);
}
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> <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">"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>);
}
</pre>
</p>
</dd>
</dl>
</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>
<dd><p>Represent a null node as a null YAML value.</p>
</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>
<dd><p>Represent a string node as a string scalar.</p>
</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>
<dd><p>Represent a bytes node as a binary scalar.</p>
</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>
<dd><p>Represent a bool node as a bool scalar.</p>
</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>
<dd><p>Represent a long node as an integer scalar.</p>
</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>
<dd><p>Represent a real node as a floating point scalar.</p>
</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>
<dd><p>Represent a SysTime node as a timestamp.</p>
</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>
<dd><p>Represent a sequence node as sequence/set.</p>
</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>
<dd><p>Represent a mapping node as map/ordered map/pairs.</p>

View file

@ -47,13 +47,13 @@
</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>
<dd><p>Resolves YAML tags (data types).
</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>
<dd><p>Construct a Resolver.
</p>
@ -61,12 +61,12 @@
you can use <b>defaultImplicitResolvers</b> to disable default resolvers.
</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>
</table></div>
</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>
<dd><p>Add an implicit scalar resolver.
</p>
@ -83,44 +83,44 @@
</p>
<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>
<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>
<tr><td valign=top>string <b>first</b></td>
<td valign=top>String of possible starting characters of the scalar.</td></tr>
</table></div>
<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">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();
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;
<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> 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>);
loader.resolver = resolver;
<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">//See Constructor API documentation and tutorial for more information.
<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">//See Constructor API documentation and tutorial for more information.
</span>
<span class="d_keyword">auto</span> node = loader.load();
}
<span class="d_keyword">auto</span> node = loader.load();
}
</pre>
</div>
</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>
<dd><p>Return default scalar tag.</p>
</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>
<dd><p>Return default sequence tag.</p>
</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>
<dd><p>Return default mapping tag.</p>

View file

@ -42,49 +42,49 @@
<!-- Generated by Ddoc from dyaml/style.d -->
<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>
<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>
<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>
<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>&gt; (<a name="Folded"></a><span class="ddoc_psymbol">Folded</span> block style)</p>
</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>
<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>
<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>
</dl>
</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>
<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>
<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>
<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>

View file

@ -39,7 +39,7 @@
<div id="content">
<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,

View file

@ -3,13 +3,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Differences between D:YAML and the YAML specification &mdash; D:YAML v0.4 documentation</title>
<title>Differences between D:YAML and the YAML specification &mdash; D:YAML 0.4 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
@ -22,7 +25,7 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.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" />
</head>
<body>
@ -32,7 +35,7 @@
<li class="right" style="margin-right: 10px">
<a href="../tutorials/yaml_syntax.html" title="YAML syntax"
accesskey="P">previous</a></li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
@ -133,13 +136,13 @@ struct appears in Phobos.</p>
<li class="right" style="margin-right: 10px">
<a href="../tutorials/yaml_syntax.html" title="YAML syntax"
>previous</a></li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
Last updated on Jan 23, 2012.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
Last updated on Dec 17, 2013.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>

View file

@ -3,13 +3,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to D:YAML documentation! &mdash; D:YAML v0.4 documentation</title>
<title>Welcome to D:YAML documentation! &mdash; D:YAML 0.4 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
@ -22,7 +25,7 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.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" />
</head>
<body>
@ -32,7 +35,7 @@
<li class="right" style="margin-right: 10px">
<a href="tutorials/getting_started.html" title="Getting started"
accesskey="N">next</a></li>
<li><a href="#">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="#">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
@ -99,13 +102,13 @@
<li class="right" style="margin-right: 10px">
<a href="tutorials/getting_started.html" title="Getting started"
>next</a></li>
<li><a href="#">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="#">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
Last updated on Jan 23, 2012.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
Last updated on Dec 17, 2013.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>

View file

@ -3,13 +3,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search &mdash; D:YAML v0.4 documentation</title>
<title>Search &mdash; D:YAML 0.4 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
@ -23,10 +26,12 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.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">
jQuery(function() { Search.loadIndex("searchindex.js"); });
</script>
<script type="text/javascript" id="searchindexloader"></script>
</head>
@ -34,7 +39,7 @@
<div class="related">
<h3>Navigation</h3>
<ul>
<li><a href="index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
@ -82,13 +87,13 @@
<div class="related">
<h3>Navigation</h3>
<ul>
<li><a href="index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
Last updated on Jan 23, 2012.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
Last updated on Dec 17, 2013.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -3,13 +3,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Custom YAML data types &mdash; D:YAML v0.4 documentation</title>
<title>Custom YAML data types &mdash; D:YAML 0.4 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
@ -22,7 +25,7 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.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="prev" title="Getting started" href="getting_started.html" />
</head>
@ -36,7 +39,7 @@
<li class="right" >
<a href="getting_started.html" title="Getting started"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
@ -369,13 +372,13 @@ directory of the D:YAML package.</p>
<li class="right" >
<a href="getting_started.html" title="Getting started"
>previous</a> |</li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
Last updated on Jan 23, 2012.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
Last updated on Dec 17, 2013.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>

View file

@ -3,13 +3,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting started &mdash; D:YAML v0.4 documentation</title>
<title>Getting started &mdash; D:YAML 0.4 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
@ -22,7 +25,7 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.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="prev" title="Welcome to D:YAML documentation!" href="../index.html" />
</head>
@ -36,7 +39,7 @@
<li class="right" >
<a href="../index.html" title="Welcome to D:YAML documentation!"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</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
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>
<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="p">{</span>
@ -124,8 +127,8 @@ into the file:</p>
</div>
<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>
<p>First, we import the <em>yaml</em> module. This is the only D:YAML module you need to
import - it automatically imports all needed modules.</p>
<p>First, we import the <em>dyaml.all</em> module. This is the only D:YAML module you
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
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
@ -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>
<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.
The import directory should be the D:YAML package directory. You can specify it
using the <tt class="docutils literal"><span class="pre">-I</span></tt> option of DMD. The library directory should point to the
compiled library. On Unix/Linux you can specify 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. On Windows, the import directory
is used as the library directory. To link with the library on Windows, just add
the path to it relative to the current directory.</p>
The import directory should be the <tt class="docutils literal"><span class="pre">source</span></tt> subdirectory of the D:YAML
directory. You can specify it using the <tt class="docutils literal"><span class="pre">-I</span></tt> option of DMD. The library
directory should point to the compiled library. On Unix/Linux you can specify
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.
On Windows, the import directory is used as the library directory. To link with
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
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>
<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>
<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>
<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>
@ -231,13 +235,13 @@ example in the <tt class="docutils literal"><span class="pre">example/getting_st
<li class="right" >
<a href="../index.html" title="Welcome to D:YAML documentation!"
>previous</a> |</li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
Last updated on Jan 23, 2012.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
Last updated on Dec 17, 2013.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>

View file

@ -3,13 +3,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>YAML syntax &mdash; D:YAML v0.4 documentation</title>
<title>YAML syntax &mdash; D:YAML 0.4 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
@ -22,7 +25,7 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.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="prev" title="Custom YAML data types" href="custom_types.html" />
</head>
@ -36,7 +39,7 @@
<li class="right" >
<a href="custom_types.html" title="Custom YAML data types"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
@ -253,36 +256,36 @@ Some of these might change in the future (especially !!map and !!set).</p>
<col width="42%" />
</colgroup>
<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>
</tr>
</thead>
<tbody valign="top">
<tr><td>!!null</td>
<tr class="row-even"><td>!!null</td>
<td>yaml.YAMLNull</td>
</tr>
<tr><td>!!bool</td>
<tr class="row-odd"><td>!!bool</td>
<td>bool</td>
</tr>
<tr><td>!!int</td>
<tr class="row-even"><td>!!int</td>
<td>long</td>
</tr>
<tr><td>!!float</td>
<tr class="row-odd"><td>!!float</td>
<td>real</td>
</tr>
<tr><td>!!binary</td>
<tr class="row-even"><td>!!binary</td>
<td>ubyte[]</td>
</tr>
<tr><td>!!timestamp</td>
<tr class="row-odd"><td>!!timestamp</td>
<td>datetime.SysTime</td>
</tr>
<tr><td>!!map, !!omap, !!pairs</td>
<tr class="row-even"><td>!!map, !!omap, !!pairs</td>
<td>Node.Pair[]</td>
</tr>
<tr><td>!!seq, !!set</td>
<tr class="row-odd"><td>!!seq, !!set</td>
<td>Node[]</td>
</tr>
<tr><td>!!str</td>
<tr class="row-even"><td>!!str</td>
<td>string</td>
</tr>
</tbody>
@ -325,13 +328,13 @@ Some of these might change in the future (especially !!map and !!set).</p>
<li class="right" >
<a href="custom_types.html" title="Custom YAML data types"
>previous</a> |</li>
<li><a href="../index.html">D:YAML v0.4 documentation</a> &raquo;</li>
<li><a href="../index.html">D:YAML 0.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
Last updated on Jan 23, 2012.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
Last updated on Dec 17, 2013.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>