1 /* $Id: plainfile.cpp,v 1.1 2006-01-25 11:27:19 adam Exp $
2 Copyright (c) 2005, Index Data.
16 #define PLAINFILE_MAX_LINE 256
19 class PlainFile::Rep {
20 friend class PlainFile;
28 yp2::PlainFile::Rep::Rep() : lineno(1)
33 yp2::PlainFile::PlainFile() : m_p(new Rep)
37 void yp2::PlainFile::Rep::close()
44 yp2::PlainFile::~PlainFile()
49 bool yp2::PlainFile::open(const std::string &fname)
53 std::ifstream *new_file = new std::ifstream(fname.c_str());
63 bool yp2::PlainFile::getline(std::vector<std::string> &args)
68 return false; // no file at all.
70 char line_cstr[PLAINFILE_MAX_LINE];
75 m_p->close(); // might as well close it now
80 m_p->fh->getline(line_cstr, PLAINFILE_MAX_LINE-1);
81 char first = line_cstr[0];
82 if (first && !strchr("# \t", first))
84 // comment or blank line.. read next.
86 const char *cp = line_cstr;
90 while (*cp && strchr(" \t", *cp))
95 while (*cp && !strchr(" \t", *cp))
97 std::string arg(cp0, cp - cp0);
106 * indent-tabs-mode: nil
107 * c-file-style: "stroustrup"
109 * vim: shiftwidth=4 tabstop=8 expandtab