本文整理汇总了C++中String::Double方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Double方法的具体用法?C++ String::Double怎么用?C++ String::Double使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Double方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initial_Table
bool User_Program::Initial_Table (String &line)
{
int i, j, index, lnum, len;
Int_Itr litr, litr0;
double fnum;
Dbl_Itr fitr, fitr0;
String token;
Str_Itr sitr, sitr0;
string::iterator ch, ch0;
i = cmd.token;
j = cmd.value;
for (;;) {
//---- remove leading spaces ----
line.Trim_Left (" \t");
if (line.empty ()) return (false);
ch = ch0 = line.begin ();
//---- determine the token type ----
if ((*ch >= '0' && *ch <= '9') || (*ch == '.' && *(ch+1) != '.') ||
(*ch == '-' && (*(ch+1) >= '0' && *(ch+1) <= '9'))) {
//---- process a number ----
if (*ch == '-') ch++;
do {
if (++ch == line.end ()) break;
} while ((*ch >= '0' && *ch <= '9') || (*ch == '.' && *(ch+1) != '.'));
len = (int) (ch - ch0);
token = line.substr (0, len);
line.erase (0, len);
//---- set the table size ----
if (open_par) {
lnum = token.Integer ();
if (lnum < 1) {
exe->Error (String ("%s Table %d Size %d is Out of Range") % Data_Type (i) % j % lnum);
return (false);
}
if (table [i] [j].size () > 0) {
exe->Write (1);
exe->Warning (String ("%s Table %d is Redefined") % Data_Type (i) % j);
table [i] [j].clear ();
}
table [i] [j].reserve (lnum);
} else {
if (table_type == STAB) {
exe->Error ("Attempt to Assign a Number to a String Table");
return (false);
}
//---- search for the value in the list ----
if (table_type == ITAB) {
lnum = token.Integer ();
for (litr = litr0 = lvalue.begin (); litr != lvalue.end (); litr++) {
if (*litr == lnum) break;
}
if (litr == lvalue.end ()) {
index = (int) lvalue.size (); //---- 0 based ----
lvalue.push_back (lnum);
} else {
index = (int) (litr - litr0); //---- 0 based ----
}
} else {
fnum = token.Double ();
for (fitr = fitr0 = fvalue.begin (); fitr != fvalue.end (); fitr++) {
if (*fitr == fnum) break;
}
if (fitr == fvalue.end ()) {
index = (int) fvalue.size (); //---- 0 based ----
fvalue.push_back (fnum);
} else {
index = (int) (fitr - fitr0); //---- 0 based ----
}
}
table [i] [j].push_back (index);
}
} else if (*ch == '"') {
if (table_type != STAB) goto error;
//---- process a string ----
ch++;
token.clear ();
//.........这里部分代码省略.........
示例2: Read_Reports
void Execution_Service::Read_Reports (void)
{
int i, num, num_reports;
String key;
Report_Name_Itr itr;
Report_Number report;
//---- get the number of selected reports ----
num_reports = Highest_Control_Group (PROGRAM_REPORTS, 0);
if (num_reports <= 0) {
report_flag = false;
return;
}
report_flag = true;
report_number.reserve (num_reports);
for (i=1; i <= num_reports; i++) {
key = Get_Control_String (PROGRAM_REPORTS, i);
if (key.empty ()) continue;
report.type = 0;
report.data = 0.0;
//---- identify the report ----
num = 1;
for (itr = report_name.begin (); itr != report_name.end (); itr++, num++) {
if (itr->name.Equals (key)) {
itr->flag = true;
report.type = num;
break;
} else {
//---- check for a variable length report label ----
size_t index = itr->name.find_last_of ('*');
if (index != string::npos) {
String temp = itr->name.substr (0, index);
if (key.Starts_With (temp)) {
itr->flag = true;
report.type = num;
temp = key.substr (index);
report.data = temp.Double ();
break;
}
}
}
}
//---- check for unrecognized report types ----
if (report.type == 0) {
Error (String ("Unrecognized Report Type = %s") % key);
} else {
report_number.push_back (report);
}
}
}
示例3: Read_Field
//.........这里部分代码省略.........
case DB_INTEGER:
if (asc_flag) {
lvalue = svalue.Integer ();
} else if (size == sizeof (int)) {
lvalue = *((int *) field);
} else if (size == sizeof (short)) {
lvalue = *((short *) field);
} else if (size == sizeof (char)) {
lvalue = *((char *) field);
} else {
return (Status (FIELD_BYTES));
}
fld_type = DB_INTEGER;
break;
case DB_UNSIGNED:
if (asc_flag) {
lvalue = svalue.Integer ();
} else if (size == sizeof (int)) {
lvalue = *((unsigned int *) field);
} else if (size == sizeof (short)) {
lvalue = *((unsigned short *) field);
} else if (size == sizeof (char)) {
lvalue = *((unsigned char *) field);
} else {
return (Status (FIELD_BYTES));
}
fld_type = DB_INTEGER;
break;
case DB_DOUBLE:
if (asc_flag) {
dvalue = svalue.Double ();
} else if (size == sizeof (double)) {
dvalue = *((double *) field);
} else if (size == sizeof (float)) {
dvalue = *((float *) field);
} else {
return (Status (FIELD_BYTES));
}
fld_type = DB_DOUBLE;
break;
case DB_FIXED:
if (asc_flag) {
dvalue = svalue.Double ();
if (svalue.find ('.') == 0) {
dvalue = dvalue / pow (10.0, fld->Decimal ());
}
} else {
if (size == sizeof (int)) {
lvalue = *((int *) field);
} else if (size == sizeof (short)) {
lvalue = *((short *) field);
} else if (size == sizeof (char)) {
lvalue = *((char *) field);
} else {
return (Status (FIELD_BYTES));
}
dvalue = (double) lvalue / pow (10.0, fld->Decimal ());
}
fld_type = DB_DOUBLE;
break;
case DB_STRING: