comments and unused defs removal

This commit is contained in:
Jean-Francois Dockes 2018-11-14 09:43:20 +01:00
parent 036e1da6b4
commit f008457493

View File

@ -24,79 +24,54 @@
class RclConfig; class RclConfig;
namespace Dijon namespace Dijon {
{
class Filter;
/** Provides the list of MIME types supported by the filter(s). /// Document handler interface.
* The character string is allocated with new[]. ///
* This function is exported by dynamically loaded filter libraries. /// Document handler can either translate the text format
*/ /// (e.g. msdoc->text/plain), or/and extract subdocuments from
typedef bool (get_filter_types_func)(std::set<std::string> &); /// multidocument formats (e.g. mbox->message, message->attachments,
/** Returns what data should be passed to the filter(s). /// zip etc.)
* Output is cast from Filter::DataInput to int for convenience. class Filter {
* This function is exported by dynamically loaded filter libraries.
* The aim is to let the client application know before-hand whether
* it should load documents or not.
*/
typedef bool (check_filter_data_input_func)(int);
/** Returns a Filter that handles the given MIME type.
* The Filter object is allocated with new.
* This function is exported by dynamically loaded filter libraries
* and serves as a factory for Filter objects, so that the client
* application doesn't have to know which Filter sub-types handle
* which MIME types.
*/
typedef Filter *(get_filter_func)(const std::string &);
/// Filter interface.
class Filter
{
public: public:
/// Destroys the filter. Filter() {}
Filter()
{
}
virtual ~Filter() {} virtual ~Filter() {}
/// Filter objects cannot be copied.
Filter(const Filter &other) = delete;
Filter& operator=(const Filter& other) = delete;
// Allow me to access the general config. This is a borrowed
// pointer. It has to be read/write, but don't delete.
virtual void setConfig(RclConfig *) = 0; virtual void setConfig(RclConfig *) = 0;
// Enumerations.
/** What data a filter supports as input.
* It can be either the whole document data, its file name, or its URI.
*/
typedef enum { DOCUMENT_DATA=0, DOCUMENT_STRING, DOCUMENT_FILE_NAME,
DOCUMENT_URI } DataInput;
/** Input properties supported by the filter.
*
* - DEFAULT_CHARSET is the source encoding that should be used
* for reading/transcoding the original data if there is no
* other way to determine it (ie: for text/plain files)
* - OPERATING_MODE can be set to either view or index.
* - DJF_UDI Unique document identifier. This can be useful if the
* filter wants to manage a persistent cache.
*/
typedef enum { DEFAULT_CHARSET=0, OPERATING_MODE, DJF_UDI } Properties;
// Information.
/// Returns the MIME type handled by the filter. /// Returns the MIME type handled by the filter.
std::string get_mime_type(void) const std::string get_mime_type(void) const {
{
return m_mimeType; return m_mimeType;
} }
/// Returns what data the filter requires as input. /** Supported input types */
typedef enum {DOCUMENT_DATA = 0, DOCUMENT_STRING, DOCUMENT_FILE_NAME,
DOCUMENT_URI} DataInput;
virtual bool is_data_input_ok(DataInput input) const = 0; virtual bool is_data_input_ok(DataInput input) const = 0;
/* Properties to be set prior to actual operation */
// Initialization. typedef enum {
// Source encoding to be used for reading/transcoding the
// original data if there is no other way to find
// (e.g. for text/plain files)
DEFAULT_CHARSET = 0,
// Either "view" or "index". Some implementations produce
// slightly different data (e.g. avoiding repeating some
// text in index mode)
OPERATING_MODE,
// Unique document identifier. This can be useful if the
// filter wants to manage a persistent cache (e.g. mh_mbox)
DJF_UDI
} Properties;
/** Sets a property, prior to calling set_document_XXX(). /** Sets a property, prior to calling set_document_XXX().
* Returns false if the property is not supported. * Returns false if the property or value is not supported. */
*/
virtual bool set_property(Properties prop_name, virtual bool set_property(Properties prop_name,
const std::string &prop_value) = 0; const std::string &prop_value) = 0;
@ -128,6 +103,7 @@ namespace Dijon
/** (Re)initializes the filter with the given URI. /** (Re)initializes the filter with the given URI.
* Call next_document() to position the filter onto the first document. * Call next_document() to position the filter onto the first document.
* Returns false if this input is not supported or an error occurred. * Returns false if this input is not supported or an error occurred.
* No implementation supports this at the moment.
*/ */
virtual bool set_document_uri(const std::string& mtype, virtual bool set_document_uri(const std::string& mtype,
const std::string &uri) = 0; const std::string &uri) = 0;
@ -161,7 +137,6 @@ namespace Dijon
*/ */
virtual bool skip_to_document(const std::string &ipath) = 0; virtual bool skip_to_document(const std::string &ipath) = 0;
// Accessing documents' contents. // Accessing documents' contents.
/// Returns the message for the most recent error that has occurred. /// Returns the message for the most recent error that has occurred.
@ -182,24 +157,28 @@ namespace Dijon
* that the client application can pass the nested document's content * that the client application can pass the nested document's content
* to another filter that supports this particular type. * to another filter that supports this particular type.
*/ */
virtual const std::map<std::string, std::string> &get_meta_data(void) const virtual const std::map<std::string, std::string>&
{ get_meta_data(void) const {
return m_metaData; return m_metaData;
} }
virtual void clear() {m_metaData.clear();} virtual void clear() {
virtual bool is_unknown() {return false;} m_metaData.clear();
}
// Hack: is this the special version used for unknown types?
virtual bool is_unknown() {
return false;
}
protected: protected:
/// The MIME type handled by the filter. /// The MIME type handled by the filter.
std::string m_mimeType; std::string m_mimeType;
/// Metadata dictionary.
std::map<std::string, std::string> m_metaData;
private: /// Current Metadata dictionary. For multi-document files,
/// Filter objects cannot be copied. /// this may be rebuilt for each sub-document. See
Filter(const Filter &other); /// common/cstr.h for the common key definitions. The document
/// Filter objects cannot be copied. /// text is "content"
Filter& operator=(const Filter& other); std::map<std::string, std::string> m_metaData;
}; };
} }