MarkLogic Connect
MarkLogic Connect Client API Collection
Public Member Functions | Static Public Attributes | List of all members
mlclient::IDocumentContent Class Referenceabstract

This class represents the internal content of a Document. It can be XML, JSON, String or Binary (or a sub type thereof). More...

#include <DocumentContent.hpp>

Inheritance diagram for mlclient::IDocumentContent:
mlclient::FileDocumentContent mlclient::ITextDocumentContent mlclient::GenericTextDocumentContent mlclient::utilities::CppRestJsonDocumentContent mlclient::utilities::PugiXmlDocumentContent

Public Member Functions

MLCLIENT_API IDocumentContent ()
 
virtual MLCLIENT_API ~IDocumentContent ()=0
 
virtual MLCLIENT_API std::istream * getStream () const =0
 Returns the content of this IDocumentContent as an istream. More...
 
virtual MLCLIENT_API std::string getContent () const =0
 Returns the content of this IDocumentContent as a std::string. More...
 
virtual MLCLIENT_API std::string getMimeType () const =0
 Returns the MIME type of this content. More...
 
virtual MLCLIENT_API void setMimeType (const std::string &mt)=0
 Sets the MIME type of this content. More...
 

Static Public Attributes

static MLCLIENT_API const std::string MIME_JSON
 
static MLCLIENT_API const std::string MIME_XML
 

Detailed Description

This class represents the internal content of a Document. It can be XML, JSON, String or Binary (or a sub type thereof).

This class can also be used to wrap search options and other JSON/XML based content. There are only two specialisations of this class - text and binary - all more complex types are created by using the CppRestJsonHelper and PugiXmlHelper to parse/create these types. E.g. a pugixml::document or web::json::value.

Author
Adam Fowler adam..nosp@m.fowl.nosp@m.er@ma.nosp@m.rklo.nosp@m.gic.c.nosp@m.om
Since
8.0.0
Date
2016-04-25
Note
This is an abstract class designed for extending, and cannot be instantiated directly.

Constructor & Destructor Documentation

MLCLIENT_API mlclient::IDocumentContent::IDocumentContent ( )

The IDocumentContent constructor. Called implicitly by subclasses only.

virtual MLCLIENT_API mlclient::IDocumentContent::~IDocumentContent ( )
pure virtual

A virtual destructor, ripe for overloading. REQUIRED to allow subclassing

Member Function Documentation

virtual MLCLIENT_API std::string mlclient::IDocumentContent::getContent ( ) const
pure virtual

Returns the content of this IDocumentContent as a std::string.

This allows streaming of a HTTP request, with data encoded as a string.

Returns
A string representing this content;

Implemented in mlclient::FileDocumentContent, mlclient::GenericTextDocumentContent, mlclient::utilities::PugiXmlDocumentContent, and mlclient::utilities::CppRestJsonDocumentContent.

virtual MLCLIENT_API std::string mlclient::IDocumentContent::getMimeType ( ) const
pure virtual

Returns the MIME type of this content.

E.g. application/json or application/xml

Returns
The string representation of the MIME type. Does not include encoding (always assume UTF-8 for MarkLogic Server)

Implemented in mlclient::FileDocumentContent, mlclient::GenericTextDocumentContent, mlclient::utilities::PugiXmlDocumentContent, and mlclient::utilities::CppRestJsonDocumentContent.

virtual MLCLIENT_API std::istream* mlclient::IDocumentContent::getStream ( ) const
pure virtual

Returns the content of this IDocumentContent as an istream.

This allows streaming to a HTTP request, and works for binary and string content.

Note
The stream may be read from asynchronously, so do not destroy the underlying content after returning the stream.
Returns
An ostream instance wrapping the content of this Document Content instance

Implemented in mlclient::FileDocumentContent, mlclient::GenericTextDocumentContent, mlclient::utilities::PugiXmlDocumentContent, and mlclient::utilities::CppRestJsonDocumentContent.

virtual MLCLIENT_API void mlclient::IDocumentContent::setMimeType ( const std::string &  mt)
pure virtual

Sets the MIME type of this content.

E.g. application/json or application/xml

Parameters
[in]mtThe mimetype string, not including encoding, for this Document Content. Assume always UTF-8 for MarkLogic Server)

Implemented in mlclient::FileDocumentContent, mlclient::GenericTextDocumentContent, mlclient::utilities::PugiXmlDocumentContent, and mlclient::utilities::CppRestJsonDocumentContent.


The documentation for this class was generated from the following file: