本文整理汇总了C++中MyString::find方法的典型用法代码示例。如果您正苦于以下问题:C++ MyString::find方法的具体用法?C++ MyString::find怎么用?C++ MyString::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyString
的用法示例。
在下文中一共展示了MyString::find方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
EnvFilter::ImportFilter( const MyString &var, const MyString &val ) const
{
if ( (var.find(";") >= 0) || (val.find(";") >= 0) ) {
return false;
}
return IsSafeEnvV2Value( val.Value() );
}
示例2: convert_hostname_to_ipaddr
condor_sockaddr convert_hostname_to_ipaddr(const MyString& fullname)
{
MyString hostname;
MyString default_domain;
bool truncated = false;
if (param(default_domain, "DEFAULT_DOMAIN_NAME")) {
MyString dotted_domain = ".";
dotted_domain += default_domain;
int pos = fullname.find(dotted_domain.Value());
if (pos != -1) {
truncated = true;
hostname = fullname.Substr(0, pos - 1);
}
}
if (!truncated)
hostname = fullname;
// detects if hostname is IPv6
//
// hostname is NODNS coded address
//
// for example,
// it could be 127-0-0-1 (127.0.0.1) as IPv4 address
// it could be fe80-3577--1234 ( fe80:3577::1234) as IPv6 address
//
// it is IPv6 address
// 1) if there are 7 '-'
// 2) if there are '--' which means compaction of zeroes in IPv6 adress
char target_char;
bool ipv6 = false;
if (hostname.find("--") != -1)
ipv6 = true;
else {
int dash_count = 0;
for (int i = 0; i < hostname.Length(); ++i)
if (hostname[i] == '-')
++dash_count;
if (dash_count == 7)
ipv6 = true;
}
if (ipv6)
target_char = ':';
else
target_char ='.';
// converts hostname to IP address string
for (int i = 0; i < hostname.Length(); ++i) {
if (hostname[i] == '-')
hostname.setChar(i, target_char);
}
condor_sockaddr ret;
ret.from_ip_string(hostname);
return ret;
}
示例3: name
Vector<MyString> split(const MyString& path)
{
Vector<MyString> ret;
int spos = 0;
while (spos < path.size())
{
int epos = path.find(_T('\\'), spos);
if (epos != -1)
{
int i = epos + 1;
while (i < path.size() && path[i] == _T('\\'))
++i;
MyString name(path.substr(spos, epos - spos));
ret.append(name);
spos = i;
}
else if (spos < path.size())
{
MyString name(path.substr(spos));
ret.append(name);
spos = path.size();
}
}
return ret;
}
示例4: DoReversedCCBConnect
bool
CCBListener::HandleCCBRequest( ClassAd &msg )
{
MyString address;
MyString connect_id;
MyString request_id;
MyString name;
if( !msg.LookupString( ATTR_MY_ADDRESS, address) ||
!msg.LookupString( ATTR_CLAIM_ID, connect_id) ||
!msg.LookupString( ATTR_REQUEST_ID, request_id) )
{
MyString msg_str;
msg.sPrint(msg_str);
EXCEPT("CCBListener: invalid CCB request from %s: %s\n",
m_ccb_address.Value(),
msg_str.Value() );
}
msg.LookupString( ATTR_NAME, name );
if( name.find(address.Value())<0 ) {
name.formatstr_cat(" with reverse connect address %s",address.Value());
}
dprintf(D_FULLDEBUG|D_NETWORK,
"CCBListener: received request to connect to %s, request id %s.\n",
name.Value(), request_id.Value());
return DoReversedCCBConnect( address.Value(), connect_id.Value(), request_id.Value(), name.Value() );
}
示例5: if
/** Parse arguments that are to be preserved when updating a .condor.sub
file. If the given argument such an argument, parse it and update the
shallowOpts structure accordingly. (This function is meant to be called
both when parsing "normal" command-line arguments, and when parsing the
existing arguments line of a .condor.sub file we're overwriting.)
@param strArg: the argument we're parsing
@param argNum: the argument number of the current argument
@param argc: the argument count (passed to get value for flag)
@param argv: the argument vector (passed to get value for flag)
@param shallowOpts: the condor_submit_dag shallow options
@return true iff the argument vector contained any arguments
processed by this function
*/
bool
parsePreservedArgs(const MyString &strArg, int &argNum, int argc,
const char * const argv[], SubmitDagShallowOptions &shallowOpts)
{
bool result = false;
if (strArg.find("-maxi") != -1) // -maxidle
{
if (argNum + 1 >= argc) {
fprintf(stderr, "-maxidle argument needs a value\n");
printUsage();
}
shallowOpts.iMaxIdle = atoi(argv[++argNum]);
result = true;
}
else if (strArg.find("-maxj") != -1) // -maxjobs
{
if (argNum + 1 >= argc) {
fprintf(stderr, "-maxjobs argument needs a value\n");
printUsage();
}
shallowOpts.iMaxJobs = atoi(argv[++argNum]);
result = true;
}
else if (strArg.find("-maxpr") != -1) // -maxpre
{
if (argNum + 1 >= argc) {
fprintf(stderr, "-maxpre argument needs a value\n");
printUsage();
}
shallowOpts.iMaxPre = atoi(argv[++argNum]);
result = true;
}
else if (strArg.find("-maxpo") != -1) // -maxpost
{
if (argNum + 1 >= argc) {
fprintf(stderr, "-maxpost argument needs a value\n");
printUsage();
}
shallowOpts.iMaxPost = atoi(argv[++argNum]);
result = true;
}
return result;
}
示例6: onIncomingConnection
void HTTPServer::onIncomingConnection ( SOCKET sock )
{
//read data from socket
char buffer[1024];
int n;
bzero ( buffer, sizeof ( buffer ) );
n = read ( sock,buffer,1024 );
if ( n < 0 ) {
mLog ( "ERROR reading from socket", LOG_PERROR );
exit ( 1 );
}
//mLog((string)"Read from buffer: " + buffer);
MyString data ( buffer );
//data now contains incoming data.
string firstLine;
firstLine = data.substr ( 0, data.find ( "\r\n" ) );
//we should check if header is correct
const string prefix ( "GET" );
const string postfix ( "HTTP/1." );
#ifdef FULLDEBUG
mLog ( ( "Data received: " + data ).c_str() );
#endif
if ( firstLine.find ( prefix ) != 0 // doesn't start with prefix
|| firstLine.find ( postfix ) != firstLine.length()-1 - postfix.length() // doesn't end with postfix
|| firstLine.length() < 14 ) { // length is small
// header is incorrect
mLog ( "Bad request: " + firstLine );
exit ( 1 );
} else {
// header is correct
MyString req = firstLine.substr ( 4, firstLine.find ( postfix )-4 );
req.trim();
#if defined(FULLDEBUG)
mLog ( "request is:" + req );
mLog ( "first line is:" + firstLine );
#endif
onUrlRequested ( req, sock );
}
close ( sock );
lock();
openConnCount--;
unlock();
}
示例7: SanitizeSubmitterName
void SanitizeSubmitterName(MyString &name)
{
// We /may/ (will!) use the name as the name of an
// attribute, so we must strip invalid characters that we
// expect to find in the name.
static const int invalid_char_len = 4;
static const char *invalid_chars[invalid_char_len] =
{"-", "@", ".", " "}; // XXX: Invert this, use [a-zA-Z_][a-zA-Z0-9_]*
for (int i = 0; i < invalid_char_len; i++) {
while (-1 != name.find(invalid_chars[i])) {
name.replaceString(invalid_chars[i], "_");
}
}
}
示例8: skipToEqual
// 在src中确定从位置pos开始,长度为len的范围内的首个与c匹配字符的位置
static int skipToEqual(const MyString& src, int pos, TCHAR c, int len = 0)
{
assert(len >= 0);
if (len == 0)
{
return src.find(c, pos);
}
for (int i = 0; i < len && (pos + i) < src.size(); ++i)
{
if (src[pos + i] == c)
{
return pos + i;
}
}
return -1;
}
示例9: isRelative
// .
// ..
// .\
// ..\
// name
bool isRelative(MyString path)
{
assert(!path.isEmpty());
if (path.startWith(_T(".")))
{
return true;
}
else
{
int pos = path.find(_T('\\'));
MyString head = path.substr(0, pos);
if (!head.isEmpty() && isLegalName(head))
return true;
}
return false;
}
示例10: stdoutHandler
void Pigeon::stdoutHandler(int /*pipe*/) {
char buff[STDOUT_READBUF_SIZE];
int bytes = 0;
int ad_type = AD_NULL;
while ( (bytes = daemonCore->Read_Pipe(m_stdOut, buff,
STDOUT_READBUF_SIZE)) > 0) {
buff[bytes] = '\0';
m_line_stdout += buff;
int pos = m_line_stdout.FindChar('\n', 0);
while (pos > 0) {
//Here we get a newline terminated string to process.
MyString line = m_line_stdout.substr(0, pos);
m_line_stdout = m_line_stdout.substr(pos+1, m_line_stdout.Length());
if (line.find("START_AD") >= 0) {
MyString adKey, adValue;
ad_type = getKeyValue(line, &adKey, &adValue);
dprintf(D_FULLDEBUG, "AD: %s type=%d\n", line.Value(), ad_type);
if (ad_type == AD_NULL) {
pos = m_line_stdout.FindChar('\n', 0);
continue;
}
dprintf(D_FULLDEBUG, "AD: key %s, value %s\n", adKey.Value(), adValue.Value());
if (ad_type == AD_STRING)
m_qpidAd.Assign(adKey.Value(), adValue);
else if (ad_type == AD_INT || ad_type == AD_BOOLEAN)
m_qpidAd.Assign(adKey.Value(), atoi(adValue.Value()));
else if (ad_type == AD_DOUBLE)
m_qpidAd.Assign(adKey.Value(), atof(adValue.Value()));
}
dprintf(D_ALWAYS, "STDOUT: %s\n", line.Value());
pos = m_line_stdout.FindChar('\n', 0);
}
}
}
示例11:
bool
create_name_for_VM(ClassAd *ad, MyString& vmname)
{
if( !ad ) {
return false;
}
int cluster_id = 0;
if( ad->LookupInteger(ATTR_CLUSTER_ID, cluster_id) != 1 ) {
dprintf(D_ALWAYS, "%s cannot be found in job classAd\n",
ATTR_CLUSTER_ID);
return false;
}
int proc_id = 0;
if( ad->LookupInteger(ATTR_PROC_ID, proc_id) != 1 ) {
dprintf(D_ALWAYS, "%s cannot be found in job classAd\n",
ATTR_PROC_ID);
return false;
}
MyString stringattr;
if( ad->LookupString(ATTR_USER, stringattr) != 1 ) {
dprintf(D_ALWAYS, "%s cannot be found in job classAd\n",
ATTR_USER);
return false;
}
// replace '@' with '_'
int pos = -1;
while( (pos = stringattr.find("@") ) >= 0 ) {
stringattr.setChar(pos, '_');
}
vmname = stringattr;
vmname += "_";
vmname += cluster_id;
vmname += "_";
vmname += proc_id;
return true;
}
示例12: hasWildcard
bool hasWildcard(const MyString& s)
{
return (s.find('*') != -1) || (s.find('?') != -1);
}
示例13: onUrlRequested
void HTTPServer::onUrlRequested ( MyString req, SOCKET sock )
{
if ( req.find ( ".." ) !=-1 ||
req.find ( "/.ht" ) !=-1 || req.endsWith ( "~" ) ) {
// evil hacker trying to read non-wwwhome or secret file
errorReport ( sock, "403", "Forbidden",
"You don't have permission to access the requested URL." );
} else {
MyString path = req;
MyFile f ( path );
if ( f.isDirectory() && !path.endsWith ( "/" ) ) {
// redirect browser if referring to directory without final '/'
path += "/";
}
if ( f.isDirectory() ) {
#if defined(FULLDEBUG) || defined(DEBUG)
mLog ( "Is a directory: " + path );
#endif
// if directory, implicitly add 'index.html'
string header;
header = ( string ) "HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/html\r\n";
string length = "Content-Length: ";
string html_header = "<html><body>";
// out all files here
string files;
getDirFiles ( path, &files );
string html_footer = "</body></html>\r\n\r\n";
string data = html_header + files + html_footer;
//count content-length.
stringstream sstm;
sstm << data.length();
length += sstm.str() + "\r\n\r\n";
data = header + length + html_header + files + html_footer;
int n = write ( sock, data.c_str(), data.length() +1 );
if ( n < 0 ) {
mLog ( "ERROR writing to socket" );
exit ( 1 );
}
#ifdef FULLDEBUG
mLog ( "Wrote: " + data );
#endif
} else {
try {
// send files
MyString temp;
temp = ( string ) "HTTP/1.0 200 OK\r\n";
temp += "Content-Type: " + guessContentType ( path ) + "\r\n";
string data;
parseFile ( sock, path, &data ); // send raw file
//count content-length.
string length = "Content-Length: ";
stringstream sstm;
sstm << data.length();
length += sstm.str() + "\r\n\r\n";
temp += length + data;
int n = write ( sock, temp.c_str(), temp.length() );
if ( n < 0 ) {
mLog ( "ERROR writing to socket" );
exit ( 1 );
}
#if defined(DEBUG) || defined(FULLDEBUG)
mLog ( "200 OK" );
#endif
} catch ( ... ) {
// file not found
errorReport ( sock, "404", "Not Found",
"The requested URL was not found on this server." );
}//try-catch
}//else
}//else
}