summaryrefslogtreecommitdiff
path: root/apps/Gateway/Gateway/File_Parser.h
blob: 80b768aff8431b6d54f185f374e04e4827a6c8ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    apps
// 
// = FILENAME
//    File_Parser.h
//
// = AUTHOR
//    Doug Schmidt 
// 
// ============================================================================

#if !defined (_FILE_PARSER)
#define _FILE_PARSER

#include "ace/OS.h"

class FP 
  // = TITLE
  //     This class serves as a namespace for the Return_Type
{
public:
  enum Return_Type 
  { 
    EOLINE,
    EOFILE,
    SUCCESS, 
    COMMENT, 
    ERROR
  };
};

template <class ENTRY>
class File_Parser
  // = TITLE
  //     Class used to parse the configuration file for the Consumer
  //     Map.
{
public:
  // = Open and Close the file specified
  int open (const char filename[]);
  int close (void);

  virtual FP::Return_Type read_entry (ENTRY &, int &line_number) = 0;
  // Implementations use protected methods to fill in the entry.

protected:
  FP::Return_Type getword (char buf[]);
  // Read the next ASCII word.

  FP::Return_Type getint (int &value);
  // Read the next integer.

  FP::Return_Type readword (char buf[]);
  int delimiter (char ch);
  int comments (char ch);
  int skipline (void);

  FILE *infile_;
};

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "File_Parser.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("File_Parser.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#endif /* _FILE_PARSER */