-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbencodedstring.cpp
More file actions
47 lines (37 loc) · 828 Bytes
/
Copy pathbencodedstring.cpp
File metadata and controls
47 lines (37 loc) · 828 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
#include "bencodedstring.h"
BencodedString::BencodedString()
{
}
std::string BencodedString::str() const
{
return m_stream.str();
}
BencodedString& BencodedString::operator<<(int i)
{
m_stream << 'i' << i << 'e';
return *this;
}
BencodedString& BencodedString::operator<<(const std::string& str)
{
m_stream << str.size() << ':' << str;
return *this;
}
BencodedString& BencodedString::operator<<(const manipulator& manip)
{
return manip(*this);
}
BencodedString& BencodedString::beginDic(BencodedString& bstr)
{
bstr.m_stream << 'd';
return bstr;
}
BencodedString& BencodedString::beginList(BencodedString& bstr)
{
bstr.m_stream << 'l';
return bstr;
}
BencodedString& BencodedString::end(BencodedString& bstr) //end a list or a dic
{
bstr.m_stream << 'e';
return bstr;
}