📄 sstr_03.cc
字号:
// clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, DEF_FMT_LLONG_8BIT, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// float arg: (input) number to convert//// return: a boolean value indicating status//// convert a double precision floating point number into a string//boolean SysString::assign(float arg_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, DEF_WFMT_FLOAT_8BIT, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// double arg: (input) number to convert//// return: a boolean value indicating status//// convert a double precision floating point number into a string//boolean SysString::assign(double arg_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, DEF_WFMT_DOUBLE_8BIT, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// const SysComplex<TIntegral>& arg: (input) value to print//// return: a boolean value indicating status//// convert a complex number into a string//template <class TIntegral>boolean SysString::assign(const SysComplex<TIntegral>& arg_a) { // covert the real part into string // assign(arg_a.real()); // case: image part is nonnegative // if (arg_a.imag() >= 0) { concat(L"+"); } // convert the image part into string // concat(arg_a.imag()); // concat the identification j and exit gracefully // return concat(L"j");}// explicit instantiations for complex types//templateboolean SysString::assign<float>(const SysComplex<float>&);templateboolean SysString::assign<double>(const SysComplex<double>&);templateboolean SysString::assign<long>(const SysComplex<long>&);// ----// method: assign//// arguments:// const void* arg: (input) pointer to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a pointer into a string//boolean SysString::assign(const void* arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); // clear out the current value // clear(Integral::RESET); // if the pointer is null, return that string // if (arg_a == NULL) { SysString p1(L"%p"); SysString r1(L"%s"); temp.replace(p1, r1); return assign(NULL_PTR, (unichar*)temp); } temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { return assign((byte*)buf); } // exit gracefully // return false;}// method: assign//// arguments:// boolean arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a boolean value into a string. note that the format should// include a %s.//boolean SysString::assign(boolean arg_a, const unichar* fmt_a) { // first convert to a string // SysString b; b.assign(arg_a); // now apply the format // return assign(b, fmt_a);}// method: assign//// arguments:// byte arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a byte integer into a string//boolean SysString::assign(byte arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, (ulong)arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// unichar arg: (input) character to assign to string// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// assign object to arg_a//boolean SysString::assign(unichar arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, (char)arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// ushort arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert an unsigned short integer into a string//boolean SysString::assign(ushort arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// ulong arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert an unsigned long integer into a string//boolean SysString::assign(ulong arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// ullong arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert an unsigned long long integer into a string//boolean SysString::assign(ullong arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// short arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a short integer into a string//boolean SysString::assign(short arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// long arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a long integer into a string//boolean SysString::assign(long arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// llong arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a long long integer into a string//boolean SysString::assign(llong arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// float arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a double precision floating point number into a string//boolean SysString::assign(float arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr; // check the arguments // if (fmt_a == (unichar*)NULL) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } SysString temp(fmt_a); temp.getBuffer((byte*)fmt, MAX_LENGTH); fmt_ptr = fmt; // clear out the current value // clear(Integral::RESET); // create and possibly assign the string // if (sprintf(buf, fmt_ptr, arg_a) > 0) { assign((byte*)buf); return true; } // exit gracefully // return false;}// method: assign//// arguments:// double arg: (input) number to convert// const unichar* fmt: (input) print format//// return: a boolean value indicating status//// convert a double precision floating point number into a string//boolean SysString::assign(double arg_a, const unichar* fmt_a) { // allocate a static buffer for printing // static char buf[MAX_LENGTH]; static char fmt[MAX_LENGTH]; static char* fmt_ptr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -