Ejemplo n.º 1
0
void MainObject::List()
{
  for(int i=0;i<edit_log_event->size();i++) {
    printf("%4d %s\n",i,(const char *)ListLine(edit_log_event,i));
  }
  printf("%4d  --- end of log ---\n",edit_log_event->size());
}
Ejemplo n.º 2
0
bool Listing::Write(std::string &listingName, std::string &inName, bool listMacros)
{
    std::fstream in(inName.c_str(), std::ios::in);
    if (in == NULL)
        return false;
    std::fstream out(listingName.c_str(), std::ios::out);
    if (out == NULL)
    {
        Utils::fatal(std::string(std::string("Could not open ") + listingName.c_str() + " for write.").c_str());
        return false;
    }
    std::vector<std::string> lines;
    int lineno = 1;
    ListedLine *cur = NULL;
    if (list.size())
    {
        cur = list.front();
        list.pop_front();
    }
    while (!in.eof())
    {
        char buf[4000];
        while ((!cur  || (cur && lineno < cur->lineno)) && !in.eof())
        {
            in.getline(buf, 4000);
            std::string bufs = buf;
            lineno++;
            lines.push_back(bufs);
            ListLine(out, bufs, NULL, false);
        }
        if (cur && cur->lineno == lineno)
        {
            in.getline(buf, 4000);
            std::string bufs = buf;
            lineno++;
            lines.push_back(bufs);
            ListLine(out, bufs, cur, false);
            if (list.size())
            {
                cur = list.front();
                list.pop_front();
            }
            else
            {
                cur = NULL;
            }
        }
        if (cur && cur->lineno < lineno)
        {
            in.getline(buf, 4000);
            std::string bufs = buf;
            lineno++;
            lines.push_back(bufs);
            ListLine(out, bufs, NULL, false);
        }
        while (cur && cur->lineno < lineno)
        {
            if (listMacros)
                ListLine(out, lines[cur->lineno-1], cur, true);
            if (list.size())
            {
                cur = list.front();
                list.pop_front();
            }
            else
            {
                cur = NULL;
            }
        }
    }
    return true;
}