1 /* $Id: plainfile.cpp,v 1.2 2006-03-16 10:40:59 adam Exp $
2 Copyright (c) 2005-2006, Index Data.
16 #define PLAINFILE_MAX_LINE 256
18 namespace mp = metaproxy_1;
20 namespace metaproxy_1 {
21 class PlainFile::Rep {
22 friend class PlainFile;
30 mp::PlainFile::Rep::Rep() : lineno(1)
35 mp::PlainFile::PlainFile() : m_p(new Rep)
39 void mp::PlainFile::Rep::close()
46 mp::PlainFile::~PlainFile()
51 bool mp::PlainFile::open(const std::string &fname)
55 std::ifstream *new_file = new std::ifstream(fname.c_str());
65 bool mp::PlainFile::getline(std::vector<std::string> &args)
70 return false; // no file at all.
72 char line_cstr[PLAINFILE_MAX_LINE];
77 m_p->close(); // might as well close it now
82 m_p->fh->getline(line_cstr, PLAINFILE_MAX_LINE-1);
83 char first = line_cstr[0];
84 if (first && !strchr("# \t", first))
86 // comment or blank line.. read next.
88 const char *cp = line_cstr;
92 while (*cp && strchr(" \t", *cp))
97 while (*cp && !strchr(" \t", *cp))
99 std::string arg(cp0, cp - cp0);
108 * indent-tabs-mode: nil
109 * c-file-style: "stroustrup"
111 * vim: shiftwidth=4 tabstop=8 expandtab