|
Contents:
Search: |
CEmdrosEnvOverviewThe CEmdrosEnv class is an abstraction of the Emdros API. Use it in your applications as the main interface to Emdros. C++ interface
#include <emdros/emdros_environment.h>
class CEmdrosEnv {
public:
CEmdrosEnv(std::ostream* output_stream,
eOutputKind output_kind, eCharsets charset,
std::string hostname,
std::string user, std::string password,
std::string initial_db);
// The following constructor uses std::cout (Standard Out)
CEmdrosEnv(eOutputKind output_kind, eCharsets charset,
std::string hostname,
std::string user, std::string password,
std::string initial_db);
virtual ~CEmdrosEnv();
// Backend-name
static std::string BackendName(void);
// Executing MQL queries
// See the mql_execute_* functions
// for information on the parameters.
bool execute_string(const std::string{PREAMP} input, bool{PREAMP} bResult,
bool bPrintResult, bool bReportError);
bool execute_file(std::string filename, bool{PREAMP} bResult,
bool bPrintResult, bool bReportError);
bool execute_stream(std::istream{PREAMP} strin, bool{PREAMP} bResult,
bool bPrintResult, bool bReportError);
// Cleaning up
// clean() calls CMQL_execution_environment::clean().
// It is good to call if you are through with a query's results
// and there is a long time till the next execute_* call.
void clean();
// Database support
// Call the corresponding EMdFDB methods
bool ConnectionOk(void);
bool Vacuum(bool bAnalyze);
bool Get_min_m(monad_m{PREAMP} /* out */ min_m);
bool Get_max_m(monad_m{PREAMP} /* out */ max_m);
bool Get_all_m_1(CSet_of_monad_ms{PREAMP} /* out */ all_m_1);
// Returns the string-representation of an enumeration constant in
// enum enum_name with the value value. If more than one enum constant
// has the same value, it is undefined which of them is returned.
// Just calls the corresponding EMdFDB method.
// bDBOK is true on no DB error.
virtual std::string GetEnumConstNameFromValue(long value,
const std::string{PREAMP} enum_name,
/* out */ bool {PREAMP}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 execute_*
// 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 execute_*. deletes the object,
// so you cannot execute a query until you are done processing
// the result
CMQLResult* getResult(void); // Return nil on no result
CSheaf* getSheaf(void); // Returns nil on no result or result not a sheaf
CTable* getTable(void); // Returns nil on no result or result not a table
CStatement *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 execute_*.
CMQLResult* takeOverResult(void); // Return nil on no result
CSheaf* takeOverSheaf(void); // Returns nil on no result or result not a sheaf
CTable* takeOverTable(void); // Returns nil on no result or result not a table
CStatement *takeOverStatement(void); // Returns nil on no statement
// Getting error-messages and info
std::string get_DB_error(void);
std::string get_compiler_error(void);
// Gets the compiler stage that was executed last
int get_last_compiler_stage(void);
// clears local DB error message in EMdFDB and local error in CMQLError
void clear_errors(void);
// Outputting
// These all output on the stream in local CEMdFOutput,
// i.e., the stream you passed to the constructor of CEmdrosEnv,
// or stdout if the other constructor was used
void Print(std::string str); // Print your own string
void Print(CMQLResult *pResult);
void Print(CSheaf *pSheaf);
void Print(CTable *pTable);
//
// XML outputting
//
// XML declaration.
// Calls CEMdFOutput::print_XMLDecl on the local CEMdFOutput
void Print_XMLDecl();
// DTDs
void Print_DTD_start(std::string root_element);
void Print_DTD_end();
void Print_DTD_CMQLResult(void);
void Print_DTD_CTable(void);
void Print_DTD_CSheaf(void);
// Accessing members
CMQL_execution_environment* getMQLEE(void);
};
|