<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Home</title><link>https://sourceforge.net/p/dtitem-library/wiki/Home/</link><description>Recent changes to Home</description><atom:link href="https://sourceforge.net/p/dtitem-library/wiki/Home/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 23 Dec 2015 13:19:44 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/dtitem-library/wiki/Home/feed" rel="self" type="application/rss+xml"/><item><title>Home modified by hpg</title><link>https://sourceforge.net/p/dtitem-library/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -1,4 +1,4 @@
-# Common DataItem library (dtitem-library)
+## Common DataItem library (dtitem-library)

 [TOC]

@@ -7,7 +7,7 @@

 I will change this in the next time and move this page downwards to a new sub page.

-## Getting started
+### Getting started
 The library contains a C++ class that can be used instead of any other type of
 variant classes or structures.

@@ -20,16 +20,16 @@
 *  uses `std::shared_ptr` and does not copy values but rather add references to objects
 *  makes use of come C++11 features like supporting a move copy c'tor and assignment operator 

-## Restrictions / Limitations
+### Restrictions / Limitations
 * Only tested with MSVC 10 yet
 * Requires C++11 or better 

-## What's coming next?
+### What's coming next?
 * Better documentation and better english.
 * A serialization format to read and store data item objects
 * Better change notification with details like what has been changed

-## Building the Library
+### Building the Library
 To build the library you will need at least MSVC 10 or better (express version should do).

 Other compilers may work, but I didn't test them yet.
@@ -63,29 +63,108 @@
 ~~~~

 `DoRef` objects may be used to assign another `dtitem` object or can be added to a child list of a `dtitem`
-without any concerns about freeing up something. This is done by `DoRef`automatically.
-
+without any concerns about freeing up something. This is done by `DoRef` automatically.
+
+## Samples
+Here are some sample C++ sources, just for given a first impression about the functions.
+
+Refer for details to the complete doxygen documentation as provided.

 ### DoRef and exception handling
 Whenever dealing with `DoRef` (or `dtitem`) classes you should consider to 
 handle `std::exception` throwings.

-@include sample-doref-exceptions.cpp
+~~~~ (cpp)
+void test()
+{
+    DoRef r;
+    
+    // this line will throw a dt::ex_unreferenced() exception rather
+    // than an access violation what would be the result when using 
+    // shared_ptr and not DoRef classes
+    std::cout &amp;lt;&amp;lt; r-&amp;gt;name() &amp;lt;&amp;lt; std::endl; 
+}
+~~~~

 A better handling would be:

-@include sample-doref-exception-handling.cpp
+~~~~ (cpp)
+void test()
+{
+    DoRef r;
+    
+    try {    
+        // this line will throw a dt::ex_unreferenced() exception
+        std::cout &amp;lt;&amp;lt; r-&amp;gt;name() &amp;lt;&amp;lt; std::endl; 
+    }
+    catch (const std::exception&amp;amp; ex) 
+    {
+        std::cerr &amp;lt;&amp;lt; "exception caught: " &amp;lt;&amp;lt; ex.what() &amp;lt;&amp;lt; std::endl;
+    }
+}
+~~~~
+---------
+
+

 ### Creating a DoRef object
 Creating an object is safe when you create it "embedded" in a `DoRef` like:

-@include sample-doref-creation.cpp
+~~~~ (cpp)
+void test()
+{
+    DoRef r;
+    
+    // the created object is "embedded" into the r object and
+    // destroyed when r is going out-of-scope 
+    //i.e. leaving the test() function.
+    r = new dt::dtstruct("hello world");
+    
+    std::cout &amp;lt;&amp;lt; "created a struct with name = "
+              &amp;lt;&amp;lt; r-&amp;gt;name() &amp;lt;&amp;lt; std::endl; 
+              
+    // r will destruct the child object automatically
+}
+
+~~~~
+--------

 ### Removing a DoRef object explicitely
 If you want to destruct a `DoRef` explicitely, you can remove it from a 
 parent object's child list by:

