Revision 5b94fd2c12712e04345d4b130358afbb352f6436 authored by vthierry on 28 October 2025, 18:54:37 UTC, committed by vthierry on 28 October 2025, 18:54:37 UTC
1 parent 4ad30c1
FValue.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>FValue - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<input type="text" id="nav-search" placeholder="Search" />
<h2><a href="index.html">Home</a></h2><h3>Objects</h3><ul><li><a href="FValue.html">FValue</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="FValue.html#set">set</a></li></ul></li><li><a href="LValue.html">LValue</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="LValue.html#getTurtoise">getTurtoise</a></li><li data-type='method' style='display: none;'><a href="LValue.html#setTurtoise">setTurtoise</a></li><li data-type='method' style='display: none;'><a href="LValue.html#deduce">deduce</a></li><li data-type='method' style='display: none;'><a href="LValue.html#.readTriples">readTriples</a></li></ul></li><li><a href="Value.html">Value</a><ul class='members'><li data-type='member' style='display: none;'><a href="Value.html#.EMPTY">EMPTY</a></li></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Value.html#asString">asString</a></li><li data-type='method' style='display: none;'><a href="Value.html#isEmpty">isEmpty</a></li><li data-type='method' style='display: none;'><a href="Value.html#isRecord">isRecord</a></li><li data-type='method' style='display: none;'><a href="Value.html#isArray">isArray</a></li><li data-type='method' style='display: none;'><a href="Value.html#isMember">isMember</a></li><li data-type='method' style='display: none;'><a href="Value.html#length">length</a></li><li data-type='method' style='display: none;'><a href="Value.html#count">count</a></li><li data-type='method' style='display: none;'><a href="Value.html#getNames">getNames</a></li><li data-type='method' style='display: none;'><a href="Value.html#size">size</a></li><li data-type='method' style='display: none;'><a href="Value.html#get">get</a></li><li data-type='method' style='display: none;'><a href="Value.html#at">at</a></li><li data-type='method' style='display: none;'><a href="Value.html#aget">aget</a></li><li data-type='method' style='display: none;'><a href="Value.html#set">set</a></li><li data-type='method' style='display: none;'><a href="Value.html#add">add</a></li><li data-type='method' style='display: none;'><a href="Value.html#copy">copy</a></li><li data-type='method' style='display: none;'><a href="Value.html#erase">erase</a></li><li data-type='method' style='display: none;'><a href="Value.html#rename">rename</a></li><li data-type='method' style='display: none;'><a href="Value.html#clear">clear</a></li><li data-type='method' style='display: none;'><a href="Value.html#sort">sort</a></li><li data-type='method' style='display: none;'><a href="Value.html#sortNames">sortNames</a></li><li data-type='method' style='display: none;'><a href="Value.html#equals">equals</a></li></ul></li><li><a href="WJSONReader.html">WJSONReader</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="WJSONReader.html#.read">read</a></li></ul></li><li><a href="WJSONWriter.html">WJSONWriter</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="WJSONWriter.html#.write">write</a></li></ul></li><li><a href="wJSON.html">wJSON</a><ul class='methods'><li data-type='method' style='display: none;'><a href="wJSON.html#.parse">parse</a></li><li data-type='method' style='display: none;'><a href="wJSON.html#.stringify">stringify</a></li><li data-type='method' style='display: none;'><a href="wJSON.html#.wjson2json">wjson2json</a></li><li data-type='method' style='display: none;'><a href="wJSON.html#.wjson2wjson">wjson2wjson</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#quote">quote</a></li><li><a href="global.html#string2json">string2json</a></li><li><a href="global.html#array2vector">array2vector</a></li><li><a href="global.html#run_protege">run_protege</a></li><li><a href="global.html#ttl2n3">ttl2n3</a></li><li><a href="global.html#wjson2html">wjson2html</a></li><li><a href="global.html#wjson2json">wjson2json</a></li><li><a href="global.html#wjson2wjson">wjson2wjson</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">FValue</h1>
<section>
<header>
<h2>
FValue
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="FValue"><span class="type-signature"></span>new FValue<span class="signature">(value<span class="signature-attributes">opt</span>, parse<span class="signature-attributes">opt</span>, sort_names<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>Implements a minimal C/C++ <a href="https://www.json.org">JSON</a> dynamic data structure.</p>
<h4>Extends: <a href='./Value.html'>Value</a>, with all public methods available.</h4>
<ul>
<li>Such a FValue has the capability to define computed attributes.</li>
<li>Value functions, beyond <a href="./Value.html">Value</a> functions
<ul>
<li>Element access:
<ul>
<li><a href="./Value.html#at"><code>value.at(name)</code></a> allows to access a static or computed value.</li>
</ul>
</li>
<li>Modifiers:
<ul>
<li><a href="#set"><code>value.set(name, Value& (*getter)(const Value&))</code></a> allows to define a value calculation via a function.</li>
</ul>
</li>
</ul>
</li>
</ul></li></ul></dd>
</dl>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">bool</span>
|
<span class="param-type">int</span>
|
<span class="param-type">uint</span>
|
<span class="param-type">double</span>
|
<span class="param-type">float</span>
|
<span class="param-type">JSON</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>The initial value.</p></td>
</tr>
<tr>
<td class="name"><code>parse</code></td>
<td class="type">
<span class="param-type">bool</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>For a string value, if true parses the string, else only copy it.</p></td>
</tr>
<tr>
<td class="name"><code>sort_names</code></td>
<td class="type">
<span class="param-type">bool</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>For a parsed string value, if true sorts the names in alphabetic order, as performed by Value::sortNames().</p></td>
</tr>
</tbody>
</table>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="set"><span class="type-signature"></span>set<span class="signature">(name, getter, cache<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="Value.html">Value</a>}</span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>Sets the calculation of a given field of this structure.</p>
<ul>
<li>Setting a value:</li>
</ul>
<pre class="prettyprint source"><code>// Defines calculations for a given field
class DynamicFields {
public:
static wjson::Value sqrt_x(const wjson::Value& value) {
return (int) sqrt(value.get("x", 0));
}
};
// Sets sqrt_x as a dynamic calculated field
fvalue.set("sqrt_x", DynamicFields::sqrt_x);
// Gets the calculation result
double sqrt_x = fvalue.get("sqrt_x", 0);
</code></pre></li></ul></dd>
</dl>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The field name</p></td>
</tr>
<tr>
<td class="name"><code>getter</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>A static method of type <code>wjson::Value (*getter)(const wjson::Value&)</code>.</p></td>
</tr>
<tr>
<td class="name"><code>cache</code></td>
<td class="type">
<span class="param-type">bool</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>true</code>
</td>
<td class="description last"><p>If true, memorizes the last calculated value in the static <code>Value</code> data structure</p></td>
</tr>
</tbody>
</table>
<h5 class="h5-returns">Returns:</h5>
<div class="param-desc">
<p>This value allowing to chain set methods.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Value.html">Value</a></span>
</dd>
</dl>
</article>
</section>
</div>
<br class="clear">
<footer>
<div style='float: right;font-style: italic;'>2025-10-28 version.</div>
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/search.js" defer></script>
<script src="scripts/collapse.js" defer></script>
</body>
</html>
Computing file changes ...