17 #include "libopenrave.h"
31 md5_byte_t digest[16];
34 md5_append(&state, (
const md5_byte_t *)s.c_str(), s.size());
35 md5_finish(&state, digest);
37 hex_output.resize(32);
38 for (
int di = 0; di < 16; ++di) {
39 int n = (digest[di]&0xf);
40 hex_output[2*di+1] = n > 9 ? (
'a'+n-10) : (
'0'+n);
41 n = (digest[di]&0xf0)>>4;
42 hex_output[2*di+0] = n > 9 ? (
'a'+n-10) : (
'0'+n);
53 md5_byte_t digest[16];
56 md5_append(&state, (
const md5_byte_t *)&v[0], v.size());
57 md5_finish(&state, digest);
59 hex_output.resize(32);
60 for (
int di = 0; di < 16; ++di) {
61 int n = (digest[di]&0xf);
62 hex_output[2*di+0] = n > 9 ? (
'a'+n-10) : (
'0'+n);
63 n = (digest[di]&0xf0)>>4;
64 hex_output[2*di+1] = n > 9 ? (
'a'+n-10) : (
'0'+n);
71 return p0.first.size() > p1.first.size();
74 std::string&
SearchAndReplace(std::string& out,
const std::string& in,
const std::vector< std::pair<std::string, std::string> >&_pairs)
76 BOOST_ASSERT(&out != &in);
77 FOREACHC(itp,_pairs) {
78 BOOST_ASSERT(itp->first.size()>0);
80 std::vector< std::pair<std::string, std::string> > pairs = _pairs;
83 size_t startindex = 0;
84 while(startindex < in.size()) {
85 size_t nextindex=std::string::npos;
86 std::vector< std::pair<std::string, std::string> >::const_iterator itbestp;
88 size_t index = in.find(itp->first,startindex);
89 if((nextindex == std::string::npos)|| ((index != std::string::npos)&&(index < nextindex)) ) {
94 if( nextindex == std::string::npos ) {
95 out += in.substr(startindex);
98 out += in.substr(startindex,nextindex-startindex);
99 out += itbestp->second;
100 startindex = nextindex+itbestp->first.size();
107 std::string filename;
108 if( !getline(sinput, filename, separator) ) {
114 std::size_t startpos = filename.find_first_not_of(
" \t");
115 std::size_t endpos = filename.find_last_not_of(
" \t");
118 if( string::npos == startpos || string::npos == endpos ) {
121 return filename.substr( startpos, endpos-startpos+1 );