A base class for nested structures that can be searched.
More...
#include <yarp/os/Searchable.h>
A base class for nested structures that can be searched.
A Searchable object promises that you can look inside it with the find() and findGroup() methods to get values and lists corresponding to keywords.
- See also
- Property Bottle Value
- Examples
- dev/fake_motor/fake_motor.cpp, and os/image_process_module/image_process_module.cpp.
Definition at line 68 of file Searchable.h.
◆ Searchable() [1/3]
yarp::os::Searchable::Searchable |
( |
| ) |
|
|
explicit |
◆ Searchable() [2/3]
yarp::os::Searchable::Searchable |
( |
const Searchable & |
rhs | ) |
|
|
default |
◆ Searchable() [3/3]
yarp::os::Searchable::Searchable |
( |
Searchable && |
rhs | ) |
|
|
defaultnoexcept |
◆ ~Searchable()
yarp::os::Searchable::~Searchable |
( |
| ) |
|
|
virtualdefault |
◆ check() [1/4]
virtual bool yarp::os::Searchable::check |
( |
const std::string & |
key | ) |
const |
|
pure virtual |
◆ check() [2/4]
bool yarp::os::Searchable::check |
( |
const std::string & |
key, |
|
|
const std::string & |
comment |
|
) |
| const |
|
virtual |
Check if there exists a property of the given name.
- Parameters
-
key | the name to check for |
comment | Human-readable explanation |
- Returns
- true iff a property of the given name exists, even if it doesn't have a value associated with it
Definition at line 84 of file Searchable.cpp.
◆ check() [3/4]
yarp::os::Value yarp::os::Searchable::check |
( |
const std::string & |
key, |
|
|
const Value & |
fallback, |
|
|
const std::string & |
comment = "" |
|
) |
| const |
|
virtual |
Gets a value corresponding to a given keyword.
- Parameters
-
key | The keyword to look for |
fallback | A default value to return if nothing found |
comment | Optional human-readable explanation |
- Returns
- A value corresponding to a given keyword, or the default if nothing is found. See the find() method for interpreting the value found.
Definition at line 58 of file Searchable.cpp.
◆ check() [4/4]
bool yarp::os::Searchable::check |
( |
const std::string & |
key, |
|
|
Value *& |
result, |
|
|
const std::string & |
comment = "" |
|
) |
| const |
|
virtual |
Gets a value corresponding to a given keyword.
If a property does not exist, this returns false and does not modify the result pointer. If a property exists but does not have a value, this again returns false and does not modify the result pointer.
Property p;
p.fromString("(width 10) (height 15) (help)");
p.check("help")
p.check("width")
p.check("foo")
Value *v;
p.check("help", v)
p.check("width", v)
- Parameters
-
key | The keyword to look for |
result | A pointer to store the address of the result in |
comment | Optional human-readable explanation |
- Returns
- True if there is a value corresponding to a given keyword, false otherwise. See the find() method for interpreting the value found.
Definition at line 39 of file Searchable.cpp.
◆ find()
virtual Value& yarp::os::Searchable::find |
( |
const std::string & |
key | ) |
const |
|
pure virtual |
Gets a value corresponding to a given keyword.
- Parameters
-
key | The keyword to look for |
- Returns
- A value corresponding to a given keyword. If there is no such value, then the isNull() method called on the result will be true. Otherwise, the value can be read by calling result.asInt32(), result.asString(), etc. as appropriate.
Implemented in yarp::os::Value, yarp::os::ResourceFinder, yarp::os::Property, yarp::os::impl::StoreDict, yarp::os::impl::StoreList, yarp::os::impl::Storable, and yarp::os::Bottle.
◆ findGroup() [1/2]
virtual Bottle& yarp::os::Searchable::findGroup |
( |
const std::string & |
key | ) |
const |
|
pure virtual |
◆ findGroup() [2/2]
yarp::os::Bottle & yarp::os::Searchable::findGroup |
( |
const std::string & |
key, |
|
|
const std::string & |
comment |
|
) |
| const |
Gets a list corresponding to a given keyword.
- Parameters
-
key | The keyword to look for |
comment | Human-readable explanation |
- Returns
- A list corresponding to a given keyword. If there is no such list, then the isNull() method called on the result will be true. Otherwise, the elements of the list can be read through result.get(index) where result.get(0) is the keyword, and result.get(i) for i>=1 are the "real" elements of the list.
Definition at line 97 of file Searchable.cpp.
◆ isNull()
bool yarp::os::Searchable::isNull |
( |
| ) |
const |
|
virtual |
◆ operator=() [1/2]
Copy assignment operator.
◆ operator=() [2/2]
Move assignment operator.
◆ toString()
virtual std::string yarp::os::Searchable::toString |
( |
| ) |
const |
|
pure virtual |
Return a standard text representation of the content of the object.
The representation is readable by the Bottle and Property classes.
- Returns
- A standard text representation of the content of the object.
Implemented in yarp::os::impl::Storable, yarp::os::Value, yarp::os::ResourceFinder, yarp::os::Property, yarp::os::impl::StoreDict, yarp::os::impl::StoreList, yarp::os::impl::StoreBlob, yarp::os::impl::StoreString, yarp::os::impl::StoreVocab, yarp::os::impl::StoreFloat64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, yarp::os::impl::StoreNull, and yarp::os::Bottle.
The documentation for this class was generated from the following files: