Lolly 1.4.27
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
parse_string_rep Class Reference

#include <parse_string.hpp>

Inheritance diagram for parse_string_rep:
Inheritance graph
[legend]
Collaboration diagram for parse_string_rep:
Collaboration graph
[legend]

Public Member Functions

 parse_string_rep ()
 
 parse_string_rep (string s)
 
 ~parse_string_rep ()
 
void advance (int n)
 
string read (int n)
 
void write (string s)
 
char get_char (int n)
 
string get_string (int n)
 
bool test (string s)
 

Private Attributes

list< stringl
 
list< int > p
 
- Private Attributes inherited from concrete_struct
int ref_count
 The reference count for the concrete object.
 

Friends

class parse_string
 
tm_ostreamoperator<< (tm_ostream &out, parse_string s)
 
bool test (parse_string s, string what)
 

Additional Inherited Members

- Private Member Functions inherited from concrete_struct
 concrete_struct ()
 Default constructor for the concrete object. Increments the reference count.
 
virtual ~concrete_struct ()
 Virtual destructor for the concrete object. Decrements the reference count.
 

Detailed Description

Definition at line 19 of file parse_string.hpp.

Constructor & Destructor Documentation

◆ parse_string_rep() [1/2]

parse_string_rep::parse_string_rep ( )
inline

Definition at line 24 of file parse_string.hpp.

24: l (), p () {}
list< string > l

◆ parse_string_rep() [2/2]

parse_string_rep::parse_string_rep ( string s)
inline

Definition at line 25 of file parse_string.hpp.

25: l (s), p (0) {}

◆ ~parse_string_rep()

parse_string_rep::~parse_string_rep ( )
inline

Definition at line 26 of file parse_string.hpp.

26{}

Member Function Documentation

◆ advance()

void parse_string_rep::advance ( int n)

Definition at line 17 of file parse_string.cpp.

17 {
18 if (is_nil (l) || n <= 0) return;
19 p->item+= n;
20 if (p->item >= N (l->item)) {
21 n= p->item - N (l->item);
22 l= l->next;
23 p= p->next;
24 advance (n);
25 }
26}
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170
bool is_nil(blackbox x)
Definition blackbox.hpp:29
void advance(int n)

◆ read()

string parse_string_rep::read ( int n)

Definition at line 29 of file parse_string.cpp.

29 {
30 string s;
31 while (!is_nil (l) && p->item + n > N (l->item)) {
32 s << l->item (p->item, N (l->item));
33 n-= (N (l->item) - p->item);
34 l= l->next;
35 p= p->next;
36 }
37 if (is_nil (l)) return s;
38 s << l->item (p->item, p->item + n);
39 p->item+= n;
40 if (p->item >= N (l->item)) {
41 l= l->next;
42 p= p->next;
43 }
44 return s;
45}

◆ write()

void parse_string_rep::write ( string s)

Definition at line 48 of file parse_string.cpp.

48 {
49 if (N (s) > 0) {
50 l= list<string> (s, l);
51 p= list<int> (0, p);
52 }
53}
The list class represents a linked list.
Definition list.hpp:48

◆ get_char()

char parse_string_rep::get_char ( int n)

Definition at line 56 of file parse_string.cpp.

56 {
57 if (is_nil (l)) return 0;
58 if (p->item + n < N (l->item)) return l->item[p->item + n];
59
61 list<int> pp= p;
62 while (!is_nil (ll) && pp->item + n >= N (ll->item)) {
63 n-= (N (ll->item) - pp->item);
64 ll= ll->next;
65 pp= pp->next;
66 }
67 if (is_nil (ll)) return 0;
68 return ll->item[pp->item + n];
69}

◆ get_string()

string parse_string_rep::get_string ( int n)

Definition at line 72 of file parse_string.cpp.

72 {
73 if (is_nil (l)) return "";
74 if (p->item + n <= N (l->item)) return l->item (p->item, p->item + n);
75
76 string s;
78 list<int> pp= p;
79 while (n >= 0 && !is_nil (ll)) {
80 int m= min (N (ll->item) - pp->item, n);
81 s << ll->item (pp->item, pp->item + m);
82 n-= m;
83 ll= ll->next;
84 pp= pp->next;
85 }
86 return s;
87}
SI min(SI i, SI j)
Returns the minimum of two signed integers.
Definition minmax.hpp:27

◆ test()

bool parse_string_rep::test ( string s)

Definition at line 90 of file parse_string.cpp.

90 {
91 if (is_nil (l)) return N (s) == 0;
92 if (p->item + N (s) <= N (l->item)) return ::test (l->item, p->item, s);
93
94 return get_string (N (s)) == s;
95}
string get_string(int n)

Friends And Related Symbol Documentation

◆ parse_string

Definition at line 35 of file parse_string.hpp.

◆ operator<<

tm_ostream & operator<< ( tm_ostream & out,
parse_string s )
friend

Definition at line 102 of file parse_string.cpp.

103 {
104 list<string> l= s->l;
105 list<int> p= s->p;
106 while (!is_nil (l)) {
107 out << l->item (p->item, N (l->item));
108 l= l->next;
109 p= p->next;
110 }
111 return out;
112}

◆ test

bool test ( parse_string s,
string what )
friend

Definition at line 98 of file parse_string.cpp.

98 {
99 return s->test (what);
100}

Member Data Documentation

◆ l

list<string> parse_string_rep::l
private

Definition at line 20 of file parse_string.hpp.

◆ p

list<int> parse_string_rep::p
private

Definition at line 21 of file parse_string.hpp.


The documentation for this class was generated from the following files: