Exemplo n.º 1
0
std::string Building::printObjectInfo(bool full) const
{
    std::stringstream ss;

    ss << Object::printObjectInfo(full) <<
          insertSpaces("Is complete") << (completeness ? "yes" : "no") <<
                                         std::endl <<
          insertSpaces("Free space")  << free_space << "/" << max_space <<
                                         std::endl;

    if (full)
    {
        ss << "Contents" << std::endl << contents -> printIDs() << std::endl;
    }

    return ss.str();
}
Exemplo n.º 2
0
 vector<string> fullJustify(vector<string>& words, int maxWidth) 
 {
     vector<string> retVec;
     if (words.empty() || maxWidth == 0)
     {
         retVec.push_back("");
         return retVec;
     }
     vector<vector<string> > wordGroups;
     splitWords(words, wordGroups, maxWidth);
     insertSpaces(wordGroups, maxWidth, retVec);
     return retVec;
 }
Exemplo n.º 3
0
void printToFile(GTokenType token)
{
  GTokenValue value=gScanner->value;
  guint uiCurLine=g_scanner_cur_line(gScanner);
  PPARSEINFO pParseInfo=(PPARSEINFO)gScanner->user_data;
  
  return;
  
  if(!pParseInfo->fPrintToken)
    return;
  
  if(0==pParseInfo->uiCurFileLine)
  {
    pParseInfo->uiCurPos=1;  
  }
  else 
  {
    while(pParseInfo->uiCurFileLine < uiCurLine)
    {
      g_printf("\n");
      pParseInfo->uiCurFileLine++;
      pParseInfo->uiCurPos=1;      
    }
  }
  pParseInfo->uiCurFileLine=uiCurLine;
  
  //g_printf("-> %d %d\n", gScanner->position, pParseInfo->uiCurPos);
  
  //g_printf("-> %d %d\n", g_scanner_cur_position(gScanner), pParseInfo->uiCurPos);
  
  //  uiCurLine+=pParseInfo->uiLineCorrection;
  //g_printf("-> %d", gScanner->position);
  
  switch(token)
  {
    case G_TOKEN_SYMBOL:
    {
      PSYMBOL pCurSymbol=value.v_symbol;
      
      
      insertSpaces(g_scanner_cur_position(gScanner)-strlen(pCurSymbol->chrSymbolName)+1);
      
      g_printf("%s", pCurSymbol->chrSymbolName);
      
      //      pParseInfo->uiCurPos+=strlen(pCurSymbol->chrSymbolName);
      break;
    }
    case G_TOKEN_STRING:
      insertSpaces(g_scanner_cur_position(gScanner)-strlen(value.v_string)-1);
      
      g_print("\"%s\"", value.v_string);
      pParseInfo->uiCurPos+=strlen(value.v_string);
      break;
    case G_TOKEN_INT:
      insertSpaces(g_scanner_cur_position(gScanner));
      g_print("%d", value.v_int);
      break;
    case G_TOKEN_IDENTIFIER:
      insertSpaces(g_scanner_cur_position(gScanner)-strlen(value.v_identifier)+1);
      
      g_print("%s", value.v_identifier);
      pParseInfo->uiCurPos+=strlen(value.v_identifier);
      break;
      
#if 0
    case G_TOKEN_IDENTIFIER:
      g_message("Token: %d (G_TOKEN_IDENTIFIER)\t\t%s (LINE %d)",
                token, value.v_identifier, uiCurLine);
      break;
    case G_TOKEN_STRING:
      g_message("Token: %d (G_TOKEN_STRING)\t\t\t%s", token, value.v_string);
      break;
    case G_TOKEN_LEFT_PAREN:
      g_message("Token: %d (G_TOKEN_LEFT_PAREN)\t\t\t( (LINE %d)", token, uiCurLine);
      break;
    case G_TOKEN_RIGHT_PAREN:
      g_message("Token: %d (G_TOKEN_RIGHT_PAREN)\t\t\t) (LINE %d)", token, uiCurLine);
      break;
    case G_TOKEN_LEFT_CURLY:
      g_message("Token: %d (G_TOKEN_LEFT_CURLY)\t\t\t{ (LINE %d)", token, uiCurLine);
      break;
    case G_TOKEN_RIGHT_CURLY:
      g_message("Token: %d (G_TOKEN_RIGHT_CURLY)\t\t\t} (LINE %d)", token, uiCurLine);
      break;
    case ':':
      g_message("Token: %d (colon)\t\t:", token);
      break;
    case ';':
      g_message("Token: %d (semicolon)\t\t\t; (LINE %d)", token, uiCurLine);
      break;
    case '#':
      g_message("Token: %d (hash)\t\t\t#", token);
      break;
    case '/':
      g_message("Token: %d (slash)\t\t\t/ %s", token, value.v_comment);
      break;
    case G_TOKEN_COMMA:
      g_message("Token: %d (G_TOKEN_COMMA)\t\t\t,", token);
      break;
    case G_TOKEN_INT:
      g_message("Token: %d (G_TOKEN_INT)\t\t\t%ld", token, value.v_int);
      break;
#endif
    default:
    {        
      insertSpaces(g_scanner_cur_position(gScanner));
      g_print("%c", token);
      pParseInfo->uiCurPos++;
      break;
    } /* default */
      
  } /* switch */
  //fprintf(fh, "#define %s_%s(nomSelf, ", pif->chrName, pm->chrName);  
}