SmartFoxServer 2X C++ API
SFSUserVariable.h
1 // ===================================================================
2 //
3 // Description
4 // Contains the definition of SFSUserVariable
5 //
6 // Revision history
7 // Date Description
8 // 30-Nov-2012 First version
9 //
10 // ===================================================================
11 #ifndef __SFSUserVariable__
12 #define __SFSUserVariable__
13 
14 #include "../../Util/Common.h"
15 #include "BaseVariable.h"
16 #include "UserVariable.h"
17 #include "VariableType.h"
18 #include "../Data/ISFSObject.h"
19 #include "../Data/ISFSArray.h"
20 #include "../Data/SFSArray.h"
21 #include "../Data/SFSObject.h"
22 #include "../../Exceptions/SFSError.h"
23 
24 #include <boost/shared_ptr.hpp> // Boost Asio shared pointer
25 
26 #if defined(_MSC_VER)
27 #pragma warning(disable:4786) // STL library: disable warning 4786; this warning is generated due to a Microsoft bug
28 #endif
29 #include <string> // STL library: string object
30 using namespace std; // STL library: declare the STL namespace
31 
32 
33 using namespace Sfs2X::Entities::Data;
34 using namespace Sfs2X::Exceptions;
35 
36 namespace Sfs2X {
37 namespace Entities {
38 namespace Variables {
39 
56  class DLLImportExport SFSUserVariable : public BaseVariable, public UserVariable
57  {
58  public:
59 
60  // -------------------------------------------------------------------
61  // Public methods
62  // -------------------------------------------------------------------
63 
64  static boost::shared_ptr<UserVariable> FromSFSArray(boost::shared_ptr<ISFSArray> sfsa);
65 
77  SFSUserVariable(string name, boost::shared_ptr<long int> val);
78  SFSUserVariable(string name, boost::shared_ptr<unsigned long int> val);
79  SFSUserVariable(string name, boost::shared_ptr<int> val);
80  SFSUserVariable(string name, boost::shared_ptr<unsigned int> val);
81  SFSUserVariable(string name, boost::shared_ptr<bool> val);
82  SFSUserVariable(string name, boost::shared_ptr<double> val);
83  SFSUserVariable(string name, boost::shared_ptr<string> val);
84  SFSUserVariable(string name, boost::shared_ptr<SFSObject> val);
85  SFSUserVariable(string name, boost::shared_ptr<SFSArray> val);
86 
96  SFSUserVariable(string name, boost::shared_ptr<void> val, long int type);
97 
108  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<long int> val);
109  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<unsigned long int> val);
110  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<int> val);
111  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<unsigned int> val);
112  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<bool> val);
113  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<double> val);
114  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<string> val);
115  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<SFSObject> val);
116  static boost::shared_ptr<SFSUserVariable> newPrivateVariable(string name, boost::shared_ptr<SFSArray> val);
117 
118  virtual ~SFSUserVariable();
119 
120  bool IsPrivate();
121  void IsPrivate(bool value);
122 
123  virtual boost::shared_ptr<string> Name();
124  virtual VariableType Type();
125  virtual boost::shared_ptr<void> Value();
126  virtual boost::shared_ptr<bool> GetBoolValue();
127  virtual boost::shared_ptr<long int> GetIntValue();
128  virtual boost::shared_ptr<double> GetDoubleValue();
129  virtual boost::shared_ptr<string> GetStringValue();
130  virtual boost::shared_ptr<ISFSObject> GetSFSObjectValue();
131  virtual boost::shared_ptr<ISFSArray> GetSFSArrayValue();
132  virtual bool IsNull();
133  virtual boost::shared_ptr<ISFSArray> ToSFSArray();
134  virtual boost::shared_ptr<string> ToString();
135 
136  // -------------------------------------------------------------------
137  // Public members
138  // -------------------------------------------------------------------
139 
140  protected:
141 
142  // -------------------------------------------------------------------
143  // Protected methods
144  // -------------------------------------------------------------------
145 
146  // -------------------------------------------------------------------
147  // Protected members
148  // -------------------------------------------------------------------
149 
150  private:
151 
152  // -------------------------------------------------------------------
153  // Private methods
154  // -------------------------------------------------------------------
155 
156  // -------------------------------------------------------------------
157  // Private members
158  // -------------------------------------------------------------------
159 
160  bool isPrivate;
161  };
162 
163 } // namespace Variables
164 } // namespace Entities
165 } // namespace Sfs2X
166 
167 #endif
Definition: SFSCodecError.cpp:14
STL namespace.
The BaseVariable object is the base class for all SmartFoxServer Variable entities on the client...
Definition: BaseVariable.h:47
The UserVariable interface defines all the public methods and properties that an object representing ...
Definition: UserVariable.h:43
The SFSUserVariable object represents a SmartFoxServer User Variable entity on the client...
Definition: SFSUserVariable.h:56
Definition: SmartFox.cpp:24
Definition: ISFSArray.h:17