Arbitrary binary data.
| 38 | |
| 39 | /// Arbitrary binary data. |
| 40 | class binary : public std::vector<uint8_t> { |
| 41 | public: |
| 42 | /// @name Constructors |
| 43 | /// @{ |
| 44 | explicit binary() = default; |
| 45 | using std::vector<value_type>::vector; |
| 46 | explicit binary(const std::vector<value_type>& v) : std::vector<value_type>(v) {} |
| 47 | explicit binary(const std::string& s) : std::vector<value_type>(s.begin(), s.end()) {} |
| 48 | /// @} |
| 49 | |
| 50 | /// Convert to std::string |
| 51 | operator std::string() const { return std::string(begin(), end()); } |
| 52 | |
| 53 | /// Assignment |
| 54 | binary& operator=(const std::string& x) { assign(x.begin(), x.end()); return *this; } |
| 55 | }; |
| 56 | |
| 57 | /// Print a binary value |
| 58 | PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const binary&); |