forked from chronolaw/boost_guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhex.cpp
More file actions
49 lines (37 loc) · 838 Bytes
/
Copy pathhex.cpp
File metadata and controls
49 lines (37 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2015
// Author: Chrono Law
#include <std.hpp>
using namespace std;
#include <boost/algorithm/hex.hpp>
using namespace boost::algorithm;
//////////////////////////////////////////
void case1()
{
string s;
hex("123", ostream_iterator<char>(cout));
cout << endl;
hex("ABC", std::back_inserter(s));
cout << s << endl;
unhex(s, ostream_iterator<char>(cout));
cout << endl;
hex("+-*/", ostream_iterator<char>(cout));
cout << endl;
hex_lower("+-*/", ostream_iterator<char>(cout));
cout << endl;
}
//////////////////////////////////////////
void case2()
try
{
//unhex("313", ostream_iterator<char>(cout));
unhex("xyz", ostream_iterator<char>(cout));
}
catch(const boost::exception& e)
{
cout << "unhex error" << endl;
}
int main()
{
case1();
case2();
}