    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: DynamicAny, Part I</title>
        <link>http://accu.org/index.php/journals/1502</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">Overload Journal #86 - August 2008 + Programming Topics + Design of applications and programs</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="http://accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="http://accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="http://accu.org/index.php/journals/c78/">Overload</a>

                     &gt;                         <a href="http://accu.org/index.php/journals/c243/">86</a>
                    (7)
<br />

                                            <a href="http://accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="http://accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="http://accu.org/index.php/journals/c65/">Programming</a>
                    (488)
<br />

                                            <a href="http://accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="http://accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="http://accu.org/index.php/journals/c67/">Design</a>
                    (168)
<br />

                                            <a href="http://accu.org/index.php/journals/c243-65-67/">Any of these categories</a>

                    -                        <a href="http://accu.org/index.php/journals/c243+65+67/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;DynamicAny, Part I</h1>
<p><strong>Author:</strong>&nbsp;webeditor</p>
<p>
<strong>Date:</strong> 17 August 2008 09:59:00 +01:00 or Sun, 17 August 2008 09:59:00 +01:00</p>
<p><strong>Summary:</strong>&nbsp;Alex Fabijanic presents a class hierarchy providing dynamic typing in standard C++.</p>
<p><strong>Body:</strong>&nbsp;<p>Dynamic and static typing are competing forces acting upon the programming languages domain. The strong typing system, such as the one in C++ can be a bulletproof vest or a straitjacket, depending on the context. While C++ strong static typing is well-justified and useful, sometimes it is convenient or even necessary to circumvent it. Over time, various ways around it have been devised, on both high and low ends of the abstraction spectrum<sup><a href="#footnote1">1</a></sup>. Additionally, standard C++ offers dynamic and static polymorphism.
  </p><p>
    Dynamic languages have no notion of variable type. Values have type, while variables are type-agnostic. Hence, the type of a variable can change during its lifetime, depending on the value assigned to it. Clearly, in addition to static type-safety loss, there is also a performance penalty associated with this convenience. There are, however, scenarios where a relaxed, dynamic type system is a desirable feature, even in a statically typed language like C++. An example that comes in mind first is a retrieval of structured data from an external source. Typically, the data will arrive in a variety of types. In a statically typed world, this implies the requirement of knowing the exact data types at compilation time. Additionally, every time the data types or layout changes, the code must change as well. A way around this obstacle is through dynamic typing support.
  </p><p>
    This article describes the approach taken by the C++ Portable Components [<a href="#POCOa">POCOa</a>] framework ('POCO' in further text) to implement safe and efficient dynamic typing capabilities within the confines of standard C++.
  </p><h2>
    Any
  </h2><p>
    Boost Libraries [<a href="#Boost">Boost</a>] contain multiple classes meant to alleviate the pains associated with static typing. Our focus here is on <tt class="code">boost::any</tt> and a solution building on its design. Through clever construction and type erasure, <tt class="code">boost::any</tt> is capable of storing any type. Both built-in and user-defined types are supported. A code example of <tt class="code">boost::any</tt> usage is shown in Listing 1.
  </p>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    std::list&lt;boost::any&gt; al;
    int i = 0;
    std::string s = &quot;1&quot;;

    al.push_back(i);
    al.push_back(s);
  </pre></td></tr><tr><td class="title">Listing 1</td></tr>
  </table>
  <p>
    However, <tt class="code">boost::any</tt> is implemented in the type-safe spirit of C++. Run-time efficiency and strong typing are the constraints behind its design. Although it provides a mechanism for dynamic type discovery (Listing 2.), <tt class="code">boost::any</tt> does not itself get involved into such activity, nor is it willing to cooperate in implicit conversions between values of different types. Moreover, an attempt to extract a type other than the one held, results in either an exception being thrown or a null pointer returned (in the manner of standard C++ <tt class="code">dynamic_cast</tt>).
  </p>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    bool isInt(const boost::any&amp; a) {
        return a.type() == typeid(int);
    }
  </pre></td></tr><tr><td class="title">Listing 2</td></tr>
  </table>
  <p>
    A <tt class="code">boost::any</tt> object is really convenient when one wants to pass around a variable of arbitrary type without having to worry about what type it actually is. The most common use is storing diverse types in an STL container. However, the true nature of <tt class="code">boost::any</tt> is static and, at the actual value extraction place, it is necessary to know precisely what type is held inside the any. While very 'soft' on the assignment side, on the extraction side <tt class="code">boost::any</tt> is even more rigid than built-in C++ types - it is only possible to cast it back to its original type. The <tt class="code">boost::any</tt> class has been ported to POCO (with some additions<sup><a href="#footnote2">2</a></sup>), where it is known as <tt class="code">Poco::Any</tt>. The design of this class has served as a foundation for development of its dynamic cousin, <tt class="code">Poco::DynamicAny</tt>, which is the main theme of this article.
  </p><h2>
    DynamicAny
  </h2><p>
    As mentioned above, <tt class="code">Poco::Any</tt> is a handy class for storing variety of types behind a common interface offering strongly typed cast mechanism and support for querying the held data type. <tt class="code">Poco::DynamicAny</tt> extends <tt class="code">Any</tt> functionality by providing full-blown runtime dynamic typing functionality within an ANSI/ISO C++ compliant framework. <tt class="code">DynamicAny</tt> builds on the heritage of <tt class="code">Any</tt> by adding the following features:
  </p>
		<ul><li>
    runtime checked value conversion and retrieval
  </li><li>
    non-initialized state support
  </li><li>
    implicit conversion to target type when possible and safe
  </li><li>
    seamless cooperation with POD types
  </li><li>
    seamless cooperation with <tt class="code">std::string</tt></li><li> <tt class="code">std::map</tt> wrapper (a.k.a. <tt class="code">DynamicStruct</tt>)
  </li><li> <tt class="code">std::vector</tt> specialization (array-like semantics support)
  </li><li>
    date/time specializations
  </li><li>
    binary large object specialization
  </li><li>
    basic JSON support.
  </li></ul><p>
    The class goes a long way to provide intuitive and reasonable conversion semantics and prevent unexpected data loss, particularly when performing narrowing or signedness conversions of numeric data types. One of the challenges during the design process was to come up with a set of intuitive conversion and behaviour rules. Of course, many conversions attempts will throw an exception because they make no sense (e.g. converting <tt class="code">&quot;abc&quot;</tt> to a numeric type). Additionally, deciding what is true or false seems like an easy task until it is actually attempted. The final verdict was that anything resembling either explicit falsehood (string <tt class="code">&quot;false&quot;</tt>, bool <tt class="code">false</tt>) or 'nothingness' (empty string, integer zero, min. float value ...) shall be <tt class="code">false</tt>, everything else is <tt class="code">true</tt>. This decision is compatible with C and C++, where zero integer is <tt class="code">false</tt> and everything else is <tt class="code">true</tt>. Also, <tt class="code">&quot;false&quot;</tt> and <tt class="code">&quot;true&quot;</tt> strings behave as expected in a case-insensitive manner.
  </p><p>
    The rules governing the behavior of <tt class="code">DynamicAny</tt> are<sup><a href="#footnote3">3</a></sup>:
  </p>
		<ul><li>
    An attempt to convert or extract from a non-initialized ('empty') <tt class="code">DynamicAny</tt> variable shall result in an exception being thrown
  </li><li>
    Loss of signedness is not permitted for numeric values. An attempt to convert a negative signed integer value to an unsigned integer type storage results in an exception being thrown.
  </li><li>
    Overflow is prohibited; attempt to assign a value larger than the target numeric type size can accommodate results in an exception being thrown.
  </li><li>
    Precision loss, such as in conversion from floating-point types to integers or from double to float on platforms where they differ in size (provided double value fits in float min/max range), is permitted.
  </li><li>
    String truncation is allowed - it is possible to convert between string and character when string length is greater than 1. An empty string gets converted to the char <tt class="code">'\0'</tt>, a non-empty string is truncated to the first character.
  </li></ul><p>
    Boolean conversions are performed as follows:
  </p>
		<ul><li>
    A string value <tt class="code">&quot;false&quot;</tt> (not case sensitive), <tt class="code">&quot;0&quot;</tt> or <tt class="code">&quot;&quot;</tt> (empty string) evaluates to <tt class="code">false</tt>; any string not evaluating to <tt class="code">false</tt> evaluates to <tt class="code">true</tt> (e.g. <tt class="code">&quot;hi&quot;</tt> &rarr; <tt class="code">true</tt>).
  </li><li>
    All integer zero values are <tt class="code">false</tt>, everything else is <tt class="code">true</tt>.
  </li><li>
    Floating point values equal to the minimal floating point representation on a given platform are <tt class="code">false</tt>, everything else is <tt class="code">true</tt>.
  </li></ul><p>
    The added value and benefit of <tt class="code">DynamicAny</tt> is in relieving the programmer from type-related worries for all the fundamental C++ types and some POCO framework objects. <tt class="code">DynamicAny</tt> allows storage of different data types and transparent conversion between them in the fashion of dynamic languages.<sup><a href="#footnote4">4</a></sup>
  </p><p>
    Some <tt class="code">DynamicAny</tt> usage examples are shown in listings 3-6.
  </p>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    // Values are interchangeable between
    // different types in a safe way
    DynamicAny any(&quot;42&quot;);
    int i = any; // i == 42
    any = 65536;
    std::string s = any; // s == &quot;65536&quot;
    char c = any; // too big, throws RangeException
  </pre></td></tr><tr><td class="title">Listing 3</td></tr>
  </table>

  <table class="sidebartable"><tr><td><pre class="programlisting">
    // Conversion operators for
    // basic types are available
    DynamicAny any = 10;
    int i = any - 5;    // i == 5
    i += any;           // i == 15
    i = 30 / any;       // i == 3
    bool b = 10 == any; // b == true
  </pre></td></tr><tr><td class="title">Listing 4</td></tr>
  </table>

  <table class="sidebartable"><tr><td><pre class="programlisting">
    // DynamicAny can be incremented or
    // decremented when holding integral value
    DynamicAny any = 10;
    any++; // any == 11
    --any; // any == 10
    any = 1.2f; // make it float
    ++any; // throws InvalidArgumentException
  </pre></td></tr><tr><td class="title">Listing 5</td></tr>
  </table>

  <table class="sidebartable"><tr><td><pre class="programlisting">
    // Workaround for std::string
    DynamicAny any(&quot;42&quot;);
    std::string s1 = any; //OK
    // std::string s2(any); //g++ compile error
    std::string s3(any.convert&lt;std::string&gt;()); //OK
  </pre></td></tr><tr><td class="title">Listing 6</td></tr>
  </table>
  <p>
    There are some conversions that require 'workarounds' with some compilers as illustrated in the code snippet in Listing 6<sup><a href="#footnote5">5</a></sup>.
  </p><h2>
    DynamicAny implementation
  </h2><p>
    In the manner of <tt class="code">boost::any</tt>, storage and extraction of an arbitrary user-defined type are supported out-of-the-box. In addition to that, <tt class="code">DynamicAny</tt>'s conversions are fully extensible. In order to provide the support for conversion to other types, the <tt class="code">DynamicAnyHolder&lt;Type&gt;</tt> must be specialized for the <tt class="code">Type</tt> with appropriate <tt class="code">convert()</tt> function overloads being defined.
  </p><p>
    The structure outline of the <tt class="code">DynamicAny</tt> and <tt class="code">DynamicAnyHolder</tt> class hierarchy is shown in Listing 7. <tt class="code">DynamicAny</tt> owns a pointer to <tt class="code">DynamicAnyHolder</tt>. The default zero pointer indicates that variable has not been initialized yet. In the non-initialized state, attempt for extraction or conversion triggers an exception. At assignment time, the <tt class="code">DynamicAnyHolder</tt> storage is allocated on the heap and the address stored in the pointer. The storage is automatically released at destruction time by virtue of the C++ RAII mechanism.
  </p>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    class DynamicAny
    {
    public:
    DynamicAny();
      /// Creates an empty DynamicAny.

    template &lt;typename T&gt; DynamicAny(const T &amp;val):
      _pHolder(new DynamicAnyHolderImpl&lt;T&gt;(val))
      /// Creates the DynamicAny from the given value.
    { }

    // ...

    DynamicAnyHolder* _pHolder;
    };

    class DynamicAnyHolder
    {
    public:
    virtual ~DynamicAnyHolder();
    // ...
    virtual void convert(Int8&amp; val) const
    { throw BadCastException(
       &quot;Can not convert to Int8&quot;); }

    virtual void convert(Int16&amp; val) const
    { throw BadCastException(
       &quot;Can not convert to Int16&quot;); }

    // ...

    virtual void convert(std::string&amp; val) const
    { throw BadCastException(
       &quot;Can not convert to string&quot;); }

    // ...
    protected:
    DynamicAnyHolder();
    // ...
    };

    template &lt;typename T&gt;
    class DynamicAnyHolderImpl: public DynamicAnyHolder
    /// template for arbitrary user-defined types
    {
    public:
    DynamicAnyHolderImpl(const T&amp; val): _val(val) { }
    ~DynamicAnyHolderImpl() { }

    const std::type_info&amp; type() const
    { return typeid(T); }

    DynamicAnyHolder* clone() const
    { return new DynamicAnyHolderImpl(_val); }

    const T&amp; value() const
    { return _val; }

    private:
    DynamicAnyHolderImpl();
    // ...
    T _val;
    }

    template &lt;&gt;
    class DynamicAnyHolderImpl&lt;Int8&gt;:
    public DynamicAnyHolder
    /// Int8 specialization
    {
    public:
    DynamicAnyHolderImpl(Int8 val): _val(val) { }

    // ...

    void convert(Int8&amp; val) const
    { val = _val; }

    void convert(Int16&amp; val) const
    { val = _val; }

    // ...

    void convert(std::string&amp; val) const
    { val = NumberFormatter::format(_val); }

    // ...

    private:
    DynamicAnyHolderImpl();
    Int8 _val;
    };
  </pre></td></tr><tr><td class="title">Listing 7</td></tr>
  </table>
  <p>
    Support for various data types is achieved through polymorphism - <tt class="code">DynamicAnyHolderImpl</tt> is a template class inheriting from <tt class="code">DynamicAnyHolder</tt> and only specializations of this class do the conversion work. The direct extraction of the original data type depends on the template and specializations having <tt class="code">value()</tt> member function returning the held value. Although it may be viewed as a questionable design decision, for efficiency sake <tt class="code">value()</tt> has intentionally not been made virtual. This decision has provided the value extraction performance comparable to that of <tt class="code">boost::any</tt>.
  </p><p>
    The most commonly used data types (all fundamental data types, <tt class="code">std::string</tt>, <tt class="code">std::vector&lt;DynamicAny&gt;</tt>, <tt class="code">DateTime</tt>, <tt class="code">Timestamp</tt>, <tt class="code">BLOB</tt>) are specialized within the POCO framework and ready for immediate use. The mentioned set of data types covers the majority of cases where automatic conversion is frequently needed. All other data types are covered by the generic <tt class="code">DynamicAnyholderImpl&lt;T&gt;</tt> template and, like <tt class="code">boost::any</tt>, allow only extraction of the held type, while an attempt to convert the value results in exception. When needed, a specialization for user-defined types is possible. A definition of sample UDT (a social security number formatter), with specialization and usage example code is shown in Listing 8.
  </p>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    class SSN
      /// a user-defined type
    {
    public:
    SSN(const SSN&amp; ssn): _ssn(ssn._ssn) { }

    SSN(const DynamicAny&amp; da): _ssn(da) { }

    operator SSN ()
    { return *this; }

    std::string sSSN() const
    { return format(); }

    int nSSN() const
    { return _ssn; }

    private:
    std::string format() const
      /// format integer as SSN
    {
      std::string tmp;
      std::string str =
         NumberFormatter::format(_ssn);
      tmp.clear();
      tmp.append(str, 0, 3);
      tmp += '-';
      tmp.append(str, 3, 2);
      tmp += '-';
      tmp.append(str, 5, 4);
      return tmp;
    }

    int _ssn;
    };


    // Sample usage:

    SSN udt1(123456789);
    DynamicAny da = udt1;
    std::string ssn = da;
    std::cout &lt;&lt; ssn &lt;&lt; std::endl;
    SSN udt2 = da;
    std::cout &lt;&lt; udt2.nSSN() &lt;&lt; std::endl;


    // Output:

    123-45-6789
    123456789
  </pre></td></tr><tr><td class="title">Listing 8</td></tr>
  </table>
  <p>
    As seen in the example, <tt class="code">DynamicAny</tt> readily holds <tt class="code">SSN</tt> and smoothly converts it to supported values. Assignment from <tt class="code">DynamicAny</tt> to <tt class="code">SSN</tt> is also possible. <tt class="code">DynamicAnyHolder</tt> provides the dynamic behaviour through polymorphism by virtue of its descendant specializations - the actual value resides in <tt class="code">DynamicAnyHolderImpl</tt> specialization. This value is converted through the overloaded <tt class="code">convert()</tt> virtual function call for the appropriate data type. Were the specializon not present, only extraction of the original type (in the fashion of <tt class="code">boost::any</tt>'s <tt class="code">any_cast</tt> functionality) would have been possible.
  </p><p>
    The main challenges encountered during the design were making <tt class="code">DynamicAny</tt> coexist in harmony with built-in types and compilers as well as implementing specializations and safe conversions for most commonly used types. The first attempt for operator overloading was template-based, but that has proved to be painting with too broad a brush, resulting in obscure compile errors on some platforms. To fix the problem, operators on both sides (member and non-member ones) have been re-implemented as overloaded functions. Also, it took several iterations of safe conversion check versions to reconcile with all supported compilers and platforms. The POCO community contribution in the process was instrumental.
  </p><h2>
    DynamicAny in real world
  </h2><p>
    Surely, all this is not without meaning [<a href="#Melville51">Melville51</a>]. The code sample shown may be a clever data formatter, but was it worth going through such effort only to provide conversion and formatting between numbers and strings? A code snippet using <tt class="code">DynamicAny</tt> in a realistic scenario is shown in Listing 9. The added value that <tt class="code">DynamicAny</tt> brings in this case is:
  </p>
		<ul><li>
    shield against the compile-time data type and layout knowledge requirement
  </li><li>
     shield against conversion data loss
  </li></ul>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    using namespace Poco::Data::Keywords;
    using Poco::Data::Session;
    using Poco::Data::Statement;
    using Poco::Data::RecordSet;

    // create a session
    Session session(&quot;SQLite&quot;, &quot;sample.db&quot;);

    // a simple query
    Statement stmt(session);
    stmt &lt;&lt; &quot;INSERT INTO Person VALUES ('Bart', 12)&quot;,
       now;

    // create a RecordSet
    RecordSet rs(session, &quot;SELECT Name,
       Age FROM Person&quot;);

    int i = rs[1]; // OK
    std::string s = rs[1]; // OK, too
    i = rs[0]; // throws, can't convert 'Bart' to int
  </pre></td></tr><tr><td class="title">Listing 9</td></tr>
  </table>
  <p>
    To achieve the desired <tt class="code">RecordSet</tt> capabilities, class <tt class="code">Row</tt> was introduced. By utilizing <tt class="code">DynamicAny</tt>'s dynamic typing facilities, <tt class="code">Row</tt> conveniently wraps a row of data and, through <tt class="code">RowIterator</tt>, works seamlessly in conjunction with STL algorithms to provide functionality for a flexible <tt class="code">RecordSet</tt> class, as shown in Listing 10. The details are outside of the scope of this article, but suffice it to say that the code shown works for any given SQL statement (i.e. any given column count/datatype combination) thanks to dynamic typing provided by <tt class="code">DynamicAny</tt>.
  </p>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    Session session(&quot;SQLite&quot;, &quot;sample.db&quot;);
    std::cout &lt;&lt; RecordSet(session, &quot;SELECT * FROM Person&quot;);

    // This is how streaming is achieved under
    // the hood:
    // copy(begin(), end(),
    //      ostream_iterator&lt;Row&gt;(cout));
  </pre></td></tr><tr><td class="title">Listing 10</td></tr>
  </table>
  <p>
    As demonstrated in Listings 9 and 10, <tt class="code">DynamicAny</tt> comes handy as a 'mediator' between type aware data storage (e.g. database) and a type relaxed representation (e.g. web page). Displaying data from database is easy by simply converting all the values to string and embedding them into HTML, for example. However, the data coming back from the web page shall all be strings. In a scenario proposed by a POCO contributor, <tt class="code">DynamicAny</tt> had been extended having two callback functions being called before and after a value assignment or change. The callbacks allow changes in the value to be instantly reflected in a XML structure and then transformed to any representation on demand. String value coming from a response XML could be put in a <tt class="code">DynamicAny</tt> then bound to database query without explicit type conversion. Full details are beyond the scope of this article, but the basic outline is laid out in Listing 11. Currently, this is not a part of mainstream code base and a discussion is going on about whether and how to integrate this functionality into the framework.
  </p>
  <table class="sidebartable"><tr><td><pre class="programlisting">
    // retrieve from a database
    RecordSet rs(session, &quot;SELECT Name,
       Age FROM Simpsons&quot;);
    // type is known here
    DynamicAny age = rs[<a href="#1">1</a>];
    // output as string (eg. in some html)
    // ...
    // assign from a string (e.g. from some html form)
    age = &quot;14&quot;;
    // bind, implicitly casting age to int
    session &lt;&lt;
      &quot;INSERT INTO Simpsons VALUES('Bart', ?)&quot;,
      use(age), now;
  </pre></td></tr><tr><td class="title">Listing 11</td></tr>
  </table>
  <h2>
    Conclusion
  </h2><p>
    Static and dynamic data typing are contrasting solutions, each with its own advantages and drawbacks. While dynamic typing affects runtime performance, in certain scenarios (e.g. fetching data from a remote database) the performance hit is dwarfed by the time spent on other operations.
  </p><p>
    As illustrated in the examples, <tt class="code">DynamicAny</tt> is useful whenever performance requirements are loose and/or data types involved are unknown at compile time. However, as will be shown in part II of the article, performance concern was not a design afterthought. <tt class="code">DynamicAny</tt> class is part of C++ Portable Components framework Foundation library with extensive use in the Data library. Additionally, some experimenting is underway with <tt class="code">DynamicAny</tt> used as a 'bridge' between C++ and scripting languages [<a href="#POCOc">POCOc</a>].
  </p><p>
    In the next installment of this article, more details about internal implementation of <tt class="code">DynamicAny</tt> will be given, as well as some comparison tests between different C++ data type conversion mechanisms and classes.</p><h2>
    Acknowledgements
  </h2><p>
    Kevlin Henney is the originator of the idea and author of the <tt class="code">boost::any</tt> class. Kevlin has provided valuable comments on the article.
  </p><p>
    Peter Schojer has ported <tt class="code">boost::any</tt> to POCO, implemented major portions of <tt class="code">DynamicAny</tt> and provided valuable comments on the article.
  </p><p>
    G&uuml;nter Obiltschnig has written majority of the POCO framework and provided valuable comments on the article.
  </p><p>
    Laszlo Keresztfalvi has provided valuable development and testing feedback, sample usage code as well as valuable comments on the article.
  </p>
  <h2>
    References
  </h2><p>
    [<a name="Boost"></a>Boost] Boost <tt class="code">any</tt> library: <a href="http://www.boost.org/doc/html/any.html">http://www.boost.org/doc/html/any.html</a>
  </p><p class="bibliomixed">
    [<a name="Henney00"></a>Henney00] Henney, Kevlin (2000) 'Valued Conversions', <i>C++ Report</i>, July-August 2000.
  </p><p class="bibliomixed">
    [<a name="Melville51"></a>Melville51] Melville, Herman (1851) <i>Moby Dick</i>, Harper &amp; Brothers Publishers
  </p><p>
    [<a name="POCOa"></a>POCOa] C++ Portable Components: <a href="http://poco.sourceforge.net">http://poco.sourceforge.net</a>
  </p><p class="bibliomixed">
    [<a name="POCOb"></a>POCOb] C++ Portable Components development repository: <a href="http://poco.svn.sourceforge.net/viewvc/poco/">http://poco.svn.sourceforge.net/viewvc/poco/</a>
  </p><p class="bibliomixed">
    [<a name="POCOc"></a>POCOc] <tt class="code">Poco::Script</tt>: <a href="http://poco.svn.sourceforge.net/viewvc/poco/sandbox/Script/">http://poco.svn.sourceforge.net/viewvc/poco/sandbox/Script/</a>
  </p><p class="bibliomixed">
    [<a name="Stroustrup97"></a>Stroustrup97] Stroustrup, Bjarne (1997) <i>The C++ Programming Language</i>, Addison-Wesley.
  </p><p class="bibliomixed">
    [<a name="Sutter07"></a>Sutter07] Sutter, Herb (2007) 'Modern C++ Libraries', <i>Proceedings, SD West</i>.
  </p>
  <p class="footnote">
      <a name="footnote1"></a>1	unions, void pointers, Microsoft COM Variant,<tt class="code">boost::variant</tt>, <tt class="code">boost::any</tt>, <tt class="code">boost::lexical_cast</tt>
      </p>
  <p class="footnote">
      <a name="footnote2"></a>2	Added <tt class="code">RefAnyCast</tt> operators returning reference and <tt class="code">const</tt> reference to stored value.
    </p>
  <p class="footnote">
      <a name="footnote3"></a>3	Some of the features are scheduled for the next release and are currently available from the development code repository [<a href="#POCOb">POCOb</a>]
  </p><p class="footnote">
      <a name="footnote4"></a>4	For conversion from type T1 to type T2 to be possible, a <tt class="code">DynamicAnyHolderImpl&lt;T1&gt;::convert(T2&amp;)</tt> must be defined.
  </p><p class="footnote">
      <a name="footnote5"></a>5	The commented line does not compile with g++ (MSVC++ and Sun Studio compile it successfully).
  </p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
