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 boost {
namespace wave {
namespace util {

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

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

}   // namespace util
}   // namespace wave
}   // namespace boost

Template parameters

The file_position template used by the default token type has to be instantiated 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.

You may use your own position types if appropriate, but in any case these should implement the same interface as the file_position template described here.

Member functions

Constructors

        file_position();
        explicit file_position(String 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

        String 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(String 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).