2using System.Collections.Generic;
5using System.Threading.Tasks;
14 Dictionary<string, List<Property>> m_rgValues =
new Dictionary<string, List<Property>>();
15 Dictionary<string, List<PropertyTree>> m_rgChildren =
new Dictionary<string, List<PropertyTree>>();
29 public void Put(
string str,
string strVal)
31 if (!m_rgValues.ContainsKey(str))
32 m_rgValues.Add(str,
new List<Property>());
34 m_rgValues[str].Add(
new Property(strVal));
42 public void Put(
string str,
double dfVal)
44 if (!m_rgValues.ContainsKey(str))
45 m_rgValues.Add(str,
new List<Property>());
47 m_rgValues[str].Add(
new Property(dfVal));
57 if (!m_rgChildren.ContainsKey(str))
58 m_rgChildren.Add(str,
new List<PropertyTree>());
60 m_rgChildren[str].Add(pt);
70 if (!m_rgValues.ContainsKey(strName))
71 throw new Exception(
"No value key with name '" + strName +
"' found!");
73 return m_rgValues[strName][0];
83 if (!m_rgValues.ContainsKey(strName))
84 throw new Exception(
"No value key with name '" + strName +
"' found!");
86 return m_rgValues[strName];
94 m_rgValues =
new Dictionary<string, List<Property>>();
95 m_rgChildren =
new Dictionary<string, List<PropertyTree>>();
105 List<PropertyTree> rgChildren =
new List<PropertyTree>();
107 foreach (KeyValuePair<
string, List<PropertyTree>> kv
in m_rgChildren)
109 rgChildren.AddRange(kv.Value);
125#warning PropertyTree.ToJson NOT completed.
143 public Property(
string strVal,
double? dfVal =
null)
154 public Property(
double dfVal,
string strVal =
null)
165 get {
return m_strVal; }
173 get {
return m_dfVal; }
The Property class stores both a numeric and text value.
Property(string strVal, double? dfVal=null)
The constructor.
double? Numeric
Returns the numeric value.
string Value
Returns the text value.
Property(double dfVal, string strVal=null)
The constructor.
The PropertyTree class implements a simple property tree similar to the ptree in Boost.
void Clear()
Clear all nodes and values from the tree.
List< PropertyTree > Children
Returns a list of all child property trees within the tree.
void Put(string str, string strVal)
Add a new property string value.
void AddChild(string str, PropertyTree pt)
Add a new child to the Property tree.
string ToJson()
Converts the property tree to a Json representation.
void Put(string str, double dfVal)
Add a new property numeric value.
Property Get(string strName)
Retrieves a property at the current level of the tree.
PropertyTree()
The constructor.
List< Property > GetChildren(string strName)
Retrieves all properties with the given key at the current level of the tree.
The MyCaffe.common namespace contains common MyCaffe classes.