YARP
Yet Another Robot Platform
Property.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_PROPERTY_H
11 #define YARP_OS_PROPERTY_H
12 
13 #include <yarp/os/Bottle.h>
14 #include <string>
15 
16 namespace yarp {
17  namespace os {
18  class Property;
19  }
20 }
21 
22 
35 class YARP_OS_API yarp::os::Property : public Searchable, public Portable {
36 
37 public:
38  using Searchable::check;
40 
49  Property(int hash_size = 0);
50 
54  Property(const char *str);
55 
56 
60  Property(const Property& prop);
61 
65  virtual ~Property();
66 
70  const Property& operator=(const Property& prop);
71 
72  // documented in Searchable
73  bool check(const std::string& key) const override;
74 
86  void put(const std::string& key, const std::string& value);
87 
99  void put(const std::string& key, const Value& value);
100 
112  void put(const std::string& key, Value *value);
113 
125  void put(const std::string& key, int value);
126 
138  void put(const std::string& key, double value);
139 
150  Property& addGroup(const std::string& key);
151 
160  void unput(const std::string& key);
161 
162  // documented in Searchable
163  virtual Value& find(const std::string& key) const override;
164 
165  // documented in Searchable
166  virtual Bottle& findGroup(const std::string& key) const override;
167 
174  void clear();
175 
197  void fromString(const std::string& txt, bool wipe=true);
198 
223  void fromCommand(int argc, char *argv[], bool skipFirst=true,
224  bool wipe=true);
225 
250  void fromCommand(int argc, const char *argv[], bool skipFirst=true,
251  bool wipe=true);
252 
274  void fromArguments(const char *arguments, bool wipe=true);
275 
352  bool fromConfigFile(const std::string& fname, bool wipe=true);
353 
367  bool fromConfigFile(const std::string& fname,
368  Searchable& env,
369  bool wipe=true);
370 
381  bool fromConfigDir(const std::string& dirname,
382  const std::string& section = std::string(),
383  bool wipe = true);
384 
392  void fromConfig(const char *txt, bool wipe=true);
393 
406  void fromConfig(const char *txt,
407  Searchable& env,
408  bool wipe=true);
409 
419  void fromQuery(const char *url,
420  bool wipe=true);
421 
422 
423  // documented in Searchable
424  std::string toString() const override;
425 
426  // documented in Portable
427  bool read(ConnectionReader& reader) override;
428 
429  // documented in Portable
430  bool write(ConnectionWriter& writer) const override;
431 
432 private:
435 
436  void summon();
437  bool check() const;
438 };
439 
440 #endif // YARP_OS_PROPERTY_H
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:430
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:393
A class for storing options and configuration information.
Definition: Property.h:35
A base class for nested structures that can be searched.
Definition: Searchable.h:65
This is a base class for objects that can be both read from and be written to the YARP network...
Definition: Portable.h:27
void * implementation
Definition: Property.h:433
#define YARP_OS_API
Definition: api.h:19
The main, catch-all namespace for YARP.
Definition: numeric.h:47
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
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:70
An interface for reading from a network connection.
A single value (typically within a Bottle).
Definition: Value.h:40
std::string toString(const T &value)
convert an arbitrary type to string.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.