dca_interface  6.3.4
dca::UrlClassificationResults Class Reference

#include <url_classification_result.h>

Detailed Description

Results of an URL classification.

See also
UrlDbClassifier, UrlClassification
// assume we have a valid DcaInstance (myDca), License (myLicense) and DbConnection (myDbConnection)
// initialize the URL Classification module
dca::UrlClassification myUrlClassification =
dca::UrlClassification::create( myDca, myLicense );
UrlDbClassifierOptions creationOptions;
// enable Feedback mechanism
creationOptions.enable_Feedback = true;
// enable detection of embedded URLs
creationOptions.enable_EmbeddedUrlDetection = true;
// create a UrlDbClassifier by using creationOptions
dca::UrlDbClassifier myUrlDbClassifier =
myUrlClassification.createDbClassifier( myDbConnection, creationOptions );
// create a URL object to classify
dca::Url myUrl = dca::Url::create( myDca, "www.ibm.com" );
// declare the classification results
dca::UrlClassificationResults myUrlClassificationResults;
// start URL Classification
myUrlDbClassifier.classify( myUrl, myUrlClassificationResults );
// if myResult returns false an error occurred.
if( !myResult ) {
cout << "Received an error from URL Classification (Error code:" <<
myResult.getReturnCode() << ", Description: " <<
myResult.getDescription() << ")." << endl;
return;
}
if( myUrlClassificationResults.isUnknownUrl() ) {
// if the given URL is unknown there are no resulting categories available
cout << "Received no results, URL is unknown." << endl;
return;
}
if( !myUrlClassificationResults.isCategorized() ) {
// given URL (or host) is KNOWN, but does not have any categories assigned
cout << "URL is known but has no assigned categories." << endl;
return;
}
// we got results and want to print them out
PrintResults( myUrlClassificationResults );

Definition at line 31 of file url_classification_result.h.

Public Member Functions

UrlClassificationResult at (DCA_INDEX_TYPE index) const
 Returns one result of the matched results (if any) with the given index. More...
 
UrlClassificationResult operator[] (DCA_INDEX_TYPE index) const
 Similar to at() but allows a more C++ style access. More...
 
DCA_SIZE_TYPE size () const
 Returns the number of results in the container. More...
 
bool isUnknownUrl () const
 Returns whether a URL is known or unknown. A URL is unknown if it is not contained in the database.
 
bool isCategorized () const
 Returns whether or not the URL matched one or more categories.
 
bool contains (DCA_CATEGORY_ID_TYPE catid) const
 Fast method to see whether the results contain a given category or not. More...
 

Member Function Documentation

◆ at()

UrlClassificationResult dca::UrlClassificationResults::at ( DCA_INDEX_TYPE  index) const

Returns one result of the matched results (if any) with the given index.

Parameters
[in]indexThe index of the UrlClassificationResult. Range is from 0 to size() - 1
Returns
The result item for the given index in the container.
Exceptions
ExDcaOne of the following error codes (available by using ExDca::getReturnCode() in your catch-handler)

◆ operator[]()

UrlClassificationResult dca::UrlClassificationResults::operator[] ( DCA_INDEX_TYPE  index) const

Similar to at() but allows a more C++ style access.

Parameters
[in]indexThe index of the UrlClassificationResult. Range is from 0 to size() - 1
Returns
The result item for the given index in the container.
Exceptions
ExDcaOne of the following error codes (available by using ExDca::getReturnCode() in your catch-handler)

◆ size()

DCA_SIZE_TYPE dca::UrlClassificationResults::size ( ) const

Returns the number of results in the container.

Returns
The size of the container or 0 if the container is empty.

◆ contains()

bool dca::UrlClassificationResults::contains ( DCA_CATEGORY_ID_TYPE  catid) const

Fast method to see whether the results contain a given category or not.

Parameters
[in]catidThe category id to match
Returns
true, if the given catid has been found in the container, false otherwise

The documentation for this class was generated from the following file:
bool isCategorized() const
Returns whether or not the URL matched one or more categories.
static Url create(const DcaInstance &aDcaInstance, const std::string &urlString)
Standard Url creation function.
DCA_RESULT_TYPE getReturnCode() const
Returns the last error code (if any).
FunctionResult classify(const Url &aUrl, UrlClassificationResults &urlResults) const
Performs the URL classification and returns the results.
bool isUnknownUrl() const
Returns whether a URL is known or unknown. A URL is unknown if it is not contained in the database.
Main class for the URL classification.
Results of an URL classification.
URL database classifier class.
static UrlClassification create(const DcaInstance &aDcaInstance, const License &aLicense)
Creates the URL classification module by using the given DcaInstance and License.
std::string getDescription() const
Returns the description for the error or warning.
Standard function result.
Definition: base_classes.h:148
Encapsulates a URL object.
Definition: base_url.h:44
UrlDbClassifier createDbClassifier(const DbConnection &aDbConnection, const UrlDbClassifierOptions &options=UrlDbClassifierOptions()) const
Create a URL database classifier. The classifier is created by using the provided database connection...