Skip to main content

Posts

Showing posts from August 22, 2010

C의 정규표현 Regular Expression

regex_t     fsm; regmatch_t  nm[2]; ret = regcomp(&fsm, "ch_[0-9]*_\\([0-9]\\+\\)\\.dat", REG_ICASE); int stat = regexec( &fsm, file_path, 2, nm, REG_NOTBOL); fileindex = substring(file_path, nm[1].rm_so, nm[1].rm_eo - nm[1].rm_so); 매칭된 문자열 전부는 nm[0]에 보존되고 () 괄호 안에 매칭된 정보는 nm[1]에 보존된다.

Sqlite - Opening A new Database connection

- 3개의 패턴이 있다. 나는 주로 sqlite3_open_v2를 애용하고 있다. int sqlite3_open( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); int sqlite3_open16( const void *filename, /* Database filename (UTF-16) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); int sqlite3_open_v2( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb, /* OUT: SQLite db handle */ int flags, /* Flags */ const char *zVfs /* Name of VFS module to use */ ); sqlite3_open_v2의 flags인수로 사용가능한 것은 SQLITE_OPEN_NOMUTEX - mutexes(Mutual Exclusion Object ) on the opened database connection are disabled and the application must insure that access to the database connection and its associated prepared statement is serialized. - 뮤텍스를 보장하지 않는다. SQLITE_OPEN_FULLMUTEX SQLITE_OPEN_SHAREDCACHE SQLITE_OPEN_PRIVATECACHE SQLITE_OPEN_READONLY - the database is opened in read-only mode. If the database does

SQLITE Result Codes

#define SQLITE_OK 0 /* Successful result */ /* beginning-of-error-codes */ #define SQLITE_ERROR 1 /* SQL error or missing database */ #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ #define SQLITE_PERM 3 /* Access permission denied */ #define SQLITE_ABORT 4 /* Callback routine requested an abort */ #define SQLITE_BUSY 5 /* The database file is locked */ #define SQLITE_LOCKED 6 /* A table in the database is locked */ #define SQLITE_NOMEM 7 /* A malloc() failed */ #define SQLITE_READONLY 8 /* Attempt to write a readonly database */ #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ #define SQLITE_CORRUPT 11 /* The database disk image is malformed */ #define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */ #define SQLITE_FULL 13 /* Insertion failed because data