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 <yarp/os/Portable.h>
15 #include <yarp/os/Searchable.h>
16 
17 #include <string>
18 
19 namespace yarp {
20 namespace os {
21 
34 class YARP_OS_API Property : public Searchable, public Portable
35 {
36 public:
37  using Searchable::check;
39 
48  Property(int hash_size = 0);
49 
53  Property(const char* str);
54 
55 
59  Property(const Property& prop);
60 
64  virtual ~Property();
65 
69  const Property& operator=(const Property& prop);
70 
71  // documented in Searchable
72  bool check(const std::string& key) const override;
73 
85  void put(const std::string& key, const std::string& value);
86 
98  void put(const std::string& key, const Value& value);
99 
111  void put(const std::string& key, Value* value);
112 
124  void put(const std::string& key, int value);
125 
137  void put(const std::string& key, double value);
138 
149  Property& addGroup(const std::string& key);
150 
159  void unput(const std::string& key);
160 
161  // documented in Searchable
162  Value& find(const std::string& key) const override;
163 
164  // documented in Searchable
165  Bottle& findGroup(const std::string& key) const override;
166 
173  void clear();
174 
196  void fromString(const std::string& txt, bool wipe = true);
197 
222  void fromCommand(int argc, char* argv[], bool skipFirst = true, bool wipe = true);
223 
248  void fromCommand(int argc, const char* argv[], bool skipFirst = true, bool wipe = true);
249 
271  void fromArguments(const char* arguments, bool wipe = true);
272 
349  bool fromConfigFile(const std::string& fname, bool wipe = true);
350 
364  bool fromConfigFile(const std::string& fname,
365  Searchable& env,
366  bool wipe = true);
367 
378  bool fromConfigDir(const std::string& dirname,
379  const std::string& section = std::string(),
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  std::string toString() const override;
422 
423  // documented in Portable
424  bool read(ConnectionReader& reader) override;
425 
426  // documented in Portable
427  bool write(ConnectionWriter& writer) const override;
428 
429 private:
432 
433  void summon();
434  bool check() const;
435 };
436 
437 } // namespace os
438 } // namespace yarp
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:34
A base class for nested structures that can be searched.
Definition: Searchable.h:66
This is a base class for objects that can be both read from and be written to the YARP network...
Definition: Portable.h:28
void * implementation
Definition: Property.h:430
#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:72
An interface for reading from a network connection.
A single value (typically within a Bottle).
Definition: Value.h:46
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.