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::os {
17 
31  public Searchable,
32  public Portable
33 {
34 public:
35  using Searchable::check;
37 
41  Property();
42 
43 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
54  YARP_DEPRECATED_MSG("Use default constructor instead")
55  Property(int hash_size);
56 #endif
57 
61  Property(const char* str);
62 
63 
67  Property(const Property& rhs);
68 
72  Property(Property&& rhs) noexcept;
73 
78  Property(std::initializer_list<std::pair<std::string, yarp::os::Value>> values);
82  ~Property() override;
83 
87  Property& operator=(const Property& prop);
88 
92  Property& operator=(Property&& prop) noexcept;
93 
94  // documented in Searchable
95  bool check(const std::string& key) const override;
96 
108  void put(const std::string& key, const std::string& value);
109 
121  void put(const std::string& key, const Value& value);
122 
134  void put(const std::string& key, Value* value);
135 
147  void put(const std::string& key, int value);
148 
160  void put(const std::string& key, double value);
161 
172  Property& addGroup(const std::string& key);
173 
182  void unput(const std::string& key);
183 
184  // documented in Searchable
185  Value& find(const std::string& key) const override;
186 
187  // documented in Searchable
188  Bottle& findGroup(const std::string& key) const override;
189 
196  void clear();
197 
219  void fromString(const std::string& txt, bool wipe = true);
220 
245  void fromCommand(int argc, char* argv[], bool skipFirst = true, bool wipe = true);
246 
271  void fromCommand(int argc, const char* argv[], bool skipFirst = true, bool wipe = true);
272 
294  void fromArguments(const char* arguments, bool wipe = true);
295 
372  bool fromConfigFile(const std::string& fname, bool wipe = true);
373 
387  bool fromConfigFile(const std::string& fname,
388  Searchable& env,
389  bool wipe = true);
390 
401  bool fromConfigDir(const std::string& dirname,
402  const std::string& section = std::string(),
403  bool wipe = true);
404 
412  void fromConfig(const char* txt, bool wipe = true);
413 
426  void fromConfig(const char* txt,
427  Searchable& env,
428  bool wipe = true);
429 
439  void fromQuery(const char* url,
440  bool wipe = true);
441 
442 
443  // documented in Searchable
444  std::string toString() const override;
445 
446  // documented in Portable
447  bool read(ConnectionReader& reader) override;
448 
449  // documented in Portable
450  bool write(ConnectionWriter& writer) const override;
451 
452 #ifndef DOXYGEN_SHOULD_SKIP_THIS
453 private:
454  class Private;
455  Private* mPriv;
456 #endif // DOXYGEN_SHOULD_SKIP_THIS
457 };
458 
459 } // namespace yarp::os
460 
461 #endif // YARP_OS_PROPERTY_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
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:25
A class for storing options and configuration information.
Definition: Property.h:33
A base class for nested structures that can be searched.
Definition: Searchable.h:63
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:43
std::string toString(const T &value)
convert an arbitrary type to string.
An interface to the operating system, including Port based communication.
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:915
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1091
#define YARP_os_API
Definition: api.h:18