WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZTextFeed.cpp
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2010-2011, 2014 Bob Dinitto
4  *
5  * ZTextFeed.cpp
6  *
7  * Created on: Dec 7, 2010
8  * Author: Bob Dinitto
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a copy
11  * of this software and associated documentation files (the "Software"), to
12  * deal in the Software without restriction, including without limitation the
13  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14  * sell copies of the Software, and to permit persons to whom the Software is
15  * furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included in
18  * all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS IN THE SOFTWARE.
27  *
28 */
29 
30 #include "ZTextFeed.h"
31 
32 
33 namespace Zbl
34 {
35 
37  : QObject(0), m_bFlushEOL(true)
38 {
39 
40 }
41 
43 {
44 }
45 
46 void ZTextFeed::send( const QString& text )
47 {
48  m_textbuf += text;
49 
50  //emit dataReady( m_textbuf ); // TBD:
51 
52  //m_textbuf.clear();
53 }
54 
55 
60 ZTextFeed& ZTextFeed::operator<<( const QString& text )
61 {
62  send(text);
63 
64  return *this;
65 }
66 
71 ZTextFeed& ZTextFeed::operator<<( const char* text )
72 {
73  send(QString(text));
74 
75  return *this;
76 }
77 
78 
80 {
81  QString str;
82  str.setNum(i);
83  send(str);
84  return *this;
85 }
86 
87 
89 {
90  return m_bFlushEOL;
91 }
92 
93 
94 void ZTextFeed::setFlushOnEOL(bool bFlushOnEOL)
95 {
96  m_bFlushEOL=bFlushOnEOL;
97 }
98 
99 
101 {
102  //emit textStream(m_textbuf);
103 
104  emit dataReady( m_textbuf ); // TBD:
105 
106  m_textbuf.clear();
107 
108  return *this;
109 }
110 
112 {
113  feed.send("\n");
114  if(feed.getFlushOnEOL())
115  feed.flush();
116 
117  return feed;
118 }
119 
120 } // Zbl
ZTextFeed & operator<<(const QString &text)
Definition: ZTextFeed.cpp:60
ZTextFeed & flush()
Definition: ZTextFeed.cpp:100
This class provides a means of directing a text stream to listeners.
Definition: ZTextFeed.h:50
ZTextFeed & tfendl(ZTextFeed &feed)
Definition: ZTextFeed.cpp:111
void send(const QString &text)
Definition: ZTextFeed.cpp:46
bool m_bFlushEOL
Definition: ZTextFeed.h:136
Definition: ZAndGate.cpp:6
QString m_textbuf
Definition: ZTextFeed.h:129
void setFlushOnEOL(bool bFlushOnEOL)
Definition: ZTextFeed.cpp:94
virtual ~ZTextFeed()
Definition: ZTextFeed.cpp:42
bool getFlushOnEOL()
Definition: ZTextFeed.cpp:88
void dataReady(const QString &text)
Sent when text in the internal buffer is being flushed.