Poco::MongoDB

class Binary

Library: MongoDB
Package: MongoDB
Header: Poco/MongoDB/Binary.h

Description

Implements BSON Binary.

A Binary stores its data in a Poco::Buffer<unsigned char>.

Member Summary

Member Functions: buffer, subtype, toRawString, toString, uuid

Types Aliases

Ptr

using Ptr = SharedPtr < Binary >;

Constructors

Binary

Binary();

Creates an empty Binary with subtype 0.

Binary

Binary(
    const UUID & uuid
);

Creates a Binary containing an UUID.

Binary

Binary(
    Poco::Int32 size,
    unsigned char subtype
);

Creates a Binary with a buffer of the given size and the given subtype.

Binary

Binary(
    const std::string & data,
    unsigned char subtype = 0
);

Creates a Binary with the contents of the given string and the given subtype.

Binary

Binary(
    const void * data,
    Poco::Int32 size,
    unsigned char subtype = 0
);

Creates a Binary with the contents of the given buffer and the given subtype.

Destructor

~Binary virtual

virtual ~Binary();

Destroys the Binary.

Member Functions

buffer inline

Buffer < unsigned char > & buffer();

Returns a reference to the internal buffer

subtype inline

unsigned char subtype() const;

Returns the subtype.

subtype

void subtype(
    unsigned char type
);

Sets the subtype.

toRawString inline

std::string toRawString() const;

Returns the raw content of the Binary as a string.

toString

std::string toString(
    int indent = 0
) const;

Returns the contents of the Binary as Base64-encoded string.

uuid

UUID uuid() const;

Returns the UUID when the binary subtype is 0x04. Otherwise, throws a Poco::BadCastException.