クラス sc_dt::sc_string_old

#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_oldoperator= (const char *s)
sc_string_oldoperator= (const sc_string_old &s)
sc_string_oldoperator+= (const char *s)
sc_string_oldoperator+= (char c)
sc_string_oldoperator+= (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_oldfmt (const T &t)
sc_string_oldfmt (const sc_string_old &s)
int pos (const sc_string_old &sub_string) const
sc_string_oldremove (unsigned index, unsigned length)
sc_string_oldinsert (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_reprep

フレンド

systemc_ostreamoperator<< (systemc_ostream &os, const sc_string_old &a)
systemc_istreamoperator>> (systemc_istream &is, sc_string_old &a)
sc_string_old operator+ (const char *s, const sc_string_old &t)


説明

sc_string.h150 行で定義されています。


コンストラクタとデストラクタ

sc_dt::sc_string_old::sc_string_old ( int  size = 16  )  [explicit]

sc_string.cpp197 行で定義されています。

00198 {
00199     rep = new sc_string_rep( size );
00200 }

sc_dt::sc_string_old::sc_string_old ( const char *  s  ) 

sc_string.cpp202 行で定義されています。

00203 {
00204     rep = new sc_string_rep( s );
00205 }

sc_dt::sc_string_old::sc_string_old ( const char *  s,
int  n 
)

sc_string.cpp207 行で定義されています。

00208 {
00209     rep = new sc_string_rep( s, n );
00210 }

sc_dt::sc_string_old::sc_string_old ( const sc_string_old s  ) 

sc_string.cpp212 行で定義されています。

00213 {
00214     rep = s.rep;
00215     rep->ref_count ++;
00216 }

sc_dt::sc_string_old::~sc_string_old (  ) 

sc_string.cpp226 行で定義されています。

00227 {
00228     if( -- (rep->ref_count) == 0 ) {
00229         delete rep;
00230     }
00231 }

sc_dt::sc_string_old::sc_string_old ( sc_string_rep r  )  [private]

sc_string.cpp218 行で定義されています。

00219 {
00220     rep = r;
00221 }


関数

sc_string_old & sc_dt::sc_string_old::operator= ( const char *  s  ) 

sc_string.cpp281 行で定義されています。

00282 {
00283     if (rep->ref_count > 1) {
00284         --rep->ref_count;
00285         rep = new sc_string_rep(s);
00286     }
00287     else {
00288         rep->set_string(s);
00289     }
00290     return *this;
00291 }

sc_string_old & sc_dt::sc_string_old::operator= ( const sc_string_old s  ) 

sc_string.cpp294 行で定義されています。

00295 {
00296     if (&s == this)
00297         return *this;
00298     if (--(rep->ref_count) == 0)
00299         delete rep;
00300     rep = s.rep;
00301     rep->ref_count++;
00302     return *this;
00303 }

sc_string_old & sc_dt::sc_string_old::operator+= ( const char *  s  ) 

sc_string.cpp306 行で定義されています。

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.cpp324 行で定義されています。

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.cpp344 行で定義されています。

00345 {
00346     return this->operator+=( s.rep->str );
00347 }

sc_string_old sc_dt::sc_string_old::operator+ ( const char *  s  )  const

sc_string.cpp241 行で定義されています。

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.cpp250 行で定義されています。

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.cpp271 行で定義されています。

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.cpp367 行で定義されています。

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

sc_string.cpp235 行で定義されています。

00236 {
00237     return strlen(rep->str);
00238 }

const char * sc_dt::sc_string_old::c_str (  )  const

sc_string.cpp361 行で定義されています。

00362 {
00363   return rep->str;
00364 }

sc_dt::sc_string_old::operator const char * (  )  const

sc_string.cpp400 行で定義されています。

00401 {
00402     return rep->str;
00403 }

char sc_dt::sc_string_old::operator[] ( int  index  )  const

sc_string.cpp406 行で定義されています。

00407 {
00408     return rep->str[i];
00409 }

char & sc_dt::sc_string_old::operator[] ( int  index  ) 

sc_string.cpp411 行で定義されています。

00412 {
00413     if (rep->ref_count > 1) {
00414         rep->ref_count--;
00415         rep = new sc_string_rep(rep->str);
00416     }
00417     return rep->str[i];
00418 }

sc_string_old sc_dt::sc_string_old::to_string ( const char *  format,
  ... 
) [static]

sc_string.cpp430 行で定義されています。

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 }

template<class T>
sc_string_old& sc_dt::sc_string_old::fmt ( const T &  t  )  [inline]

sc_string.h240 行で定義されています。

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  ) 

sc_string.cpp544 行で定義されています。

00545 {
00546     return fmt(s.c_str());
00547 }

int sc_dt::sc_string_old::pos ( const sc_string_old sub_string  )  const

sc_string.cpp550 行で定義されています。

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.cpp572 行で定義されています。

00573 {
00574     test((int)index);
00575     if(length!=0)
00576         (*this) = substr(0,index-1) + substr(index+length,this->length()-1);
00577     return *this;
00578 }

sc_string_old & sc_dt::sc_string_old::insert ( const sc_string_old sub_string,
unsigned  index 
)

sc_string.cpp581 行で定義されています。

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

sc_string.cpp589 行で定義されています。

00590 {
00591     test((int)index);
00592     return str.contains(rep->str[index]);
00593 }

bool sc_dt::sc_string_old::contains ( char  c  )  const

sc_string.cpp596 行で定義されています。

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.cpp607 行で定義されています。

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.cpp621 行で定義されています。

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.cpp375 行で定義されています。

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 
)

sc_string.cpp421 行で定義されています。

00422 {
00423     if (rep->ref_count > 1) {
00424         rep->ref_count--;
00425         rep = new sc_string_rep(rep->str);
00426     }
00427     rep->str[i] = c;
00428 }

int sc_dt::sc_string_old::cmp ( const char *  s  )  const

sc_string.cpp350 行で定義されています。

00351 {
00352     return strcmp( rep->str, s );
00353 }

int sc_dt::sc_string_old::cmp ( const sc_string_old s  )  const

sc_string.cpp356 行で定義されています。

00357 {
00358     return strcmp( rep->str, s.rep->str );
00359 }

void sc_dt::sc_string_old::print ( systemc_ostream os = ::std::cout  )  const

sc_string.cpp495 行で定義されています。

00496 {
00497     os << rep->str;
00498 }

void sc_dt::sc_string_old::test ( int  position  )  const [private]

sc_string.cpp500 行で定義されています。

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.cpp516 行で定義されています。

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]

sc_string.h323 行で定義されています。

00324 {
00325     a.print( os );
00326     return os;
00327 }

systemc_istream& operator>> ( systemc_istream is,
sc_string_old a 
) [friend]

sc_string.cpp638 行で定義されています。

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.cpp261 行で定義されています。

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.h303 行で定義されています。


このクラスの説明は次のファイルから生成されました:

SystemCに対してFri Jun 6 20:13:08 2008に生成されました。  doxygen 1.5.6