-@include sample-doref-remove.cpp
+~~~~ (cpp)
+void test()
+{
+    DoRef r;
+    
+    // create the parent object 
+    r = new dt::dtstruct("hello");
+    
+    { // extra scope for adding a new item
+        // create a new string type dtitem and add it to 'r'
+        DoRef childRef(new dtstring("world"));
+        r-&amp;gt;add(childRef);
+    }
+    
+    std::cout &amp;lt;&amp;lt; "'r' contains count = child object(s)" 
+              &amp;lt;&amp;lt; r.count() &amp;lt;&amp;lt; ")" &amp;lt;&amp;lt; std::endl; // &amp;gt; 1
+              
+    { // extra scope for the removal test
+        // get a pointer to the first child object of 'r'
+        DoRef childRef = r-&amp;gt;at(0);
+        
+        // remove it from the child list of 'r'
+        r-&amp;gt;remove(childRef);
+        
+        // the referenced object of childRef is destroyed here
+    }
+    
+    std::cout &amp;lt;&amp;lt; "'r' contains count = child object(s)" 
+              &amp;lt;&amp;lt; r.count() &amp;lt;&amp;lt; ")" &amp;lt;&amp;lt; std::endl; // &amp;gt; 0
+}
+~~~~
+-------

 ### DoRef and parent()
 Use the relation `child-&amp;gt;parent` safely.
@@ -105,11 +184,44 @@

 You must also expect to get a null pointer when doing so.

-@include sample-doref-parent.cpp
-
-See also doxygen documentation:
-- dt::DoRef 
-- dt::RefPtr&amp;lt;t&amp;gt;
+~~~~ (cpp)
+void test(DoRef r)
+{
+    DoRef guardRef(r); // do not allow destruction from outside e.g. another thread
+        
+    if (r.empty()) {
+        std::cerr &amp;lt;&amp;lt; "'r' does not point to a valid object" &amp;lt;&amp;lt; std::endl;
+        return;
+    }
+    
+    if (r-&amp;gt;empty()) {
+        std::cout &amp;lt;&amp;lt; "Given 'r' does not contain any child object" &amp;lt;&amp;lt; std::endl;
+        return;
+    }
+    
+    // get a pointer to the first child object of 'r'
+    DoRef childRef = r-&amp;gt;at(0);
+
+    // DoRef parentRef = childRef-&amp;gt;parent();    
+    // WRONG: This would create a NEW shared_ptr with pointing to 
+    // the object childRef-&amp;gt;parent() points to
+    //        
+    // And this would destruct the new shared_ptr when leaving
+    // the inner scope.
+    //
+    // What finally would lead to an access violation when leaving 
+    // test() or the function called test()
+    
+    // Correctly accessing the parent by using:
+    const dtitem *parentPtr = childRef-&amp;gt;parent();
+    
+    // the reference count of childRef's parent is not changed
+    if (parentPtr) {
+        std::cout &amp;lt;&amp;lt; "The parent object's name = " 
+                  &amp;lt;&amp;lt; parentPtr-&amp;gt;name() &amp;lt;&amp;lt; std::endl;
+    }
+}
+~~~~

 ---------------------------------------------------------------------------

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">hpg</dc:creator><pubDate>Wed, 23 Dec 2015 13:19:44 -0000</pubDate><guid>https://sourceforge.netd862e54b91b13f9867e1b2fc2285af5790237eb3</guid></item><item><title>Home modified by hpg</title><link>https://sourceforge.net/p/dtitem-library/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,8 +1,122 @@
-Welcome to your wiki!
+# Common DataItem library (dtitem-library)

-This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].
+[TOC]

