YARP
Yet Another Robot Platform
Property.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_PROPERTY_H
8 #define YARP_OS_PROPERTY_H
9 
10 #include <yarp/os/Bottle.h>
11 #include <yarp/os/Portable.h>
12 #include <yarp/os/Searchable.h>
13 
14 #include <string>
15 
16 namespace yarp {
17 namespace os {
18 
32  public Searchable,
33  public Portable
34 {
35 public:
36  using Searchable::check;
38 
42  Property();
43 
44 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
55  YARP_DEPRECATED_MSG("Use default constructor instead")
56  Property(int hash_size);
57 #endif
58 
62  Property(const char* str);
63 
64 
68  Property(const Property& rhs);
69 
73  Property(Property&& rhs) noexcept;
74 
79  Property(std::initializer_list<std::pair<std::string, yarp::os::Value>> values);
83  ~Property() override;
84 
88  Property& operator=(const Property& prop);
89 
93  Property& operator=(Property&& prop) noexcept;
94 
95  // documented in Searchable
96  bool check(const std::string& key) const override;
97 
109  void put(const std::string& key, const std::string& value);
110 
122  void put(const std::string& key, const Value& value);
123 
135  void put(const std::string& key, Value* value);
136 
148  void put(const std::string& key, int value);
149 
161  void put(const std::string& key, double value);
162 
173  Property& addGroup(const std::string& key);
174 
183  void unput(const std::string& key);
184 
185  // documented in Searchable
186  Value& find(const std::string& key) const override;
187 
188  // documented in Searchable
189  Bottle& findGroup(const std::string& key) const override;
190 
197  void clear();
198 
220  void fromString(const std::string& txt, bool wipe = true);
221 
246  void fromCommand(int argc, char* argv[], bool skipFirst = true, bool wipe = true);
247 
272  void fromCommand(int argc, const char* argv[], bool skipFirst = true, bool wipe = true);
273 
295  void fromArguments(const char* arguments, bool wipe = true);
296 
373  bool fromConfigFile(const std::string& fname, bool wipe = true);
374 
388  bool fromConfigFile(const std::string& fname,
389  Searchable& env,
390  bool wipe = true);
391 
402  bool fromConfigDir(const std::string& dirname,
403  const std::string& section = std::string(),
404  bool wipe = true);
405 
413  void fromConfig(const char* txt, bool wipe = true);
414 
427  void fromConfig(const char* txt,
428  Searchable& env,
429  bool wipe = true);
430 
440  void fromQuery(const char* url,
441  bool wipe = true);
442 
443 
444  // documented in Searchable
445  std::string toString() const override;
446 
447  // documented in Portable
448  bool read(ConnectionReader& reader) override;
449 
450  // documented in Portable
451  bool write(ConnectionWriter& writer) const override;
452 
453 #ifndef DOXYGEN_SHOULD_SKIP_THIS
454 private:
455  class Private;
456  Private* mPriv;
457 #endif // DOXYGEN_SHOULD_SKIP_THIS
458 };
459 
460 } // namespace os
461 } // namespace yarp
462 
463 #endif // YARP_OS_PROPERTY_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:26
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
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
A single value (typically within a Bottle).
Definition: Value.h:45
std::string toString(const T &value)
convert an arbitrary type to string.
std::string findGroup(const robotinterface::ParamList &list, const std::string &name)
Definition: Types.cpp:47
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:923
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1099
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18