92 if (
type_ == new_type)
107 data_.value =
new QVariant;
159 for (
int i = 0; i < num_children; i++)
192 node_->setType(new_type);
218 Node::ChildMap::const_iterator iter =
node_->data_.map->find(key);
219 if (iter ==
node_->data_.map->end())
225 return Config(iter.value());
243 if (
mapGetValue(key, &v) && (v.type() == QVariant::Int || v.type() == QVariant::String))
246 int i = v.toInt(&ok);
259 if (
mapGetValue(key, &v) && (
int(v.type()) ==
int(QMetaType::Float) || v.type() == QVariant::Double ||
260 v.type() == QVariant::String))
263 float f = v.toFloat(&ok);
269 QString as_string = v.toString();
271 QLocale german(QLocale::German);
272 f = german.toFloat(as_string, &ok);
285 if (
mapGetValue(key, &v) && (v.type() == QVariant::Bool || v.type() == QVariant::String))
287 *value_out = v.toBool();
296 if (
mapGetValue(key, &v) && v.type() == QVariant::String)
298 *value_out = v.toString();
306 if (
node_.get() ==
nullptr)
314 return node_.get() !=
nullptr;
321 *
node_->data_.value = value;
336 if (
isValid() &&
node_->type_ ==
List && i >= 0 && i < node_->data_.list->size())
void setValue(const QVariant &value)
Ensures this is a valid Config object, sets the type to Value then sets the value.
void setType(Config::Type new_type)
static Config invalidConfig()
QVariant getValue() const
If this config object is valid and is a Value type, this returns its value. Otherwise it returns an i...
Config()
Default constructor. Creates an empty config object.
MapIterator()
Private constructor enforces that MapIterators are only made by their friend the Config class...
int listLength() const
Returns the length of the List in this Node, or 0 if this Node does not have type List...
bool isValid()
Return true if the iterator currently points to a valid entry, false if not.
Config mapGetChild(const QString &key) const
If the referenced Node is a Map and it has a child with the given key, return a reference to the chil...
bool mapGetString(const QString &key, QString *value_out) const
Convenience function for looking up a named string.
void makeValid()
If the node pointer is NULL, this sets it to a new empty node.
boost::shared_ptr< Node > NodePtr
void start()
Resets the iterator to the start of the map.
bool isValid() const
Returns true if the internal Node reference is valid, false if not. Same as (getType() != Invalid)...
void mapSetValue(const QString &key, QVariant value)
Set a named child to the given value.
Configuration data storage class.
QString currentKey()
Return the name of the current map entry.
Type
Possible types a Config Node can have are Map, List, Value, and Empty. Invalid means the Config objec...
Config mapMakeChild(const QString &key)
Create a child node stored with the given key, and return the child.
Iterator class for looping over all entries in a Map type Config Node.
bool mapGetValue(const QString &key, QVariant *value_out) const
Convenience function for looking up a named value.
bool mapGetFloat(const QString &key, float *value_out) const
Convenience function for looking up a named float.
Type getType() const
Return the Type of the referenced Node, or Invalid if this Config does not refer to a Node at all...
bool mapGetBool(const QString &key, bool *value_out) const
Convenience function for looking up a named boolean.
Config listAppendNew()
Ensure the referenced Node is of type List, append a new Empty Node to the end of the list...
Config listChildAt(int i) const
Return the i'th child in the list, if the referenced Node has type List. Returns an Invalid Config if...
Config currentChild()
Return a Config reference to the current map entry.
MapIterator mapIterator() const
Return a new iterator for looping over key/value pairs.
QMap< QString, Config::NodePtr >::const_iterator iterator_
bool mapGetInt(const QString &key, int *value_out) const
Convenience function for looking up a named integer.
QList< NodePtr > ChildList
void copy(const Config &source)
Make this a deep copy of source.
void setType(Type new_type)
Set the type of this Config Node.
union rviz::Config::Node::@0 data_
QMap< QString, NodePtr > ChildMap
void advance()
Advance iterator to next entry.