本文整理汇总了C++中String::At方法的典型用法代码示例。如果您正苦于以下问题:C++ String::At方法的具体用法?C++ String::At怎么用?C++ String::At使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::At方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __TextBox_CaretPosition
void ConvolutionFilterCodeDialog::__TextBox_CaretPosition( TextBox& sender, int oldPos, int newPos )
{
if ( sender == FilterCode_TextBox )
{
String t = FilterCode_TextBox.Text();
line = 1;
column = 1;
for ( String::iterator i = t.Begin(); i < t.At( newPos ); i++ )
{
if( *i == '\n')
{
++line;
column = 0;
}
++column;
}
LineCol_Label.SetText( String().Format( "Line: %d Col: %d", line , column ) );
}
}
示例2: convertFromDayHourMinInDecimal
String Scheduler::convertFromDayHourMinInDecimal(String timeDate) {
// convert the timeDate from DayHourMin-Format into Decimal-Format
// DAY : MON = 1, TUE = 2, WED = 3, THU = 4, FRI = 5, SAT = 6, SUN = 6
// HOUR : 00..23
// MIN : 00..60
// WED 10:27 -----> 31027
bool statusOk = true;
String value;
// Analyze the day
if (timeDate.CompareN("MON", 3, 0) == 0) {
value.Append("1");
} else if (timeDate.CompareN("TUE", 3, 0) == 0) {
value.Append("2");
} else if (timeDate.CompareN("WED", 3, 0) == 0) {
value.Append("3");
} else if (timeDate.CompareN("THU", 3, 0) == 0) {
value.Append("4");
} else if (timeDate.CompareN("FRI", 3, 0) == 0) {
value.Append("5");
} else if (timeDate.CompareN("SAT", 3, 0) == 0) {
value.Append("6");
} else if (timeDate.CompareN("SUN", 3, 0) == 0) {
value.Append("7");
} else {
statusOk = false;
}
// Analyze the hour
if (statusOk) {
char td4 = timeDate.At(4), td5 = timeDate.At(5);
if (isdigit(td4) && isdigit(td5)) {
long val = (td4 - '0') * 10 + (td5 - '0');
if (val < 24) {
value.Append(timeDate.SubString(4, 2));
} else {
statusOk = false;
}
} else {
statusOk = false;
}
}
// Analyze the minutes
if (statusOk) {
char td7 = timeDate.At(7), td8 = timeDate.At(8);
if (isdigit(td7) && isdigit(td8)) {
long val = (td7 - '0') * 10 + (td8 - '0');
if (val < 60) {
value.Append(timeDate.SubString(7, 2));
} else {
statusOk = false;
}
} else {
statusOk = false;
}
}
if (statusOk) {
return value;
} else {
return "";
}
}
示例3: LoadFromFile
//.........这里部分代码省略.........
if (element && element != root){\
bool addedOK = root->AddToParent(defaultParent, element);\
if (!addedOK)\
delete element;\
else\
element->CreateChildren();\
}\
element = NULL;\
}
/// Read until done or too many errors!
bool wasLastLine = false;
std::cout<<"\nLines to parse: "<<lines.Size();
for (int i = 0; i < lines.Size(); ++i){
String line = lines[i];
// return true;
if (i == 59){
std::cout<<"Shouga die gooha.";
}
// str = line;
if (line.Length() < 1)
continue;
/// Manually parse the line using a few identifiers that can be relevant.
List<String> tokens;
int lastEvaluatedIndex = 0;
List<char> stack;
char last;
char cChar;
for (int l = 0; l < line.Length(); ++l){
cChar = line.At(l);
// std::cout<<"\nChar at "<<l<<": int("<<(int)cChar<<") char: "<<cChar;
switch(cChar)
{
// If not in a current stack, save as a separate word.
case ' ':
case '\t':
case '\n':
case '\r':
case '\f':
if (!stack.Size()){
// Add it.
String t;
for (int j = lastEvaluatedIndex; j < l; j++){
t += line.At(j);
}
t.RemoveInitialWhitespaces();
if (t.Length())
tokens.Add(t);
lastEvaluatedIndex = l;
}
break;
case '(':
stack.Add(cChar);
break;
case ')':
last = stack.Last();
assert(last == '(');
stack.RemoveIndex(stack.Size()-1);
break;
default:
;
}
示例4: CurrTimeDateInDecimal
String Scheduler::CurrTimeDateInDecimal() {
// CTimeDate = "Wed Apr 07 17:27:04 1999
// decimal = "199904071727"
time_t now;
time(&now);
struct tm result;
String cTimeDate;
system::LocalTime(&now, &result);
system::AscTime(&result, cTimeDate);
bool statusOk = true;
String value;
// Analyze the year
char td20 = cTimeDate.At(20), td21 = cTimeDate.At(21), td22 = cTimeDate.At(22), td23 = cTimeDate.At(23);
if (isdigit(td20) && isdigit(td21) && isdigit(td22) && isdigit(td23)) {
value.Append(cTimeDate.SubString(20, 4));
} else {
statusOk = false;
}
// Analyze the month
if (statusOk) {
cTimeDate.ToUpper();
;
if (cTimeDate.CompareN("JAN", 3, 4) == 0) {
value.Append("01");
} else if (cTimeDate.CompareN("FEB", 3, 4) == 0) {
value.Append("02");
} else if (cTimeDate.CompareN("MAR", 3, 4) == 0) {
value.Append("03");
} else if (cTimeDate.CompareN("APR", 3, 4) == 0) {
value.Append("04");
} else if (cTimeDate.CompareN("MAY", 3, 4) == 0) {
value.Append("05");
} else if (cTimeDate.CompareN("JUN", 3, 4) == 0) {
value.Append("06");
} else if (cTimeDate.CompareN("JUL", 3, 4) == 0) {
value.Append("07");
} else if (cTimeDate.CompareN("AUG", 3, 4) == 0) {
value.Append("08");
} else if (cTimeDate.CompareN("SEP", 3, 4) == 0) {
value.Append("09");
} else if (cTimeDate.CompareN("OCT", 3, 4) == 0) {
value.Append("10");
} else if (cTimeDate.CompareN("NOV", 3, 4) == 0) {
value.Append("11");
} else if (cTimeDate.CompareN("DEC", 3, 4) == 0) {
value.Append("12");
} else {
statusOk = false;
}
}
// Analyze the day
if (statusOk) {
char td8 = cTimeDate.At(8), td9 = cTimeDate.At(9);
if (isdigit(td8) && isdigit(td9)) {
long val = (td8 - '0') * 10 + (td9 - '0');
if (val <= 31) {
value.Append(cTimeDate.SubString(8, 2));
} else {
statusOk = false;
}
} else {
statusOk = false;
}
}
// Analyze the hour
if (statusOk) {
char td11 = cTimeDate.At(11), td12 = cTimeDate.At(12);
if (isdigit(td11) && isdigit(td12)) {
long val = (td11 - '0') * 10 + (td12 - '0');
if (val < 24) {
value.Append(cTimeDate.SubString(11, 2));
} else {
statusOk = false;
}
} else {
statusOk = false;
}
}
// Analyze the min
if (statusOk) {
char td14 = cTimeDate.At(14), td15 = cTimeDate.At(15);
if (isdigit(td14) && isdigit(td15)) {
long val = (td14 - '0') * 10 + (td15 - '0');
if (val < 60) {
value.Append(cTimeDate.SubString(14, 2));
} else {
statusOk = false;
}
} else {
statusOk = false;
}
}
//.........这里部分代码省略.........