The File Position

Introduction
Header 'wave/util/file_position.hpp' synopsis
Template parameters
Member functions

Introduction

The file position template is used to represent a concrete token position inside the underlying input stream. This token position contains the corresponding filename, the line number and the column number, where the token was recognized.

Header wave/util/file_position.hpp synopsis

namespace wave {
namespace util {

    template <typename StringT = std::string>
    class file_position {
 
    public:
        file_position();
        explicit file_position(StringT const &file, 
            int line_ = 1, int column_ = 1);

    // accessors
        StringT const &get_file() const;
        int get_line() const;
        int get_column() const;
    
        void set_file(StringT const &file);
        void set_line(int line);
        void set_column(int column);
    };

}   // namespace util
}   // namespace wave

Template parameters

The file_position template may be instantiatet with one template parameter, which gives the string type to use for storing the file name member of the file position. If this parameter isn't given, it defaults to a std::string. Please note, that the type given as the template parameter must be compatible with a std::string.

Member functions

Constructors

        file_position();
        explicit file_position(StringT const &file, 
            int line_ = 1, int column_ = 1);

The constructors initialize a new instance of a file_position in correspondence to the supplied parameters. The parameters default to an empty filename and the line number and column number set to one.

get_file, get_line, get_column

        StringT const &get_file() const;
        int get_line() const;
        int get_column() const;

The get_... functions are used to access the current values of the file position members: the filename (get_file), the line number (get_line) and the column number (get_column).

set_file, set_line, set_column

        void set_file(StringT const &file);
        void set_line(int line);
        void set_column(int column);

The set_... functions are used to set new values to the file position members: the filename (set_file), the line number (set_line) and the column number (set_column).


Last updated: Monday, January 5, 2004 14:57