sources/mystring.cpp

changeset 12
8d0d1b368de0
parent 10
3874575d924d
child 14
33b8f428bacb
equal deleted inserted replaced
11:cffa2777d917 12:8d0d1b368de0
487 char checksum[33]; 487 char checksum[33];
488 CalculateMD5 (reinterpret_cast<const unsigned char*> (chars()), length(), checksum); 488 CalculateMD5 (reinterpret_cast<const unsigned char*> (chars()), length(), checksum);
489 checksum[sizeof checksum - 1] = '\0'; 489 checksum[sizeof checksum - 1] = '\0';
490 return String (checksum); 490 return String (checksum);
491 } 491 }
492
493 // -------------------------------------------------------------------------------------------------
494 //
495 METHOD
496 String::normalize (int (*filter)(int)) -> void
497 {
498 int a = 0;
499 int b = length() - 1;
500
501 while ((*filter) (m_string[a]) and a != b)
502 ++a;
503
504 while ((*filter) (m_string[b]) and a != b)
505 --b;
506
507 if (a == b)
508 m_string = "";
509 else if (a != 0 or b != length() - 1)
510 m_string = m_string.substr (a, b - a + 1);
511 }

mercurial