-The wiki uses [Markdown](/p/dtitem-library/wiki/markdown_syntax/) syntax.
+This is taken partially from the doxygen documentation (already in progress) and should
+better tell more about the Library itself than to tell how to use it.
+
+I will change this in the next time and move this page downwards to a new sub page.
+
+## Getting started
+The library contains a C++ class that can be used instead of any other type of
+variant classes or structures.
+
+It is easy-to-use and provides a lot of features such as:
+*  native C++ class
+*  not based on other 3rd party libraries
+*  a data item may have a child list of other data items 
+*  dynamic adding or remove items at runtime is supported
+*  intergrated iteration support by using `at()`and `count()`
+*  uses `std::shared_ptr` and does not copy values but rather add references to objects
+*  makes use of come C++11 features like supporting a move copy c'tor and assignment operator 
+
+## Restrictions / Limitations
+* Only tested with MSVC 10 yet
+* Requires C++11 or better 
+
+## What's coming next?
+* Better documentation and better english.
+* A serialization format to read and store data item objects
+* Better change notification with details like what has been changed
+
+## Building the Library
+To build the library you will need at least MSVC 10 or better (express version should do).
+
+Other compilers may work, but I didn't test them yet.
+
+If you make the library compile with another compiler, please let me know, drop me a line 
+and/or send me the makefile together with version of you compiler and system :)
+
+----------
+## DataItem Objects
+The library consist mainly of the main data item class `dtitem`, that is the data item class itself.
+
+All classes, functions and variables are located in namespace `dt`.
+
+All strings in the library are of type `dt::str_type`.
+This is a `typedef` to `std::string` currently but may be changed to e.g. `std::wstring` later.
+
+### DoRef - a reference to a `dt::dtitem`
+`DoRef` is s a specialized `dt::RefPtr&amp;lt;std::shared_ptr&amp;gt;` and is the type to be used with
+the library.
+
+A `DoRef` may point to nothing or to created `dtitem`. To call a method of the item simply use the `-&amp;gt;`
+e.g.
+
+~~~~ (cpp)
+DoRef ref;
+ref.reset(new dt::dtitem("struct")); // creates the object, ref holds the reference to it
+
+// calls method name() which is 'struct' for this item
+std::cout &amp;lt;&amp;lt; ref-&amp;gt;name() &amp;lt;&amp;lt; std::endl;
+// ==&amp;gt; &amp;gt;struct
+~~~~
+
+`DoRef` objects may be used to assign another `dtitem` object or can be added to a child list of a `dtitem`
+without any concerns about freeing up something. This is done by `DoRef`automatically.
+
+
+### DoRef and exception handling
+Whenever dealing with `DoRef` (or `dtitem`) classes you should consider to 
+handle `std::exception` throwings.
+
+@include sample-doref-exceptions.cpp
+
+A better handling would be:
+
+@include sample-doref-exception-handling.cpp
+
+### Creating a DoRef object
+Creating an object is safe when you create it "embedded" in a `DoRef` like:
+
+@include sample-doref-creation.cpp
+
+### Removing a DoRef object explicitely
+If you want to destruct a `DoRef` explicitely, you can remove it from a 
+parent object's child list by:
+
+@include sample-doref-remove.cpp
+
+### DoRef and parent()
+Use the relation `child-&amp;gt;parent` safely.
+
+The design of the `dtitem` child list is done by using `DoRef` classes to
+reference objects. 
+
+An object contains a reference to its parent as well. 
+
+This is a so called `weak` kind of reference or simply said its just a pointer to a `dtitem`.
+
+This circumvents recursion trouble that otherwise would appear when adding an 
+object to a parent and the object would reference it with a `DoRef` instead.
+
+I.e. you may "access" the parent of a `dtitem` object only with a raw `const dtitem*` 
+and never using a `DoRef`. 
+
+You must also expect to get a null pointer when doing so.
+
+@include sample-doref-parent.cpp
+
+See also doxygen documentation:
+- dt::DoRef 
+- dt::RefPtr&amp;lt;t&amp;gt;
+
+---------------------------------------------------------------------------
+

 [[members limit=20]]
 [[download_button]]
+
+
+
+
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">hpg</dc:creator><pubDate>Wed, 23 Dec 2015 13:09:21 -0000</pubDate><guid>https://sourceforge.netcf1a8bddb3ab8f8adfb7cc1c8c80be2d1db0112e</guid></item><item><title>Home modified by hpg</title><link>https://sourceforge.net/p/dtitem-library/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Welcome to your wiki!&lt;/p&gt;
&lt;p&gt;This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: &lt;span&gt;[SamplePage]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The wiki uses &lt;a class="" href="/p/dtitem-library/wiki/markdown_syntax/"&gt;Markdown&lt;/a&gt; syntax.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;h6&gt;Project Members:&lt;/h6&gt;
	&lt;ul class="md-users-list"&gt;
		&lt;li&gt;&lt;a href="/u/hpg666/"&gt;hpg&lt;/a&gt; (admin)&lt;/li&gt;
		
	&lt;/ul&gt;&lt;br/&gt;
&lt;p&gt;&lt;span class="download-button-5679bb111be1ce3331604113" style="margin-bottom: 1em; display: block;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">hpg</dc:creator><pubDate>Tue, 22 Dec 2015 21:05:21 -0000</pubDate><guid>https://sourceforge.nete2552fcd1dcf70b31b686e8e432eca60878aedee</guid></item></channel></rss>