diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:30 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:30 +0000 |
commit | 7a52d43a162b23d9e85e7b955e9b2c8e9caf550e (patch) | |
tree | 66a84b20d47f2269d8bdc6e0323f338763424d3a /ACE/apps/Gateway/Gateway/File_Parser.h | |
parent | 0e49389337be86641451a5c36c24bf742fe97523 (diff) | |
download | ATCD-7a52d43a162b23d9e85e7b955e9b2c8e9caf550e.tar.gz |
Repo restructuring
Diffstat (limited to 'ACE/apps/Gateway/Gateway/File_Parser.h')
-rw-r--r-- | ACE/apps/Gateway/Gateway/File_Parser.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/ACE/apps/Gateway/Gateway/File_Parser.h b/ACE/apps/Gateway/Gateway/File_Parser.h new file mode 100644 index 00000000000..6e971090ad8 --- /dev/null +++ b/ACE/apps/Gateway/Gateway/File_Parser.h @@ -0,0 +1,97 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// gateway +// +// = FILENAME +// File_Parser.h +// +// = AUTHOR +// Doug Schmidt +// +// ============================================================================ + +#ifndef _FILE_PARSER +#define _FILE_PARSER + +#include "ace/Basic_Types.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class FP +{ + // = TITLE + // This class serves as a namespace for the <Return_Type>. +public: + enum Return_Type + { + RT_EOLINE, + RT_EOFILE, + RT_SUCCESS, + RT_COMMENT, + RT_DEFAULT, + RT_PARSE_ERROR + }; +}; + +template <class ENTRY> +class File_Parser +{ + // = TITLE + // Class used to parse the configuration file for the + // <Consumer_Map>. +public: + + /// Destructor. + virtual ~File_Parser (void); + + // = Open and Close the file specified + int open (const ACE_TCHAR filename[]); + int close (void); + + virtual FP::Return_Type read_entry (ENTRY &entry, + int &line_number) = 0; + // Pure virtual hook that subclasses override and use the protected + // methods to fill in the <entry>. + +protected: + FP::Return_Type getword (char buf[]); + // Read the next ASCII word. + + FP::Return_Type getint (ACE_INT32 &value); + // Read the next integer. + + FP::Return_Type readword (char buf[]); + // Read the next "word," which is demarcated by <delimiter>s. + // + // @@ This function is inherently flawed since it doesn't take a + // count of the size of <buf>... + + int delimiter (char ch); + // Returns true if <ch> is a delimiter, i.e., ' ', ',', or '\t'. + + int comments (char ch); + // Returns true if <ch> is the comment character, i.e., '#'. + + int skipline (void); + // Skips to the remainder of a line, e.g., when we find a comment + // character. + + FILE *infile_; + // Pointer to the file we're reading. +}; + +#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 */ |