#include <sc_string.h>
Public メソッド | |
sc_string_old (int size=16) | |
sc_string_old (const char *s) | |
sc_string_old (const char *s, int n) | |
sc_string_old (const sc_string_old &s) | |
~sc_string_old () | |
sc_string_old & | operator= (const char *s) |
sc_string_old & | operator= (const sc_string_old &s) |
sc_string_old & | operator+= (const char *s) |
sc_string_old & | operator+= (char c) |
sc_string_old & | operator+= (const sc_string_old &s) |
sc_string_old | operator+ (const char *s) const |
sc_string_old | operator+ (char c) const |
sc_string_old | operator+ (const sc_string_old &s) const |
sc_string_old | substr (int first, int last) const |
bool | operator== (const char *s) const |
bool | operator!= (const char *s) const |
bool | operator< (const char *s) const |
bool | operator<= (const char *s) const |
bool | operator> (const char *s) const |
bool | operator>= (const char *s) const |
bool | operator== (const sc_string_old &s) const |
bool | operator!= (const sc_string_old &s) const |
bool | operator< (const sc_string_old &s) const |
bool | operator<= (const sc_string_old &s) const |
bool | operator> (const sc_string_old &s) const |
bool | operator>= (const sc_string_old &s) const |
int | length () const |
const char * | c_str () const |
operator const char * () const | |
char | operator[] (int index) const |
char & | operator[] (int index) |
template<class T> | |
sc_string_old & | fmt (const T &t) |
sc_string_old & | fmt (const sc_string_old &s) |
int | pos (const sc_string_old &sub_string) const |
sc_string_old & | remove (unsigned index, unsigned length) |
sc_string_old & | insert (const sc_string_old &sub_string, unsigned index) |
bool | is_delimiter (const sc_string_old &str, unsigned index) const |
bool | contains (char c) const |
sc_string_old | uppercase () const |
sc_string_old | lowercase () const |
void | set (int index, char c) |
int | cmp (const char *s) const |
int | cmp (const sc_string_old &s) const |
void | print (systemc_ostream &os=::std::cout) const |
Static Public メソッド | |
static sc_string_old | to_string (const char *format,...) |
static sc_string_old | make_str (long n) |
Private メソッド | |
sc_string_old (sc_string_rep *r) | |
void | test (int position) const |
unsigned | fmt_length () const |
Private 変数 | |
sc_string_rep * | rep |
フレンド | |
systemc_ostream & | operator<< (systemc_ostream &os, const sc_string_old &a) |
systemc_istream & | operator>> (systemc_istream &is, sc_string_old &a) |
sc_string_old | operator+ (const char *s, const sc_string_old &t) |
sc_string.h の 150 行で定義されています。
sc_dt::sc_string_old::sc_string_old | ( | int | size = 16 |
) | [explicit] |
sc_dt::sc_string_old::sc_string_old | ( | const char * | s | ) |
sc_dt::sc_string_old::sc_string_old | ( | const char * | s, | |
int | n | |||
) |
sc_dt::sc_string_old::sc_string_old | ( | const sc_string_old & | s | ) |
sc_dt::sc_string_old::~sc_string_old | ( | ) |
sc_dt::sc_string_old::sc_string_old | ( | sc_string_rep * | r | ) | [private] |
sc_string_old & sc_dt::sc_string_old::operator= | ( | const char * | s | ) |
sc_string_old & sc_dt::sc_string_old::operator= | ( | const sc_string_old & | s | ) |
sc_string_old & sc_dt::sc_string_old::operator+= | ( | const char * | s | ) |
sc_string.cpp の 306 行で定義されています。
00307 { 00308 int oldlen = length(); 00309 int slen = strlen(s); 00310 if (rep->ref_count > 1) { 00311 sc_string_rep* oldrep = rep; 00312 --rep->ref_count; 00313 rep = new sc_string_rep( oldlen + slen + 1 ); 00314 strcpy( rep->str, oldrep->str ); 00315 strcpy( rep->str + oldlen, s ); 00316 } 00317 else { 00318 rep->resize( oldlen + slen + 1 ); 00319 strcpy( rep->str + oldlen, s ); 00320 } 00321 return *this; 00322 }
sc_string_old & sc_dt::sc_string_old::operator+= | ( | char | c | ) |
sc_string.cpp の 324 行で定義されています。
00325 { 00326 int oldlen = length(); 00327 if (rep->ref_count > 1) { 00328 sc_string_rep* oldrep = rep; 00329 --rep->ref_count; 00330 rep = new sc_string_rep( oldlen + 2 ); 00331 strcpy( rep->str, oldrep->str ); 00332 rep->str[oldlen]=c; 00333 rep->str[oldlen+1]=00; 00334 } 00335 else { 00336 rep->resize( oldlen + 2 ); 00337 rep->str[oldlen]=c; 00338 rep->str[oldlen+1]=00; 00339 } 00340 return *this; 00341 }
sc_string_old & sc_dt::sc_string_old::operator+= | ( | const sc_string_old & | s | ) |
sc_string_old sc_dt::sc_string_old::operator+ | ( | const char * | s | ) | const |
sc_string.cpp の 241 行で定義されています。
00242 { 00243 int len = length(); 00244 sc_string_rep* r = new sc_string_rep( len + strlen(s) + 1 ); 00245 strcpy( r->str, rep->str ); 00246 strcpy( r->str + len, s ); 00247 return sc_string_old(r); 00248 }
sc_string_old sc_dt::sc_string_old::operator+ | ( | char | c | ) | const |
sc_string.cpp の 250 行で定義されています。
00251 { 00252 int len = length(); 00253 sc_string_rep* r = new sc_string_rep( len + 2 ); 00254 strcpy( r->str, rep->str ); 00255 r->str[len] = c; 00256 r->str[len+1] = 00; 00257 return sc_string_old(r); 00258 }
sc_string_old sc_dt::sc_string_old::operator+ | ( | const sc_string_old & | s | ) | const |
sc_string.cpp の 271 行で定義されています。
00272 { 00273 int len = length(); 00274 sc_string_rep* r = new sc_string_rep( len + s.length() + 1 ); 00275 strcpy( r->str, rep->str ); 00276 strcpy( r->str + len, s.rep->str ); 00277 return sc_string_old(r); 00278 }
sc_string_old sc_dt::sc_string_old::substr | ( | int | first, | |
int | last | |||
) | const |
sc_string.cpp の 367 行で定義されています。
00368 { 00369 if(first<0 || last<0 || first>last || first>=length() || last>=length()) 00370 return ""; 00371 return sc_string_old(rep->str+first, last-first+1); 00372 }
bool sc_dt::sc_string_old::operator== | ( | const char * | s | ) | const |
bool sc_dt::sc_string_old::operator!= | ( | const char * | s | ) | const |
bool sc_dt::sc_string_old::operator< | ( | const char * | s | ) | const |
bool sc_dt::sc_string_old::operator<= | ( | const char * | s | ) | const |
bool sc_dt::sc_string_old::operator> | ( | const char * | s | ) | const |
bool sc_dt::sc_string_old::operator>= | ( | const char * | s | ) | const |
bool sc_dt::sc_string_old::operator== | ( | const sc_string_old & | s | ) | const |
bool sc_dt::sc_string_old::operator!= | ( | const sc_string_old & | s | ) | const |
bool sc_dt::sc_string_old::operator< | ( | const sc_string_old & | s | ) | const |
bool sc_dt::sc_string_old::operator<= | ( | const sc_string_old & | s | ) | const |
bool sc_dt::sc_string_old::operator> | ( | const sc_string_old & | s | ) | const |
bool sc_dt::sc_string_old::operator>= | ( | const sc_string_old & | s | ) | const |
int sc_dt::sc_string_old::length | ( | ) | const |
const char * sc_dt::sc_string_old::c_str | ( | ) | const |
sc_dt::sc_string_old::operator const char * | ( | ) | const |
char sc_dt::sc_string_old::operator[] | ( | int | index | ) | const |
char & sc_dt::sc_string_old::operator[] | ( | int | index | ) |
sc_string_old sc_dt::sc_string_old::to_string | ( | const char * | format, | |
... | ||||
) | [static] |
sc_string.cpp の 430 行で定義されています。
00431 { 00432 va_list argptr; 00433 int cnt; 00434 sc_string_old result; 00435 char buffer[1024]; // static string buffer 00436 buffer[1023]=000; 00437 00438 va_start(argptr, format); 00439 #if defined(WIN32) 00440 // Windows provides safer implementation 00441 #if defined(_MSC_VER) 00442 cnt = _vsnprintf(buffer, 1024, format, argptr); 00443 #else 00444 cnt = vsnprintf(buffer, 1024, format, argptr); 00445 #endif 00446 if(cnt>1023) // string too long 00447 { 00448 int buf_size = 1024; 00449 const int max_size = 65000; 00450 char* buf; // dynamic buffer 00451 do 00452 { 00453 buf_size*=2; 00454 buf = new char[buf_size]; 00455 #if defined(_MSC_VER) 00456 cnt = _vsnprintf(buffer, buf_size, format, argptr); 00457 #else 00458 cnt = vsnprintf(buffer, buf_size, format, argptr); 00459 #endif 00460 if(buf_size<max_size && cnt>=buf_size) 00461 delete[] buf; 00462 } 00463 while( buf_size<max_size && cnt>=buf_size); 00464 if(cnt>=buf_size) 00465 { 00466 // string is longer the the maximum buffer size (max_size) 00467 SC_REPORT_WARNING( sc_core::SC_ID_STRING_TOO_LONG_, "truncated" ); 00468 buf[buf_size-1] = 000; 00469 } 00470 result = buf; 00471 delete[] buf; 00472 } 00473 else 00474 result = buffer; 00475 #else 00476 try { 00477 // this may end up in a core dump 00478 // if we are lucky we can catch exception 00479 cnt = vsprintf(buffer, format, argptr); 00480 } 00481 catch(...) 00482 { 00483 SC_REPORT_WARNING( sc_core::SC_ID_STRING_TOO_LONG_, 00484 "program may become unstable" ); 00485 } 00486 buffer[1023]=000; // in case it's longer 00487 result = buffer; 00488 #endif 00489 va_end(argptr); 00490 00491 return result; 00492 }
sc_string_old& sc_dt::sc_string_old::fmt | ( | const T & | t | ) | [inline] |
sc_string.h の 240 行で定義されています。
00241 { 00242 // search % 00243 int index; 00244 int last_char = length()-1; 00245 sc_string_old temp(*this); 00246 do 00247 { 00248 index = temp.pos("%"); 00249 if(index == last_char) 00250 return *this; 00251 temp = substr(index,last_char); 00252 } while(temp[0] != '%'); 00253 int f_len = (int)temp.fmt_length(); // length of format field 00254 temp = to_string(substr(0,index+f_len-1).c_str(),t); 00255 return (*this) = temp + substr(index+f_len,last_char); 00256 }
sc_string_old & sc_dt::sc_string_old::fmt | ( | const sc_string_old & | s | ) |
int sc_dt::sc_string_old::pos | ( | const sc_string_old & | sub_string | ) | const |
sc_string.cpp の 550 行で定義されています。
00551 { 00552 int sub_len = sub_string.length(); 00553 if( sub_len == 0 ) { 00554 return 0; // empty string always matches 00555 } 00556 int ind = 0; 00557 int len = length(); 00558 bool found = false; 00559 while( ind < len && ! found ) 00560 { 00561 found = ( sub_string == substr( ind, ind + sub_len - 1 ) ); 00562 ++ ind; 00563 } 00564 if( found ) { 00565 return -- ind; 00566 } else { 00567 return -1; 00568 } 00569 }
sc_string_old & sc_dt::sc_string_old::remove | ( | unsigned | index, | |
unsigned | length | |||
) |
sc_string_old & sc_dt::sc_string_old::insert | ( | const sc_string_old & | sub_string, | |
unsigned | index | |||
) |
sc_string.cpp の 581 行で定義されています。
00582 { 00583 if(index>(unsigned)length()) 00584 SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, "sc_string_old::insert" ); 00585 return (*this) = substr(0,index-1)+sub_string+substr(index,length()-1); 00586 }
bool sc_dt::sc_string_old::is_delimiter | ( | const sc_string_old & | str, | |
unsigned | index | |||
) | const |
bool sc_dt::sc_string_old::contains | ( | char | c | ) | const |
sc_string.cpp の 596 行で定義されています。
00597 { 00598 int len = length(); 00599 int i=0; 00600 bool found = false; 00601 while(!found && i<len) 00602 found = rep->str[i++]==c; 00603 return found; 00604 }
sc_string_old sc_dt::sc_string_old::uppercase | ( | ) | const |
sc_string.cpp の 607 行で定義されています。
00608 { 00609 int len = length(); 00610 sc_string_old temp(*this); 00611 for(int i=0; i<len; i++) 00612 { 00613 char c = temp.rep->str[i]; 00614 if(c>='a' && c<='z') 00615 temp.rep->str[i] = static_cast<char>( c-32 ); 00616 } 00617 return temp; 00618 }
sc_string_old sc_dt::sc_string_old::lowercase | ( | ) | const |
sc_string.cpp の 621 行で定義されています。
00622 { 00623 int len = length(); 00624 sc_string_old temp(*this); 00625 for(int i=0; i<len; i++) 00626 { 00627 char c = temp.rep->str[i]; 00628 if(c>='A' && c<='Z') 00629 temp.rep->str[i] = static_cast<char>( c+32 ); 00630 } 00631 return temp; 00632 }
sc_string_old sc_dt::sc_string_old::make_str | ( | long | n | ) | [static] |
sc_string.cpp の 375 行で定義されています。
00376 { 00377 char buf[32]; 00378 ::std::sprintf(buf,"%ld",n); 00379 return sc_string_old(buf); 00380 }
void sc_dt::sc_string_old::set | ( | int | index, | |
char | c | |||
) |
int sc_dt::sc_string_old::cmp | ( | const char * | s | ) | const |
int sc_dt::sc_string_old::cmp | ( | const sc_string_old & | s | ) | const |
void sc_dt::sc_string_old::print | ( | systemc_ostream & | os = ::std::cout |
) | const |
void sc_dt::sc_string_old::test | ( | int | position | ) | const [private] |
sc_string.cpp の 500 行で定義されています。
00501 { 00502 if(position<0 || position>=length()) 00503 SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, "sc_string_old::test" ); 00504 }
unsigned sc_dt::sc_string_old::fmt_length | ( | ) | const [private] |
sc_string.cpp の 516 行で定義されています。
00517 { 00518 unsigned result=0; 00519 if((*this)[0]!='%') 00520 return 0; 00521 else 00522 result++; 00523 if(is_delimiter("-+0 #",result)) // flags 00524 result++; 00525 while(is_delimiter("0123456789*",result)) // width 00526 result++; 00527 if(rep->str[result]=='.') // precision 00528 { 00529 result++; 00530 unsigned old_result = result; 00531 while(is_delimiter("0123456789*",result)) result++; 00532 if(old_result == result) //error in format 00533 return 0; 00534 } 00535 if(is_delimiter("hlL",result)) result++; // I64 is not supported 00536 if(is_delimiter("cCdiouxXeEfgGnpsS",result)) 00537 result++; 00538 else // error in format 00539 return 0; 00540 return result; 00541 }
systemc_ostream& operator<< | ( | systemc_ostream & | os, | |
const sc_string_old & | a | |||
) | [friend] |
systemc_istream& operator>> | ( | systemc_istream & | is, | |
sc_string_old & | a | |||
) | [friend] |
sc_string.cpp の 638 行で定義されています。
00639 { 00640 if( s.rep->ref_count > 1 ) { 00641 -- s.rep->ref_count; 00642 s.rep = new sc_string_rep; 00643 } 00644 00645 int i = 0; 00646 char* p = s.rep->str; 00647 char c; 00648 00649 // skip white spaces 00650 while( is.get( c ) && isspace( c ) ) 00651 ; 00652 00653 for( ; is.good() && ! isspace( c ); is.get( c ) ) { 00654 if( i > s.rep->alloc - 2 ) { 00655 s.rep->str[i] = '\0'; 00656 s.rep->resize( (int) (s.rep->alloc * 1.5) ); 00657 p = s.rep->str + i; 00658 } 00659 *p ++ = c; 00660 i ++; 00661 } 00662 *p = '\0'; 00663 00664 return is; 00665 }
sc_string_old operator+ | ( | const char * | s, | |
const sc_string_old & | t | |||
) | [friend] |
sc_string.cpp の 261 行で定義されています。
00262 { 00263 int len = strlen(s); 00264 sc_string_rep* r = new sc_string_rep( len + t.length() + 1 ); 00265 strcpy( r->str, s ); 00266 strcpy( r->str + len, t ); 00267 return sc_string_old(r); 00268 }
sc_string_rep* sc_dt::sc_string_old::rep [private] |
sc_string.h の 303 行で定義されています。