|
YARP
Yet Another Robot Platform
|
|
Experiment with bottles and properties.
#include <stdio.h>
#include <stdlib.h>
int main(
int argc,
char *argv[]) {
printf(
"Bottle b is: %s\n", b.
toString().c_str());
printf(
"Bottle b2 is: %s\n", b2.
toString().c_str());
printf(
"Bottle b3 is: %s\n", b3.
toString().c_str());
printf(
"color check: %s\n", b3.
find(
"color").
asString().c_str());
printf(
"height check: %d\n", b3.
find(
"height").
asInt32());
printf(
"Bottle b4 is: %s\n", b4.
toString().c_str());
Bottle b5(
"(pos left top) (size 10)");
printf(
"Bottle b5 is: %s\n", b5.
toString().c_str());
b6 = b5;
printf(
"Bottle b6 is: %s\n", b6.
toString().c_str());
printf(
"pos check: %s\n", b6.
find(
"pos").
asString().c_str());
printf(
"nested check: %s\n", b6.
find(
"nested").
toString().c_str());
printf(
"nested height check: %d\n", b6.
find(
"nested").
find(
"height").
asInt32());
printf("\n");
printf("Relationship of Bottle and Property\n");
subProp.
put(
"hello",
"there");
subProp.
put(
"fortytwo",42);
printf(
"subProp: %s\n", subProp.
toString().c_str());
if (lst==NULL) {
printf("Failed to allocate list\n");
return 1;
}
printf(
"lst: %s\n", lst->
toString().c_str());
printf(
"prop: %s\n", prop.
toString().c_str());
return 0;
}
A simple collection of objects that can be described and transmitted in a portable way.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
static Value * makeList()
Create a list Value.
int main(int argc, char *argv[])
void fromString(const std::string &text)
Initializes bottle from a string.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual std::string asString() const
Get string value.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
An interface to the operating system, including Port based communication.
virtual Bottle * asList() const
Get list value.
std::string toString() const override
Return a standard text representation of the content of the object.
A single value (typically within a Bottle).
A class for storing options and configuration information.
- 3.4.100+20201223.2+gitb8ea4d712