LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
tokensstream.cpp
Go to the documentation of this file.
1// Copyright (C) 2003 by CEA LIST (LVIC)
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#include "tokensstream.h"
7
8
9namespace Lima {
10namespace DocumentsReader {
11
12//**********************************************************************
13// constructors,destructor,copy assignment
14//**********************************************************************
16std::deque< IndexToken* >()
17{
18}
19
20
22std::deque< IndexToken* >()
23{
24 copy(t);
25}
26
28{
29 if (this != &t)
30 {
31 clear();
32 copy(t);
33 }
34 return *this;
35}
36
41
42//********************
43// helper functions
45 for (TokensStream::const_iterator i(t.begin());
46 i != t.end(); i++) {
47 push_back((*i)->clone());
48 }
49}
51 for (TokensStream::const_iterator i(begin());
52 i != end(); i++) {
53 delete (*i);
54 }
55 std::deque< IndexToken* >::clear();
56}
57
58//**********************************************************************
59
60void TokensStream::push(const IndexToken& t) {
61 push_back(t.clone());
62}
63
68{
69 return (!empty());
70}
71
76{
77 if (empty())
78 {
79 throw std::runtime_error("nextToken in an empty tokens stream.");
80 }
81 IndexToken* res = front();
82 pop_front();
83 return res;
84}
85
86//**********************************************************************
87// input/output functions
88/*
89std::wostream& operator << (std::wostream& os, TokensStream& stream) {
90 for (TokensStream::const_iterator i(stream.begin());
91 i != stream.end(); i++) {
92 os << *i << std::endl;
93 }
94 os << CODE_ENDOFSTREAM;
95 return os;
96}
97
98std::wistream& operator >> (std::wistream& is, TokensStream& stream) {
99 bool endOfStream(false);
100 while (! endOfStream) {
101 IndexToken* token=readFromStream(is);
102 if (token == NULL) {
103 endOfStream=true;
104 }
105 else {
106 stream.push_back(token);
107 }
108 }
109 return is;
110}
111*/
112
113} // namespace DocumentsReader
114} // namespace Lima
This is a stream of tokens.
TokensStream & operator=(const TokensStream &)
bool hasToken() const
Tests if a token is available.
IndexToken * nextToken()
Returns the next token.
void copy(const TokensStream &)
void push(const IndexToken &)
NAUTITIA.
STL namespace.