TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
json_scanner.cpp
Go to the documentation of this file.
1 /* This file is part of QJson
2  *
3  * Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
4  * Copyright (C) 2013 Silvio Moioli <silvio@moioli.net>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License version 2.1, as published by the Free Software Foundation.
9  *
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 #include "json_scanner.cc"
22 
23 #include "qjson_debug.h"
24 #include "json_scanner.h"
25 #include "json_parser.hh"
26 
27 #include <ctype.h>
28 #include <cassert>
29 
31  : m_allowSpecialNumbers(false),
32  m_io (io),
33  m_criticalError(false),
34  m_C_locale(QLocale::C)
35 {
36 
37 }
38 
40 {
41 }
42 
44 {
45  m_allowSpecialNumbers = allow;
46 }
47 
48 int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc)
49 {
50  m_yylval = yylval;
51  m_yylloc = yylloc;
52  m_yylloc->step();
53  int result = yylex();
54 
55  if (m_criticalError) {
56  return -1;
57  }
58 
59  return result;
60 }
61 
62 int JSonScanner::LexerInput(char* buf, int max_size)
63 {
64  if (!m_io->isOpen()) {
65  qCritical() << "JSonScanner::yylex - io device is not open";
66  m_criticalError = true;
67  return 0;
68  }
69 
70  int readBytes = m_io->read(buf, max_size);
71  if(readBytes < 0) {
72  qCritical() << "JSonScanner::yylex - error while reading from io device";
73  m_criticalError = true;
74  return 0;
75  }
76 
77  return readBytes;
78 }
79 
80 
#define YYSTYPE
Definition: json_scanner.h:28
void allowSpecialNumbers(bool allow)
voidpf void * buf
Definition: ioapi.h:136
QIODevice * m_io
Definition: json_scanner.h:58
bool m_allowSpecialNumbers
Definition: json_scanner.h:57
YYSTYPE * m_yylval
Definition: json_scanner.h:60
yy::location * m_yylloc
Definition: json_scanner.h:61
JSonScanner(QIODevice *io)
int LexerInput(char *buf, int max_size)
bool m_criticalError
Definition: json_scanner.h:62