FrontPage|FindPage|TitleIndex|RecentChanges|RSS TDB Data
 
ÅÆÇø´¿¡ Àç¹ÌºÙÀ̱â

¸ñÀû #

ÀÔÃâ·ÂÀ» ´õ ÆíÇÏ°Ô ÇÏ°í ½Í´Ù. ¾î¶² key¿¡ ´ëÇÑ dbÀÇ ³»¿ëÀ» ¹Ù·Î ´ã°í½Í°í, ¶Ç ¹Ù·Î ÀúÀåÇÏ°í ½Í´Ù.

main() #

ÀÌ·¸°Ô ¾²°í ½ÍÀº °ÍÀÌ´Ù.
// key¶ó´Â Çʵ带 °¡Áö´Â ±¸Á¶Ã¼¸¦ Çϳª ¼±¾ðÇÏ°í,
typedef struct _mydata
{
    char key[32];
    char email[80];
} RMyData; 

int main(void)
{
    // RMyDataÇü½ÄÀ» ÀÐ°í ¾µ DB¸¦ ÁغñÇÑ´Ù.
    TDBData<RMyData> mdata("test.db");

    RMyData dw  ={ "hello", "hello@world" };
    RMyData dw2 ={ "hello" };

    // Å×½ºÆ® writing
    mdata.Write(dw);

    // Àß ¾²¿©Áø°ÇÁö Å×½ºÆ® reading
    mdata.Read(dw2);
    cout << dw2.email << endl;

} 

TDBData Ŭ·¡½º ±¸Çö #

class TDBData
{
protected :
    TDB *db;

public :
    TDBData(const char *dbname){
        db = new TDB(dbname);
    };
    
    ~TDBData()
    {   
        delete db;
    };
    
    int Read(T &outdata)
    {   
        return db->Read(outdata.key, (char *)&outdata);
    };
    
    int Read(const char *key, T &outdata)
    {
        return db->Read(key, (char *)&outdata);
    };

    int Write(T &indata)
    {   
        return db->Update(indata.key, (char *)&indata, sizeof(T));
    };

    TDBData &operator << (const T &dw)
    {   
        db->Update(dw.key, (char *)&dw, sizeof(T));
        return (*this);
    };
}; 


°³¼±°èȹ #

ÇöÀçÀÇ ÇÁ·Î±×·¥À¸·Î´Â µð½ºÅ© °ø°£ ³¶ºñ°¡ ½ÉÇϹǷÎ, ÆÐÅ·ÇÏ¿© º¸°üÇϰųª Àд ±¸Á¶·Î °³¼± TDBVarData



¼Ò½º #


Replace original file
Rename if it already exist

File nameSize(byte)Date
 .. 2007-01-09
tdg2.tgz9002004-07-06
Total 1 files
Password:

last modified 2004-07-20 14:23:38
EditText|FindPage|DeletePage|LikePages|UploadedFiles|UploadFile|