12 inline bool vsprintf(std::string& a_string,
int a_length,
const char* a_format,va_list a_args){
14 if(a_length<0)
return false;
15 if(!a_format)
return false;
16 char* s =
new char[a_length+1];
19 int n =
vsnpf(s,a_length+1,a_format,a_args);
24 if(s[a_length]!=
'\0') {
34 inline bool sprintf(std::string& a_string,
int a_length,
const char* a_format,...){
36 if(a_length<0)
return false;
37 if(!a_format)
return false;
38 char* s =
new char[a_length+1];
42 va_start(
args,a_format);
43 int n =
vsnpf(s,a_length+1,a_format,
args);
49 if(s[a_length]!=
'\0') {
58 inline bool print2sv(std::string& a_string,
int a_length,
const char* a_format,va_list a_args){
59 if(a_length<0) {a_string.clear();
return false;}
60 if(!a_format) {a_string.clear();
return false;}
61 a_string.assign(a_length,
' ');
62 char* s =
const_cast<char*
>(a_string.c_str());
64 int n =
vsnpf(s,a_length+1,a_format,a_args);
69 if(s[a_length]!=
'\0') {
77 inline bool print2s(std::string& a_string,
int a_length,
const char* a_format,...){
78 if(a_length<0) {a_string.clear();
return false;}
79 if(!a_format) {a_string.clear();
return false;}
80 a_string.assign(a_length,
' ');
81 char* s =
const_cast<char*
>(a_string.c_str());
84 va_start(
args,a_format);
85 int n =
vsnpf(s,a_length+1,a_format,
args);
91 if(s[a_length]!=
'\0') {
99 template <
class MATRIX>
100 inline void set_matrix(MATRIX& a_matrix,
const std::string& a_fmt) {
101 unsigned int DR = a_matrix.rows();
102 unsigned int DC = a_matrix.cols();
104 for(
unsigned int i=0;i<DR;i++) {
105 for(
unsigned int j=0;j<DC;j++) {
107 a_matrix.set_value(i,j,ss);