fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / autodoc / source / inc / tools / tkpchars.hxx
blob345d2ff4727904188db4cb0c59fd8f7d81c2665e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef ADC_TKPCHARS_HXX
21 #define ADC_TKPCHARS_HXX
23 // USED SERVICES
24 // BASE CLASSES
25 // COMPONENTS
26 // PARAMETRS
27 #include <adc_cl.hxx>
28 #include <stack>
32 /** @descr
34 dpSource:
36 1||||||||||||||||||||||a||||||||||||b|||c||||||||||||||||||||...
39 1 := first character of Sourcecode.
40 a := nLastTokenStart, there starts the last cut token.
41 b := nLastCut, there is a '\0'-char which marks the end of
42 the last cut token. The original character at b is stored
43 in cCharAtLastCut and will replace the '\0'-char, when the
44 next token is cut.
45 c := The current cursor position.
48 @needs cosv.lib
50 @use This class can be used by any parser to get the chars of a
51 text one by one and separate them to tokens.
52 **/
54 class CharacterSource
56 public:
57 // LIFECYCLE
58 CharacterSource();
59 ~CharacterSource();
61 // OPERATIONS
62 /** Loads the complete contents of in_rSource into the classes private memory.
63 If in_rSource is a file, it has to be open of course.
64 After loading the text, the CurChar() is set on the begin of the text.
65 **/
66 void LoadText(
67 csv::bstream & io_rSource);
69 /// @return CurChar() after moving forward one char.
70 char MoveOn();
71 /** @return
72 The token which starts at the char which was CurChar(), when
73 CutToken() was called the last time - or at the beginning of the text.
74 The token ends by the CurChar() being replaced by a '\0'.
76 Value is valid until the next call of CutToken() or ~CharacterSource().
77 **/
78 const char * CutToken();
80 // INQUIRY
81 char CurChar() const;
82 /// @return The result of the last CutToken(). Or NULL, if there was none yet.
83 const char * CurToken() const;
85 // INQUIRY
86 /// @return true, if
87 bool IsFinished() const;
89 private:
90 void BeginSource();
91 intt CurPos() const;
93 DYN char * dpSource;
94 intt nSourceSize;
96 intt nCurPos;
97 intt nLastCut;
98 intt nLastTokenStart;
99 char cCharAtLastCut;
103 inline char
104 CharacterSource::MoveOn()
106 if (DEBUG_ShowText())
108 Cerr() << char(dpSource[nCurPos+1]) << Flush();
110 if ( nCurPos < nSourceSize-1 )
111 return dpSource[++nCurPos];
112 else
113 return dpSource[nCurPos = nSourceSize];
115 inline char
116 CharacterSource::CurChar() const
117 { return nCurPos != nLastCut ? dpSource[nCurPos] : cCharAtLastCut; }
118 inline const char *
119 CharacterSource::CurToken() const
120 { return &dpSource[nLastTokenStart]; }
121 inline bool
122 CharacterSource::IsFinished() const
123 { return nCurPos >= nSourceSize; }
124 inline intt
125 CharacterSource::CurPos() const
126 { return nCurPos; }
131 #endif
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */