Subversion Repositories HomeAutomation

Rev

Rev 1608 | Rev 1916 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1608 Rev 1642
Line 23... Line 23...
23
#include "string.h"
23
#include "string.h"
24
 
24
 
25
#include <boost/lexical_cast.hpp>
25
#include <boost/lexical_cast.hpp>
26
 
26
 
27
namespace atom {
27
namespace atom {
28
namespace type {
28
namespace common {
29
 
29
 
30
Byteset::Byteset(unsigned int max_size)
30
Byteset::Byteset(unsigned int max_size)
31
{
31
{
32
    this->max_size_ = max_size;
32
    this->max_size_ = max_size;
33
    this->bytes_ = new unsigned char[this->max_size_];
33
    this->bytes_ = new unsigned char[this->max_size_];
Line 80... Line 80...
80
    return debug_string;
80
    return debug_string;
81
}
81
}
82
 
82
 
83
unsigned char& Byteset::operator[](unsigned int index)
83
unsigned char& Byteset::operator[](unsigned int index)
84
{
84
{
-
 
85
    if (this->size_ < index + 1)
-
 
86
    {
-
 
87
        this->size_ = index + 1;
-
 
88
    }
-
 
89
   
85
    return this->bytes_[index];
90
    return this->bytes_[index];
86
}
91
}
87
 
92
 
88
unsigned int Byteset::GetMaxSize() const
93
unsigned int Byteset::GetMaxSize() const
89
{
94
{
90
    return this->max_size_;
95
    return this->max_size_;
91
}
96
}
92
 
97
 
93
unsigned int Byteset::GetSize() const
98
unsigned int Byteset::GetSize() const
94
{
99
{
95
    return this->size_;
100
    return this->size_;
96
}
101
}
97
 
102
 
98
void Byteset::SetSize(unsigned int size)
103
void Byteset::SetSize(unsigned int size)
99
{
104
{
100
    this->size_ = size;
105
    this->size_ = size;
101
}
106
}
102
 
107
 
103
void Byteset::Append(unsigned char byte)
108
void Byteset::Append(unsigned char byte)
104
{
109
{
105
    this->bytes_[this->size_] = byte;
110
    this->bytes_[this->size_] = byte;
106
    this->size_++;
111
    this->size_++;
107
}
112
}
108
 
113
 
109
void Byteset::Clear()
114
void Byteset::Clear()
-
 
115
{
-
 
116
    memset(this->bytes_, 0, this->max_size_);
-
 
117
    this->size_ = 0;
-
 
118
}
-
 
119
 
-
 
120
void Byteset::Fill(char c)
110
{
121
{
111
    memset(this->bytes_, 0, this->max_size_);
122
    memset(this->bytes_, c, this->max_size_);
112
    this->size_ = 0;
123
    this->size_ = 0;
113
}
124
}
114
   
125
   
115
}; // namespace type
126
}; // namespace type
116
}; // namespace atom
127
}; // namespace atom