REC RPC library
rec_rpc_serialization_String.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2011, REC Robotics Equipment Corporation GmbH, Planegg, Germany
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 - Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 - Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation and/or
12  other materials provided with the distribution.
13 - Neither the name of the REC Robotics Equipment Corporation GmbH nor the names of
14  its contributors may be used to endorse or promote products derived from this software
15  without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
18 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
24 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 #ifndef _REC_RPC_SERIALIZATION_STRING_H_
28 #define _REC_RPC_SERIALIZATION_STRING_H_
29 
31 #include "rec/rpc/defines.h"
32 
33 #include <QString>
34 
35 namespace rec
36 {
37  namespace rpc
38  {
39  namespace serialization
40  {
42  class REC_RPC_EXPORT String : public Primitive< QString >
43  {
44  public:
46  String();
48  String( const QString& s );
50  String( const std::string& s );
52  String( const std::wstring& s );
54  String( const char* s );
56  String( const wchar_t* s );
57 
59  std::string toStdString() const;
61  void setStdString( const std::string& s );
62 
64  std::wstring toStdWString() const;
66  void setStdWString( const std::wstring& s );
67 
69  void setCString( const char* s );
71  void setCWString( const wchar_t* s );
72  };
73  }
74  }
75 }
76 
87 #define DECLARE_STRING_MEMBER( NAME ) \
88  private: \
89  QSharedPointer< rec::rpc::serialization::String > _##NAME; \
90  void create_##NAME() { _##NAME = QSharedPointer< rec::rpc::serialization::String >( new rec::rpc::serialization::String ); } \
91  public: \
92  const QString& NAME() const { return *_##NAME; } \
93  QString& NAME() { return *_##NAME; } \
94  void set##NAME( const QString& value ) { _##NAME->setValue( value ); }
95 
101 #define DEFINE_STRING_PARAM( FUNCTIONNAME ) DEFINE_SERIALIZABLE( FUNCTIONNAME##Param, rec::rpc::serialization::String );
102 
108 #define DEFINE_STRING_RESULT( FUNCTIONNAME ) DEFINE_SERIALIZABLE( FUNCTIONNAME##Result, rec::rpc::serialization::String );
109 
115 #define DEFINE_STRING_TOPICDATA( TOPICNAME ) DEFINE_SERIALIZABLE( topic##TOPICNAME##Data, rec::rpc::serialization::String );
116 
117 #endif //_REC_RPC_SERIALIZATION_STRING_H_
Serialization class for strings.
#define REC_RPC_EXPORT
Definition: defines.h:49
Serialization class for primitive objects and values.