YARP
Yet Another Robot Platform
Property.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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 
35  public Searchable,
36  public Portable
37 {
38 public:
39  using Searchable::check;
41 
45  Property();
46 
47 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
48 
58  YARP_DEPRECATED_MSG("Use default constructor instead")
59  Property(int hash_size);
60 #endif
61 
65  Property(const char* str);
66 
67 
71  Property(const Property& rhs);
72 
76  Property(Property&& rhs) noexcept;
77 
82  Property(std::initializer_list<std::pair<std::string, yarp::os::Value>> values);
86  ~Property() override;
87 
91  Property& operator=(const Property& prop);
92 
96  Property& operator=(Property&& prop) noexcept;
97 
98  // documented in Searchable
99  bool check(const std::string& key) const override;
100 
112  void put(const std::string& key, const std::string& value);
113 
125  void put(const std::string& key, const Value& value);
126 
138  void put(const std::string& key, Value* value);
139 
151  void put(const std::string& key, int value);
152 
164  void put(const std::string& key, double value);
165 
176  Property& addGroup(const std::string& key);
177 
186  void unput(const std::string& key);
187 
188  // documented in Searchable
189  Value& find(const std::string& key) const override;
190 
191  // documented in Searchable
192  Bottle& findGroup(const std::string& key) const override;
193 
200  void clear();
201 
223  void fromString(const std::string& txt, bool wipe = true);
224 
249  void fromCommand(int argc, char* argv[], bool skipFirst = true, bool wipe = true);
250 
275  void fromCommand(int argc, const char* argv[], bool skipFirst = true, bool wipe = true);
276 
298  void fromArguments(const char* arguments, bool wipe = true);
299 
376  bool fromConfigFile(const std::string& fname, bool wipe = true);
377 
391  bool fromConfigFile(const std::string& fname,
392  Searchable& env,
393  bool wipe = true);
394 
405  bool fromConfigDir(const std::string& dirname,
406  const std::string& section = std::string(),
407  bool wipe = true);
408 
416  void fromConfig(const char* txt, bool wipe = true);
417 
430  void fromConfig(const char* txt,
431  Searchable& env,
432  bool wipe = true);
433 
443  void fromQuery(const char* url,
444  bool wipe = true);
445 
446 
447  // documented in Searchable
448  std::string toString() const override;
449 
450  // documented in Portable
451  bool read(ConnectionReader& reader) override;
452 
453  // documented in Portable
454  bool write(ConnectionWriter& writer) const override;
455 
456 #ifndef DOXYGEN_SHOULD_SKIP_THIS
457 private:
458  class Private;
459  Private* mPriv;
460 #endif // DOXYGEN_SHOULD_SKIP_THIS
461 };
462 
463 } // namespace os
464 } // namespace yarp
465 
466 #endif // YARP_OS_PROPERTY_H
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:72
yarp::os::Portable
Definition: Portable.h:28
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:68
yarp::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:656
yarp::os::Searchable::findGroup
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
Portable.h
Searchable.h
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:39
yarp::os::Searchable::check
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:39
yarp::os::Property::Private
Definition: Property.cpp:103
YARP_DEPRECATED_MSG
#define YARP_DEPRECATED_MSG(MSG)
Definition: compiler.h:2873
toString
std::string toString(const T &value)
convert an arbitrary type to string.
Definition: fakeMotionControl.cpp:121
yarp
Definition: environment.h:18
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:804
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:46
Bottle.h
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:34