Permalink
Browse files

added Buffer class

  • Loading branch information...
1 parent ff510be commit 61a0c7bd1175226c95d4c36413b70eb6b67a134f @d5 committed Feb 18, 2012
Showing with 47 additions and 0 deletions.
  1. +46 −0 native/buffers.h
  2. +1 −0 native/events.h
View
@@ -0,0 +1,46 @@
+#ifndef __BUFFERS_H__
+#define __BUFFERS_H__
+
+#include "base.h"
+
+namespace native
+{
+ // TODO: implement Buffer class
+ class Buffer
+ {
+ public:
+ Buffer()
+ : data_()
+ {}
+
+ Buffer(const Buffer& c)
+ : data_(c.data_)
+ {}
+
+ Buffer(const std::vector<char>& data)
+ : data_(data)
+ {}
+
+ Buffer(const std::string& str)
+ : data_(str.begin(), str.end())
+ {}
+
+ virtual ~Buffer()
+ {}
+
+ public:
+ char& operator[](std::size_t idx) { return data_[idx]; }
+ const char& operator[](std::size_t idx) const { return data_[idx]; }
+
+ Buffer& operator =(const Buffer& c)
+ {
+ data_ = c.data_;
+ return *this;
+ }
+
+ private:
+ std::vector<char> data_;
+ };
+}
+
+#endif
View
@@ -9,6 +9,7 @@ namespace native
{
class Exception;
class Stream;
+ class Buffer;
namespace net { class Socket; }
namespace ev

0 comments on commit 61a0c7b

Please sign in to comment.