ptextmap.cxx

来自「PTypes是一个扩充了多线程和网络功能的STL库」· CXX 代码 · 共 80 行

CXX
80
字号
/* * *  C++ Portable Types Library (PTypes) *  Version 2.0.2  Released 17-May-2004 * *  Copyright (C) 2001-2004 Hovik Melikyan * *  http://www.melikyan.com/ptypes/ * */#include "ptypes.h"PTYPES_BEGINtypedef _textitem* ptextitem;textmap::textmap(bool casesens)    : tobjlist<_textitem>(true){    config.sorted = true;    config.casesens = casesens;}textmap::~textmap(){}int textmap::compare(const void* key, const void* item) const{   if (config.casesens)        return strcmp(pconst(key), ptextitem(item)->key);    else        return strcasecmp(pconst(key), ptextitem(item)->key);}const string& textmap::get(const char* key) const{    int index;    if (search(key, index))        return dogetvalue(index);    else        return nullstring;}int textmap::put(const string& key, const string& value){    int index;    if (search(pconst(key), index))    {        if (isempty(value))            dodel(index);        else            doget(index)->value = value;    }    else if (!isempty(value))        doins(index, new _textitem(key, value));    return index;}int textmap::indexof(const char* key) const{    int index;    if (search(key, index))        return index;    else        return -1;}PTYPES_END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?