Subversion Repositories HomeAutomation

Rev

Rev 1598 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  *
  3.  *  Copyright (C) 2010  Mattias Runge
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License along
  16.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  *
  19.  */
  20.  
  21. #ifndef TYPE_BUFFER_H
  22. #define TYPE_BUFFER_H
  23.  
  24. #include <string>
  25.  
  26. #include <boost/shared_ptr.hpp>
  27.  
  28. #include "common.h"
  29.  
  30. namespace atom {
  31. namespace common {
  32.  
  33. class Byteset
  34. {
  35. public:
  36.     typedef boost::shared_ptr<Byteset> Pointer;
  37.    
  38.     Byteset(unsigned int max_size);
  39.     Byteset(const Byteset& set);
  40.     Byteset(std::string str);
  41.     virtual ~Byteset();
  42.    
  43.     unsigned int GetMaxSize() const;
  44.     unsigned char* Get() const;
  45.    
  46.     std::string ToCharString();
  47.     std::string ToDebugString();
  48.    
  49.     unsigned char& operator[](unsigned int index);
  50.  
  51.     unsigned int GetSize() const;
  52.     void SetSize(unsigned int size);
  53.    
  54.     void Append(unsigned char byte);
  55.    
  56.     void Clear();
  57.     void Fill(char c);
  58.    
  59. private:
  60.     unsigned char* bytes_;
  61.     unsigned int max_size_;
  62.    
  63.     unsigned int size_;
  64.    
  65. };
  66.  
  67. }; // namespace type
  68. }; // namespace atom
  69.  
  70. #endif // TYPE_BUFFER_H
  71.