How to read a configuration file.
How to read a configuration file. This example is designed to read a file like the following (property/config.txt):
#include <stdio.h>
#include <stdlib.h>
int main(
int argc,
char *argv[]) {
if (!cmdLine.
check(
"file")) {
printf("Please call with: --file config.txt\n");
exit(1);
}
printf("Working with config file %s\n", fname.c_str());
if (!robot.
check(
"GENERAL")) {
printf("Cannot understand config file\n");
exit(1);
}
printf("Robot has %d joints\n", joints);
printf("Robot has limits: ");
for (
int i=1; i<maxes.
size(); i++) {
}
printf("\n");
return 0;
}
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
bool fromConfigFile(const std::string &fname, bool wipe=true)
Interprets a file as a list of properties.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
void fromCommand(int argc, char *argv[], bool skipFirst=true, bool wipe=true)
Interprets a list of command arguments as a list of properties.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::string asString() const
Get string value.
An interface to the operating system, including Port based communication.
int main(int argc, char *argv[])