YARP  2.3.68+272-20170522.1+git50f0ae7
Yet Another Robot Platform
Property.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 RobotCub Consortium
3  * Authors: Paul Fitzpatrick
4  * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
5  */
6 
7 #ifndef YARP_OS_PROPERTY_H
8 #define YARP_OS_PROPERTY_H
9 
10 #include <yarp/os/ConstString.h>
11 #include <yarp/os/Bottle.h>
12 
13 namespace yarp {
14  namespace os {
15  class Property;
16  }
17 }
18 
19 
32 class YARP_OS_API yarp::os::Property : public Searchable, public Portable {
33 
34 public:
35  using Searchable::check;
37 
46  Property(int hash_size = 0);
47 
51  Property(const char *str);
52 
53 
57  Property(const Property& prop);
58 
62  virtual ~Property();
63 
67  const Property& operator=(const Property& prop);
68 
69  // documented in Searchable
70  bool check(const ConstString& key) const;
71 
83  void put(const ConstString& key, const ConstString& value);
84 
96  void put(const ConstString& key, const Value& value);
97 
109  void put(const ConstString& key, Value *value);
110 
122  void put(const ConstString& key, int value);
123 
135  void put(const ConstString& key, double value);
136 
147  Property& addGroup(const ConstString& key);
148 
157  void unput(const ConstString& key);
158 
159  // documented in Searchable
160  virtual Value& find(const ConstString& key) const;
161 
162  // documented in Searchable
163  virtual Bottle& findGroup(const ConstString& key) const;
164 
171  void clear();
172 
194  void fromString(const ConstString& txt, bool wipe=true);
195 
220  void fromCommand(int argc, char *argv[], bool skipFirst=true,
221  bool wipe=true);
222 
247  void fromCommand(int argc, const char *argv[], bool skipFirst=true,
248  bool wipe=true);
249 
271  void fromArguments(const char *arguments, bool wipe=true);
272 
349  bool fromConfigFile(const ConstString& fname, bool wipe=true);
350 
364  bool fromConfigFile(const ConstString& fname,
365  Searchable& env,
366  bool wipe=true);
367 
378  bool fromConfigDir(const ConstString& dirname,
379  const ConstString& section = ConstString(),
380  bool wipe = true);
381 
389  void fromConfig(const char *txt, bool wipe=true);
390 
403  void fromConfig(const char *txt,
404  Searchable& env,
405  bool wipe=true);
406 
416  void fromQuery(const char *url,
417  bool wipe=true);
418 
419 
420  // documented in Searchable
421  ConstString toString() const;
422 
423  // documented in Portable
424  bool read(ConnectionReader& reader);
425 
426  // documented in Portable
427  bool write(ConnectionWriter& writer);
428 
429 private:
432 
433  void summon();
434  bool check() const;
435 };
436 
437 #endif // YARP_OS_PROPERTY_H
virtual YARP_SSIZE_T read(const Bytes &b)
A class for storing options and configuration information.
Definition: Property.h:32
A base class for nested structures that can be searched.
Definition: Searchable.h:56
This is a base class for objects that can be both read from and be written to the YARP network...
Definition: Portable.h:26
void * implementation
Definition: Property.h:430
The main, catch-all namespace for YARP.
A string with almost the same api as std::string.
Definition: ConstString.h:44
virtual Bottle & findGroup(const ConstString &key) const =0
Gets a list corresponding to a given keyword.
An interface for writing to a network connection.
A simple collection of objects that can be described and transmitted in a portable way...
Definition: Bottle.h:57
virtual void write(const Bytes &b)
An interface for reading from a network connection.
A single value (typically within a Bottle).
Definition: Value.h:36
virtual bool check(const ConstString &key) const =0
Check if there exists a property of the given name.
std::string toString(const T &value)
convert an arbitary type to string.