AgentXcpp
Revision:0.1.1
Internals Documentation
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Friends
Pages
binary.hpp
Go to the documentation of this file.
1
/*
2
* Copyright 2011-2012 Tanjeff-Nicolai Moos <tanjeff@cccmz.de>
3
*
4
* This file is part of the agentXcpp library.
5
*
6
* AgentXcpp is free software: you can redistribute it and/or modify
7
* it under the terms of the AgentXcpp library license, version 1, which
8
* consists of the GNU General Public License and some additional
9
* permissions.
10
*
11
* AgentXcpp is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* See the AgentXcpp library license in the LICENSE file of this package
17
* for more details.
18
*/
19
#ifndef _TYPES_H_
20
#define _TYPES_H_
21
22
#include <string>
23
#include <ostream>
24
25
#include <boost/cstdint.hpp>
26
27
namespace
agentxcpp
28
{
29
30
/**
31
* \brief A type representing a contigous byte stream.
32
*
33
* This class is used as container for binary data.
34
*/
35
class
binary
:
public
std::basic_string<boost::uint8_t>
36
{
37
};
38
39
/**
40
* \brief Output operator for binary.
41
*/
42
inline
std::ostream&
operator<<
(std::ostream& out,
const
binary
& data)
43
{
44
out <<
"+----------+----------+----------+----------+"
<< std::endl;
45
out <<
"| "
;
//begin line
46
for
(
size_t
i = 0; i < data.size(); i++)
47
{
48
out.width(8);
// 8 chars per field
49
out << (int)data[i] <<
" | "
;
50
if
( (i+1)%4 == 0 )
51
{
52
out << std::endl;
// end line
53
out <<
"+----------+----------+----------+----------+"
;
54
if
( i != data.size() - 1 )
55
{
56
// We have further data; begin a new line
57
out << std::endl <<
"| "
;
58
}
59
}
60
}
61
out << std::endl;
62
63
return
out;
64
}
65
}
66
67
#endif
src
binary.hpp
Generated by
1.8.1.1