use assert for getinitflag

This commit is contained in:
wyy 2013-12-11 04:52:33 -08:00
parent acb4150e3c
commit 1e29d25855
5 changed files with 40 additions and 29 deletions

View File

@ -3,6 +3,7 @@
#include <algorithm>
#include <set>
#include <cassert>
#include "Limonp/logger.hpp"
#include "Trie.hpp"
#include "ISegment.hpp"
@ -63,15 +64,16 @@ namespace CppJieba
public:
bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<Unicode>& res) const
{
assert(_getInitFlag());
#ifndef NO_CODING_LOG
if (!_getInitFlag())
//if (!_getInitFlag())
//{
// LogError("not inited.");
// return false;
//}
if (begin >= end)
{
LogError("not inited.");
return false;
}
if (begin > end)
{
LogError("begin > end");
LogError("begin >= end");
return false;
}
#endif

View File

@ -4,6 +4,7 @@
#include <iostream>
#include <fstream>
#include <memory.h>
#include <cassert>
#include "Limonp/str_functs.hpp"
#include "Limonp/logger.hpp"
#include "TransCode.hpp"
@ -93,11 +94,12 @@ namespace CppJieba
public:
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
{
if(!_getInitFlag())
{
LogError("not inited.");
return false;
}
//if(!_getInitFlag())
//{
// LogError("not inited.");
// return false;
//}
assert(_getInitFlag());
if(begin == end)
{
return false;

View File

@ -7,6 +7,7 @@
#include <algorithm>
#include <set>
#include <cassert>
#include "Limonp/logger.hpp"
#include "Trie.hpp"
#include "ISegment.hpp"
@ -73,11 +74,13 @@ namespace CppJieba
public:
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
{
if(!_getInitFlag())
{
LogError("not inited.");
return false;
}
//if(!_getInitFlag())
//{
// LogError("not inited.");
// return false;
//}
assert(_getInitFlag());
vector<TrieNodeInfo> segWordInfos;
if(!cut(begin, end, segWordInfos))
{

View File

@ -1,6 +1,7 @@
#ifndef CPPJIEBA_MIXSEGMENT_H
#define CPPJIEBA_MIXSEGMENT_H
#include <cassert>
#include "MPSegment.hpp"
#include "HMMSegment.hpp"
#include "Limonp/str_functs.hpp"
@ -56,11 +57,12 @@ namespace CppJieba
public:
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
{
if(!_getInitFlag())
{
LogError("not inited.");
return false;
}
//if(!_getInitFlag())
//{
// LogError("not inited.");
// return false;
//}
assert(_getInitFlag());
if(begin == end)
{
return false;

View File

@ -3,6 +3,7 @@
#include <algorithm>
#include <set>
#include <cassert>
#include "Limonp/logger.hpp"
#include "Trie.hpp"
#include "ISegment.hpp"
@ -64,15 +65,16 @@ namespace CppJieba
public:
bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<Unicode>& res) const
{
assert(_getInitFlag());
#ifndef NO_CODING_LOG
if (!_getInitFlag())
//if (!_getInitFlag())
//{
// LogError("not inited.");
// return false;
//}
if (begin >= end)
{
LogError("not inited.");
return false;
}
if (begin > end)
{
LogError("begin > end");
LogError("begin >= end");
return false;
}
#endif