main.cpp File Reference

Custom Database sample - create a database program. More...

#include <string>
#include <set>
#include <iostream>
#include <fstream>
#include <sstream>
#include <ctime>
#include "dca/dca_base.h"
#include "dca/dca_customdb_toolbox.h"
#include "dca/dca_url_classification.h"
#include "dca/dca_callbacks.h"

Go to the source code of this file.


#define DCA_BINDIR   "bin/linux"
 DCA subdirectory of the DCA binaries.
#define DCA_INITDIR   "init"
 DCA subdirectory of the DCA initialization data.
#define DCA_LOGDIR   "./logs"
 Relative directory for logfile(s).


const std::string S_UrlString ("")
static void SetupInitData (const std::string &redist_folder, InitData &initData)
 Sets up the given initData by substituting the given redist_folder with DCA subdirectories.
static void SetupLicense (const std::string &ticket, const std::string &product, LicenseData &licenseData)
 Sets up the given licenseData by copying the given ticket and product strings.
static void SetupConnectionData (const std::string &custom_db_folder, DbConnectionData &cData)
 Sets up the given cData to use a custom URL database.
static void PrintToolHeader ()
 Prints out the name and the version of this sample.
static void PrintUsage (const char *name)
 Prints out the syntax of the sample.
static void PrintLicenseInfo (const License &aLicense)
 Prints out the information about the provided License.
void AddUrlAndCategories (UrlCustomDb &aUrlCustomDb, const std::string &aUrlString, const CategorySet &aCategories)
 Adds a given UrlString and given CategorySet to the custom database.
void RemoveUrl (UrlCustomDb &aUrlCustomDb, const std::string &aUrlString)
 Removes a given UrlString from the custom database.
bool LookupUrl (const DcaInstance &theDca, const UrlDbClassifier &aUrlDbClassifier, const std::string &aUrlString, UrlClassificationResults &aUrlClassificationResults)
 Retrieves the UrlClassificationResults for a given UrlString.
bool CreateCustomDbFile (UrlCustomDbModule &aUrlCustomDbModule, const std::string &dbfolder)
 Creates physically a custom database in the given folder.
bool CreateCustomDbInstances (const DcaInstance &theDca, const License &aLicense, UrlCustomDbModule &aUrlCustomDbModule, DbConnection &aDbConnection, const std::string &dbfolder, UrlCustomDb &aUrlCustomDb)
 Creates the given DbConnection and UrlCustomDb instances and returns true on success or false on failure.
bool CreateUrlClassificationInstances (const DcaInstance &theDca, const License &aLicense, const DbConnection &aDbConnection, UrlClassification &aUrlClassification, UrlDbClassifier &aUrlDbClassifier)
 Creates the UrlClassification and UrlDbClassifier instances using the provided initialized DcaInstance, DbConnection and License instances.
bool ProcessCustomDatabase (const DcaInstance &theDca, const License &aLicense)
 Performs the following steps:

  • Initializes the CustomDbModule
  • Creates a custom database file
  • Connects to the custom database
  • Adds an URL with categorizations to the custom database
  • Retrieves the categorization for that URL and print it out
  • Removes the URL from the custom database and verifies that
  • Adds the URL again to the custom database
  • Retrieves the categorization by using the UrlDbClassifier and print it out.

int main (int argc, char *argv[])
 The main routine.


const std::string S_ToolName = "createdbsample"
const std::string S_ToolVersion = "1.0"
std::string custom_db_folder
const std::string S_UsageString
 Usage string, displayed if a parameter is missing.

Detailed Description

Custom Database sample - create a database program.

Definition in file customdb_samples/createdbsample/main.cpp.

Generated on 26 Sep 2016 for dca_interface by  doxygen 1.6.1