EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
ASCIIParser.h
1 // -------------------------------------------- -*- c++ -*-
2 // $Id: ASCIIParser.h,v 1.4 2006/05/12 20:36:50 kasemir Exp $
3 //
4 // Please refer to NOTICE.txt,
5 // included as part of this distribution,
6 // for legal information.
7 //
8 // Kay-Uwe Kasemir, kasemir@lanl.gov
9 // --------------------------------------------------------
10 
11 #ifndef __ASCII_PARSER__
12 #define __ASCII_PARSER__
13 
14 // system
15 #include <stdio.h>
16 
17 // tools
18 #include "tools/ToolsConfig.h"
19 #include "tools/AutoFilePtr.h"
20 #include "tools/NoCopy.h"
21 
23 
33 {
34 public:
35  ASCIIParser();
36 
41  bool open(const stdString &file_name);
42 
46  bool nextLine();
47 
49  const stdString & getLine() const;
50 
52  size_t getLineNo() const;
53 
57  bool getParameter(stdString &parameter, stdString &value);
58 
59 private:
60  PROHIBIT_DEFAULT_COPY(ASCIIParser);
61  AutoFilePtr file;
62  size_t line_no;
63  stdString line;
64 };
65 
66 inline const stdString &ASCIIParser::getLine() const
67 { return line; }
68 
69 inline size_t ASCIIParser::getLineNo() const
70 { return line_no; }
71 
72 #endif
73 
74 
bool nextLine()
Read next line from file, skipping comment lines.
bool open(const stdString &file_name)
Open file for parsing.
Helper class for programming an ASCII-file parser.
Definition: ASCIIParser.h:32
Auto-close FILE pointer wrapper.
Definition: AutoFilePtr.h:15
bool getParameter(stdString &parameter, stdString &value)
Try to extract parameter=value pair from current line.
const stdString & getLine() const
Get current line as string, excluding &#39; &#39;.
Definition: ASCIIParser.h:66
size_t getLineNo() const
Get number of current line.
Definition: ASCIIParser.h:69