stromx  0.8.0
String.h
1 /*
2 * Copyright 2012 Matthias Fuchs
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17 #ifndef STROMX_RUNTIME_STRING_H
18 #define STROMX_RUNTIME_STRING_H
19 
20 #include <string>
21 #include "stromx/runtime/Data.h"
22 
23 namespace stromx
24 {
25  namespace runtime
26  {
28  class STROMX_RUNTIME_API String : public Data
29  {
30  friend STROMX_RUNTIME_API bool operator==(const String & lhs, const String & rhs);
31  friend STROMX_RUNTIME_API bool operator!=(const String & lhs, const String & rhs);
32  friend STROMX_RUNTIME_API std::ostream& operator<<(std::ostream& out, const String& string);
33 
34  public:
36  explicit String() {}
37 
39  explicit String(const std::string & value) : m_value(value) {}
40 
42  explicit String(const char * value) : m_value(value) {}
43 
44  virtual const std::string & type() const { return TYPE; }
45  virtual const Version & version() const { return VERSION; }
46  virtual const std::string & package() const { return PACKAGE; }
47 
48  virtual const VariantHandle & variant() const;
49 
50  virtual Data* clone() const { return new String(m_value); }
51 
52  virtual void serialize(OutputProvider & out) const;
53 
54  virtual void deserialize(InputProvider & in, const Version & version);
55 
57  const std::string & get() const { return m_value; }
58 
60  operator std::string() const { return get(); }
61 
62  private:
63  static const std::string TYPE;
64  static const std::string PACKAGE;
65  static const Version VERSION;
66 
67  std::string m_value;
68  };
69 
71  STROMX_RUNTIME_API bool operator==(const String & lhs, const String & rhs);
72 
74  STROMX_RUNTIME_API bool operator!=(const String & lhs, const String & rhs);
75 
76  STROMX_RUNTIME_API std::ostream& operator<<(std::ostream& out, const String& string);
77 
79  template <>
80  class STROMX_RUNTIME_API data_traits<String>
81  {
82  public:
83  static const VariantHandle & variant();
84  };
86  }
87 }
88 
89 
90 
91 #endif // STROMX_RUNTIME_STRING_H
A version of an operator or data type.
Definition: Version.h:46
Abstract data object.
Definition: Data.h:53
Definition: VariantHandle.h:34
virtual const Version & version() const
Definition: String.h:45
virtual const std::string & package() const
Definition: String.h:46
virtual const std::string & type() const
Definition: String.h:44
Provides functions to serialize data to strings and files.
Definition: OutputProvider.h:27
Provides functions to deserialize data from strings and files.
Definition: InputProvider.h:27
String(const char *value)
Definition: String.h:42
Version version()
Returns the version of the stromx runtime library.
Definition: Runtime.cpp:54
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
String()
Definition: String.h:36
String(const std::string &value)
Definition: String.h:39
String data value.
Definition: String.h:28
virtual Data * clone() const
Definition: String.h:50
bool operator!=(const runtime::DataContainer &lhs, const runtime::DataContainer &rhs)
Definition: DataContainer.cpp:46