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.h
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.h
6  *
7  * Created on: Dec 7, 2010
8  * Author: Bob Dinitto
9  *
10  * Copyright (c) 2010-2011 Bob Dinitto
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy
13  * of this software and associated documentation files (the "Software"), to
14  * deal in the Software without restriction, including without limitation the
15  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16  * sell copies of the Software, and to permit persons to whom the Software is
17  * furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included in
20  * all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  *
30 */
31 
32 #ifndef ZZTextFeed_H_
33 #define ZZTextFeed_H_
34 
35 #include "zblcore_global.h"
36 
37 #include <QObject>
38 #include <QString>
39 #include <QException>
40 #include <QTextStream>
41 
42 namespace Zbl
43 {
44 
50  class ZBLCORESHARED_EXPORT ZTextFeed : public QObject
51 {
52  Q_OBJECT
53 public:
54 
55  ZTextFeed();
56  virtual ~ZTextFeed();
57 
58  signals:
59 
65  void dataReady( const QString& text );
66 
67 
68  public slots:
69 
76  void send( const QString& text );
77 
84  ZTextFeed& flush();
85 
86 
87 public:
88 
93  ZTextFeed& operator<<( const QString& text );
98  ZTextFeed& operator<<( const char* text );
99 
103  ZTextFeed& operator<<( const int i );
104 
105 // TODO: add operator<< methods for common data types
106 
107 
114  bool getFlushOnEOL();
115 
122  void setFlushOnEOL(bool bFlushOnEOL);
123 
124 protected:
125 
129  QString m_textbuf;
130 
137 
138  };
139 
149 ZTextFeed& tfendl( ZTextFeed& feed );
150 
155 typedef ZTextFeed& (*Omanip)(ZTextFeed&);
156 
162 {
163  return f(tf);
164 }
165 
170 inline QTextStream& operator>>(QTextStream& ts, ZTextFeed& tf)
171 {
172  ts.flush();
173 
174  QMetaObject::invokeMethod(&tf, "send",
175  Qt::AutoConnection, Q_ARG(QString, ts.readAll()));
176 
177  return ts;
178 }
179 
180 } //Zbl
181 
182 
183 #endif /* ZZTextFeed_H_ */
ZTextFeed &(* Omanip)(ZTextFeed &)
Definition: ZTextFeed.h:155
#define ZBLCORESHARED_EXPORT
QTextStream & operator>>(QTextStream &ts, ZTextFeed &tf)
Definition: ZTextFeed.h:170
This class provides a means of directing a text stream to listeners.
Definition: ZTextFeed.h:50
ZTextFeed & tfendl(ZTextFeed &feed)
Definition: ZTextFeed.cpp:111
bool m_bFlushEOL
Definition: ZTextFeed.h:136
Definition: ZAndGate.cpp:6
ZTextFeed & operator<<(ZTextFeed &tf, Omanip f)
Definition: ZTextFeed.h:161
QString m_textbuf
Definition: ZTextFeed.h:129