Implementation file:
# Include "stdafx. H"
# Include <string>
# Include <vector>
# Include <algorithm>
# Include <functional>
# Include "wordlib. H"
# Include "_ string. H"
Namespace wordlib {
Typedef STD: basic_string <char, chattraintsex >__ string;
Typedef STD: vector <__ string> _ wordlist;
Static const char * _ strwordlib [] = {
"***",
"***",
"***",
"****",
"**** You ",
"Script"
};
Static _ wordlist;
Static _ string _ nullstr = "";
Void _ initwordlist ()
{
If (_ wordlist. Size ()! = 0)
Return;
For (size_t I = 0; I <sizeof (_ strwordlib)/sizeof (const char *); ++ I)
_ Wordlist. push_back (_ strwordlib [I]);
STD: Sort (_ wordlist. Begin (), _ wordlist. End ());
}
Bool _ flyingmagic_2_cut_word isvalid (const char * Str)
{
_ Initwordlist ();
If (STR! = NULL)
{
_ String strsrc (STR );
_ Wordlist: iterator itend = _ wordlist. End ();
For (_ wordlist: iterator it = _ wordlist. Begin (); it! = Itend; ++ it)
{
If (strsrc. Find (* It )! =-1)
Return false;
}
}
Return true;
}
Bool _ flyingmagic_2_cut_word filtrate (char * DST, size_t Len, const char * SRC)
{
_ Initwordlist ();
Bool Bret = false;
If (SRC! = NULL & DST! = NULL & strlen (SRC) <= Len)
{
_ String strsrc (SRC );
_ Wordlist: iterator itend = _ wordlist. End ();
For (_ wordlist: iterator it = _ wordlist. Begin (); it! = Itend; ++ it)
{
_ String: size_type begin = strsrc. Find (* it );
If (begin! =-1)
{
For (_ string: size_type T = 0; t <it-> size (); ++ T)
Strsrc [begin + T] = '';
// Strsrc. Assign (_ nullstr, begin, it-> size ());
Bret = true;
}
}
Strcpy (DST, strsrc. c_str ());
}
Return Bret;
}
}