My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Port.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_PORT_H
2 #define GCP_UTIL_PORT_H
3 
11 #include <string>
12 #include <deque>
13 #include "gcp/util/common/String.h"
14 #include "gcp/util/common/Vector.h"
15 
16 namespace gcp {
17  namespace util {
18 
19  class Port {
20  public:
21 
22  static const unsigned int MAX_RCV_BUFFER = 300;
23 
24  // The default telnet port number
25 
26  static const unsigned TELNET_PORT_NO = 23;
27 
31  Port(int fd = -1);
32 
36  virtual ~Port();
37 
41  inline int getFd() {
42  return fd_;
43  }
44 
48  virtual int connect() {};
49 
53  void writeString(std::string& message, int fd=-1);
55  static void writeBytes(Vector<unsigned char>& buffer, int fd);
56 
60  unsigned int readBytes(unsigned char *message, int fd=-1);
61  unsigned int readBytes(Vector<unsigned char>& buffer);
62 
63  // Read tne next byte from the serial port
64 
65  unsigned char getNextByte();
66 
67  std::string readString(int fd=-1);
68 
69  bool concatenateString(std::ostringstream& os, int fd=-1, bool cont=true);
70  void concatenateChar(std::ostringstream& os, int fd=-1);
71  int getNbyte(int fd=-1);
72 
77  void terminateAt(std::string strip);
78 
83  void strip(std::string strip);
84 
89  void dontStrip(std::string strip);
90 
94  void stripUnprintable(bool strip);
95 
99  void append(std::string append);
100 
104  void setNoBuf();
105 
109  void setLineBuf();
110 
111  protected:
112 
113  int fd_;
114 
115  private:
116 
117  String termStr_;
118  String stripStr_;
119  String dontStripStr_;
120  String appendStr_;
121  bool stripUnprintable_;
122 
123  }; // End class Port
124 
125  } // End namespace util
126 } // End namespace gcp
127 
128 
129 
130 
131 #endif // End #ifndef GCP_UTIL_PORT_H
void stripUnprintable(bool strip)
Definition: Port.cc:358
Port(int fd=-1)
Definition: Port.cc:22
void setNoBuf()
Definition: Port.cc:379
Definition: Port.h:19
int getFd()
Definition: Port.h:41
Definition: String.h:16
virtual int connect()
Definition: Port.h:48
virtual ~Port()
Definition: Port.cc:30
void dontStrip(std::string strip)
Definition: Port.cc:350
void setLineBuf()
Definition: Port.cc:371
void writeString(std::string &message, int fd=-1)
Definition: Port.cc:35
Definition: Vector.h:27
void writeBytes(Vector< unsigned char > &buffer)
Definition: Port.cc:95
void terminateAt(std::string strip)
Definition: Port.cc:334
Definition: tVideoCapabilitiesEml.cc:67
void strip(std::string strip)
Definition: Port.cc:342
unsigned int readBytes(unsigned char *message, int fd=-1)
Definition: Port.cc:193
void append(std::string append)
Definition: Port.cc:366