add NO_FILTER macro

This commit is contained in:
wyy 2013-12-07 17:32:11 +08:00
parent 45a5df5856
commit 18de12a21c
2 changed files with 12 additions and 1 deletions

View File

@ -4,6 +4,7 @@ ADD_DEFINITIONS(-std=c++0x -O3)
IF (DEFINED ENC)
ADD_DEFINITIONS(-DCPPJIEBA_${ENC})
ENDIF()
#ADD_DEFINITIONS(-DNO_FILTER)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(dicts)
ADD_SUBDIRECTORY(scripts)

View File

@ -31,13 +31,22 @@ namespace CppJieba
LogError("not inited.");
return false;
}
Unicode unico;
#ifdef NO_FILTER
unico.clear();
if(!TransCode::decode(str, unico))
{
LogFatal("str[%s] decode failed.", str.c_str());
return false;
}
return cut(unico.begin(), unico.end(), res);
#else
const char * const cstr = str.c_str();
uint size = str.size();
uint offset = 0;
string subs;
int ret;
uint len;
Unicode unico;
while(offset < size)
{
const char * const nstr = cstr + offset;
@ -65,6 +74,7 @@ namespace CppJieba
offset += len;
}
return true;
#endif
}
};