Subversion Repositories HomeAutomation

Rev

Rev 1642 | Rev 1914 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1596 runge 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_COMMON_H
22
#define TYPE_COMMON_H
23
 
24
#include <iostream>
25
#include <string>
26
#include <vector>
1602 runge 27
#include <map>
1642 runge 28
#include <stdexcept>
1596 runge 29
 
1598 runge 30
#include <stdio.h>
31
 
1596 runge 32
#include <boost/shared_ptr.hpp>
1642 runge 33
#include <boost/lexical_cast.hpp>
1596 runge 34
 
35
namespace atom {
1642 runge 36
namespace common {
1596 runge 37
 
38
typedef boost::shared_ptr<unsigned char> BytePointer;
39
typedef std::vector<std::string> StringList;
1602 runge 40
typedef std::map<std::string, std::string> StringMap;
1642 runge 41
 
42
#define SWAP_BYTE_ORDER_16(x) (((x << 8) | (x >> 8)) & 0xFFFF)
43
#define GET_HIGH_BYTE_16(x)   ((x >> 8) & 0xFF);
44
#define GET_LOW_BYTE_16(x)    (x & 0xFF)
45
 
46
template <typename ElemT>
47
struct HexTo {
48
    ElemT value;
49
    operator ElemT() const {return value;}
50
    friend std::istream& operator>>(std::istream& in, HexTo& out) {
51
        in >> std::hex >> out.value;
52
        return in;
53
    }
54
};
55
 
1647 runge 56
std::string PadNumber(unsigned int number, unsigned int length);
57
unsigned int FromHex(std::string hex_chars);
58
std::string ToHex(unsigned int value);
1596 runge 59
 
60
}; // namespace type
61
}; // namespace atom
62
 
63
#endif // TYPE_COMMON_H