1 #ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
15 std::string
EncodeBase64(const unsigned char *data
, std::size_t size
);
16 std::vector
<unsigned char> DecodeBase64(const std::string
& input
);
20 Binary(): m_unownedData(0), m_unownedSize(0) {}
21 Binary(const unsigned char *data
, std::size_t size
): m_unownedData(data
), m_unownedSize(size
) {}
23 bool owned() const { return !m_unownedData
; }
24 std::size_t size() const { return owned() ? m_data
.size() : m_unownedSize
; }
25 const unsigned char *data() const { return owned() ? &m_data
[0] : m_unownedData
; }
27 void swap(std::vector
<unsigned char>& rhs
) {
31 rhs
.resize(m_unownedSize
);
32 std::copy(m_unownedData
, m_unownedData
+ m_unownedSize
, &rhs
[0]);
40 bool operator == (const Binary
& rhs
) const {
41 const std::size_t s
= size();
44 const unsigned char *d1
= data();
45 const unsigned char *d2
= rhs
.data();
46 for(std::size_t i
=0;i
<s
;i
++) {
53 bool operator != (const Binary
& rhs
) const {
54 return !(*this == rhs
);
58 std::vector
<unsigned char> m_data
;
59 const unsigned char *m_unownedData
;
60 std::size_t m_unownedSize
;
63 void operator >> (const Node
& node
, Binary
& binary
);
66 #endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66