Example #1
0
	/*
	 * Returns true if the specified string is a Palindrome.
	 */
	bool isPalindrome( STR str ) {
		str.erase( std::remove_if( str.begin(), str.end(), ::isspace ), str.end() );
		STR copy = str;
		std::reverse( copy.begin(), copy.end() );
		
		return ( strcmp( str.c_str(), copy.c_str() ) == 0 );
	} 
Example #2
0
		void operator () (char ch) {
			str_ += ch;
			if(str_.size() >= str_.capacity()) {
				term_(str_.c_str(), str_.size());
				str_.clear();
			}			
		}
Example #3
0
bool FileExists(STR fn){
    FILE *F = fopen(fn.c_str(), "r");
    if(F){
        fclose(F);
        return true;
    }
    return false;
}
Example #4
0
STR CCrypt::md5(STR value){
    MD5_CTX ctx;
    unsigned char buff[MD5_DIGEST_LENGTH];
    MD5_Init(&ctx);
    MD5_Update(&ctx, value.c_str(), value.length());
    MD5_Final(buff, &ctx);
    char res[33];
    for(int i = 0; i < 16; i++){
        sprintf(res+i*2, "%02x", buff[i]);
    }
    return STR(res);
}
Example #5
0
		void flush() {
			if(str_.size() > 0) {
				term_(str_.c_str(), str_.size());
				str_.clear();
			}
		}
Example #6
0
		void clear() {
			if(str_.size() > 0) {
				term_(str_.c_str(), str_.size());
			}
			str_.clear();
		}