Example #1
0
File: expr.cpp Project: nmmmnu/ccc
expr_type Calculator::calc_br(){
   StringBuffer *sb = new StringBuffer();

   for (;pos < strlen(expr); pos++){
      //printf(">>>%c %5d\n", expr[pos], pos);

      if   (expr[pos] == '('){
         pos++;
         sb->add( exprtoa(calc_br()) );
      }elif (expr[pos] == ')')
         break;
      else
         if (!isspace(expr[pos]))
            sb->add(expr[pos]);
   }
Example #2
0
const char *AbstractMacroReplacer::replace(const char *source){
   if (isempty(source))
      return NULL;

   StringEscaper *se   = new StringEscaper(source);
   StringBuffer  *pole = new StringBuffer();

   sb->clear();

   boolean b = false;

   while (!se->eof()){
      char x = se->getChar();
      
      if (!b){
         if ((!se->getStatus() ) && (x == bdelim))
   	    b = true; 
         else
	    sb->add(x);
      }else{
         if ((!se->getStatus() ) && (x == edelim)){
	    sb->add( replaceField( pole->get() ) );
            b = false;
            pole->clear();
         }
else
            pole->add(x);
 
      }
   }

   delete(pole);
   delete(se);
   return sb->get();
};
Example #3
0
void TextFile::iterate(){
   if (len <= 0)
      return;

   StringBuffer *sb = new StringBuffer();
   boolean b = false;

   for (size_t i = 0; i <= len; i++)
      if ((data[i] != '\n') && 
          (data[i] != '\r')){
         sb->add(data[i]);
         b = true;
      }else{
         if (!iterator(sb->get()))
            break;
         b = false;
         sb->clear();
      }

   if (b) //resolving <EOF> at the end
      iterator(sb->get() );

   delete(sb);
};