Index: /trunk/FACT++/src/State.cc
===================================================================
--- /trunk/FACT++/src/State.cc	(revision 10395)
+++ /trunk/FACT++/src/State.cc	(revision 10395)
@@ -0,0 +1,85 @@
+// **************************************************************************
+/** @struct State
+
+@brief A struct which stores an index, a comment and a name of a State
+
+To have proper descriptions of states in the network, this struct provides
+a simple storage for the properties of a state.
+
+Assume you want to write a descriptive string for a state machine
+with two states, it could look like this:
+
+"1:Disconnected=Connection not established\n2:Connected=Connection established."
+
+Such a string can then be converted with SplitStates into a vector
+of State objects.
+
+*/
+// **************************************************************************
+#include "State.h"
+
+#include <sstream>
+#include <algorithm>
+
+#include "tools.h"
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//! Construct a Description object
+//!
+//! @param i
+//!     Index of the state, e.g. 1
+//!
+//! @param n
+//!     Name of the state, e.g. 'Connected'
+//!
+//! @param c
+//!     Descriptive text of the state, e.g. "Connection to hardware established."
+//
+State::State(int i, const std::string &n, const std::string &c)
+    : index(i), name(Trim(n)), comment(Trim(c))
+{
+}
+
+// --------------------------------------------------------------------------
+//
+//! This function breaks down a descriptive string into its components.
+//! For details see class reference.
+//!
+//! @param buffer
+//!     string which should be broekn into pieces
+//!
+//! @returns
+//!     A vector<State> containing all the states found.
+//
+vector<State> State::SplitStates(const string &buffer)
+{
+    vector<State> vec;
+
+    string buf;
+    stringstream stream(buffer);
+    while (getline(stream, buf, '\n'))
+    {
+        if (buf.empty())
+            continue;
+
+        const size_t p1 = buf.find_first_of(':');
+        const size_t p2 = buf.find_first_of('=');
+
+        stringstream s(buf.substr(0, p1));
+
+        int index;
+        s >> index;
+
+        const string name    = buf.substr(p1+1, p2-p1-1);
+        const string comment = p2==string::npos ? "" : buf.substr(p2+1);
+
+        vec.push_back(State(index, name, comment));
+    }
+
+    sort(vec.begin(), vec.end(), State::Compare);
+
+    return vec;
+}
Index: /trunk/FACT++/src/State.h
===================================================================
--- /trunk/FACT++/src/State.h	(revision 10395)
+++ /trunk/FACT++/src/State.h	(revision 10395)
@@ -0,0 +1,20 @@
+#ifndef FACT_State
+#define FACT_State
+
+#include <string>
+#include <vector>
+
+struct State
+{
+    int         index;    /// Index (e.g. 1)
+    std::string name;     /// Name (e.g. 'Connected')
+    std::string comment;  /// Description (e.g. 'Connection to hardware established.')
+
+    static std::vector<State> SplitStates(const std::string &buffer);
+
+    static bool Compare(const State &i, const State &j) { return i.index<j.index; }
+
+    State(int i, const std::string &n, const std::string &c="");
+};
+
+#endif
