xref: /minix3/external/bsd/kyua-cli/dist/utils/config/nodes.ipp (revision 11be35a165022172ed3cea20f2b5df0307540b0e)
1*11be35a1SLionel Sambuc// Copyright 2012 Google Inc.
2*11be35a1SLionel Sambuc// All rights reserved.
3*11be35a1SLionel Sambuc//
4*11be35a1SLionel Sambuc// Redistribution and use in source and binary forms, with or without
5*11be35a1SLionel Sambuc// modification, are permitted provided that the following conditions are
6*11be35a1SLionel Sambuc// met:
7*11be35a1SLionel Sambuc//
8*11be35a1SLionel Sambuc// * Redistributions of source code must retain the above copyright
9*11be35a1SLionel Sambuc//   notice, this list of conditions and the following disclaimer.
10*11be35a1SLionel Sambuc// * Redistributions in binary form must reproduce the above copyright
11*11be35a1SLionel Sambuc//   notice, this list of conditions and the following disclaimer in the
12*11be35a1SLionel Sambuc//   documentation and/or other materials provided with the distribution.
13*11be35a1SLionel Sambuc// * Neither the name of Google Inc. nor the names of its contributors
14*11be35a1SLionel Sambuc//   may be used to endorse or promote products derived from this software
15*11be35a1SLionel Sambuc//   without specific prior written permission.
16*11be35a1SLionel Sambuc//
17*11be35a1SLionel Sambuc// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18*11be35a1SLionel Sambuc// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*11be35a1SLionel Sambuc// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20*11be35a1SLionel Sambuc// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21*11be35a1SLionel Sambuc// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22*11be35a1SLionel Sambuc// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23*11be35a1SLionel Sambuc// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*11be35a1SLionel Sambuc// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*11be35a1SLionel Sambuc// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*11be35a1SLionel Sambuc// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27*11be35a1SLionel Sambuc// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*11be35a1SLionel Sambuc
29*11be35a1SLionel Sambuc#include "utils/config/nodes.hpp"
30*11be35a1SLionel Sambuc
31*11be35a1SLionel Sambuc#if !defined(UTILS_CONFIG_NODES_IPP)
32*11be35a1SLionel Sambuc#define UTILS_CONFIG_NODES_IPP
33*11be35a1SLionel Sambuc
34*11be35a1SLionel Sambuc#include <memory>
35*11be35a1SLionel Sambuc#include <typeinfo>
36*11be35a1SLionel Sambuc
37*11be35a1SLionel Sambuc#include "utils/config/exceptions.hpp"
38*11be35a1SLionel Sambuc#include "utils/defs.hpp"
39*11be35a1SLionel Sambuc#include "utils/format/macros.hpp"
40*11be35a1SLionel Sambuc#include "utils/optional.ipp"
41*11be35a1SLionel Sambuc#include "utils/text/exceptions.hpp"
42*11be35a1SLionel Sambuc#include "utils/text/operations.ipp"
43*11be35a1SLionel Sambuc#include "utils/sanity.hpp"
44*11be35a1SLionel Sambuc
45*11be35a1SLionel Sambucnamespace utils {
46*11be35a1SLionel Sambuc
47*11be35a1SLionel Sambuc
48*11be35a1SLionel Sambucnamespace config {
49*11be35a1SLionel Sambucnamespace detail {
50*11be35a1SLionel Sambuc
51*11be35a1SLionel Sambuc
52*11be35a1SLionel Sambuc/// Type of the new_node() family of functions.
53*11be35a1SLionel Sambuctypedef base_node* (*new_node_hook)(void);
54*11be35a1SLionel Sambuc
55*11be35a1SLionel Sambuc
56*11be35a1SLionel Sambuc/// Creates a new leaf node of a given type.
57*11be35a1SLionel Sambuc///
58*11be35a1SLionel Sambuc/// \tparam NodeType The type of the leaf node to create.
59*11be35a1SLionel Sambuc///
60*11be35a1SLionel Sambuc/// \return A pointer to the newly-created node.
61*11be35a1SLionel Sambuctemplate< class NodeType >
62*11be35a1SLionel Sambucbase_node*
63*11be35a1SLionel Sambucnew_node(void)
64*11be35a1SLionel Sambuc{
65*11be35a1SLionel Sambuc    return new NodeType();
66*11be35a1SLionel Sambuc}
67*11be35a1SLionel Sambuc
68*11be35a1SLionel Sambuc
69*11be35a1SLionel Sambuc/// Internal node of the tree.
70*11be35a1SLionel Sambuc///
71*11be35a1SLionel Sambuc/// This abstract base class provides the mechanism to implement both static and
72*11be35a1SLionel Sambuc/// dynamic nodes.  Ideally, the implementation would be split in subclasses and
73*11be35a1SLionel Sambuc/// this class would not include the knowledge of whether the node is dynamic or
74*11be35a1SLionel Sambuc/// not.  However, because the static/dynamic difference depends on the leaf
75*11be35a1SLionel Sambuc/// types, we need to declare template functions and these cannot be virtual.
76*11be35a1SLionel Sambucclass inner_node : public base_node {
77*11be35a1SLionel Sambuc    /// Whether the node is dynamic or not.
78*11be35a1SLionel Sambuc    bool _dynamic;
79*11be35a1SLionel Sambuc
80*11be35a1SLionel Sambucprotected:
81*11be35a1SLionel Sambuc    /// Type to represent the collection of children of this node.
82*11be35a1SLionel Sambuc    ///
83*11be35a1SLionel Sambuc    /// Note that these are one-level keys.  They cannot contain dots, and thus
84*11be35a1SLionel Sambuc    /// is why we use a string rather than a tree_key.
85*11be35a1SLionel Sambuc    typedef std::map< std::string, base_node* > children_map;
86*11be35a1SLionel Sambuc
87*11be35a1SLionel Sambuc    /// Mapping of keys to values that are descendants of this node.
88*11be35a1SLionel Sambuc    children_map _children;
89*11be35a1SLionel Sambuc
90*11be35a1SLionel Sambuc    void copy_into(inner_node* new_node) const;
91*11be35a1SLionel Sambuc
92*11be35a1SLionel Sambucpublic:
93*11be35a1SLionel Sambuc    inner_node(const bool);
94*11be35a1SLionel Sambuc    virtual ~inner_node(void) = 0;
95*11be35a1SLionel Sambuc
96*11be35a1SLionel Sambuc    const base_node* lookup_ro(const tree_key&,
97*11be35a1SLionel Sambuc                               const tree_key::size_type) const;
98*11be35a1SLionel Sambuc    leaf_node* lookup_rw(const tree_key&, const tree_key::size_type,
99*11be35a1SLionel Sambuc                         new_node_hook);
100*11be35a1SLionel Sambuc
101*11be35a1SLionel Sambuc    void all_properties(properties_map&, const tree_key&) const;
102*11be35a1SLionel Sambuc};
103*11be35a1SLionel Sambuc
104*11be35a1SLionel Sambuc
105*11be35a1SLionel Sambuc/// Static internal node of the tree.
106*11be35a1SLionel Sambuc///
107*11be35a1SLionel Sambuc/// The direct children of this node must be pre-defined by calls to define().
108*11be35a1SLionel Sambuc/// Attempts to traverse this node and resolve a key that is not a pre-defined
109*11be35a1SLionel Sambuc/// children will result in an "unknown key" error.
110*11be35a1SLionel Sambucclass static_inner_node : public config::detail::inner_node {
111*11be35a1SLionel Sambucpublic:
112*11be35a1SLionel Sambuc    static_inner_node(void);
113*11be35a1SLionel Sambuc
114*11be35a1SLionel Sambuc    virtual base_node* deep_copy(void) const;
115*11be35a1SLionel Sambuc
116*11be35a1SLionel Sambuc    void define(const tree_key&, const tree_key::size_type, new_node_hook);
117*11be35a1SLionel Sambuc};
118*11be35a1SLionel Sambuc
119*11be35a1SLionel Sambuc
120*11be35a1SLionel Sambuc/// Dynamic internal node of the tree.
121*11be35a1SLionel Sambuc///
122*11be35a1SLionel Sambuc/// The children of this node need not be pre-defined.  Attempts to traverse
123*11be35a1SLionel Sambuc/// this node and resolve a key will result in such key being created.  Any
124*11be35a1SLionel Sambuc/// intermediate non-existent nodes of the traversal will be created as dynamic
125*11be35a1SLionel Sambuc/// inner nodes as well.
126*11be35a1SLionel Sambucclass dynamic_inner_node : public config::detail::inner_node {
127*11be35a1SLionel Sambucpublic:
128*11be35a1SLionel Sambuc    virtual base_node* deep_copy(void) const;
129*11be35a1SLionel Sambuc
130*11be35a1SLionel Sambuc    dynamic_inner_node(void);
131*11be35a1SLionel Sambuc};
132*11be35a1SLionel Sambuc
133*11be35a1SLionel Sambuc
134*11be35a1SLionel Sambuc}  // namespace detail
135*11be35a1SLionel Sambuc}  // namespace config
136*11be35a1SLionel Sambuc
137*11be35a1SLionel Sambuc
138*11be35a1SLionel Sambuc/// Constructor for a node with an undefined value.
139*11be35a1SLionel Sambuc///
140*11be35a1SLionel Sambuc/// This should only be called by the tree's define() method as a way to
141*11be35a1SLionel Sambuc/// register a node as known but undefined.  The node will then serve as a
142*11be35a1SLionel Sambuc/// placeholder for future values.
143*11be35a1SLionel Sambuctemplate< typename ValueType >
144*11be35a1SLionel Sambucconfig::typed_leaf_node< ValueType >::typed_leaf_node(void) :
145*11be35a1SLionel Sambuc    _value(none)
146*11be35a1SLionel Sambuc{
147*11be35a1SLionel Sambuc}
148*11be35a1SLionel Sambuc
149*11be35a1SLionel Sambuc
150*11be35a1SLionel Sambuc/// Checks whether the node has been set.
151*11be35a1SLionel Sambuc///
152*11be35a1SLionel Sambuc/// Remember that a node can exist before holding a value (i.e. when the node
153*11be35a1SLionel Sambuc/// has been defined as "known" but not yet set by the user).  This function
154*11be35a1SLionel Sambuc/// checks whether the node laready holds a value.
155*11be35a1SLionel Sambuc///
156*11be35a1SLionel Sambuc/// \return True if a value has been set in the node.
157*11be35a1SLionel Sambuctemplate< typename ValueType >
158*11be35a1SLionel Sambucbool
159*11be35a1SLionel Sambucconfig::typed_leaf_node< ValueType >::is_set(void) const
160*11be35a1SLionel Sambuc{
161*11be35a1SLionel Sambuc    return static_cast< bool >(_value);
162*11be35a1SLionel Sambuc}
163*11be35a1SLionel Sambuc
164*11be35a1SLionel Sambuc
165*11be35a1SLionel Sambuc/// Gets the value stored in the node.
166*11be35a1SLionel Sambuc///
167*11be35a1SLionel Sambuc/// \pre The node must have a value.
168*11be35a1SLionel Sambuc///
169*11be35a1SLionel Sambuc/// \return The value in the node.
170*11be35a1SLionel Sambuctemplate< typename ValueType >
171*11be35a1SLionel Sambucconst typename config::typed_leaf_node< ValueType >::value_type&
172*11be35a1SLionel Sambucconfig::typed_leaf_node< ValueType >::value(void) const
173*11be35a1SLionel Sambuc{
174*11be35a1SLionel Sambuc    PRE(is_set());
175*11be35a1SLionel Sambuc    return _value.get();
176*11be35a1SLionel Sambuc}
177*11be35a1SLionel Sambuc
178*11be35a1SLionel Sambuc
179*11be35a1SLionel Sambuc/// Gets the read-write value stored in the node.
180*11be35a1SLionel Sambuc///
181*11be35a1SLionel Sambuc/// \pre The node must have a value.
182*11be35a1SLionel Sambuc///
183*11be35a1SLionel Sambuc/// \return The value in the node.
184*11be35a1SLionel Sambuctemplate< typename ValueType >
185*11be35a1SLionel Sambuctypename config::typed_leaf_node< ValueType >::value_type&
186*11be35a1SLionel Sambucconfig::typed_leaf_node< ValueType >::value(void)
187*11be35a1SLionel Sambuc{
188*11be35a1SLionel Sambuc    PRE(is_set());
189*11be35a1SLionel Sambuc    return _value.get();
190*11be35a1SLionel Sambuc}
191*11be35a1SLionel Sambuc
192*11be35a1SLionel Sambuc
193*11be35a1SLionel Sambuc/// Sets the value of the node.
194*11be35a1SLionel Sambuc///
195*11be35a1SLionel Sambuc/// \param value_ The new value to set the node to.
196*11be35a1SLionel Sambuc///
197*11be35a1SLionel Sambuc/// \throw value_error If the value is invalid, according to validate().
198*11be35a1SLionel Sambuctemplate< typename ValueType >
199*11be35a1SLionel Sambucvoid
200*11be35a1SLionel Sambucconfig::typed_leaf_node< ValueType >::set(const value_type& value_)
201*11be35a1SLionel Sambuc{
202*11be35a1SLionel Sambuc    validate(value_);
203*11be35a1SLionel Sambuc    _value = optional< value_type >(value_);
204*11be35a1SLionel Sambuc}
205*11be35a1SLionel Sambuc
206*11be35a1SLionel Sambuc
207*11be35a1SLionel Sambuc/// Checks a given value for validity.
208*11be35a1SLionel Sambuc///
209*11be35a1SLionel Sambuc/// This is called internally by the node right before updating the recorded
210*11be35a1SLionel Sambuc/// value.  This method can be redefined by subclasses.
211*11be35a1SLionel Sambuc///
212*11be35a1SLionel Sambuc/// \param unused_new_value The value to validate.
213*11be35a1SLionel Sambuc///
214*11be35a1SLionel Sambuc/// \throw value_error If the value is not valid.
215*11be35a1SLionel Sambuctemplate< typename ValueType >
216*11be35a1SLionel Sambucvoid
217*11be35a1SLionel Sambucconfig::typed_leaf_node< ValueType >::validate(
218*11be35a1SLionel Sambuc    const value_type& UTILS_UNUSED_PARAM(new_value)) const
219*11be35a1SLionel Sambuc{
220*11be35a1SLionel Sambuc}
221*11be35a1SLionel Sambuc
222*11be35a1SLionel Sambuc
223*11be35a1SLionel Sambuc/// Sets the value of the node from a raw string representation.
224*11be35a1SLionel Sambuc///
225*11be35a1SLionel Sambuc/// \param raw_value The value to set the node to.
226*11be35a1SLionel Sambuc///
227*11be35a1SLionel Sambuc/// \throw value_error If the value is invalid.
228*11be35a1SLionel Sambuctemplate< typename ValueType >
229*11be35a1SLionel Sambucvoid
230*11be35a1SLionel Sambucconfig::native_leaf_node< ValueType >::set_string(const std::string& raw_value)
231*11be35a1SLionel Sambuc{
232*11be35a1SLionel Sambuc    try {
233*11be35a1SLionel Sambuc        typed_leaf_node< ValueType >::set(text::to_type< ValueType >(
234*11be35a1SLionel Sambuc            raw_value));
235*11be35a1SLionel Sambuc    } catch (const text::value_error& e) {
236*11be35a1SLionel Sambuc        throw config::value_error(F("Failed to convert string value '%s' to "
237*11be35a1SLionel Sambuc                                    "the node's type") % raw_value);
238*11be35a1SLionel Sambuc    }
239*11be35a1SLionel Sambuc}
240*11be35a1SLionel Sambuc
241*11be35a1SLionel Sambuc
242*11be35a1SLionel Sambuc/// Converts the contents of the node to a string.
243*11be35a1SLionel Sambuc///
244*11be35a1SLionel Sambuc/// \pre The node must have a value.
245*11be35a1SLionel Sambuc///
246*11be35a1SLionel Sambuc/// \return A string representation of the value held by the node.
247*11be35a1SLionel Sambuctemplate< typename ValueType >
248*11be35a1SLionel Sambucstd::string
249*11be35a1SLionel Sambucconfig::native_leaf_node< ValueType >::to_string(void) const
250*11be35a1SLionel Sambuc{
251*11be35a1SLionel Sambuc    PRE(typed_leaf_node< ValueType >::is_set());
252*11be35a1SLionel Sambuc    return F("%s") % typed_leaf_node< ValueType >::value();
253*11be35a1SLionel Sambuc}
254*11be35a1SLionel Sambuc
255*11be35a1SLionel Sambuc
256*11be35a1SLionel Sambuc/// Constructor for a node with an undefined value.
257*11be35a1SLionel Sambuc///
258*11be35a1SLionel Sambuc/// This should only be called by the tree's define() method as a way to
259*11be35a1SLionel Sambuc/// register a node as known but undefined.  The node will then serve as a
260*11be35a1SLionel Sambuc/// placeholder for future values.
261*11be35a1SLionel Sambuctemplate< typename ValueType >
262*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::base_set_node(void) :
263*11be35a1SLionel Sambuc    _value(none)
264*11be35a1SLionel Sambuc{
265*11be35a1SLionel Sambuc}
266*11be35a1SLionel Sambuc
267*11be35a1SLionel Sambuc
268*11be35a1SLionel Sambuc/// Checks whether the node has been set.
269*11be35a1SLionel Sambuc///
270*11be35a1SLionel Sambuc/// Remember that a node can exist before holding a value (i.e. when the node
271*11be35a1SLionel Sambuc/// has been defined as "known" but not yet set by the user).  This function
272*11be35a1SLionel Sambuc/// checks whether the node laready holds a value.
273*11be35a1SLionel Sambuc///
274*11be35a1SLionel Sambuc/// \return True if a value has been set in the node.
275*11be35a1SLionel Sambuctemplate< typename ValueType >
276*11be35a1SLionel Sambucbool
277*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::is_set(void) const
278*11be35a1SLionel Sambuc{
279*11be35a1SLionel Sambuc    return static_cast< bool >(_value);
280*11be35a1SLionel Sambuc}
281*11be35a1SLionel Sambuc
282*11be35a1SLionel Sambuc
283*11be35a1SLionel Sambuc/// Gets the value stored in the node.
284*11be35a1SLionel Sambuc///
285*11be35a1SLionel Sambuc/// \pre The node must have a value.
286*11be35a1SLionel Sambuc///
287*11be35a1SLionel Sambuc/// \return The value in the node.
288*11be35a1SLionel Sambuctemplate< typename ValueType >
289*11be35a1SLionel Sambucconst typename config::base_set_node< ValueType >::value_type&
290*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::value(void) const
291*11be35a1SLionel Sambuc{
292*11be35a1SLionel Sambuc    PRE(is_set());
293*11be35a1SLionel Sambuc    return _value.get();
294*11be35a1SLionel Sambuc}
295*11be35a1SLionel Sambuc
296*11be35a1SLionel Sambuc
297*11be35a1SLionel Sambuc/// Gets the read-write value stored in the node.
298*11be35a1SLionel Sambuc///
299*11be35a1SLionel Sambuc/// \pre The node must have a value.
300*11be35a1SLionel Sambuc///
301*11be35a1SLionel Sambuc/// \return The value in the node.
302*11be35a1SLionel Sambuctemplate< typename ValueType >
303*11be35a1SLionel Sambuctypename config::base_set_node< ValueType >::value_type&
304*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::value(void)
305*11be35a1SLionel Sambuc{
306*11be35a1SLionel Sambuc    PRE(is_set());
307*11be35a1SLionel Sambuc    return _value.get();
308*11be35a1SLionel Sambuc}
309*11be35a1SLionel Sambuc
310*11be35a1SLionel Sambuc
311*11be35a1SLionel Sambuc/// Sets the value of the node.
312*11be35a1SLionel Sambuc///
313*11be35a1SLionel Sambuc/// \param value_ The new value to set the node to.
314*11be35a1SLionel Sambuc///
315*11be35a1SLionel Sambuc/// \throw value_error If the value is invalid, according to validate().
316*11be35a1SLionel Sambuctemplate< typename ValueType >
317*11be35a1SLionel Sambucvoid
318*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::set(const value_type& value_)
319*11be35a1SLionel Sambuc{
320*11be35a1SLionel Sambuc    validate(value_);
321*11be35a1SLionel Sambuc    _value = optional< value_type >(value_);
322*11be35a1SLionel Sambuc}
323*11be35a1SLionel Sambuc
324*11be35a1SLionel Sambuc
325*11be35a1SLionel Sambuc/// Sets the value of the node from a raw string representation.
326*11be35a1SLionel Sambuc///
327*11be35a1SLionel Sambuc/// \param raw_value The value to set the node to.
328*11be35a1SLionel Sambuc///
329*11be35a1SLionel Sambuc/// \throw value_error If the value is invalid.
330*11be35a1SLionel Sambuctemplate< typename ValueType >
331*11be35a1SLionel Sambucvoid
332*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::set_string(const std::string& raw_value)
333*11be35a1SLionel Sambuc{
334*11be35a1SLionel Sambuc    std::set< ValueType > new_value;
335*11be35a1SLionel Sambuc
336*11be35a1SLionel Sambuc    const std::vector< std::string > words = text::split(raw_value, ' ');
337*11be35a1SLionel Sambuc    for (std::vector< std::string >::const_iterator iter = words.begin();
338*11be35a1SLionel Sambuc         iter != words.end(); ++iter) {
339*11be35a1SLionel Sambuc        if (!(*iter).empty())
340*11be35a1SLionel Sambuc            new_value.insert(parse_one(*iter));
341*11be35a1SLionel Sambuc    }
342*11be35a1SLionel Sambuc
343*11be35a1SLionel Sambuc    set(new_value);
344*11be35a1SLionel Sambuc}
345*11be35a1SLionel Sambuc
346*11be35a1SLionel Sambuc
347*11be35a1SLionel Sambuc/// Converts the contents of the node to a string.
348*11be35a1SLionel Sambuc///
349*11be35a1SLionel Sambuc/// \pre The node must have a value.
350*11be35a1SLionel Sambuc///
351*11be35a1SLionel Sambuc/// \return A string representation of the value held by the node.
352*11be35a1SLionel Sambuctemplate< typename ValueType >
353*11be35a1SLionel Sambucstd::string
354*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::to_string(void) const
355*11be35a1SLionel Sambuc{
356*11be35a1SLionel Sambuc    PRE(is_set());
357*11be35a1SLionel Sambuc    return text::join(_value.get(), " ");
358*11be35a1SLionel Sambuc}
359*11be35a1SLionel Sambuc
360*11be35a1SLionel Sambuc
361*11be35a1SLionel Sambuc/// Pushes the node's value onto the Lua stack.
362*11be35a1SLionel Sambuc///
363*11be35a1SLionel Sambuc/// \param unused_state The Lua state onto which to push the value.
364*11be35a1SLionel Sambuctemplate< typename ValueType >
365*11be35a1SLionel Sambucvoid
366*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::push_lua(
367*11be35a1SLionel Sambuc    lutok::state& UTILS_UNUSED_PARAM(state)) const
368*11be35a1SLionel Sambuc{
369*11be35a1SLionel Sambuc    UNREACHABLE;
370*11be35a1SLionel Sambuc}
371*11be35a1SLionel Sambuc
372*11be35a1SLionel Sambuc
373*11be35a1SLionel Sambuc/// Sets the value of the node from an entry in the Lua stack.
374*11be35a1SLionel Sambuc///
375*11be35a1SLionel Sambuc/// \param unused_state The Lua state from which to get the value.
376*11be35a1SLionel Sambuc/// \param unused_value_index The stack index in which the value resides.
377*11be35a1SLionel Sambuc///
378*11be35a1SLionel Sambuc/// \throw value_error If the value in state(value_index) cannot be
379*11be35a1SLionel Sambuc///     processed by this node.
380*11be35a1SLionel Sambuctemplate< typename ValueType >
381*11be35a1SLionel Sambucvoid
382*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::set_lua(
383*11be35a1SLionel Sambuc    lutok::state& UTILS_UNUSED_PARAM(state),
384*11be35a1SLionel Sambuc    const int UTILS_UNUSED_PARAM(value_index))
385*11be35a1SLionel Sambuc{
386*11be35a1SLionel Sambuc    UNREACHABLE;
387*11be35a1SLionel Sambuc}
388*11be35a1SLionel Sambuc
389*11be35a1SLionel Sambuc
390*11be35a1SLionel Sambuc/// Checks a given value for validity.
391*11be35a1SLionel Sambuc///
392*11be35a1SLionel Sambuc/// This is called internally by the node right before updating the recorded
393*11be35a1SLionel Sambuc/// value.  This method can be redefined by subclasses.
394*11be35a1SLionel Sambuc///
395*11be35a1SLionel Sambuc/// \param unused_new_value The value to validate.
396*11be35a1SLionel Sambuc///
397*11be35a1SLionel Sambuc/// \throw value_error If the value is not valid.
398*11be35a1SLionel Sambuctemplate< typename ValueType >
399*11be35a1SLionel Sambucvoid
400*11be35a1SLionel Sambucconfig::base_set_node< ValueType >::validate(
401*11be35a1SLionel Sambuc    const value_type& UTILS_UNUSED_PARAM(new_value)) const
402*11be35a1SLionel Sambuc{
403*11be35a1SLionel Sambuc}
404*11be35a1SLionel Sambuc
405*11be35a1SLionel Sambuc
406*11be35a1SLionel Sambuc}  // namespace utils
407*11be35a1SLionel Sambuc
408*11be35a1SLionel Sambuc#endif  // !defined(UTILS_CONFIG_NODES_IPP)
409