示例#1
0
script_type script_type::parse(const std::wstring & Str)
{
    std::wstring tmp = Str;
    boost::algorithm::to_lower(tmp);

    if (tmp == L"latin")
        return script_type( Latin );
    if (tmp == L"asian")
        return script_type( Asian );
    if (tmp == L"complex")
        return script_type( Complex );
    if (tmp == L"ignore")
        return script_type( Ignore );
    else
    {
        BOOST_THROW_EXCEPTION( errors::invalid_attribute() );        
        return script_type( Latin );
    }
}
示例#2
0
void SQLiteObjectFactory::generate() {
    SQLiteDBPtr db = SQLite::getSingleton().open(mDBFilename);
    sqlite3_busy_timeout(db->db(), 1000);


    String value_query = "SELECT object, script_type, script_args, script_contents FROM ";
    value_query += "\"" TABLE_NAME "\"";
    int rc;
    char* remain;
    sqlite3_stmt* value_query_stmt;
    rc = sqlite3_prepare_v2(db->db(), value_query.c_str(), -1, &value_query_stmt, (const char**)&remain);
    SQLite::check_sql_error(db->db(), rc, NULL, "Error preparing value query statement");
    if (rc==SQLITE_OK) {
        int step_rc = sqlite3_step(value_query_stmt);
        while(step_rc == SQLITE_ROW) {
            String object_str(
                (const char*)sqlite3_column_text(value_query_stmt, 0),
                sqlite3_column_bytes(value_query_stmt, 0)
            );
            String script_type(
                (const char*)sqlite3_column_text(value_query_stmt, 1),
                sqlite3_column_bytes(value_query_stmt, 1)
            );
            String script_args(
                (const char*)sqlite3_column_text(value_query_stmt, 2),
                sqlite3_column_bytes(value_query_stmt, 2)
            );
            String script_contents(
                (const char*)sqlite3_column_text(value_query_stmt, 3),
                sqlite3_column_bytes(value_query_stmt, 3)
            );

            HostedObjectPtr obj = mOH->createObject(
                                      UUID(object_str, UUID::HexString()),
                                      script_type, script_args, script_contents
                                  );

            step_rc = sqlite3_step(value_query_stmt);
        }
        if (step_rc != SQLITE_DONE) {
            // reset the statement so it'll clean up properly
            rc = sqlite3_reset(value_query_stmt);
            SQLite::check_sql_error(db->db(), rc, NULL, "Error finalizing value query statement");
        }
    }

    rc = sqlite3_finalize(value_query_stmt);
    SQLite::check_sql_error(db->db(), rc, NULL, "Error finalizing value query statement");
}