本文整理汇总了C++中KKStr::Len方法的典型用法代码示例。如果您正苦于以下问题:C++ KKStr::Len方法的具体用法?C++ KKStr::Len怎么用?C++ KKStr::Len使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KKStr
的用法示例。
在下文中一共展示了KKStr::Len方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StripOutAnyComments
void StripOutAnyComments (KKStr& line)
{
bool found = false;
kkint32 len = line.Len ();
kkint32 x = 0;
while ((x < (len - 1)) && (!found))
{
if ((line[x] == '/') &&
(line[x + 1] == '/'))
found = true;
else
x++;
}
if (found)
{
if (x == 0)
line = "";
else
line = line.SubStrPart (0, x - 1);
}
} /* StripOutAnyComments */
示例2: ParameterIsASwitch
bool CmdLineExpander::ParameterIsASwitch (const KKStr& parm)
{
if (parm.Len () < 1)
return false;
if (parm[(kkint16)0] != '-')
return false;
if (parm.Len () == 1)
return true;
double parmValue = 0.0;
if (parm.ValidNum (parmValue))
return false;
return true;
} /* ParameterIsASwitch */
示例3: s
/**
*@brief Adds Instrument data to the underlying Scanner files as text.
*/
void ScannerFile::WriteInstrumentDataWord (uchar idNum,
kkuint32 scanLineNum,
WordFormat32Bits dataWord
)
{
KKStr s (100);
s << "InstrumentDataWord" << "\t" << (int)idNum << "\t" << scanLineNum << "\t" << dataWord.unsigned32BitInt;
WriteTextBlock ((const uchar*)s.Str (), s.Len ());
} /* WriteInstrumentDataWord */
示例4: trimWhiteSpace
KKStrParser::KKStrParser (const KKStr& _str):
len (_str.Len ()),
nextPos (0),
str (_str.Str ()),
trimWhiteSpace (false),
weOwnStr (false),
whiteSpace (NULL)
{
}
示例5: WriteHeader
void ScannerFile::WriteHeader ()
{
KKStr ln (100);
ln << "ScannerFile" << "\t" << FileFormatStr () << "\n";
fwrite (ln.Str (), 1, ln.Len (), file);
ScannerHeaderFields::const_iterator idx;
for (idx = headerFields->begin (); idx != headerFields->end (); ++idx)
{
ln = "";
ln << idx->first << "\t" << idx->second << "\n";
fwrite (ln.Str (), 1, ln.Len (), file);
}
// Write End of text Marker
char ch = 0;
fwrite (&ch, 1, 1, file);
headerDataWritten = true;
} /* WriteHeader */
示例6: FromDelStr
PointListPtr PointList::FromDelStr (const KKStr& _s)
{
PointListPtr result = new PointList (true);
KKStr s (_s);
s.TrimLeft ();
while (s.Len () > 0)
{
char nextCh = s.FirstChar ();
char endPairChar = 0;
if (nextCh == '[')
endPairChar = ']';
else if (nextCh == '(')
endPairChar = ')';
else
{
// Not Bracketed.
endPairChar = 0;
kkint16 row = (kkint16)s.ExtractTokenInt (",\t\n\t");
kkint16 col = (kkint16)s.ExtractTokenInt (",\t\n\t");
result->PushOnBack (new Point (row, col));
}
if (endPairChar != 0)
{
KKStr pairStr = "";
auto idx = s.Find (endPairChar);
if (idx)
{
pairStr = s.SubStrSeg (0, idx);
s = s.SubStrPart (idx + 1);
}
else
{
pairStr = s;
s = "";
}
kkint16 row = (kkint16)pairStr.ExtractTokenInt (",");
kkint16 col = (kkint16)pairStr.ExtractTokenInt (",");
result->PushOnBack (new Point (row, col));
nextCh = s.FirstChar ();
if ((nextCh == ',') || (nextCh == '\n') || (nextCh == '\r') || (nextCh == '\t'))
s.ChopFirstChar ();
}
s.TrimLeft ();
}
return result;
} /* FromDelStr */
示例7: DetermineClassFromFileName
/****************************************************************************************
* DetermineClassFromFileName
*
* Given an Image File Name(fileName) will return and mlClass. Will use the
* path name in fileName to determine class. If the class does not exist in
* mlClasses, will create a new instance and add it to mlClasses.
*
* After talking to the user it has come to light that the first sub-directory in
* a path will dictate what class he/she feels a image belongs to.
* Ex:
* .../Protista/
* .../Protista/SubDir1
* .../Trichodesmium
* .../Trichodesmium/SubDir1
* .../Trichodesmium/SubDir2
*
* The idea is that when trying to determine what class a image really is we look
* at the first sub-dir name in the path. We may also have to deal with seq-num's
* as part of the name, in that case we strip the _ and following numbers from the
* name to get the correct class name.
****************************************************************************************/
MLClassPtr OurNeighbors::DetermineClassFromFileName (const KKStr& fileName)
{
KKStr filename_copy = fileName;
// If there are no path separator characters('\' or '/') characters in name
// then we will not be able to determine the class.
auto x = osLocateFirstSlashChar (filename_copy);
if (!x || (x.value () < 1))
return mlClasses->GetUnKnownClass ();
KKStr className = filename_copy.SubStrSeg (0, x);
// now lets get rid of any possible trailing seq number.
// We are assuming that a underscore{"_") character separates the calcs name from the seq number.
// So if there is an underscore character, and all the characters to the right of it are
// underscore characters, then we will remove the underscore and the following numbers.
x = className.LocateLastOccurrence ('_');
if (x)
{
// Now lets eliminate any sequence number in name
// We are assuming that a underscore{"_") character separates the class name from the seq number.
// So if there is an underscore character, and all the characters to the right of it are
// numeric characters, then we will remove the underscore and the following numbers.
kkuint32 y = x.value () + 1;
bool allFollowingCharsAreNumeric = true;
while ((y < className.Len ()) && (allFollowingCharsAreNumeric))
{
char ch = className[y];
allFollowingCharsAreNumeric = ((ch >= '0') && (ch <= '9'));
y++;
}
if (allFollowingCharsAreNumeric)
{
className = className.SubStrSeg (0, x);
}
}
// Now that we have a string with the class name, lets get a pointer
// to a mlClass object from mlClasses , if none there then we get
// to create a new class.
MLClassPtr mlClass = mlClasses->GetMLClassPtr (className);
return mlClass;
} /* DetermineClassFromFileName */
示例8: minute
TimeType::TimeType (KKStr s):
hour (0),
minute (0),
second (0)
{
KKStr field1, field2, field3;
if (s.Len () == 6)
{
field1 = s.SubStrPart (0, 1);
field2 = s.SubStrPart (2, 3);
field3 = s.SubStrPart (4, 5);
}
else
{
field1 = s.ExtractToken ("\n\r\t: ");
field2 = s.ExtractToken ("\n\r\t: ");
field3 = s.ExtractToken ("\n\r\t: ");
}
int32 f1 = atoi (field1.Str ());
int32 f2 = atoi (field2.Str ());
int32 f3 = atoi (field3.Str ());
if (((f1 >= 0) && (f1 <= 24)) &&
((f2 >= 0) && (f2 <= 59)) &&
((f3 >= 0) && (f3 <= 59))
)
{
hour = (uchar)f1;
minute = (uchar)f2;
second = (uchar)f3;
}
}
示例9: ReadConfigFile
void DataBaseServerList::ReadConfigFile ()
{
KKStr configFileName = osAddSlash (PicesVariables::ConfigurationDirectory ()) + "MySql.cfg";
log.Level (10) << "DataBaseServerList::ReadConfigFile ConfigFileName[" << configFileName << "]" << endl;
FILE* in = osFOPEN (configFileName.Str (), "r");
if (!in)
{
log.Level (-1) << "DataBaseServerList::ReadConfigFile Error loading ConfigFileName[" << configFileName << "]" << endl;
return;
}
defaultServerDescription = "";
bool defaultServerFound = false;
char buff[1024];
while (fgets (buff, sizeof (buff), in))
{
buff[sizeof(buff) - 1] = 0; // Just to make sure that buffer not completely full
KKStr ln (buff);
if (ln.Len () < 3)
continue;
if ((ln[0] == '/') && (ln[1] == '/'))
continue;
KKStr lineName = ln.ExtractToken2 ("\n\r\t");
if (lineName.EqualIgnoreCase ("Server"))
{
DataBaseServerPtr server = new DataBaseServer (ln);
PushOnBack (server);
}
else if (lineName.EqualIgnoreCase ("DefaultServer"))
{
defaultServerDescription = ln.ExtractToken2 ("\n\r\t");
defaultServerFound = true;
}
}
if (!defaultServerFound)
{
DataBaseServerPtr defaultServer = LookUpByDescription ("Local");
if (!defaultServer)
defaultServer = LookUpByDescription ("localhost");
if (!defaultServer)
{
defaultServer = new DataBaseServer ();
defaultServer->UserName ("Root");
defaultServer->Description ("localhost");
defaultServer->Embedded (false);
defaultServer->HostName ("localhost");
defaultServer->PortNum (3306),
defaultServer->MySqlDataDir ("");
defaultServer->UserName ("root");
defaultServer->PassWord ("dasani30");
defaultServer->DataBaseName ("pices_new");
defaultServerDescription = defaultServer->Description ();
PushOnBack (defaultServer);
}
defaultServerDescription = defaultServer->Description ();
}
fclose (in);
} /* ReadConfigFile */
示例10: LoadFile
void Configuration::LoadFile (RunLog& log)
{
log.Level (10) << "Configuration::LoadFile: " << fileName << endl;
kkint32 lastLineNum = 0;
if (fileName == "")
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** File-Name is blank" << endl
<< endl;
FormatGood (false);
return;
}
FILE* inFile = osFOPEN (fileName.Str (), "r");
if (!inFile)
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** Opening File: " << fileName << endl
<< endl;
FormatGood (false);
return;
}
char buff[10240];
kkint32 lineCount = 0;
curSectionName = "";
ConfSectionPtr curSection = NULL;
while (fgets (buff, sizeof (buff), inFile))
{
lastLineNum++;
KKStr line (buff);
line.TrimRight ();
line.TrimLeft ();
StripOutAnyComments (line);
log.Level (70) << line << endl;
StripOutAnyComments (line);
if (line.Empty ())
{
// If we have a blank line, we do nothing.
}
else if (line.FirstChar () == '[')
{
// Looks like definition of new section.
if (line.LastChar () == ']')
{
curSectionName = line.SubStrPart (1, line.Len () - 2);
curSectionName.TrimLeft ();
curSectionName.TrimRight ();
curSectionName.Upper ();
curSection = new ConfSection (curSectionName, lastLineNum);
sections->AddConfSection (curSection);
log.Level (30) << "LoadFile SectionName[" << curSectionName << "]." << endl;
}
else
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** LineNumber[" << lastLineNum << "] Improper Section Name[" << line << "]." << endl
<< endl;
formatGood = false;
}
}
else
{
if (!curSection)
{
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** Format Error LineNumber[" << lastLineNum << "]" << endl
<< " No Section Defined." << endl
<< endl;
formatGood = false;
curSectionName = "GLOBAL";
curSection = new ConfSection (curSectionName, lastLineNum);
sections->AddConfSection (curSection);
}
kkint32 equalIdx = line.LocateCharacter ('=');
if (equalIdx < 0)
{
// We have a improperly formated line.
log.Level (-1) << endl
<< "Configuration::LoadFile ***ERROR*** LineNumber[" << lastLineNum << "] Improperly Formated Line[" << line << "]."
<< endl;
formatGood = false;
//.........这里部分代码省略.........
示例11: ExtractAttribute
void ExtractAttribute (KKStr& tagStr,
KKStr& attributeName,
KKStr& attributeValue
)
{
int32 startIdx = 0;
int32 len = tagStr.Len ();
attributeName = "";
attributeValue = "";
// Skip over lading spaces
while (startIdx < len)
{
if (strchr ("\n\t\r ", tagStr[startIdx]) == NULL)
break;
startIdx++;
}
if (startIdx >= len)
{
tagStr = "";
return;
}
int32 idx = startIdx;
// Skip until we find the '=' character.
while (idx < len)
{
if (tagStr[idx] == '=')
break;
++idx;
}
if (idx >= len)
{
tagStr = "";
return;
}
attributeName = tagStr.SubStrPart (startIdx, idx - 1);
++idx; // Skip past '=' character.
// Skip over leading spaces
while (idx < len)
{
if (strchr ("\n\t\r ", tagStr[idx]) == NULL)
break;
++idx;
}
if (idx >= len)
{
tagStr = "";
return;
}
int valueStartIdx = idx;
while (idx < len)
{
if (strchr ("\n\t\r ", tagStr[idx]) != NULL)
break;
++idx;
}
attributeValue = tagStr.SubStrPart (valueStartIdx, idx - 1);
tagStr = tagStr.SubStrPart (idx + 1);
return;
} /* ExtractAttribute */