as2js: /home/snapwebsites/snapcpp/contrib/as2js/include/as2js/position.h Source File

position.h
Go to the documentation of this file.
1 #ifndef AS2JS_POSITION_H
2 #define AS2JS_POSITION_H
3 /* include/as2js/position.h
4 
5 Copyright (c) 2005-2019 Made to Order Software Corp. All Rights Reserved
6 
8 
9 Permission is hereby granted, free of charge, to any
10 person obtaining a copy of this software and
11 associated documentation files (the "Software"), to
12 deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify,
14 merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom
16 the Software is furnished to do so, subject to the
17 following conditions:
18 
19 The above copyright notice and this permission notice
20 shall be included in all copies or substantial
21 portions of the Software.
22 
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
24 ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
25 LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
26 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
27 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30 ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 SOFTWARE.
33 
34 */
35 
36 #include "string.h"
37 
38 
39 namespace as2js
40 {
41 
42 
43 
44 class Position
45 {
46 public:
47  typedef int32_t counter_t;
48  static counter_t const DEFAULT_COUNTER = 1;
49 
50 // Position();
51 // Position(Position const& rhs);
52 //
53 // Position& operator = (Position const& rhs);
54 
55  void set_filename(String const& filename);
56  void set_function(String const& function);
57  void reset_counters(counter_t line = DEFAULT_COUNTER);
58  void new_page();
59  void new_paragraph();
60  void new_line();
61 
62  String get_filename() const;
63  String get_function() const;
64  counter_t get_page() const;
65  counter_t get_page_line() const;
66  counter_t get_paragraph() const;
67  counter_t get_line() const;
68 
69 private:
72  counter_t f_page = DEFAULT_COUNTER;
75  counter_t f_line = DEFAULT_COUNTER;
76 };
77 
78 std::ostream& operator << (std::ostream& out, Position const& pos);
79 
80 
81 }
82 // namespace as2js
83 #endif
84 // #ifndef AS2JS_POSITION_H
85 
86 // vim: ts=4 sw=4 et
counter_t f_page
Definition: position.h:72
counter_t f_page_line
Definition: position.h:73
counter_t f_line
Definition: position.h:75
counter_t get_page() const
Retrieve the current page counter.
Definition: position.cpp:171
void new_paragraph()
Increments the paragraph counter by 1.
Definition: position.cpp:116
counter_t get_paragraph() const
Retrieve the current paragraph counter.
Definition: position.cpp:199
String f_filename
Definition: position.h:70
String f_function
Definition: position.h:71
counter_t get_page_line() const
Retrieve the current page line counter.
Definition: position.cpp:185
void reset_counters(counter_t line=DEFAULT_COUNTER)
Reset the counter.
Definition: position.cpp:84
int32_t counter_t
Definition: position.h:47
counter_t get_line() const
Retrieve the current line counter.
Definition: position.cpp:214
void new_page()
Increment the page counter by 1.
Definition: position.cpp:103
void set_function(String const &function)
Set the function being read.
Definition: position.cpp:68
void new_line()
Increment the line counter by 1.
Definition: position.cpp:127
static counter_t const DEFAULT_COUNTER
Definition: position.h:48
std::ostream & operator<<(std::ostream &out, Node const &node)
Send a node to the specified output stream.
String get_filename() const
Retrieve the filename.
Definition: position.cpp:143
counter_t f_paragraph
Definition: position.h:74
The AlexScript to JavaScript namespace.
Definition: compiler.cpp:37
String get_function() const
Retrieve the function name.
Definition: position.cpp:158
void set_filename(String const &filename)
Set the filename being read.
Definition: position.cpp:52

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly