libcryptosec
ByteArray.h
Go to the documentation of this file.
1 #ifndef BYTEARRAY_H_
2 #define BYTEARRAY_H_
3 
4 #include <string>
5 #include <stdexcept>
6 #include <iostream>
7 #include <sstream>
8 #include <vector>
9 #include <string.h>
10 #include <stdio.h>
11 
12 using namespace std;
13 
24 class ByteArray
25 {
26 public:
30  ByteArray();
31 
37  ByteArray(unsigned int length);
38 
45  ByteArray(const unsigned char* data, unsigned int length);
46 
52  ByteArray(std::ostringstream *buffer);
53 
59  ByteArray(std::string data);
60 
61  ByteArray(char *data);
67  ByteArray(int length);
68 
74  ByteArray(const ByteArray& value);
75 
79  virtual ~ByteArray();
80 
86  char at(int pos) const throw (out_of_range);
87 
93  ByteArray& operator =(const ByteArray& value);
94 
101  friend bool operator ==(const ByteArray& left, const ByteArray& right);
102 
109  friend bool operator !=(const ByteArray& left, const ByteArray& right);
110 
116  unsigned char& operator [](int pos) throw (out_of_range);
117 
124  friend ByteArray& operator xor(const ByteArray& left, const ByteArray& right);
125 
132  void copyFrom(unsigned char* data, unsigned int length);
133 
142  void copyFrom(int offset, int length, ByteArray& data, int offset2);
143 
147  std::istringstream * toStream();
148 
155  void setDataPointer(unsigned char* data, unsigned int length);
156 
160  unsigned char* getDataPointer();
161 
165 // char* data();
166 
170 // std::string toBase64();
171 
175  unsigned int size() const;
176 
180  virtual std::string toString();
181 
185  virtual std::string toHex();
186 
190  virtual std::string toHex(char separator);
191 
195  static ByteArray xOr(vector<ByteArray> &array);
196 
197 private:
198  unsigned char* m_data;
199  unsigned int length;
200 };
201 
202 #endif /*BYTEARRAY_H_*/
bool operator!=(const ByteArray &left, const ByteArray &right)
Definition: ByteArray.cpp:107
Classe usada para transportar dados binários pelo sistema. Pode ser usada para conversão de texto em ...
Definition: ByteArray.h:24
bool operator==(const ByteArray &left, const ByteArray &right)
Definition: ByteArray.cpp:95