C++ Client  0.0.0.0
C++ wrapper for Corelink DLL
CorelinkConst.h
Go to the documentation of this file.
1 
5 #ifndef CORELINKCONST_H
6 #define CORELINKCONST_H
7 #pragma once
8 
9 /*
10 Use if it is preferable allocating data from the wrapper side.
11 May come in handy when dealing with languages other than c++.
12 Performance is better if this is off, though difference should be negligible.
13 */
14 #define WRAPPER_ALLOC
15 
16 #include "corelink/corelink_dll.h"
17 
18 namespace Corelink {
23  static int streamStateToBitIndex(int state) {
24  return CorelinkDLL::streamStateToBitIndex(state);
25  }
26 
27  static std::string streamStateName(int state) {
28  #ifdef WRAPPER_ALLOC
29  int len;
30  char* buffer;
31  std::string name;
32  len = CorelinkDLL::streamStateNameLen(state);
33  if (len == 0) { return ""; }
34  buffer = new char[len];
35  CorelinkDLL::streamStateNameStr(state, buffer);
36  // get rid of null character at end of the string
37  name = std::string(buffer, len - 1);
38  delete[] buffer;
39  return name;
40  #else
41  return std::string(CorelinkDLL::streamStateName(state));
42  #endif
43  }
44 
50  static std::string errorCodeName(int errorCode) {
51  #ifdef WRAPPER_ALLOC
52  int len;
53  char* buffer;
54  std::string name;
55  len = CorelinkDLL::errorCodeNameLen(errorCode);
56  if (len == 0) { return ""; }
57  buffer = new char[len];
58  CorelinkDLL::errorCodeNameStr(errorCode, buffer);
59  // get rid of null character at end of the string
60  name = std::string(buffer, len - 1);
61  delete[] buffer;
62  return name;
63  #else
64  return std::string(CorelinkDLL::errorCodeName(errorCode));
65  #endif
66  }
67 }
68 
69 namespace Corelink {
70  namespace Const {
71  static const int STREAM_STATE_NONE = CorelinkDLL::STREAM_STATE_NONE;
72  static const int STREAM_STATE_SEND_UDP = CorelinkDLL::STREAM_STATE_SEND_UDP;
73  static const int STREAM_STATE_RECV_UDP = CorelinkDLL::STREAM_STATE_RECV_UDP;
74  static const int STREAM_STATE_SEND_TCP = CorelinkDLL::STREAM_STATE_SEND_TCP;
75  static const int STREAM_STATE_RECV_TCP = CorelinkDLL::STREAM_STATE_RECV_TCP;
76  static const int STREAM_STATE_SEND_WS = CorelinkDLL::STREAM_STATE_SEND_WS;
77  static const int STREAM_STATE_RECV_WS = CorelinkDLL::STREAM_STATE_RECV_WS;
78  static const int STREAM_STATE_UDP = CorelinkDLL::STREAM_STATE_UDP;
79  static const int STREAM_STATE_TCP = CorelinkDLL::STREAM_STATE_TCP;
80  static const int STREAM_STATE_WS = CorelinkDLL::STREAM_STATE_WS;
81  static const int STREAM_STATE_SEND = CorelinkDLL::STREAM_STATE_SEND;
82  static const int STREAM_STATE_RECV = CorelinkDLL::STREAM_STATE_RECV;
83  static const int STREAM_STATE_ALL = CorelinkDLL::STREAM_STATE_ALL;
84 
85  static const int ERROR_CODE_NONE = CorelinkDLL::ERROR_CODE_NONE;
86  static const int ERROR_CODE_STATE = CorelinkDLL::ERROR_CODE_STATE;
87  static const int ERROR_CODE_VALUE = CorelinkDLL::ERROR_CODE_VALUE;
88  static const int ERROR_CODE_SOCKET = CorelinkDLL::ERROR_CODE_SOCKET;
89  static const int ERROR_CODE_COMM = CorelinkDLL::ERROR_CODE_COMM;
90  static const int ERROR_CODE_NO_TOKEN = CorelinkDLL::ERROR_CODE_NO_TOKEN;
91 
92  static const int CALLBACK_DROPPED = CorelinkDLL::CALLBACK_DROPPED;
93  static const int CALLBACK_STALE = CorelinkDLL::CALLBACK_STALE;
94  static const int CALLBACK_SUBSCRIBE = CorelinkDLL::CALLBACK_SUBSCRIBE;
95  static const int CALLBACK_UPDATE = CorelinkDLL::CALLBACK_UPDATE;
96 
97  static const std::string ErrorCodeString[6] = {
98  errorCodeName(0),
99  errorCodeName(1),
100  errorCodeName(2),
101  errorCodeName(3),
102  errorCodeName(4),
103  errorCodeName(5)
104  };
105  }
106 }
107 
108 #endif