Listing 1
// Database class initialisation
// database_base
inline database_base::database_base(ORJDatabase const *database)
: m_database(database)
{
stlsoft_message_assert("Initialisng database_base with NULL database",
NULL != m_database);
}
// file_database
inline /* static */ ORJDatabase const
*file_database::create_database_( char const *jarName, unsigned flags)
{
ORJDatabase const *database;
ORJError error;
ORJRC rc = ORJ_ReadDatabase(jarName, NULL, flags, &database, &error);
if(ORJ_RC_SUCCESS != rc)
{
throw database_exception(rc, error);
}
return database;
}
inline file_database::file_database(char const *jarName, unsigned flags)
: parent_class_type(create_database_(jarName, flags))
{}
#endif /* !OPENRJ_NO_FILE_HANDLING */
// memory_database
inline /* static */ ORJDatabase const
*memory_database::create_database_(char const *contents
, size_t cbContents, unsigned flags)
{
ORJDatabase const *database;
ORJError error;
ORJRC rc = ORJ_CreateDatabaseFromMemory(contents, cbContents
, NULL, flags, &database, &error);
if(ORJ_RC_SUCCESS != rc)
{
throw database_exception(rc, error);
}
return database;
}
inline memory_database::memory_database(char const *contents
, size_t cbContents, unsigned flags)
: parent_class_type(create_database_(contents, cbContents, flags))
{}