Contents:
Search: |
EmdrosEnvOverviewThe EmdrosEnv class is an abstraction of the Emdros API. Use it in your applications as the main interface to Emdros. C++ interface#include <emdros_environment.h> /** Backend kind * * Used to distinguish among backends. * */ enum eBackendKind { kBackendNone = 0,/**< No backend selected */ kPostgreSQL = 1, /**< PostgreSQL */ kMySQL = 2, /**< MySQL */ kSQLite2 = 3, /**< SQLite 2.X.X */ kSQLite3 = 4 /**< SQLite 3.X.X */ }; class EmdrosEnv { public: EmdrosEnv(std::ostream* output_stream, eOutputKind output_kind, eCharsets charset, std::string hostname, std::string user, std::string password, std::string initial_db, eBackendKind backend_kind = DEFAULT_BACKEND_ENUM); // The following constructor uses std::cout (Standard Out) EmdrosEnv(eOutputKind output_kind, eCharsets charset, std::string hostname, std::string user, std::string password, std::string initial_db, eBackendKind backend_kind = DEFAULT_BACKEND_ENUM); virtual ~EmdrosEnv(); // Backend-name static std::string getBackendName(void); // Executing MQL queries // See the mqlExecute* functions // for information on the parameters. bool executeString(const std::string& input, bool& bResult, bool bPrintResult, bool bReportError); bool executeFile(std::string filename, bool& bResult, bool bPrintResult, bool bReportError); bool executeStream(std::istream& strin, bool& bResult, bool bPrintResult, bool bReportError); // Cleaning up // clean() calls MQLExecEnv::clean(). // It is good to call if you are through with a query's results // and there is a long time till the next executeXXX call. void clean(); // Database support // Call the corresponding EMdFDB methods bool connectionOk(void); bool vacuum(bool bAnalyze); bool getMin_m(monad_m& /* out */ min_m); bool getMax_m(monad_m& /* out */ max_m); bool getAll_m_1(SetOfMonads& /* out */ all_m_1); // Returns the string-representation of an enumeration constant in // enum enum_name with the value value. // Just calls the corresponding EMdFDB method. // bDBOK is true on no DB error. virtual std::string getEnumConstNameFromValue(long value, const std::string& enum_name, /* out */ bool &bDBOK); // Transactions // Call the corresponding EMdFDB methods bool beginTransaction(void); bool commitTransaction(void); bool abortTransaction(void); // // Check for results // // Check for sheaf // Returns true on result is sheaf. // Returns false on no result or result not sheaf bool isSheaf(void); // Check for table // Returns true on result is table. // Returns false on no result or result not table. bool isTable(void); // NOTE on statements: // If only one MQL query was executed by the last executeXXX // invocation, then there will be only one statement to get. // If more than one MQL query was given to one of these methods, // only the results from the last statement executed will be available. // Getting results. Next invocation of executeXXX deletes the object, // so you cannot execute a query until you are done processing // the result MQLResult* getResult(void); // Return nil on no result Sheaf* getSheaf(void); // Returns nil on no result or result not a sheaf FlatSheaf* getFlatSheaf(void); // Returns nil on no result or result not a flat sheaf Table* getTable(void); // Returns nil on no result or result not a table Statement *getStatement(void); // Returns nil on no statement // Take over object. You now have responsibility for deleting it, // and it will not be deleted by the next invocation of executeXXX. MQLResult* takeOverResult(void); // Return nil on no result Sheaf* takeOverSheaf(void); // Returns nil on no result or result not a sheaf FlatSheaf* takeOverFlatSheaf(void); // Returns nil on no result or result not a flat sheaf Table* takeOverTable(void); // Returns nil on no result or result not a table Statement *takeOverStatement(void); // Returns nil on no statement // Getting error-messages and info std::string getDBError(void); std::string getCompilerError(void); // Gets the compiler stage that was executed last int getLastCompilerStage(void); // clears local DB error message in EMdFDB and local error in MQLError void clearErrors(void); // Outputting // These all output on the stream in local EMdFOutput, // i.e., the stream you passed to the constructor of EmdrosEnv, // or stdout if the other constructor was used void out(std::string str); // out your own string void out(MQLResult *pResult); void out(Sheaf *pSheaf); void out(Table *pTable); // // XML outputting // // XML declaration. // Calls EMdFOutput::printXMLDecl on the local EMdFOutput void printXMLDecl(); // DTDs void printDTDStart(std::string root_element); void printDTDEnd(); void printDTDMQLResult(void); void printDTDTable(void); void printDTDSheaf(void); // Accessing members MQLExecEnv* getMQLEE(void); }; |