commit 5c71260c12798afe3c331d08477bb241acdb78ca Author: Keith Bennett Date: Sat Mar 22 17:05:45 2014 +0000 Squashed 'src/http/qjson/' content from commit c6d92ba git-subtree-dir: src/http/qjson git-subtree-split: c6d92bada76be2c46dcf6f585f03b2fba47f9da3 diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..a3ed5a764 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +lib +Makefile +doc/html + +# -- kdevelop +.kdev4 +*.kdev4 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..2e7d7258e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,121 @@ +PROJECT(qjson) + +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII" ) + +# Force cmake 2.8.8 in order to have a decent support of Qt5 +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) +CMAKE_POLICY(SET CMP0003 NEW) + +# Do not link against qtmain on Windows +cmake_policy(SET CMP0020 OLD) + +set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR}) + +IF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*") + ADD_DEFINITIONS("-DQT_NO_DEBUG_OUTPUT") +ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*") + +# Ability to disable verbose debug output +IF(QJSON_VERBOSE_DEBUG_OUTPUT) + ADD_DEFINITIONS("-DQJSON_VERBOSE_DEBUG_OUTPUT") +endif(QJSON_VERBOSE_DEBUG_OUTPUT) + +# On Windows debug library should have 'd' postfix. +IF (WIN32) + SET(CMAKE_DEBUG_POSTFIX "d") +ENDIF (WIN32) + +OPTION(OSX_FRAMEWORK "Build a Mac OS X Framework") +SET(FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Library/Frameworks" + CACHE PATH "Where to place qjson.framework if OSX_FRAMEWORK is selected") + +# Don't use absolute path in qjson-targets-*.cmake +# (This will have no effect with CMake < 2.8) +SET(QT_USE_IMPORTED_TARGETS TRUE) + +option(QT4_BUILD "Force building with Qt4 even if Qt5 is found") +IF (NOT QT4_BUILD) + FIND_PACKAGE( Qt5Core QUIET ) +ENDIF() + +IF (Qt5Core_FOUND) + MESSAGE ("Qt5 found") + + INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS}) + ADD_DEFINITIONS(${Qt5Core_DEFINITIONS}) + + # Tell CMake to run moc when necessary: + set(CMAKE_AUTOMOC ON) + # As moc files are generated in the binary dir, tell CMake + # to always look for includes there: + set(CMAKE_INCLUDE_CURRENT_DIR ON) +ELSE() + MESSAGE ("Qt5 not found, searching for Qt4") + # Find Qt4 + FIND_PACKAGE( Qt4 REQUIRED ) + + # Include the cmake file needed to use qt4 + INCLUDE( ${QT_USE_FILE} ) + +ENDIF() + +IF (NOT WIN32) + SET( QT_DONT_USE_QTGUI TRUE ) +ENDIF() + + +#add extra search paths for libraries and includes +SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) +SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Directory where lib will install") +SET (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") +SET (CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${CMAKE_PROJECT_NAME}" CACHE PATH "Directory where to install QJSONConfig.cmake") + +set(QJSON_LIB_MAJOR_VERSION "0") +set(QJSON_LIB_MINOR_VERSION "8") +set(QJSON_LIB_PATCH_VERSION "1") + +set(QJSON_LIB_VERSION_STRING "${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSION}.${QJSON_LIB_PATCH_VERSION}") + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) + +# pkg-config +IF (NOT WIN32) + CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/QJson.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc + @ONLY) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/QJson.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +ENDIF (NOT WIN32) + +# Subdirs +ADD_SUBDIRECTORY(src) +IF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS) + enable_testing() + ADD_SUBDIRECTORY(tests) +ENDIF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS) + +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +INSTALL(EXPORT qjson-export DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE QJSONTargets.cmake) + +# figure out the relative path from the installed Config.cmake file to the install prefix (which may be at +# runtime different from the chosen CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere) +# This relative path will be configured into the QJSONConfig.cmake +file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX} ) + +# cmake-modules +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake + @ONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfigVersion.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake + @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake + DESTINATION "${CMAKECONFIG_INSTALL_DIR}") + +ADD_CUSTOM_TARGET(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") diff --git a/COPYING.lib b/COPYING.lib new file mode 100644 index 000000000..08f25cd2f --- /dev/null +++ b/COPYING.lib @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1, as published by the Free Software Foundation. + + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 000000000..817d5849d --- /dev/null +++ b/ChangeLog @@ -0,0 +1,103 @@ +Mon Jan 28 23:01:40 CET 2013 Flavio Castelli + + * Fix compilation on BlackBerry 10. + +Tue Nov 27 11:04:12 CET 2012 Flavio Castelli + + * Relase 0.8.1: + - ensure API and ABI compatibility with 0.7.1 + +Thu Nov 22 21:20:11 CET 2012 Flavio Castelli + + * Fix unsafe pointer usage in Serializer::serialize() + +---------------------------------------------------------------------- +Wed Nov 21 22:01:51 CET 2012 Flavio Castelli + + * Version 0.8.0 released + +Tue Nov 20 11:19:49 CET 2012 Flavio Castelli + + * Serializer: handle QVariantHash + +Tue Oct 30 15:50:10 CET 2012 Flavio Castelli + + * Improve error handling inside of Serializer + * Serializer: handle quint16. + +Tue Jan 31 10:15:06 CET 2012 Flavio Castelli + + * Make possible to build qjson as an OS X framework. + +Fri Nov 04 16:50:56 CET 2011 Flavio Castelli + + * Make possible to set double precision during serialization. + +Wed Aug 24 17:58:56 CEST 2011 Flavio Castelli + + * Buildsystem adjustments, fix issues mentioned here: + - http://lists.kde.org/?l=kde-buildsystem&m=130947194605100&w=3 + - http://lists.kde.org/?l=kde-buildsystem&m=128835747626464&w=3 + The biggest difference now is that FindQJSON.cmake is not provided + anymore. Instead, QJSONConfig.cmake and QJSONConfigVersion.cmake are + installed and can be used in find_package(QJSON) calls. Applications + using QJson can write their own FindQJSON.cmake files if they need to. + +Fri Apr 23:04:29 CEST 2011 Flavio Castelli + + * Fixed QVariant de-serialization. QVariant properties were ignored + during QVariant -> QObject conversion. + +Sun Dec 18:59:28 CET 2010 Flavio Castelli + + * It's now possible to indent the output produced by the Serializer. + +Mon Sep 06 18:53:02 CEST 2010 Flavio Castelli + + * 50% performance improvement when parsing numbers. + +Sun Jul 04 15:41:08 CEST 2010 Flavio Castelli + + * fix make install when not installing as root + * provide "make uninstall" + +Tue Jun 15 13:16:57 CEST 2010 Flavio Castelli + + * Allow top level values + +---------------------------------------------------------------------- +Sat Mar 13 23:57:00 CEST 2009 - flavio@castelli.name + + * Merged the symbian branch into master, + +---------------------------------------------------------------------- +Sun Oct 11 19:18:00 CEST 2009 - flavio@castelli.name + + * Updated to 0.6.3: fixed a bug affecting ulonglong numbers serialization. + +------------------------------------------------------------------- +Wed Sep 15 19:21:00 CEST 2009 - flavio@castelli.name + + * Updated to 0.6.2: fixed a bug affecting ulonglong numbers parsing. + +------------------------------------------------------------------- +Wed Sep 09 09:55:00 CEST 2009 - flavio@castelli.name + + * Updated to 0.6.1: relevant bugs fixed. + * Moved the SerializerRunnable class inside QJson namespace. + * Fixed a bug in cmdline_tester. + +------------------------------------------------------------------- +Mon Jul 20 15:24:32 CEST 2009 - prusnak@suse.cz + + * Updated to 0.6.0 (KDE SVN rev 999750). + +------------------------------------------------------------------- +Mon Apr 07 00:00:00 UTC 2009 - flavio@castelli.name + + * Released 0.5.1 - added unicode support. + +------------------------------------------------------------------- +Mon Apr 03 00:00:00 UTC 2009 - flavio@castelli.name + + * First release. diff --git a/QJSONConfig.cmake.in b/QJSONConfig.cmake.in new file mode 100644 index 000000000..def072cbb --- /dev/null +++ b/QJSONConfig.cmake.in @@ -0,0 +1,6 @@ +GET_FILENAME_COMPONENT(myDir ${CMAKE_CURRENT_LIST_FILE} PATH) + +SET(QJSON_LIBRARIES qjson) +SET(QJSON_INCLUDE_DIR "@INCLUDE_INSTALL_DIR@") + +include(${myDir}/QJSONTargets.cmake) diff --git a/QJSONConfigVersion.cmake.in b/QJSONConfigVersion.cmake.in new file mode 100644 index 000000000..6005d2dc8 --- /dev/null +++ b/QJSONConfigVersion.cmake.in @@ -0,0 +1,9 @@ +SET(PACKAGE_VERSION "@QJSON_LIB_VERSION_STRING@") +IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + SET(PACKAGE_VERSION_EXACT TRUE) +ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) +IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + SET(PACKAGE_VERSION_COMPATIBLE TRUE) +ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + SET(PACKAGE_VERSION_UNSUITABLE TRUE) +ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) diff --git a/QJson.pc.in b/QJson.pc.in new file mode 100644 index 000000000..e4704bda7 --- /dev/null +++ b/QJson.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@LIB_INSTALL_DIR@ +includedir=@INCLUDE_INSTALL_DIR@ + +Name: QJson +Description: QJson is a qt-based library that maps JSON data to QVariant objects +Version: @QJSON_LIB_MAJOR_VERSION@.@QJSON_LIB_MINOR_VERSION@.@QJSON_LIB_PATCH_VERSION@ +Requires: QtCore +Libs: -L${libdir} -lqjson +Cflags: -I${includedir} \ No newline at end of file diff --git a/README.license b/README.license new file mode 100644 index 000000000..3ede31323 --- /dev/null +++ b/README.license @@ -0,0 +1,89 @@ +Qjson version xxxx, Date + +The following files are licensed under LGPL V2.1: +------------------------------------------------ +src/json_parser.yy +src/json_scanner.cpp +src/json_scanner.h +src/parser.cpp +src/parser.h +src/parser_p.h +src/parserrunnable.cpp +src/parserrunnable.h +src/qjson_debug.h +src/qjson_export.h +src/qobjecthelper.cpp +src/serializer.cpp +src/qobjecthelper.h +src/serializer.h +src/serializerrunnable.cpp +src/serializerrunnable.h +tests/cmdline_tester/cmdline_tester.cpp +tests/cmdline_tester/cmdlineparser.cpp +tests/cmdline_tester/cmdlineparser.h +tests/parser/testparser.cpp +tests/qobjecthelper/person.h +tests/qobjecthelper/testqobjecthelper.cpp +tests/serializer/testserializer.cpp + + +The following files are licensed under GPL V2 with Bison Exception: +-------------------------------------------------------------------- +/src/json_parser.cc +/src/stack.hh +/src/location.hh +/src/position.hh +/src/json_parser.hh + + +Copyrights: +---------- +Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +Copyright (C) 2009 Flavio Castelli 2009 Frank Osterfeld +Copyright (C) 2008 Flavio Castelli +Copyright (C) 2009 Till Adam +Copyright (C) 2009 Michael Leupold +Copyright (C) 2009 Flavio Castelli +Copyright (C) 2009 Frank Osterfeld +Copyright (C) 2009 Pino Toscano +Copyright (C) 2010 Flavio Castelli + + +GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999: +------------------------------------------------------------- + +Checkout COPYING.lib + + +GPL V2 with Bison Exception: +---------------------------- +Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. + +As a special exception, you may create a larger work that contains +part or all of the Bison parser skeleton and distribute that work +under terms of your choice, so long as that work isn't itself a +parser generator using the skeleton or a modified version thereof +as a parser skeleton. Alternatively, if you modify or redistribute +the parser skeleton itself, you may (at your option) remove this +special exception, which will cause the skeleton and the resulting +Bison output files to be licensed under the GNU General Public +License without this special exception. + +This special exception was added by the Free Software Foundation in +version 2.2 of Bison. + diff --git a/README.md b/README.md new file mode 100644 index 000000000..80ff3e9a2 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# QJson +JSON (JavaScript Object Notation) is a lightweight data-interchange format. +It can represents integer, real number, string, an ordered sequence of value, and a collection of name/value pairs. + +QJson is a qt-based library that maps JSON data to QVariant objects. +JSON arrays will be mapped to QVariantList instances, while JSON's objects will be mapped to QVariantMap. + +# Install + +QJson requires: + - Qt 4.0 or greater + - cmake 2.6 or greater + +Some possible cmake options: + - `-DCMAKE_BUILD_TYPE=DEBUG`: enables some debug output (other than making + easier to debug the code) + - `-DQJSON_BUILD_TESTS=yes` or `-DKDE4_BUILD_TESTS=yes`: builds the unit tests + - `-DCMAKE_INSTALL_PREFIX=${HOME}/testinstall`: install qjson in a custom directory + - `-DCMAKE_INCLUDE_PATH=${HOME}/testinstall/include`: include a custom include directory + - `-DCMAKE_LIBRARY_PATH=${HOME}/testinstall/lib`: include a custom library directory + - `-DLIB_DESTINATION=lib64`: if you have a 64 bit system with separate + libraries for 64 bit libraries + - `-DQJSON_VERBOSE_DEBUG_OUTPUT:BOOL=ON`: more debugging statements are + generated by the parser. It's useful only if you are trying to fix + the bison grammar. + +For Unix/Linux/Mac: + + mkdir build + cd build + cmake -DCMAKE_INSTALL_PREFIX=_preferred_path_ .. + make + make install + /sbin/ldconfig #if necessary + +# License + This library is licensed under the Lesser GNU General Public License version 2.1. + See the COPYING.lib file for more information. + +# Resources + +* [Website](http://qjson.sourceforge.net/) +* [Mailing List](https://lists.sourceforge.net/mailman/listinfo/qjson-devel) +* Project Lead/Maintainer (2008-current): [Flavio Castelli](mailto:flavio@castelli.name). diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 000000000..776e9c965 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,17 @@ +IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF(NOT "${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF(NOT "${rm_retval}" STREQUAL 0) +ENDFOREACH(file) diff --git a/doc/Doxyfile b/doc/Doxyfile new file mode 100644 index 000000000..85c630c2b --- /dev/null +++ b/doc/Doxyfile @@ -0,0 +1,1851 @@ +# Doxyfile 1.8.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = QJson + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 0.8.1 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = the easiest way to manage JSON objects with Qt + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = ./ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = YES + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ./qjson.dox \ + ../src + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.vhd \ + *.vhdl \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.PY \ + *.F90 \ + *.F \ + *.VHD \ + *.VHDL + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = ./header.html + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = ./footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 1000 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/doc/footer.html b/doc/footer.html new file mode 100644 index 000000000..fe2e2a770 --- /dev/null +++ b/doc/footer.html @@ -0,0 +1,32 @@ +
+ + + + + + + +
+ + SourceForge Logo + + hosts this site. + + + Send comments to:
+ QJson Developers +
+ + + + + + diff --git a/doc/header.html b/doc/header.html new file mode 100644 index 000000000..d0ca99369 --- /dev/null +++ b/doc/header.html @@ -0,0 +1,13 @@ + + + +QJson - a Qt based library for mapping JSON data to QVariant objects + + + + + + + QJson home page + +
diff --git a/doc/qjson.dox b/doc/qjson.dox new file mode 100644 index 000000000..ea84e7554 --- /dev/null +++ b/doc/qjson.dox @@ -0,0 +1,87 @@ +/** +\mainpage +\section _intro Introduction + +JSON (JavaScript Object Notation) + is a lightweight data-interchange format. +It can represents integer, real number, string, an ordered sequence of value, and +a collection of name/value pairs. + +QJson is a qt-based library that maps JSON data to QVariant objects. + +JSON arrays will be mapped to QVariantList instances, while JSON's objects will +be mapped to QVariantMap. + +\section _usage Usage +Converting JSON's data to QVariant instance is really simple: +\code +// create a JSonDriver instance +QJson::Parser parser; + +bool ok; + +// json is a QString containing the data to convert +QVariant result = parser.parse (json, &ok); +\endcode + +Suppose you're going to convert this JSON data: +\verbatim +{ + "encoding" : "UTF-8", + "plug-ins" : [ + "python", + "c++", + "ruby" + ], + "indent" : { "length" : 3, "use_space" : true } +} +\endverbatim + +The following code would convert the JSON data and parse it: +\code +QJson::Parser parser; +bool ok; + +QVariantMap result = parser.parse (json, &ok).toMap(); +if (!ok) { + qFatal("An error occured during parsing"); + exit (1); +} + +qDebug() << "encoding:" << result["encoding"].toString(); +qDebug() << "plugins:"; + +foreach (QVariant plugin, result["plug-ins"].toList()) { + qDebug() << "\t-" << plugin.toString(); +} + +QVariantMap nestedMap = result["indent"].toMap(); +qDebug() << "length:" << nestedMap["length"].toInt(); +qDebug() << "use_space:" << nestedMap["use_space"].toBool(); +\endcode +The output would be: +\verbatim +encoding: "UTF-8" +plugins: + - "python" + - "c++" + - "ruby" +length: 3 +use_space: true +\endverbatim + +The QJson::QObjectHelper class permits to serialize QObject instances into JSON. QJson::QObjectHelper also allows to +initialize a QObject using the values stored inside of a JSON object. + +\section _build Build instructions +QJson build system is based on cmake. Download QJson sources, extract them, move inside the sources directory and then: +\code +mkdir build +cd build +cmake .. +make +sudo make install +\endcode + +\author Flavio Castelli +*/ diff --git a/include/QJson/Parser b/include/QJson/Parser new file mode 100644 index 000000000..68f06e432 --- /dev/null +++ b/include/QJson/Parser @@ -0,0 +1 @@ +#include "../../src/parser.h" diff --git a/include/QJson/QObjectHelper b/include/QJson/QObjectHelper new file mode 100644 index 000000000..1b72c2e0a --- /dev/null +++ b/include/QJson/QObjectHelper @@ -0,0 +1 @@ +#include "../../src/qobjecthelper.h" diff --git a/include/QJson/Serializer b/include/QJson/Serializer new file mode 100644 index 000000000..2b7fe7a9e --- /dev/null +++ b/include/QJson/Serializer @@ -0,0 +1 @@ +#include "../../src/serializer.h" diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 000000000..04ec50a55 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,3 @@ +moc_* +*.o +Makefile diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..d2f2ebe66 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,61 @@ +# add_custom_command (OUTPUT ${qjson_SOURCE_DIR}/lib/json_parser.cc +# PRE_BUILD +# COMMAND bison -t -o json_parser.cc -d json_parser.yy +# DEPENDS json_parser.yy +# WORKING_DIRECTORY ${qjson_SOURCE_DIR}/lib/ +# ) + +# To regenerate json_scanner.cc use: +# flex json_scanner.yy + +set(qjson_MOC_HDRS + parserrunnable.h + serializerrunnable.h +) + +IF (NOT Qt5Core_FOUND) + qt4_wrap_cpp(qjson_MOC_SRCS ${qjson_MOC_HDRS}) +ENDIF() + +set (qjson_SRCS parser.cpp qobjecthelper.cpp json_scanner.cpp json_parser.cc parserrunnable.cpp serializer.cpp serializerrunnable.cpp) +set (qjson_HEADERS parser.h parserrunnable.h qobjecthelper.h serializer.h serializerrunnable.h qjson_export.h) + +# Required to use the intree copy of FlexLexer.h +INCLUDE_DIRECTORIES(.) + +add_library (qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS} ${qjson_HEADERS}) +IF (Qt5Core_FOUND) + target_link_libraries( qjson ${Qt5Core_LIBRARIES}) +ELSE() + target_link_libraries( qjson ${QT_LIBRARIES}) +ENDIF() + +if(NOT android) + set_target_properties(qjson PROPERTIES + VERSION ${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSION}.${QJSON_LIB_PATCH_VERSION} + SOVERSION ${QJSON_LIB_MAJOR_VERSION} + ) +endif() +set_target_properties(qjson PROPERTIES + DEFINE_SYMBOL QJSON_MAKEDLL + PUBLIC_HEADER "${qjson_HEADERS}" + FRAMEWORK ${OSX_FRAMEWORK} + ) + +INSTALL(TARGETS qjson EXPORT qjson-export + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} + FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} + PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/qjson +) + +if(MSVC) + get_target_property(LOCATION qjson LOCATION_DEBUG) + string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") + install(FILES ${LOCATION} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin CONFIGURATIONS Debug) + + get_target_property(LOCATION qjson LOCATION_RELWITHDEBINFO) + string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") + install(FILES ${LOCATION} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin CONFIGURATIONS RelWithDebInfo) +endif(MSVC) diff --git a/src/FlexLexer.h b/src/FlexLexer.h new file mode 100644 index 000000000..bad4ce03f --- /dev/null +++ b/src/FlexLexer.h @@ -0,0 +1,206 @@ +// -*-C++-*- +// FlexLexer.h -- define interfaces for lexical analyzer classes generated +// by flex + +// Copyright (c) 1993 The Regents of the University of California. +// All rights reserved. +// +// This code is derived from software contributed to Berkeley by +// Kent Williams and Tom Epperly. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: + +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. + +// Neither the name of the University nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE. + +// This file defines FlexLexer, an abstract class which specifies the +// external interface provided to flex C++ lexer objects, and yyFlexLexer, +// which defines a particular lexer class. +// +// If you want to create multiple lexer classes, you use the -P flag +// to rename each yyFlexLexer to some other xxFlexLexer. You then +// include in your other sources once per lexer class: +// +// #undef yyFlexLexer +// #define yyFlexLexer xxFlexLexer +// #include +// +// #undef yyFlexLexer +// #define yyFlexLexer zzFlexLexer +// #include +// ... + +#ifndef __FLEX_LEXER_H +// Never included before - need to define base class. +#define __FLEX_LEXER_H + +#include +# ifndef FLEX_STD +# define FLEX_STD std:: +# endif + +extern "C++" { + +struct yy_buffer_state; +typedef int yy_state_type; + +class FlexLexer { +public: + virtual ~FlexLexer() { } + + const char* YYText() const { return yytext; } + int YYLeng() const { return yyleng; } + + virtual void + yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; + virtual struct yy_buffer_state* + yy_create_buffer( FLEX_STD istream* s, int size ) = 0; + virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; + virtual void yyrestart( FLEX_STD istream* s ) = 0; + + virtual int yylex() = 0; + + // Call yylex with new input/output sources. + int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + // Switch to new input/output streams. A nil stream pointer + // indicates "keep the current one". + virtual void switch_streams( FLEX_STD istream* new_in = 0, + FLEX_STD ostream* new_out = 0 ) = 0; + + int lineno() const { return yylineno; } + + int debug() const { return yy_flex_debug; } + void set_debug( int flag ) { yy_flex_debug = flag; } + +protected: + char* yytext; + int yyleng; + int yylineno; // only maintained if you use %option yylineno + int yy_flex_debug; // only has effect with -d or "%option debug" +}; + +} +#endif // FLEXLEXER_H + +#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) +// Either this is the first time through (yyFlexLexerOnce not defined), +// or this is a repeated include to define a different flavor of +// yyFlexLexer, as discussed in the flex manual. +#define yyFlexLexerOnce + +extern "C++" { + +class yyFlexLexer : public FlexLexer { +public: + // arg_yyin and arg_yyout default to the cin and cout, but we + // only make that assignment when initializing in yylex(). + yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); + + virtual ~yyFlexLexer(); + + void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); + struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); + void yy_delete_buffer( struct yy_buffer_state* b ); + void yyrestart( FLEX_STD istream* s ); + + void yypush_buffer_state( struct yy_buffer_state* new_buffer ); + void yypop_buffer_state(); + + virtual int yylex(); + virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ); + virtual int yywrap(); + +protected: + virtual int LexerInput( char* buf, int max_size ); + virtual void LexerOutput( const char* buf, int size ); + virtual void LexerError( const char* msg ); + + void yyunput( int c, char* buf_ptr ); + int yyinput(); + + void yy_load_buffer_state(); + void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); + void yy_flush_buffer( struct yy_buffer_state* b ); + + int yy_start_stack_ptr; + int yy_start_stack_depth; + int* yy_start_stack; + + void yy_push_state( int new_state ); + void yy_pop_state(); + int yy_top_state(); + + yy_state_type yy_get_previous_state(); + yy_state_type yy_try_NUL_trans( yy_state_type current_state ); + int yy_get_next_buffer(); + + FLEX_STD istream* yyin; // input source for default LexerInput + FLEX_STD ostream* yyout; // output sink for default LexerOutput + + // yy_hold_char holds the character lost when yytext is formed. + char yy_hold_char; + + // Number of characters read into yy_ch_buf. + int yy_n_chars; + + // Points to current character in buffer. + char* yy_c_buf_p; + + int yy_init; // whether we need to initialize + int yy_start; // start state number + + // Flag which is used to allow yywrap()'s to do buffer switches + // instead of setting up a fresh yyin. A bit of a hack ... + int yy_did_buffer_switch_on_eof; + + + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ + void yyensure_buffer_stack(void); + + // The following are not always needed, but may be depending + // on use of certain flex features (like REJECT or yymore()). + + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + yy_state_type* yy_state_buf; + yy_state_type* yy_state_ptr; + + char* yy_full_match; + int* yy_full_state; + int yy_full_lp; + + int yy_lp; + int yy_looking_for_trail_begin; + + int yy_more_flag; + int yy_more_len; + int yy_more_offset; + int yy_prev_more_offset; +}; + +} + +#endif // yyFlexLexer || ! yyFlexLexerOnce + diff --git a/src/json_parser.cc b/src/json_parser.cc new file mode 100644 index 000000000..84fdfac73 --- /dev/null +++ b/src/json_parser.cc @@ -0,0 +1,1103 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Skeleton implementation for Bison LALR(1) parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* First part of user declarations. */ + +/* Line 279 of lalr1.cc */ +#line 38 "json_parser.cc" + + +#include "json_parser.hh" + +/* User implementation prologue. */ + +/* Line 285 of lalr1.cc */ +#line 46 "json_parser.cc" + + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* FIXME: INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ false) +# endif + + +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) ((void) (e)) + +/* Enable debugging if requested. */ +#if YYDEBUG + +/* A pseudo ostream that takes yydebug_ into account. */ +# define YYCDEBUG if (yydebug_) (*yycdebug_) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug_) \ + { \ + *yycdebug_ << Title << ' '; \ + yy_symbol_print_ ((Type), (Value), (Location)); \ + *yycdebug_ << std::endl; \ + } \ +} while (false) + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug_) \ + yy_reduce_print_ (Rule); \ +} while (false) + +# define YY_STACK_PRINT() \ +do { \ + if (yydebug_) \ + yystack_print_ (); \ +} while (false) + +#else /* !YYDEBUG */ + +# define YYCDEBUG if (false) std::cerr +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type) +# define YY_REDUCE_PRINT(Rule) static_cast(0) +# define YY_STACK_PRINT() static_cast(0) + +#endif /* !YYDEBUG */ + +#define yyerrok (yyerrstatus_ = 0) +#define yyclearin (yychar = yyempty_) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYRECOVERING() (!!yyerrstatus_) + + +namespace yy { +/* Line 353 of lalr1.cc */ +#line 141 "json_parser.cc" + + /* Return YYSTR after stripping away unnecessary quotes and + backslashes, so that it's suitable for yyerror. The heuristic is + that double-quoting is unnecessary unless the string contains an + apostrophe, a comma, or backslash (other than backslash-backslash). + YYSTR is taken from yytname. */ + std::string + json_parser::yytnamerr_ (const char *yystr) + { + if (*yystr == '"') + { + std::string yyr = ""; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + yyr += *yyp; + break; + + case '"': + return yyr; + } + do_not_strip_quotes: ; + } + + return yystr; + } + + + /// Build a parser object. + json_parser::json_parser (QJson::ParserPrivate* driver_yyarg) + : +#if YYDEBUG + yydebug_ (false), + yycdebug_ (&std::cerr), +#endif + driver (driver_yyarg) + { + } + + json_parser::~json_parser () + { + } + +#if YYDEBUG + /*--------------------------------. + | Print this symbol on YYOUTPUT. | + `--------------------------------*/ + + inline void + json_parser::yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yyvaluep); + std::ostream& yyo = debug_stream (); + std::ostream& yyoutput = yyo; + YYUSE (yyoutput); + switch (yytype) + { + default: + break; + } + } + + + void + json_parser::yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") + << ' ' << yytname_[yytype] << " (" + << *yylocationp << ": "; + yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); + *yycdebug_ << ')'; + } +#endif + + void + json_parser::yydestruct_ (const char* yymsg, + int yytype, semantic_type* yyvaluep, location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yymsg); + YYUSE (yyvaluep); + + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } + } + + void + json_parser::yypop_ (unsigned int n) + { + yystate_stack_.pop (n); + yysemantic_stack_.pop (n); + yylocation_stack_.pop (n); + } + +#if YYDEBUG + std::ostream& + json_parser::debug_stream () const + { + return *yycdebug_; + } + + void + json_parser::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } + + + json_parser::debug_level_type + json_parser::debug_level () const + { + return yydebug_; + } + + void + json_parser::set_debug_level (debug_level_type l) + { + yydebug_ = l; + } +#endif + + inline bool + json_parser::yy_pact_value_is_default_ (int yyvalue) + { + return yyvalue == yypact_ninf_; + } + + inline bool + json_parser::yy_table_value_is_error_ (int yyvalue) + { + return yyvalue == yytable_ninf_; + } + + int + json_parser::parse () + { + /// Lookahead and lookahead in internal form. + int yychar = yyempty_; + int yytoken = 0; + + // State. + int yyn; + int yylen = 0; + int yystate = 0; + + // Error handling. + int yynerrs_ = 0; + int yyerrstatus_ = 0; + + /// Semantic value of the lookahead. + static semantic_type yyval_default; + semantic_type yylval = yyval_default; + /// Location of the lookahead. + location_type yylloc; + /// The locations where the error started and ended. + location_type yyerror_range[3]; + + /// $$. + semantic_type yyval; + /// @$. + location_type yyloc; + + int yyresult; + + // FIXME: This shoud be completely indented. It is not yet to + // avoid gratuitous conflicts when merging into the master branch. + try + { + YYCDEBUG << "Starting parse" << std::endl; + + + /* Initialize the stacks. The initial state will be pushed in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystate_stack_ = state_stack_type (0); + yysemantic_stack_ = semantic_stack_type (0); + yylocation_stack_ = location_stack_type (0); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* New state. */ + yynewstate: + yystate_stack_.push (yystate); + YYCDEBUG << "Entering state " << yystate << std::endl; + + /* Accept? */ + if (yystate == yyfinal_) + goto yyacceptlab; + + goto yybackup; + + /* Backup. */ + yybackup: + + /* Try to take a decision without lookahead. */ + yyn = yypact_[yystate]; + if (yy_pact_value_is_default_ (yyn)) + goto yydefault; + + /* Read a lookahead token. */ + if (yychar == yyempty_) + { + YYCDEBUG << "Reading a token: "; + yychar = yylex (&yylval, &yylloc, driver); + } + + /* Convert token to internal form. */ + if (yychar <= yyeof_) + { + yychar = yytoken = yyeof_; + YYCDEBUG << "Now at end of input." << std::endl; + } + else + { + yytoken = yytranslate_ (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) + goto yydefault; + + /* Reduce or error. */ + yyn = yytable_[yyn]; + if (yyn <= 0) + { + if (yy_table_value_is_error_ (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the token being shifted. */ + yychar = yyempty_; + + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus_) + --yyerrstatus_; + + yystate = yyn; + goto yynewstate; + + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + /*-----------------------------. + | yyreduce -- Do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. */ + if (yylen) + yyval = yysemantic_stack_[yylen - 1]; + else + yyval = yysemantic_stack_[0]; + + // Compute the default @$. + { + slice slice (yylocation_stack_, yylen); + YYLLOC_DEFAULT (yyloc, slice, yylen); + } + + // Perform the reduction. + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +/* Line 670 of lalr1.cc */ +#line 82 "json_parser.yy" + { + driver->m_result = (yysemantic_stack_[(1) - (1)]); + qjsonDebug() << "json_parser - parsing finished"; + } + break; + + case 3: +/* Line 670 of lalr1.cc */ +#line 87 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); } + break; + + case 4: +/* Line 670 of lalr1.cc */ +#line 89 "json_parser.yy" + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << (yyloc).begin.line << "Column" << (yyloc).begin.column; + YYABORT; + } + break; + + case 6: +/* Line 670 of lalr1.cc */ +#line 96 "json_parser.yy" + { + (yyval) = QVariant(QVariantMap()); + } + break; + + case 7: +/* Line 670 of lalr1.cc */ +#line 99 "json_parser.yy" + { + QVariantMap* map = (yysemantic_stack_[(3) - (2)]).value(); + (yyval) = QVariant(*map); + delete map; + } + break; + + case 8: +/* Line 670 of lalr1.cc */ +#line 105 "json_parser.yy" + { + QVariantMap* pair = new QVariantMap(); + pair->insert((yysemantic_stack_[(3) - (1)]).toString(), (yysemantic_stack_[(3) - (3)])); + (yyval).setValue(pair); + } + break; + + case 9: +/* Line 670 of lalr1.cc */ +#line 110 "json_parser.yy" + { + (yyval).value()->insert((yysemantic_stack_[(5) - (3)]).toString(), (yysemantic_stack_[(5) - (5)])); + } + break; + + case 10: +/* Line 670 of lalr1.cc */ +#line 114 "json_parser.yy" + { + (yyval) = QVariant(QVariantList()); + } + break; + + case 11: +/* Line 670 of lalr1.cc */ +#line 117 "json_parser.yy" + { + QVector* list = (yysemantic_stack_[(3) - (2)]).value* >(); + (yyval) = QVariant(list->toList()); + delete list; + } + break; + + case 12: +/* Line 670 of lalr1.cc */ +#line 123 "json_parser.yy" + { + QVector* list = new QVector(1); + list->replace(0, (yysemantic_stack_[(1) - (1)])); + (yyval).setValue(list); + } + break; + + case 13: +/* Line 670 of lalr1.cc */ +#line 128 "json_parser.yy" + { + (yyval).value* >()->append((yysemantic_stack_[(3) - (3)])); + } + break; + + +/* Line 670 of lalr1.cc */ +#line 549 "json_parser.cc" + default: + break; + } + + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action + invokes YYABORT, YYACCEPT, or YYERROR immediately after altering + yychar. In the case of YYABORT or YYACCEPT, an incorrect + destructor might then be invoked immediately. In the case of + YYERROR, subsequent parser actions might lead to an incorrect + destructor call or verbose syntax error message before the + lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); + + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + + yysemantic_stack_.push (yyval); + yylocation_stack_.push (yyloc); + + /* Shift the result of the reduction. */ + yyn = yyr1_[yyn]; + yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; + if (0 <= yystate && yystate <= yylast_ + && yycheck_[yystate] == yystate_stack_[0]) + yystate = yytable_[yystate]; + else + yystate = yydefgoto_[yyn - yyntokens_]; + goto yynewstate; + + /*------------------------------------. + | yyerrlab -- here on detecting error | + `------------------------------------*/ + yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yytranslate_ (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus_) + { + ++yynerrs_; + if (yychar == yyempty_) + yytoken = yyempty_; + error (yylloc, yysyntax_error_ (yystate, yytoken)); + } + + yyerror_range[1] = yylloc; + if (yyerrstatus_ == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + if (yychar <= yyeof_) + { + /* Return failure if at end of input. */ + if (yychar == yyeof_) + YYABORT; + } + else + { + yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = yyempty_; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (false) + goto yyerrorlab; + + yyerror_range[1] = yylocation_stack_[yylen - 1]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + yypop_ (yylen); + yylen = 0; + yystate = yystate_stack_[0]; + goto yyerrlab1; + + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact_[yystate]; + if (!yy_pact_value_is_default_ (yyn)) + { + yyn += yyterror_; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yystate_stack_.height () == 1) + YYABORT; + + yyerror_range[1] = yylocation_stack_[0]; + yydestruct_ ("Error: popping", + yystos_[yystate], + &yysemantic_stack_[0], &yylocation_stack_[0]); + yypop_ (); + yystate = yystate_stack_[0]; + YY_STACK_PRINT (); + } + + yyerror_range[2] = yylloc; + // Using YYLLOC is tempting, but would change the location of + // the lookahead. YYLOC is available though. + YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yyloc); + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], + &yysemantic_stack_[0], &yylocation_stack_[0]); + + yystate = yyn; + goto yynewstate; + + /* Accept. */ + yyacceptlab: + yyresult = 0; + goto yyreturn; + + /* Abort. */ + yyabortlab: + yyresult = 1; + goto yyreturn; + + yyreturn: + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See comments + at user semantic actions for why this is necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, + &yylloc); + } + + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + yypop_ (yylen); + while (1 < yystate_stack_.height ()) + { + yydestruct_ ("Cleanup: popping", + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + + return yyresult; + } + catch (...) + { + YYCDEBUG << "Exception caught: cleaning lookahead and stack" + << std::endl; + // Do not try to display the values of the reclaimed symbols, + // as their printer might throw an exception. + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See + comments at user semantic actions for why this is + necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc); + } + + while (1 < yystate_stack_.height ()) + { + yydestruct_ (YY_NULL, + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + throw; + } + } + + // Generate an error message. + std::string + json_parser::yysyntax_error_ (int yystate, int yytoken) + { + std::string yyres; + // Number of reported tokens (one for the "unexpected", one per + // "expected"). + size_t yycount = 0; + // Its maximum. + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + // Arguments of yyformat. + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yytoken) is + if this state is a consistent state with a default action. + Thus, detecting the absence of a lookahead is sufficient to + determine that there is no unexpected or expected token to + report. In that case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is + a consistent state with a default action. There might have + been a previous inconsistent state, consistent state with a + non-default action, or user semantic action that manipulated + yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state + merging (from LALR or IELR) and default reductions corrupt the + expected token list. However, the list is correct for + canonical LR with one exception: it will still contain any + token that will not be accepted due to an error action in a + later state. + */ + if (yytoken != yyempty_) + { + yyarg[yycount++] = yytname_[yytoken]; + int yyn = yypact_[yystate]; + if (!yy_pact_value_is_default_ (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + for (int yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ + && !yy_table_value_is_error_ (yytable_[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + break; + } + else + yyarg[yycount++] = yytname_[yyx]; + } + } + } + + char const* yyformat = YY_NULL; + switch (yycount) + { +#define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +#undef YYCASE_ + } + + // Argument number. + size_t yyi = 0; + for (char const* yyp = yyformat; *yyp; ++yyp) + if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) + { + yyres += yytnamerr_ (yyarg[yyi++]); + ++yyp; + } + else + yyres += *yyp; + return yyres; + } + + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ + const signed char json_parser::yypact_ninf_ = -5; + const signed char + json_parser::yypact_[] = + { + 1, -5, -5, 3, 18, -5, -5, -5, -5, -5, + 8, -5, -5, -5, -5, -5, 2, 11, -5, -3, + -5, -5, 29, -5, 4, -5, 29, -5, 13, -5, + 29, -5 + }; + + /* YYDEFACT[S] -- default reduction number in state S. Performed when + YYTABLE doesn't specify something else to do. Zero means the + default is an error. */ + const unsigned char + json_parser::yydefact_[] = + { + 0, 5, 4, 0, 0, 15, 16, 17, 18, 14, + 0, 2, 19, 20, 3, 6, 0, 0, 10, 0, + 12, 1, 0, 7, 0, 11, 0, 8, 0, 13, + 0, 9 + }; + + /* YYPGOTO[NTERM-NUM]. */ + const signed char + json_parser::yypgoto_[] = + { + -5, -5, -5, -5, -5, -5, -5, -4 + }; + + /* YYDEFGOTO[NTERM-NUM]. */ + const signed char + json_parser::yydefgoto_[] = + { + -1, 10, 11, 12, 17, 13, 19, 14 + }; + + /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF_, syntax error. */ + const signed char json_parser::yytable_ninf_ = -1; + const unsigned char + json_parser::yytable_[] = + { + 20, 1, 2, 25, 3, 26, 4, 15, 21, 22, + 5, 6, 7, 8, 9, 23, 16, 28, 27, 24, + 30, 3, 29, 4, 18, 0, 31, 5, 6, 7, + 8, 9, 3, 0, 4, 0, 0, 0, 5, 6, + 7, 8, 9 + }; + + /* YYCHECK. */ + const signed char + json_parser::yycheck_[] = + { + 4, 0, 1, 6, 3, 8, 5, 4, 0, 7, + 9, 10, 11, 12, 13, 4, 13, 13, 22, 8, + 7, 3, 26, 5, 6, -1, 30, 9, 10, 11, + 12, 13, 3, -1, 5, -1, -1, -1, 9, 10, + 11, 12, 13 + }; + + /* STOS_[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ + const unsigned char + json_parser::yystos_[] = + { + 0, 0, 1, 3, 5, 9, 10, 11, 12, 13, + 16, 17, 18, 20, 22, 4, 13, 19, 6, 21, + 22, 0, 7, 4, 8, 6, 8, 22, 13, 22, + 7, 22 + }; + +#if YYDEBUG + /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding + to YYLEX-NUM. */ + const unsigned short int + json_parser::yytoken_number_[] = + { + 0, 256, 257, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12 + }; +#endif + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ + const unsigned char + json_parser::yyr1_[] = + { + 0, 15, 16, 17, 17, 17, 18, 18, 19, 19, + 20, 20, 21, 21, 22, 22, 22, 22, 22, 22, + 22 + }; + + /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ + const unsigned char + json_parser::yyr2_[] = + { + 0, 2, 1, 1, 1, 1, 2, 3, 3, 5, + 2, 3, 1, 3, 1, 1, 1, 1, 1, 1, + 1 + }; + + + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at \a yyntokens_, nonterminals. */ + const char* + const json_parser::yytname_[] = + { + "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"", + "\"]\"", "\":\"", "\",\"", "\"number\"", "\"true\"", "\"false\"", + "\"null\"", "\"string\"", "\"invalid\"", "$accept", "start", "data", + "object", "members", "array", "values", "value", YY_NULL + }; + +#if YYDEBUG + /* YYRHS -- A `-1'-separated list of the rules' RHS. */ + const json_parser::rhs_number_type + json_parser::yyrhs_[] = + { + 16, 0, -1, 17, -1, 22, -1, 1, -1, 0, + -1, 3, 4, -1, 3, 19, 4, -1, 13, 7, + 22, -1, 19, 8, 13, 7, 22, -1, 5, 6, + -1, 5, 21, 6, -1, 22, -1, 21, 8, 22, + -1, 13, -1, 9, -1, 10, -1, 11, -1, 12, + -1, 18, -1, 20, -1 + }; + + /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ + const unsigned char + json_parser::yyprhs_[] = + { + 0, 0, 3, 5, 7, 9, 11, 14, 18, 22, + 28, 31, 35, 37, 41, 43, 45, 47, 49, 51, + 53 + }; + + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ + const unsigned char + json_parser::yyrline_[] = + { + 0, 82, 82, 87, 88, 94, 96, 99, 105, 110, + 114, 117, 123, 128, 132, 133, 134, 135, 136, 137, + 138 + }; + + // Print the state stack on the debug stream. + void + json_parser::yystack_print_ () + { + *yycdebug_ << "Stack now"; + for (state_stack_type::const_iterator i = yystate_stack_.begin (); + i != yystate_stack_.end (); ++i) + *yycdebug_ << ' ' << *i; + *yycdebug_ << std::endl; + } + + // Report on the debug stream that the rule \a yyrule is going to be reduced. + void + json_parser::yy_reduce_print_ (int yyrule) + { + unsigned int yylno = yyrline_[yyrule]; + int yynrhs = yyr2_[yyrule]; + /* Print the symbols being reduced, and their result. */ + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 + << " (line " << yylno << "):" << std::endl; + /* The symbols being reduced. */ + for (int yyi = 0; yyi < yynrhs; yyi++) + YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", + yyrhs_[yyprhs_[yyrule] + yyi], + &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), + &(yylocation_stack_[(yynrhs) - (yyi + 1)])); + } +#endif // YYDEBUG + + /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ + json_parser::token_number_type + json_parser::yytranslate_ (int t) + { + static + const token_number_type + translate_table[] = + { + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2 + }; + if ((unsigned int) t <= yyuser_token_number_max_) + return translate_table[t]; + else + return yyundef_token_; + } + + const int json_parser::yyeof_ = 0; + const int json_parser::yylast_ = 42; + const int json_parser::yynnts_ = 8; + const int json_parser::yyempty_ = -2; + const int json_parser::yyfinal_ = 21; + const int json_parser::yyterror_ = 1; + const int json_parser::yyerrcode_ = 256; + const int json_parser::yyntokens_ = 15; + + const unsigned int json_parser::yyuser_token_number_max_ = 257; + const json_parser::token_number_type json_parser::yyundef_token_ = 2; + + +} // yy +/* Line 1141 of lalr1.cc */ +#line 1079 "json_parser.cc" +/* Line 1142 of lalr1.cc */ +#line 140 "json_parser.yy" + + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} diff --git a/src/json_parser.hh b/src/json_parser.hh new file mode 100644 index 000000000..25e00fa1b --- /dev/null +++ b/src/json_parser.hh @@ -0,0 +1,300 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Skeleton interface for Bison LALR(1) parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file json_parser.hh + ** Define the yy::parser class. + */ + +/* C++ LALR(1) parser skeleton written by Akim Demaille. */ + +#ifndef YY_YY_JSON_PARSER_HH_INCLUDED +# define YY_YY_JSON_PARSER_HH_INCLUDED + +/* "%code requires" blocks. */ +/* Line 33 of lalr1.cc */ +#line 26 "json_parser.yy" + + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 + + Q_DECLARE_METATYPE(QVector*) + Q_DECLARE_METATYPE(QVariantMap*) + + +/* Line 33 of lalr1.cc */ +#line 72 "json_parser.hh" + + +#include +#include +#include "stack.hh" +#include "location.hh" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif + + +namespace yy { +/* Line 33 of lalr1.cc */ +#line 88 "json_parser.hh" + + /// A Bison parser. + class json_parser + { + public: + /// Symbol semantic values. +#ifndef YYSTYPE + typedef int semantic_type; +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef location location_type; + /// Tokens. + struct token + { + /* Tokens. */ + enum yytokentype { + END = 0, + CURLY_BRACKET_OPEN = 1, + CURLY_BRACKET_CLOSE = 2, + SQUARE_BRACKET_OPEN = 3, + SQUARE_BRACKET_CLOSE = 4, + COLON = 5, + COMMA = 6, + NUMBER = 7, + TRUE_VAL = 8, + FALSE_VAL = 9, + NULL_VAL = 10, + STRING = 11, + INVALID = 12 + }; + + }; + /// Token type. + typedef token::yytokentype token_type; + + /// Build a parser object. + json_parser (QJson::ParserPrivate* driver_yyarg); + virtual ~json_parser (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + +#if YYDEBUG + /// The current debugging stream. + std::ostream& debug_stream () const; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); +#endif + + private: + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + + /// Generate an error message. + /// \param state the state where the error occurred. + /// \param tok the lookahead token. + virtual std::string yysyntax_error_ (int yystate, int tok); + +#if YYDEBUG + /// \brief Report a symbol value on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); + /// \brief Report a symbol on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); +#endif + + + /// State numbers. + typedef int state_type; + /// State stack type. + typedef stack state_stack_type; + /// Semantic value stack type. + typedef stack semantic_stack_type; + /// location stack type. + typedef stack location_stack_type; + + /// The state stack. + state_stack_type yystate_stack_; + /// The semantic value stack. + semantic_stack_type yysemantic_stack_; + /// The location stack. + location_stack_type yylocation_stack_; + + /// Whether the given \c yypact_ value indicates a defaulted state. + /// \param yyvalue the value to check + static bool yy_pact_value_is_default_ (int yyvalue); + + /// Whether the given \c yytable_ value indicates a syntax error. + /// \param yyvalue the value to check + static bool yy_table_value_is_error_ (int yyvalue); + + /// Internal symbol numbers. + typedef unsigned char token_number_type; + /* Tables. */ + /// For a state, the index in \a yytable_ of its portion. + static const signed char yypact_[]; + static const signed char yypact_ninf_; + + /// For a state, default reduction number. + /// Unless\a yytable_ specifies something else to do. + /// Zero means the default is an error. + static const unsigned char yydefact_[]; + + static const signed char yypgoto_[]; + static const signed char yydefgoto_[]; + + /// What to do in a state. + /// \a yytable_[yypact_[s]]: what to do in state \a s. + /// - if positive, shift that token. + /// - if negative, reduce the rule which number is the opposite. + /// - if zero, do what YYDEFACT says. + static const unsigned char yytable_[]; + static const signed char yytable_ninf_; + + static const signed char yycheck_[]; + + /// For a state, its accessing symbol. + static const unsigned char yystos_[]; + + /// For a rule, its LHS. + static const unsigned char yyr1_[]; + /// For a rule, its RHS length. + static const unsigned char yyr2_[]; + + /// Convert the symbol name \a n to a form suitable for a diagnostic. + static std::string yytnamerr_ (const char *n); + + + /// For a symbol, its name in clear. + static const char* const yytname_[]; +#if YYDEBUG + /// A type to store symbol numbers and -1. + typedef signed char rhs_number_type; + /// A `-1'-separated list of the rules' RHS. + static const rhs_number_type yyrhs_[]; + /// For each rule, the index of the first RHS symbol in \a yyrhs_. + static const unsigned char yyprhs_[]; + /// For each rule, its source line number. + static const unsigned char yyrline_[]; + /// For each scanner token number, its symbol number. + static const unsigned short int yytoken_number_[]; + /// Report on the debug stream that the rule \a r is going to be reduced. + virtual void yy_reduce_print_ (int r); + /// Print the state stack on the debug stream. + virtual void yystack_print_ (); + + /* Debugging. */ + int yydebug_; + std::ostream* yycdebug_; +#endif + + /// Convert a scanner token number \a t to a symbol number. + token_number_type yytranslate_ (int t); + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// If null, do not display the symbol, just free it. + /// \param yytype The symbol type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + inline void yydestruct_ (const char* yymsg, + int yytype, + semantic_type* yyvaluep, + location_type* yylocationp); + + /// Pop \a n symbols the three stacks. + inline void yypop_ (unsigned int n = 1); + + /* Constants. */ + static const int yyeof_; + /* LAST_ -- Last index in TABLE_. */ + static const int yylast_; + static const int yynnts_; + static const int yyempty_; + static const int yyfinal_; + static const int yyterror_; + static const int yyerrcode_; + static const int yyntokens_; + static const unsigned int yyuser_token_number_max_; + static const token_number_type yyundef_token_; + + /* User arguments. */ + QJson::ParserPrivate* driver; + }; + +} // yy +/* Line 33 of lalr1.cc */ +#line 297 "json_parser.hh" + + + +#endif /* !YY_YY_JSON_PARSER_HH_INCLUDED */ diff --git a/src/json_parser.yy b/src/json_parser.yy new file mode 100644 index 000000000..fa4656bab --- /dev/null +++ b/src/json_parser.yy @@ -0,0 +1,162 @@ +/* This file is part of QJSon + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +%skeleton "lalr1.cc" +%defines +%define "parser_class_name" "json_parser" + +%code requires{ + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 + + Q_DECLARE_METATYPE(QVector*) + Q_DECLARE_METATYPE(QVariantMap*) +} + +%parse-param { QJson::ParserPrivate* driver } +%lex-param { QJson::ParserPrivate* driver } + +%locations + +%debug +%error-verbose + +%token END 0 "end of file" + +%token CURLY_BRACKET_OPEN 1 "{" +%token CURLY_BRACKET_CLOSE 2 "}" +%token SQUARE_BRACKET_OPEN 3 "[" +%token SQUARE_BRACKET_CLOSE 4 "]" +%token COLON 5 ":" +%token COMMA 6 "," + +%token NUMBER 7 "number" +%token TRUE_VAL 8 "true" +%token FALSE_VAL 9 "false" +%token NULL_VAL 10 "null" +%token STRING 11 "string" + +%token INVALID 12 "invalid" + +// define the initial token +%start start + +%% + +// grammar rules + +start: data { + driver->m_result = $1; + qjsonDebug() << "json_parser - parsing finished"; + }; + +data: value { $$ = $1; } + | error + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << @$.begin.line << "Column" << @$.begin.column; + YYABORT; + } + | END; + +object: CURLY_BRACKET_OPEN CURLY_BRACKET_CLOSE { + $$ = QVariant(QVariantMap()); + } + | CURLY_BRACKET_OPEN members CURLY_BRACKET_CLOSE { + QVariantMap* map = $2.value(); + $$ = QVariant(*map); + delete map; + }; + +members: STRING COLON value { + QVariantMap* pair = new QVariantMap(); + pair->insert($1.toString(), $3); + $$.setValue(pair); + } + | members COMMA STRING COLON value { + $$.value()->insert($3.toString(), $5); + }; + +array: SQUARE_BRACKET_OPEN SQUARE_BRACKET_CLOSE { + $$ = QVariant(QVariantList()); + } + | SQUARE_BRACKET_OPEN values SQUARE_BRACKET_CLOSE { + QVector* list = $2.value* >(); + $$ = QVariant(list->toList()); + delete list; + }; + +values: value { + QVector* list = new QVector(1); + list->replace(0, $1); + $$.setValue(list); + } + | values COMMA value { + $$.value* >()->append($3); + }; + +value: STRING + | NUMBER + | TRUE_VAL + | FALSE_VAL + | NULL_VAL + | object + | array; + +%% + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} diff --git a/src/json_scanner.cc b/src/json_scanner.cc new file mode 100644 index 000000000..d148b0cd6 --- /dev/null +++ b/src/json_scanner.cc @@ -0,0 +1,4513 @@ +#line 2 "json_scanner.cc" + +#line 4 "json_scanner.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 37 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer yyFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +#include +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext + +#include + +int yyFlexLexer::yywrap() { return 1; } +int yyFlexLexer::yylex() + { + LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); + return 0; + } + +#define YY_DECL int JSonScanner::yylex() +static yyconst flex_int16_t yy_nxt[][256] = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, + 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 16, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 10, 10, 10, 10, 10, + 23, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27 + }, + + { + 9, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 29, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27 + + }, + + { + 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, + 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, + + 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30 + }, + + { + 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, + 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, + 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, + 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, + 12, 11, 11, 13, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 10, 14, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 15, 32, 10, 10, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 19, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 33, 10, 10, 10, 10, 34, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 20, 10, 21, 10, 10, 10, 10, 10, 10, + 10, 10, 22, 10, 10, 33, 10, 10, 10, 10, + 35, 10, 10, 10, 10, 10, 24, 10, 10, 10, + + 10, 10, 10, 25, 10, 26, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10 + }, + + { + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, + -9, -9, -9, -9, -9, -9 + + }, + + { + 9, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10, -10, -10 + }, + + { + 9, -11, -11, -11, -11, -11, -11, -11, -11, 36, + -11, 36, 36, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, 36, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11 + }, + + { + 9, -12, -12, -12, -12, -12, -12, -12, -12, -12, + 37, -12, -12, 37, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12 + }, + + { + 9, -13, -13, -13, -13, -13, -13, -13, -13, -13, + 37, -13, -13, 37, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, + -13, -13, -13, -13, -13, -13 + }, + + { + 9, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14 + + }, + + { + 9, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15, -15, -15, -15, -15, -15 + }, + + { + 9, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, 38, 39, + 39, 39, 39, 39, 39, 39, 39, 39, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + + -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16 + }, + + { + 9, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, 40, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, 41, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, 41, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17 + }, + + { + 9, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, 40, -18, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, 41, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, 41, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, -18, -18, -18 + }, + + { + 9, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -19, -19, -19, -19, -19, -19 + + }, + + { + 9, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20 + }, + + { + 9, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -21 + }, + + { + 9, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, 43, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22 + }, + + { + 9, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, 44, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23 + }, + + { + 9, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, 45, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24 + + }, + + { + 9, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25 + }, + + { + 9, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26 + }, + + { + 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, -27, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, -27, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46 + }, + + { + 9, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, -28, -28 + }, + + { + 9, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, 47, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, 48, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, 49, -29, -29, -29, -29, -29, 50, -29, + -29, -29, 51, -29, -29, -29, -29, -29, -29, -29, + 52, -29, -29, -29, 53, -29, 54, 55, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29 + + }, + + { + 9, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30 + }, + + { + 9, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, -31, -31, + -31, -31, -31, -31, -31, 56, 56, 56, 56, 56, + 56, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, 56, 56, 56, + 56, 56, 56, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + + -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -31, -31 + }, + + { + 9, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, 38, 39, + 39, 39, 39, 39, 39, 39, 39, 39, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, 57, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, 57, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32 + }, + + { + 9, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + 58, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33 + }, + + { + 9, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + + -34, -34, -34, -34, -34, 59, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, 59, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, -34, -34, -34, -34, -34 + + }, + + { + 9, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, 59, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, 59, -35, -35, + + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, 44, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, -35, -35, -35, -35, -35 + }, + + { + 9, -36, -36, -36, -36, -36, -36, -36, -36, 36, + -36, 36, 36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, 36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + + -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36 + }, + + { + 9, -37, -37, -37, -37, -37, -37, -37, -37, -37, + 37, -37, -37, 37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37 + }, + + { + 9, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, 40, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, 41, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, 41, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38 + }, + + { + 9, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, 40, -39, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, -39, -39, + + -39, -39, -39, -39, -39, -39, -39, -39, -39, 41, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, 41, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39 + + }, + + { + 9, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40 + }, + + { + 9, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, 62, -41, 62, -41, -41, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + + -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, + -41, -41, -41, -41, -41, -41 + }, + + { + 9, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, 40, -42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, 41, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, 41, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, + -42, -42, -42, -42, -42, -42 + }, + + { + 9, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, 64, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43 + }, + + { + 9, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, 65, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, -44, -44, -44 + + }, + + { + 9, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, 66, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, + -45, -45, -45, -45, -45, -45 + }, + + { + 9, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, -46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, -46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46 + }, + + { + 9, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47 + }, + + { + 9, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48 + }, + + { + 9, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49 + + }, + + { + 9, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50 + }, + + { + 9, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + + -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51 + }, + + { + 9, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52 + }, + + { + 9, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53 + }, + + { + 9, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54 + + }, + + { + 9, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55 + }, + + { + 9, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, -56, -56, + -56, -56, -56, -56, -56, 67, 67, 67, 67, 67, + 67, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, 67, 67, 67, + 67, 67, 67, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56 + }, + + { + 9, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + 68, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57 + }, + + { + 9, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, 69, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58 + }, + + { + 9, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, 70, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + 70, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59 + + }, + + { + 9, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, 40, -60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, 41, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + + -60, 41, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60 + }, + + { + 9, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, 41, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, 41, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61 + }, + + { + 9, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62 + }, + + { + 9, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, + -63, -63, -63, -63, -63, -63 + }, + + { + 9, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, 71, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64 + + }, + + { + 9, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + + -65, -65, -65, -65, -65, -65, -65, -65, 72, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, + -65, -65, -65, -65, -65, -65 + }, + + { + 9, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, 73, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66 + }, + + { + 9, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, 74, 74, + 74, 74, 74, 74, 74, 74, 74, 74, -67, -67, + -67, -67, -67, -67, -67, 74, 74, 74, 74, 74, + 74, -67, -67, -67, -67, -67, -67, -67, -67, -67, + + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, 74, 74, 74, + 74, 74, 74, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, + -67, -67, -67, -67, -67, -67 + }, + + { + 9, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, 75, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, + -68, -68, -68, -68, -68, -68 + }, + + { + 9, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, 76, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, + -69, -69, -69, -69, -69, -69 + + }, + + { + 9, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, + -70, -70, -70, -70, -70, -70 + }, + + { + 9, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, 77, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + + -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, + -71, -71, -71, -71, -71, -71 + }, + + { + 9, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, + -72, -72, -72, -72, -72, -72 + }, + + { + 9, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73 + }, + + { + 9, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, -74, -74 + + }, + + { + 9, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + + -75, -75, -75, -75, -75, 78, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, + -75, -75, -75, -75, -75, -75 + }, + + { + 9, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + 79, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + + -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, + -76, -76, -76, -76, -76, -76 + }, + + { + 9, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, + -77, -77, -77, -77, -77, -77 + }, + + { + 9, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + 80, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, -78 + }, + + { + 9, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, 81, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, + -79, -79, -79, -79, -79, -79 + + }, + + { + 9, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + + -80, -80, -80, -80, -80, 82, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80 + }, + + { + 9, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, 83, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + + -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, + -81, -81, -81, -81, -81, -81 + }, + + { + 9, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, 84, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, + -82, -82, -82, -82, -82, -82 + }, + + { + 9, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, 85, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, + -83, -83, -83, -83, -83, -83 + }, + + { + 9, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, 86, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, + -84, -84, -84, -84, -84, -84 + + }, + + { + 9, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85 + }, + + { + 9, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + + -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, + -86, -86, -86, -86, -86, -86 + }, + + } ; + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 36 +#define YY_END_OF_BUFFER 37 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[87] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 37, 35, + 1, 2, 2, 11, 27, 35, 6, 6, 26, 28, + 29, 35, 35, 35, 30, 31, 21, 23, 22, 25, + 25, 35, 35, 35, 35, 1, 2, 8, 8, 0, + 0, 7, 0, 0, 0, 21, 12, 14, 13, 15, + 16, 17, 18, 19, 20, 0, 0, 0, 0, 9, + 10, 0, 10, 0, 0, 0, 0, 0, 0, 32, + 0, 5, 3, 24, 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 33, 34 + } ; + +static yyconst yy_state_type yy_NUL_trans[87] = + { 0, + 10, 10, 27, 27, 30, 30, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "json_scanner.yy" +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110yy::json_parser::token::INVALID301, USA. + */ +/* Flex output settings */ +#define YY_NO_UNISTD_H 1 +#define YY_NO_INPUT 1 +#line 29 "json_scanner.yy" + #include "json_scanner.h" + #include "json_parser.hh" + + #if defined(_WIN32) && !defined(__MINGW32__) + #define strtoll _strtoi64 + #define strtoull _strtoui64 + #endif + + #define YY_USER_INIT if(m_allowSpecialNumbers) { \ + BEGIN(ALLOW_SPECIAL_NUMBERS); \ + } +/* Exclusive subscanners for strings and escaped hex sequences */ + +/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ + +#line 3168 "json_scanner.cc" + +#define INITIAL 0 +#define QUOTMARK_OPEN 1 +#define HEX_OPEN 2 +#define ALLOW_SPECIAL_NUMBERS 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 48 "json_scanner.yy" + + + /* Whitespace */ +#line 3275 "json_scanner.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ YY_SC_TO_UI(*yy_cp) ]) > 0 ) + { + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + + ++yy_cp; + } + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos) + 1; + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 51 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + } + YY_BREAK +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 55 "json_scanner.yy" +{ + m_yylloc->lines(yyleng); + } + YY_BREAK +/* Special values */ +case 3: +YY_RULE_SETUP +#line 61 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(true); + return yy::json_parser::token::TRUE_VAL; + } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 67 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(false); + return yy::json_parser::token::FALSE_VAL; + } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 73 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(); + return yy::json_parser::token::NULL_VAL; + } + YY_BREAK +/* Numbers */ +case 6: +#line 82 "json_scanner.yy" +case 7: +YY_RULE_SETUP +#line 82 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoull(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 8: +#line 93 "json_scanner.yy" +case 9: +YY_RULE_SETUP +#line 93 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoll(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 103 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + bool ok; + *m_yylval = QVariant(m_C_locale.toDouble(QLatin1String(yytext),&ok)); + if (!ok) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + YY_BREAK +/* Strings */ +case 11: +YY_RULE_SETUP +#line 115 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + BEGIN(QUOTMARK_OPEN); + } + YY_BREAK + +case 12: +YY_RULE_SETUP +#line 121 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\"")); + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 125 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\\")); + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 129 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("/")); + } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 133 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\b")); + } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 137 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\f")); + } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 141 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\n")); + } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 145 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\r")); + } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 149 "json_scanner.yy" +{ + m_currentString.append(QLatin1String("\t")); + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 153 "json_scanner.yy" +{ + BEGIN(HEX_OPEN); + } + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +#line 157 "json_scanner.yy" +{ + m_currentString.append(QString::fromUtf8(yytext)); + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 161 "json_scanner.yy" +{ + // ignore + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 165 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(m_currentString); + m_currentString.clear(); + BEGIN(INITIAL); + return yy::json_parser::token::STRING; + } + YY_BREAK + + +case 24: +YY_RULE_SETUP +#line 175 "json_scanner.yy" +{ + QString hexDigits = QString::fromUtf8(yytext, yyleng); + bool ok; + ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); + ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); + m_currentString.append(QChar(hexDigit2, hexDigit1)); + BEGIN(QUOTMARK_OPEN); + } + YY_BREAK +case 25: +/* rule 25 can match eol */ +YY_RULE_SETUP +#line 184 "json_scanner.yy" +{ + qCritical() << "Invalid hex string"; + m_yylloc->columns(yyleng); + *m_yylval = QVariant(QLatin1String("")); + BEGIN(QUOTMARK_OPEN); + return yy::json_parser::token::INVALID; + } + YY_BREAK + +/* "Compound type" related tokens */ +case 26: +YY_RULE_SETUP +#line 196 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::COLON; + } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 201 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::COMMA; + } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 206 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_OPEN; + } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 211 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_CLOSE; + } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 216 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_OPEN; + } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 221 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_CLOSE; + } + YY_BREAK +/* Extra-JSON numbers */ + +case 32: +YY_RULE_SETUP +#line 229 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 235 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 241 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + *m_yylval = QVariant(-std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + YY_BREAK + +/* If all else fails */ +case 35: +YY_RULE_SETUP +#line 249 "json_scanner.yy" +{ + m_yylloc->columns(yyleng); + return yy::json_parser::token::INVALID; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(QUOTMARK_OPEN): +case YY_STATE_EOF(HEX_OPEN): +case YY_STATE_EOF(ALLOW_SPECIAL_NUMBERS): +#line 254 "json_scanner.yy" +return yy::json_parser::token::END; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 255 "json_scanner.yy" +ECHO; + YY_BREAK +#line 3660 "json_scanner.cc" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + yyfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + yyfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) +#else +int yyFlexLexer::LexerInput( char* buf, int max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, int size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + if ( *yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][YY_SC_TO_UI(*yy_cp)]; + } + else + yy_current_state = yy_NUL_trans[yy_current_state]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + yy_current_state = yy_NUL_trans[yy_current_state]; + yy_is_jam = (yy_current_state == 0); + + if ( ! yy_is_jam ) + { + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + } + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 255 "json_scanner.yy" diff --git a/src/json_scanner.cpp b/src/json_scanner.cpp new file mode 100644 index 000000000..eb4ec8357 --- /dev/null +++ b/src/json_scanner.cpp @@ -0,0 +1,82 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#include "json_scanner.cc" + +#include "qjson_debug.h" +#include "json_scanner.h" +#include "json_parser.hh" + +#include + +#include +#include + +#include + + +JSonScanner::JSonScanner(QIODevice* io) + : m_allowSpecialNumbers(false), + m_io (io), + m_criticalError(false), + m_C_locale(QLocale::C) +{ + +} + +JSonScanner::~JSonScanner() +{ +} + +void JSonScanner::allowSpecialNumbers(bool allow) { + m_allowSpecialNumbers = allow; +} + +int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc) { + m_yylval = yylval; + m_yylloc = yylloc; + m_yylloc->step(); + int result = yylex(); + + if (m_criticalError) { + return -1; + } + + return result; +} + +int JSonScanner::LexerInput(char* buf, int max_size) { + if (!m_io->isOpen()) { + qCritical() << "JSonScanner::yylex - io device is not open"; + m_criticalError = true; + return 0; + } + + int readBytes = m_io->read(buf, max_size); + if(readBytes < 0) { + qCritical() << "JSonScanner::yylex - error while reading from io device"; + m_criticalError = true; + return 0; + } + + return readBytes; +} + + diff --git a/src/json_scanner.h b/src/json_scanner.h new file mode 100644 index 000000000..6a0e97b6f --- /dev/null +++ b/src/json_scanner.h @@ -0,0 +1,66 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _JSON_SCANNER +#define _JSON_SCANNER + +#include +#include +#include + +#define YYSTYPE QVariant + +// Only include FlexLexer.h if it hasn't been already included +#if ! defined(yyFlexLexerOnce) +#include +#endif + +#include "parser_p.h" + + + +namespace yy { + class location; + int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver); +} + +class JSonScanner : public yyFlexLexer +{ + public: + explicit JSonScanner(QIODevice* io); + ~JSonScanner(); + + void allowSpecialNumbers(bool allow); + + int yylex(YYSTYPE* yylval, yy::location *yylloc); + int yylex(); + int LexerInput(char* buf, int max_size); + protected: + bool m_allowSpecialNumbers; + QIODevice* m_io; + + YYSTYPE* m_yylval; + yy::location* m_yylloc; + bool m_criticalError; + QString m_currentString; + QLocale m_C_locale; +}; + +#endif diff --git a/src/json_scanner.yy b/src/json_scanner.yy new file mode 100644 index 000000000..27104b28e --- /dev/null +++ b/src/json_scanner.yy @@ -0,0 +1,254 @@ +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110yy::json_parser::token::INVALID301, USA. + */ + +/* Flex output settings */ +%option 8bit c++ full warn +%option noyywrap nounistd +%option noinput nounput noyy_push_state noyy_pop_state noyy_top_state noyy_scan_buffer noyy_scan_bytes noyy_scan_string noyyget_extra noyyset_extra noyyget_leng noyyget_text noyyget_lineno noyyset_lineno noyyget_in noyyset_in noyyget_out noyyset_out noyyget_lval noyyset_lval noyyget_lloc noyyset_lloc noyyget_debug noyyset_debug +%option yyclass="JSonScanner" +%option outfile="json_scanner.cc" + +%{ + #include "json_scanner.h" + #include "json_parser.hh" + + #if defined(_WIN32) && !defined(__MINGW32__) + #define strtoll _strtoi64 + #define strtoull _strtoui64 + #endif + + #define YY_USER_INIT if(m_allowSpecialNumbers) { \ + BEGIN(ALLOW_SPECIAL_NUMBERS); \ + } +%} + +/* Exclusive subscanners for strings and escaped hex sequences */ +%x QUOTMARK_OPEN HEX_OPEN + +/* Extra-JSON rules active iff m_allowSpecialNumbers is true */ +%s ALLOW_SPECIAL_NUMBERS + +%% + + /* Whitespace */ +[\v\f\t ]+ { + m_yylloc->columns(yyleng); + } + +[\r\n]+ { + m_yylloc->lines(yyleng); + } + + + /* Special values */ +true { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(true); + return yy::json_parser::token::TRUE_VAL; + } + +false { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(false); + return yy::json_parser::token::FALSE_VAL; + } + +null { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(); + return yy::json_parser::token::NULL_VAL; + } + + + /* Numbers */ +[0-9] | +[1-9][0-9]+ { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoull(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + +-[0-9] | +-[1-9][0-9]+ { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(strtoll(yytext, NULL, 10)); + if (errno == ERANGE) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + +-?(([0-9])|([1-9][0-9]+))(\.[0-9]+)?([Ee][+\-]?[0-9]+)? { + m_yylloc->columns(yyleng); + bool ok; + *m_yylval = QVariant(m_C_locale.toDouble(QLatin1String(yytext),&ok)); + if (!ok) { + qCritical() << "Number is out of range: " << yytext; + return yy::json_parser::token::INVALID; + } + return yy::json_parser::token::NUMBER; + } + + /* Strings */ +\" { + m_yylloc->columns(yyleng); + BEGIN(QUOTMARK_OPEN); + } + +{ + \\\" { + m_currentString.append(QLatin1String("\"")); + } + + \\\\ { + m_currentString.append(QLatin1String("\\")); + } + + \\\/ { + m_currentString.append(QLatin1String("/")); + } + + \\b { + m_currentString.append(QLatin1String("\b")); + } + + \\f { + m_currentString.append(QLatin1String("\f")); + } + + \\n { + m_currentString.append(QLatin1String("\n")); + } + + \\r { + m_currentString.append(QLatin1String("\r")); + } + + \\t { + m_currentString.append(QLatin1String("\t")); + } + + \\u { + BEGIN(HEX_OPEN); + } + + [^\"\\]+ { + m_currentString.append(QString::fromUtf8(yytext)); + } + + \\ { + // ignore + } + + \" { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(m_currentString); + m_currentString.clear(); + BEGIN(INITIAL); + return yy::json_parser::token::STRING; + } +} + +{ + [0-9A-Fa-f]{4} { + QString hexDigits = QString::fromUtf8(yytext, yyleng); + bool ok; + ushort hexDigit1 = hexDigits.left(2).toShort(&ok, 16); + ushort hexDigit2 = hexDigits.right(2).toShort(&ok, 16); + m_currentString.append(QChar(hexDigit2, hexDigit1)); + BEGIN(QUOTMARK_OPEN); + } + + .|\n { + qCritical() << "Invalid hex string"; + m_yylloc->columns(yyleng); + *m_yylval = QVariant(QLatin1String("")); + BEGIN(QUOTMARK_OPEN); + return yy::json_parser::token::INVALID; + } +} + + + + /* "Compound type" related tokens */ +: { + m_yylloc->columns(yyleng); + return yy::json_parser::token::COLON; + } + +, { + m_yylloc->columns(yyleng); + return yy::json_parser::token::COMMA; + } + +\[ { + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_OPEN; + } + +\] { + m_yylloc->columns(yyleng); + return yy::json_parser::token::SQUARE_BRACKET_CLOSE; + } + +\{ { + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_OPEN; + } + +\} { + m_yylloc->columns(yyleng); + return yy::json_parser::token::CURLY_BRACKET_CLOSE; + } + + + /* Extra-JSON numbers */ +{ + (?i:nan) { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::quiet_NaN()); + return yy::json_parser::token::NUMBER; + } + + [Ii]nfinity { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } + + -[Ii]nfinity { + m_yylloc->columns(yyleng); + *m_yylval = QVariant(-std::numeric_limits::infinity()); + return yy::json_parser::token::NUMBER; + } +} + + /* If all else fails */ +. { + m_yylloc->columns(yyleng); + return yy::json_parser::token::INVALID; + } + +<> return yy::json_parser::token::END; diff --git a/src/location.hh b/src/location.hh new file mode 100644 index 000000000..0bf1a74e8 --- /dev/null +++ b/src/location.hh @@ -0,0 +1,181 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Locations for Bison parsers in C++ + + Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file location.hh + ** Define the yy::location class. + */ + +#ifndef YY_YY_LOCATION_HH_INCLUDED +# define YY_YY_LOCATION_HH_INCLUDED + +# include "position.hh" + + +namespace yy { +/* Line 166 of location.cc */ +#line 47 "location.hh" + + /// Abstract a location. + class location + { + public: + + /// Construct a location from \a b to \a e. + location (const position& b, const position& e) + : begin (b) + , end (e) + { + } + + /// Construct a 0-width location in \a p. + explicit location (const position& p = position ()) + : begin (p) + , end (p) + { + } + + /// Construct a 0-width location in \a f, \a l, \a c. + explicit location (std::string* f, + unsigned int l = 1u, + unsigned int c = 1u) + : begin (f, l, c) + , end (f, l, c) + { + } + + + /// Initialization. + void initialize (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + { + begin.initialize (f, l, c); + end = begin; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// Reset initial location to final location. + void step () + { + begin = end; + } + + /// Extend the current location to the COUNT next columns. + void columns (unsigned int count = 1) + { + end += count; + } + + /// Extend the current location to the COUNT next lines. + void lines (unsigned int count = 1) + { + end.lines (count); + } + /** \} */ + + + public: + /// Beginning of the located region. + position begin; + /// End of the located region. + position end; + }; + + /// Join two location objects to create a location. + inline const location operator+ (const location& begin, const location& end) + { + location res = begin; + res.end = end.end; + return res; + } + + /// Add two location objects. + inline const location operator+ (const location& begin, unsigned int width) + { + location res = begin; + res.columns (width); + return res; + } + + /// Add and assign a location. + inline location& operator+= (location& res, unsigned int width) + { + res.columns (width); + return res; + } + + /// Compare two location objects. + inline bool + operator== (const location& loc1, const location& loc2) + { + return loc1.begin == loc2.begin && loc1.end == loc2.end; + } + + /// Compare two location objects. + inline bool + operator!= (const location& loc1, const location& loc2) + { + return !(loc1 == loc2); + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param loc a reference to the location to redirect + ** + ** Avoid duplicate information. + */ + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const location& loc) + { + position last = loc.end - 1; + ostr << loc.begin; + if (last.filename + && (!loc.begin.filename + || *loc.begin.filename != *last.filename)) + ostr << '-' << last; + else if (loc.begin.line != last.line) + ostr << '-' << last.line << '.' << last.column; + else if (loc.begin.column != last.column) + ostr << '-' << last.column; + return ostr; + } + + +} // yy +/* Line 296 of location.cc */ +#line 180 "location.hh" + +#endif /* !YY_YY_LOCATION_HH_INCLUDED */ diff --git a/src/parser.cpp b/src/parser.cpp new file mode 100644 index 000000000..73de8ceae --- /dev/null +++ b/src/parser.cpp @@ -0,0 +1,141 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parser.h" +#include "parser_p.h" +#include "json_parser.hh" +#include "json_scanner.h" + +#include +#include +#include +#include + +using namespace QJson; + +ParserPrivate::ParserPrivate() : + m_scanner(0) +{ + m_specialNumbersAllowed = false; + reset(); +} + +ParserPrivate::~ParserPrivate() +{ + if (m_scanner) + delete m_scanner; +} + +void ParserPrivate::setError(QString errorMsg, int errorLine) { + m_error = true; + m_errorMsg = errorMsg; + m_errorLine = errorLine; +} + +void ParserPrivate::reset() +{ + m_error = false; + m_errorLine = 0; + m_errorMsg.clear(); + if (m_scanner) { + delete m_scanner; + m_scanner = 0; + } +} + +Parser::Parser() : + d(new ParserPrivate) +{ +} + +Parser::~Parser() +{ + delete d; +} + +QVariant Parser::parse (QIODevice* io, bool* ok) +{ + d->reset(); + + if (!io->isOpen()) { + if (!io->open(QIODevice::ReadOnly)) { + if (ok != 0) + *ok = false; + qCritical ("Error opening device"); + return QVariant(); + } + } + + if (!io->isReadable()) { + if (ok != 0) + *ok = false; + qCritical ("Device is not readable"); + io->close(); + return QVariant(); + } + + if (io->atEnd()) { + if (ok != 0) + *ok = false; + d->setError(QLatin1String("No data"), 0); + io->close(); + return QVariant(); + } + + d->m_scanner = new JSonScanner (io); + d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed); + yy::json_parser parser(d); + parser.parse(); + + delete d->m_scanner; + d->m_scanner = 0; + + if (ok != 0) + *ok = !d->m_error; + + io->close(); + return d->m_result; +} + +QVariant Parser::parse(const QByteArray& jsonString, bool* ok) { + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(jsonString); + buffer.seek(0); + return parse (&buffer, ok); +} + +QString Parser::errorString() const +{ + return d->m_errorMsg; +} + +int Parser::errorLine() const +{ + return d->m_errorLine; +} + +void QJson::Parser::allowSpecialNumbers(bool allowSpecialNumbers) { + d->m_specialNumbersAllowed = allowSpecialNumbers; +} + +bool Parser::specialNumbersAllowed() const { + return d->m_specialNumbersAllowed; +} diff --git a/src/parser.h b/src/parser.h new file mode 100644 index 000000000..c3132f506 --- /dev/null +++ b/src/parser.h @@ -0,0 +1,99 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_H +#define QJSON_PARSER_H + +#include "qjson_export.h" + +QT_BEGIN_NAMESPACE +class QIODevice; +class QVariant; +QT_END_NAMESPACE + +/** + * Namespace used by QJson + */ +namespace QJson { + + class ParserPrivate; + + /** + * @brief Main class used to convert JSON data to QVariant objects + */ + class QJSON_EXPORT Parser + { + public: + Parser(); + ~Parser(); + + /** + * Read JSON string from the I/O Device and converts it to a QVariant object + * @param io Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + */ + QVariant parse(QIODevice* io, bool* ok = 0); + + /** + * This is a method provided for convenience. + * @param jsonData data containing the JSON object representation + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + * @sa errorString + * @sa errorLine + */ + QVariant parse(const QByteArray& jsonData, bool* ok = 0); + + /** + * This method returns the error message + * @returns a QString object containing the error message of the last parse operation + * @sa errorLine + */ + QString errorString() const; + + /** + * This method returns line number where the error occurred + * @returns the line number where the error occurred + * @sa errorString + */ + int errorLine() const; + + /** + * Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to + * the standard + * @param allowSpecialNumbers new value of whether special numbers are allowed + * @sa specialNumbersAllowed + */ + void allowSpecialNumbers(bool allowSpecialNumbers); + + /** + * @returns whether special numbers (Infinity, -Infinity, NaN) are allowed + * @sa allowSpecialNumbers + */ + bool specialNumbersAllowed() const; + + private: + Q_DISABLE_COPY(Parser) + ParserPrivate* const d; + }; +} + +#endif // QJSON_PARSER_H diff --git a/src/parser_p.h b/src/parser_p.h new file mode 100644 index 000000000..de98b9b6b --- /dev/null +++ b/src/parser_p.h @@ -0,0 +1,57 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2009 Michael Leupold + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_P_H +#define QJSON_PARSER_P_H + +#include "parser.h" + +#include +#include + +class JSonScanner; + +namespace yy { + class json_parser; +} + +namespace QJson { + + class ParserPrivate + { + public: + ParserPrivate(); + ~ParserPrivate(); + + void reset(); + + void setError(QString errorMsg, int line); + + JSonScanner* m_scanner; + bool m_error; + int m_errorLine; + QString m_errorMsg; + QVariant m_result; + bool m_specialNumbersAllowed; + }; +} + +#endif // QJSON_PARSER_H diff --git a/src/parserrunnable.cpp b/src/parserrunnable.cpp new file mode 100644 index 000000000..88baf4cf6 --- /dev/null +++ b/src/parserrunnable.cpp @@ -0,0 +1,68 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" + +#include "parser.h" + +#include +#include + +using namespace QJson; + +class QJson::ParserRunnable::Private +{ + public: + QByteArray m_data; +}; + +ParserRunnable::ParserRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +ParserRunnable::~ParserRunnable() +{ + delete d; +} + +void ParserRunnable::setData( const QByteArray& data ) { + d->m_data = data; +} + +void ParserRunnable::run() +{ + qDebug() << Q_FUNC_INFO; + + bool ok; + Parser parser; + QVariant result = parser.parse (d->m_data, &ok); + if (ok) { + qDebug() << "successfully converted json item to QVariant object"; + emit parsingFinished(result, true, QString()); + } else { + const QString errorText = tr("An error occurred while parsing json: %1").arg(parser.errorString()); + qCritical() << errorText; + emit parsingFinished(QVariant(), false, errorText); + } +} diff --git a/src/parserrunnable.h b/src/parserrunnable.h new file mode 100644 index 000000000..fddcacd3f --- /dev/null +++ b/src/parserrunnable.h @@ -0,0 +1,64 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PARSERRUNNABLE_H +#define PARSERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + explicit ParserRunnable(QObject* parent = 0); + ~ParserRunnable(); + + void setData( const QByteArray& data ); + + void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the parsing process has been completed + * @param json contains the result of the parsing + * @param ok if a parsing error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QVariant& json, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(ParserRunnable) + class Private; + Private* const d; + }; +} + +#endif // PARSERRUNNABLE_H diff --git a/src/position.hh b/src/position.hh new file mode 100644 index 000000000..3b33c2734 --- /dev/null +++ b/src/position.hh @@ -0,0 +1,172 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Positions for Bison parsers in C++ + + Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file position.hh + ** Define the yy::position class. + */ + +#ifndef YY_YY_POSITION_HH_INCLUDED +# define YY_YY_POSITION_HH_INCLUDED + +# include // std::max +# include +# include + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + + +namespace yy { +/* Line 36 of location.cc */ +#line 57 "position.hh" + /// Abstract a position. + class position + { + public: + + /// Construct a position. + explicit position (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + : filename (f) + , line (l) + , column (c) + { + } + + + /// Initialization. + void initialize (std::string* fn = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + { + filename = fn; + line = l; + column = c; + } + + /** \name Line and Column related manipulators + ** \{ */ + /// (line related) Advance to the COUNT next lines. + void lines (int count = 1) + { + column = 1u; + line += count; + } + + /// (column related) Advance to the COUNT next columns. + void columns (int count = 1) + { + column = std::max (1u, column + count); + } + /** \} */ + + /// File name to which this position refers. + std::string* filename; + /// Current line number. + unsigned int line; + /// Current column number. + unsigned int column; + }; + + /// Add and assign a position. + inline position& + operator+= (position& res, const int width) + { + res.columns (width); + return res; + } + + /// Add two position objects. + inline const position + operator+ (const position& begin, const int width) + { + position res = begin; + return res += width; + } + + /// Add and assign a position. + inline position& + operator-= (position& res, const int width) + { + return res += -width; + } + + /// Add two position objects. + inline const position + operator- (const position& begin, const int width) + { + return begin + -width; + } + + /// Compare two position objects. + inline bool + operator== (const position& pos1, const position& pos2) + { + return (pos1.line == pos2.line + && pos1.column == pos2.column + && (pos1.filename == pos2.filename + || (pos1.filename && pos2.filename + && *pos1.filename == *pos2.filename))); + } + + /// Compare two position objects. + inline bool + operator!= (const position& pos1, const position& pos2) + { + return !(pos1 == pos2); + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param pos a reference to the position to redirect + */ + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const position& pos) + { + if (pos.filename) + ostr << *pos.filename << ':'; + return ostr << pos.line << '.' << pos.column; + } + + +} // yy +/* Line 148 of location.cc */ +#line 172 "position.hh" +#endif /* !YY_YY_POSITION_HH_INCLUDED */ diff --git a/src/qjson_debug.h b/src/qjson_debug.h new file mode 100644 index 000000000..6036b2268 --- /dev/null +++ b/src/qjson_debug.h @@ -0,0 +1,34 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Michael Leupold + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_DEBUG_H +#define QJSON_DEBUG_H + +#include + +// define qjsonDebug() +#ifdef QJSON_VERBOSE_DEBUG_OUTPUT + inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); } +#else + #define qjsonDebug() if(false) QDebug(QtDebugMsg) +#endif + +#endif diff --git a/src/qjson_export.h b/src/qjson_export.h new file mode 100644 index 000000000..9a807b91b --- /dev/null +++ b/src/qjson_export.h @@ -0,0 +1,35 @@ +/* This file is part of the KDE project + Copyright (C) 2009 Pino Toscano + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1, as published by the Free Software Foundation. + + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef QJSON_EXPORT_H +#define QJSON_EXPORT_H + +#include + +#ifndef QJSON_EXPORT +# if defined(QJSON_MAKEDLL) + /* We are building this library */ +# define QJSON_EXPORT Q_DECL_EXPORT +# else + /* We are using this library */ +# define QJSON_EXPORT Q_DECL_IMPORT +# endif +#endif + +#endif diff --git a/src/qobjecthelper.cpp b/src/qobjecthelper.cpp new file mode 100644 index 000000000..4f8daf722 --- /dev/null +++ b/src/qobjecthelper.cpp @@ -0,0 +1,85 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + + +#include "qobjecthelper.h" + +#include +#include +#include + +using namespace QJson; + +class QObjectHelper::QObjectHelperPrivate { +}; + +QObjectHelper::QObjectHelper() + : d (new QObjectHelperPrivate) +{ +} + +QObjectHelper::~QObjectHelper() +{ + delete d; +} + +QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties) +{ + QVariantMap result; + const QMetaObject *metaobject = object->metaObject(); + int count = metaobject->propertyCount(); + for (int i=0; iproperty(i); + const char *name = metaproperty.name(); + + if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) + continue; + + QVariant value = object->property(name); + result[QLatin1String(name)] = value; + } + return result; +} + +void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object) +{ + const QMetaObject *metaobject = object->metaObject(); + + QVariantMap::const_iterator iter; + for (iter = variant.constBegin(); iter != variant.constEnd(); ++iter) { + int pIdx = metaobject->indexOfProperty( iter.key().toLatin1() ); + + if ( pIdx < 0 ) { + continue; + } + + QMetaProperty metaproperty = metaobject->property( pIdx ); + QVariant::Type type = metaproperty.type(); + QVariant v( iter.value() ); + if ( v.canConvert( type ) ) { + v.convert( type ); + metaproperty.write( object, v ); + } else if (QString(QLatin1String("QVariant")).compare(QLatin1String(metaproperty.typeName())) == 0) { + metaproperty.write( object, v ); + } + } +} diff --git a/src/qobjecthelper.h b/src/qobjecthelper.h new file mode 100644 index 000000000..e4dfed0c8 --- /dev/null +++ b/src/qobjecthelper.h @@ -0,0 +1,147 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QOBJECTHELPER_H +#define QOBJECTHELPER_H + +#include "qjson_export.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QObject; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Class used to convert QObject into QVariant and vivce-versa. + * During these operations only the class attributes defined as properties will + * be considered. + * Properties marked as 'non-stored' will be ignored. + * + * Suppose the declaration of the Person class looks like this: + * \code + * class Person : public QObject + { + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) + Q_PROPERTY(Gender gender READ gender WRITE setGender) + Q_PROPERTY(QDate dob READ dob WRITE setDob) + Q_ENUMS(Gender) + + public: + Person(QObject* parent = 0); + ~Person(); + + QString name() const; + void setName(const QString& name); + + int phoneNumber() const; + void setPhoneNumber(const int phoneNumber); + + enum Gender {Male, Female}; + void setGender(Gender gender); + Gender gender() const; + + QDate dob() const; + void setDob(const QDate& dob); + + private: + QString m_name; + int m_phoneNumber; + Gender m_gender; + QDate m_dob; + }; + \endcode + + The following code will serialize an instance of Person to JSON : + + \code + Person person; + person.setName("Flavio"); + person.setPhoneNumber(123456); + person.setGender(Person::Male); + person.setDob(QDate(1982, 7, 12)); + + QVariantMap variant = QObjectHelper::qobject2qvariant(&person); + Serializer serializer; + qDebug() << serializer.serialize( variant); + \endcode + + The generated output will be: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + It's also possible to initialize a QObject using the values stored inside of + a QVariantMap. + + Suppose you have the following JSON data stored into a QString: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + The following code will initialize an already allocated instance of Person + using the JSON values: + \code + Parser parser; + QVariant variant = parser.parse(json); + + Person person; + QObjectHelper::qvariant2qobject(variant.toMap(), &person); + \endcode + + \sa Parser + \sa Serializer + */ + class QJSON_EXPORT QObjectHelper { + public: + QObjectHelper(); + ~QObjectHelper(); + + /** + * This method converts a QObject instance into a QVariantMap. + * + * @param object The QObject instance to be converted. + * @param ignoredProperties Properties that won't be converted. + */ + static QVariantMap qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + + /** + * This method converts a QVariantMap instance into a QObject + * + * @param variant Attributes to assign to the object. + * @param object The QObject instance to update. + */ + static void qvariant2qobject(const QVariantMap& variant, QObject* object); + + private: + Q_DISABLE_COPY(QObjectHelper) + class QObjectHelperPrivate; + QObjectHelperPrivate* const d; + }; +} + +#endif // QOBJECTHELPER_H diff --git a/src/serializer.cpp b/src/serializer.cpp new file mode 100644 index 000000000..25f9bb981 --- /dev/null +++ b/src/serializer.cpp @@ -0,0 +1,444 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "serializer.h" + +#include +#include +#include + +#include + +#ifdef Q_OS_SOLARIS +# ifndef isinf +# include +# define isinf(x) (!finite((x)) && (x)==(x)) +# endif +#endif + +#ifdef _MSC_VER // using MSVC compiler +#include +#endif + +using namespace QJson; + +class Serializer::SerializerPrivate { + public: + SerializerPrivate() : + specialNumbersAllowed(false), + indentMode(QJson::IndentNone), + doublePrecision(6) { + errorMessage.clear(); + } + QString errorMessage; + bool specialNumbersAllowed; + IndentMode indentMode; + int doublePrecision; + QByteArray buildIndent(int spaces); + QByteArray serialize( const QVariant &v, bool *ok, int indentLevel = 0); + QString sanitizeString( QString str ); + QByteArray join( const QList& list, const QByteArray& sep ); +}; + +QByteArray Serializer::SerializerPrivate::join( const QList& list, const QByteArray& sep ) { + QByteArray res; + Q_FOREACH( const QByteArray& i, list ) { + if ( !res.isEmpty() ) + res += sep; + res += i; + } + return res; +} + +QByteArray Serializer::SerializerPrivate::serialize( const QVariant &v, bool *ok, int indentLevel) +{ + QByteArray str; + + if ( ! v.isValid() ) { // invalid or null? + str = "null"; + } else if (( v.type() == QVariant::List ) || ( v.type() == QVariant::StringList )){ // an array or a stringlist? + const QVariantList list = v.toList(); + QList values; + Q_FOREACH( const QVariant& var, list ) + { + QByteArray serializedValue; + + serializedValue = serialize( var, ok, indentLevel+1); + + if ( !*ok ) { + break; + } + switch(indentMode) { + case QJson::IndentFull : + case QJson::IndentMedium : + case QJson::IndentMinimum : + values << serializedValue; + break; + case QJson::IndentCompact : + case QJson::IndentNone : + default: + values << serializedValue.trimmed(); + break; + } + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull ) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; + } + else if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "[\n" + join( values, ",\n" ) + "\n" + indent + "]"; + } + else if (indentMode == QJson::IndentCompact) { + str = "[" + join( values, "," ) + "]"; + } + else { + str = "[ " + join( values, ", " ) + " ]"; + } + + } else if ( v.type() == QVariant::Map ) { // variant is a map? + const QVariantMap vmap = v.toMap(); + QMapIterator it( vmap ); + + if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "{ "; + } + else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + QByteArray nextindent = buildIndent(indentLevel + 1); + str = indent + "{\n" + nextindent; + } + else if (indentMode == QJson::IndentCompact) { + str = "{"; + } + else { + str = "{ "; + } + + QList pairs; + while ( it.hasNext() ) { + it.next(); + indentLevel++; + QByteArray serializedValue = serialize( it.value(), ok, indentLevel); + indentLevel--; + if ( !*ok ) { + break; + } + QByteArray key = sanitizeString( it.key() ).toUtf8(); + QByteArray value = serializedValue.trimmed(); + if (indentMode == QJson::IndentCompact) { + pairs << key + ":" + value; + } else { + pairs << key + " : " + value; + } + } + + if (indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel + 1); + str += join( pairs, ",\n" + indent); + } + else if (indentMode == QJson::IndentCompact) { + str += join( pairs, "," ); + } + else { + str += join( pairs, ", " ); + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + str += "\n" + indent + "}"; + } + else if (indentMode == QJson::IndentCompact) { + str += "}"; + } + else { + str += " }"; + } + + } else if ( v.type() == QVariant::Hash ) { // variant is a hash? + const QVariantHash vhash = v.toHash(); + QHashIterator it( vhash ); + + if (indentMode == QJson::IndentMinimum) { + QByteArray indent = buildIndent(indentLevel); + str = indent + "{ "; + } + else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + QByteArray nextindent = buildIndent(indentLevel + 1); + str = indent + "{\n" + nextindent; + } + else if (indentMode == QJson::IndentCompact) { + str = "{"; + } + else { + str = "{ "; + } + + QList pairs; + while ( it.hasNext() ) { + it.next(); + + QByteArray serializedValue = serialize( it.value(), ok, indentLevel + 1); + + if ( !*ok ) { + break; + } + QByteArray key = sanitizeString( it.key() ).toUtf8(); + QByteArray value = serializedValue.trimmed(); + if (indentMode == QJson::IndentCompact) { + pairs << key + ":" + value; + } else { + pairs << key + " : " + value; + } + } + + if (indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel + 1); + str += join( pairs, ",\n" + indent); + } + else if (indentMode == QJson::IndentCompact) { + str += join( pairs, "," ); + } + else { + str += join( pairs, ", " ); + } + + if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) { + QByteArray indent = buildIndent(indentLevel); + str += "\n" + indent + "}"; + } + else if (indentMode == QJson::IndentCompact) { + str += "}"; + } + else { + str += " }"; + } + + } else { + // Add indent, we may need to remove it later for some layouts + switch(indentMode) { + case QJson::IndentFull : + case QJson::IndentMedium : + case QJson::IndentMinimum : + str += buildIndent(indentLevel); + break; + case QJson::IndentCompact : + case QJson::IndentNone : + default: + break; + } + + if (( v.type() == QVariant::String ) || ( v.type() == QVariant::ByteArray )) { // a string or a byte array? + str = sanitizeString( v.toString() ).toUtf8(); + } else if (( v.type() == QVariant::Double) || ((QMetaType::Type)v.type() == QMetaType::Float)) { // a double or a float? + const double value = v.toDouble(); + #if defined _WIN32 && !defined(Q_OS_SYMBIAN) + const bool special = _isnan(value) || !_finite(value); + #elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_SOLARIS) + const bool special = isnan(value) || isinf(value); + #else + const bool special = std::isnan(value) || std::isinf(value); + #endif + if (special) { + if (specialNumbersAllowed) { + #if defined _WIN32 && !defined(Q_OS_SYMBIAN) + if (_isnan(value)) { + #elif defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_SOLARIS) + if (isnan(value)) { + #else + if (std::isnan(value)) { + #endif + str += "NaN"; + } else { + if (value<0) { + str += '-'; + } + str += "Infinity"; + } + } else { + errorMessage += QLatin1String("Attempt to write NaN or infinity, which is not supported by json\n"); + *ok = false; + } + } else { + str = QByteArray::number( value , 'g', doublePrecision); + if( ! str.contains( "." ) && ! str.contains( "e" ) ) { + str += ".0"; + } + } + } else if ( v.type() == QVariant::Bool ) { // boolean value? + str += ( v.toBool() ? "true" : "false" ); + } else if ( v.type() == QVariant::ULongLong ) { // large unsigned number? + str += QByteArray::number( v.value() ); + } else if ( v.type() == QVariant::UInt ) { // unsigned int number? + str += QByteArray::number( v.value() ); + } else if ( v.canConvert() ) { // any signed number? + str += QByteArray::number( v.value() ); + } else if ( v.canConvert() ) { // unsigned short number? + str += QByteArray::number( v.value() ); + } else if ( v.canConvert() ){ // can value be converted to string? + // this will catch QDate, QDateTime, QUrl, ... + str += sanitizeString( v.toString() ).toUtf8(); + //TODO: catch other values like QImage, QRect, ... + } else { + *ok = false; + errorMessage += QLatin1String("Cannot serialize "); + errorMessage += v.toString(); + errorMessage += QLatin1String(" because type "); + errorMessage += QLatin1String(v.typeName()); + errorMessage += QLatin1String(" is not supported by QJson\n"); + } + } + if ( *ok ) + { + return str; + } + else + return QByteArray(); +} + +QByteArray Serializer::SerializerPrivate::buildIndent(int spaces) +{ + QByteArray indent; + if (spaces < 0) { + spaces = 0; + } + for (int i = 0; i < spaces; i++ ) { + indent += " "; + } + return indent; +} + +QString Serializer::SerializerPrivate::sanitizeString( QString str ) +{ + str.replace( QLatin1String( "\\" ), QLatin1String( "\\\\" ) ); + + // escape unicode chars + QString result; + const ushort* unicode = str.utf16(); + unsigned int i = 0; + + while ( unicode[ i ] ) { + if ( unicode[ i ] < 128 ) { + result.append( QChar( unicode[ i ] ) ); + } + else { + QString hexCode = QString::number( unicode[ i ], 16 ).rightJustified( 4, + QLatin1Char('0') ); + + result.append( QLatin1String ("\\u") ).append( hexCode ); + } + ++i; + } + str = result; + + str.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) ); + str.replace( QLatin1String( "\b" ), QLatin1String( "\\b" ) ); + str.replace( QLatin1String( "\f" ), QLatin1String( "\\f" ) ); + str.replace( QLatin1String( "\n" ), QLatin1String( "\\n" ) ); + str.replace( QLatin1String( "\r" ), QLatin1String( "\\r" ) ); + str.replace( QLatin1String( "\t" ), QLatin1String( "\\t" ) ); + + return QString( QLatin1String( "\"%1\"" ) ).arg( str ); +} + +Serializer::Serializer() + : d( new SerializerPrivate ) +{ +} + +Serializer::~Serializer() { + delete d; +} + +void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok) +{ + Q_ASSERT( io ); + *ok = true; + + if (!io->isOpen()) { + if (!io->open(QIODevice::WriteOnly)) { + d->errorMessage = QLatin1String("Error opening device"); + *ok = false; + return; + } + } + + if (!io->isWritable()) { + d->errorMessage = QLatin1String("Device is not readable"); + io->close(); + *ok = false; + return; + } + + const QByteArray str = serialize( v, ok); + if (*ok && (io->write(str) != str.count())) { + *ok = false; + d->errorMessage = QLatin1String("Something went wrong while writing to IO device"); + } +} + +QByteArray Serializer::serialize( const QVariant &v) +{ + bool ok; + + return serialize(v, &ok); +} + +QByteArray Serializer::serialize( const QVariant &v, bool *ok) +{ + bool _ok = true; + d->errorMessage.clear(); + + if (ok) { + *ok = true; + } else { + ok = &_ok; + } + + return d->serialize(v, ok); +} + +void QJson::Serializer::allowSpecialNumbers(bool allow) { + d->specialNumbersAllowed = allow; +} + +bool QJson::Serializer::specialNumbersAllowed() const { + return d->specialNumbersAllowed; +} + +void QJson::Serializer::setIndentMode(IndentMode mode) { + d->indentMode = mode; +} + +void QJson::Serializer::setDoublePrecision(int precision) { + d->doublePrecision = precision; +} + +IndentMode QJson::Serializer::indentMode() const { + return d->indentMode; +} + +QString QJson::Serializer::errorMessage() const { + return d->errorMessage; +} + diff --git a/src/serializer.h b/src/serializer.h new file mode 100644 index 000000000..48dc9ae98 --- /dev/null +++ b/src/serializer.h @@ -0,0 +1,230 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_SERIALIZER_H +#define QJSON_SERIALIZER_H + +#include "qjson_export.h" + +QT_BEGIN_NAMESPACE +class QIODevice; +class QString; +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + @brief How the indentation should work. + \verbatim + none (default) : + { "foo" : 0, "foo1" : 1, "foo2" : [ { "bar" : 1, "foo" : 0, "foobar" : 0 }, { "bar" : 1, "foo" : 1, "foobar" : 1 } ], "foo3" : [ 1, 2, 3, 4, 5, 6 ] } + + compact : + {"foo":0,"foo1":1,"foo2":[{"bar":1,"foo":0,"foobar":0},{"bar":1,"foo":1,"foobar":1}],"foo3":[1,2,3,4,5,6]} + + minimum : + { "foo" : 0, "foo1" : 1, "foo2" : [ + { "bar" : 1, "foo" : 0, "foobar" : 0 }, + { "bar" : 1, "foo" : 1, "foobar" : 1 } + ], "foo3" : [ + 1, + 2, + 3, + 4, + 5, + 6 + ] } + + medium : + { + "foo" : 0, "foo1" : 1, "foo2" : [ + { + "bar" : 1, "foo" : 0, "foobar" : 0 + }, + { + "bar" : 1, "foo" : 1, "foobar" : 1 + } + ], "foo3" : [ + 1, + 2, + 3, + 4, + 5, + 6 + ] + } + + full : + { + "foo" : 0, + "foo1" : 1, + "foo2" : [ + { + "bar" : 1, + "foo" : 0, + "foobar" : 0 + }, + { + "bar" : 1, + "foo" : 1, + "foobar" : 1 + } + ], + "foo3" : [ + 1, + 2, + 3, + 4, + 5, + 6 + ] + } + + + \endverbatim + */ + enum IndentMode { + IndentNone, + IndentCompact, + IndentMinimum, + IndentMedium, + IndentFull + }; + /** + * @brief Main class used to convert QVariant objects to JSON data. + * + * QVariant objects are converted to a string containing the JSON data. + * + * + * Usage: + * + * \code + * QVariantList people; + * + * QVariantMap bob; + * bob.insert("Name", "Bob"); + * bob.insert("Phonenumber", 123); + * + * QVariantMap alice; + * alice.insert("Name", "Alice"); + * alice.insert("Phonenumber", 321); + * + * people << bob << alice; + * + * QJson::Serializer serializer; + * bool ok; + * QByteArray json = serializer.serialize(people, &ok); + * + * if (ok) { + * qDebug() << json; + * } else { + * qCritical() << "Something went wrong:" << serializer.errorMessage(); + * } + * \endcode + * + * The output will be: + * + * \code + * "[ { "Name" : "Bob", "Phonenumber" : 123 }, + * { "Name" : "Alice", "Phonenumber" : 321 } ]" + * \endcode + * + * It's possible to tune the indentation level of the resulting string. \sa setIndentMode + */ + class QJSON_EXPORT Serializer { + public: + Serializer(); + ~Serializer(); + + /** + * This method generates a textual JSON representation and outputs it to the + * passed in I/O Device. + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * @param out Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true + */ + void serialize( const QVariant& variant, QIODevice* out, bool* ok); + + /** + * This is a method provided for convenience. It turns the passed in in-memory + * representation of the JSON document into a textual one, which is returned. + * If the returned string is empty, the document was empty. If it was null, there + * was a parsing error. + * + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * + * \deprecated This method is going to be removed with the next major release of QJson. + */ + QByteArray serialize( const QVariant& variant); + + /** + * This is a method provided for convenience. It turns the passed in in-memory + * representation of the JSON document into a textual one, which is returned. + * If the returned string is empty, the document was empty. If it was null, there + * was a parsing error. + * + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true + */ + QByteArray serialize( const QVariant& variant, bool *ok); + + /** + * Allow or disallow writing of NaN and/or Infinity (as an extension to QJson) + */ + void allowSpecialNumbers(bool allow); + + /** + * Is Nan and/or Infinity allowed? + */ + bool specialNumbersAllowed() const; + + /** + * set output indentation mode as defined in QJson::IndentMode + */ + void setIndentMode(IndentMode mode = QJson::IndentNone); + + + /** + * set double precision used while converting Double + * \sa QByteArray::number + */ + void setDoublePrecision(int precision); + + /** + * Returns one of the indentation modes defined in QJson::IndentMode + */ + IndentMode indentMode() const; + + /** + * Returns the error message + */ + QString errorMessage() const; + + private: + Q_DISABLE_COPY(Serializer) + class SerializerPrivate; + SerializerPrivate* const d; + }; +} + +#endif // QJSON_SERIALIZER_H diff --git a/src/serializerrunnable.cpp b/src/serializerrunnable.cpp new file mode 100644 index 000000000..b1894a238 --- /dev/null +++ b/src/serializerrunnable.cpp @@ -0,0 +1,62 @@ +#include "serializerrunnable.h" + +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" +#include "serializer.h" + +#include +#include + +using namespace QJson; + +class SerializerRunnable::Private +{ +public: + QVariant json; +}; + +SerializerRunnable::SerializerRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +SerializerRunnable::~SerializerRunnable() +{ + delete d; +} + +void SerializerRunnable::setJsonObject( const QVariant& json ) +{ + d->json = json; +} + +void SerializerRunnable::run() +{ + Serializer serializer; + bool ok; + const QByteArray serialized = serializer.serialize( d->json, &ok); + emit parsingFinished( serialized, ok, serializer.errorMessage() ); +} diff --git a/src/serializerrunnable.h b/src/serializerrunnable.h new file mode 100644 index 000000000..1a3df7c1c --- /dev/null +++ b/src/serializerrunnable.h @@ -0,0 +1,71 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SERIALIZERRUNNABLE_H +#define SERIALIZERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QByteArray; +class QString; +class QVariant; +QT_END_NAMESPACE + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + explicit SerializerRunnable(QObject* parent = 0); + ~SerializerRunnable(); + + /** + * Sets the json object to serialize. + * + * @param json QVariant containing the json representation to be serialized + */ + void setJsonObject( const QVariant& json ); + + /* reimp */ void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the serialization process has been completed + * @param serialized contains the result of the serialization + * @param ok if a serialization error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QByteArray& serialized, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(SerializerRunnable) + class Private; + Private* const d; + }; +} + +#endif // SERIALIZERRUNNABLE_H diff --git a/src/stack.hh b/src/stack.hh new file mode 100644 index 000000000..590accbaf --- /dev/null +++ b/src/stack.hh @@ -0,0 +1,133 @@ +/* A Bison parser, made by GNU Bison 2.7. */ + +/* Stack handling for Bison parsers in C++ + + Copyright (C) 2002-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file stack.hh + ** Define the yy::stack class. + */ + +#ifndef YY_YY_STACK_HH_INCLUDED +# define YY_YY_STACK_HH_INCLUDED + +# include + + +namespace yy { +/* Line 34 of stack.hh */ +#line 47 "stack.hh" + template > + class stack + { + public: + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; + + stack () : seq_ () + { + } + + stack (unsigned int n) : seq_ (n) + { + } + + inline + T& + operator [] (unsigned int i) + { + return seq_[i]; + } + + inline + const T& + operator [] (unsigned int i) const + { + return seq_[i]; + } + + inline + void + push (const T& t) + { + seq_.push_front (t); + } + + inline + void + pop (unsigned int n = 1) + { + for (; n; --n) + seq_.pop_front (); + } + + inline + unsigned int + height () const + { + return seq_.size (); + } + + inline const_iterator begin () const { return seq_.rbegin (); } + inline const_iterator end () const { return seq_.rend (); } + + private: + S seq_; + }; + + /// Present a slice of the top of a stack. + template > + class slice + { + public: + slice (const S& stack, unsigned int range) + : stack_ (stack) + , range_ (range) + { + } + + inline + const T& + operator [] (unsigned int i) const + { + return stack_[range_ - i]; + } + + private: + const S& stack_; + unsigned int range_; + }; + +} // yy +/* Line 116 of stack.hh */ +#line 132 "stack.hh" + +#endif /* !YY_YY_STACK_HH_INCLUDED */ diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..f3c7a7c5d --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +Makefile diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..dab0cdca8 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,15 @@ +IF (Qt5Core_FOUND) + FIND_PACKAGE( Qt5Test REQUIRED ) + + INCLUDE_DIRECTORIES(${Qt5Test_INCLUDE_DIRS}) + ADD_DEFINITIONS(${Qt5Test_DEFINITIONS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Test_EXECUTABLE_COMPILE_FLAGS}") + + SET (TEST_LIBRARIES ${Qt5Test_LIBRARIES}) +ENDIF() + +ADD_SUBDIRECTORY(cmdline_tester) +ADD_SUBDIRECTORY(parser) +ADD_SUBDIRECTORY(scanner) +ADD_SUBDIRECTORY(qobjecthelper) +ADD_SUBDIRECTORY(serializer) diff --git a/tests/benchmarks/CMakeLists.txt b/tests/benchmarks/CMakeLists.txt new file mode 100644 index 000000000..824b56ec3 --- /dev/null +++ b/tests/benchmarks/CMakeLists.txt @@ -0,0 +1,38 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + parsingbenchmark + qlocalevsstrtod_l +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/benchmarks/parsingbenchmark.cpp b/tests/benchmarks/parsingbenchmark.cpp new file mode 100644 index 000000000..51cbd8606 --- /dev/null +++ b/tests/benchmarks/parsingbenchmark.cpp @@ -0,0 +1,55 @@ +/* This file is part of QJson + * + * Copyright (C) 2014 Sune Vuorela + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +class ParsingBenchmark: public QObject { + Q_OBJECT + private Q_SLOTS: + void benchmark(); +}; + +void ParsingBenchmark::benchmark() { + QString path = QFINDTESTDATA("largefile.json"); + + QVERIFY(QFile::exists(path)); + + QFile f(path); + QVERIFY(f.open(QIODevice::ReadOnly)); + + QByteArray data = f.readAll(); + + QVariant result; + + QJson::Parser parser; + QBENCHMARK { + result = parser.parse(data); + } + + Q_UNUSED(result); +} + + +QTEST_MAIN(ParsingBenchmark) + +#include "parsingbenchmark.moc" diff --git a/tests/benchmarks/qlocalevsstrtod_l.cpp b/tests/benchmarks/qlocalevsstrtod_l.cpp new file mode 100644 index 000000000..9bda9d454 --- /dev/null +++ b/tests/benchmarks/qlocalevsstrtod_l.cpp @@ -0,0 +1,70 @@ +/* This file is part of QJson + * + * Copyright (C) 2014 Sune Vuorela + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include + +class QLocaleVsStrtod_l : public QObject { + Q_OBJECT + private Q_SLOTS: + void benchmark(); + void benchmark_data(); + +}; + +void QLocaleVsStrtod_l::benchmark() { + QFETCH(bool, useQLocale); + QList l; + l << strdup("0.123") << strdup("0.947834") << strdup("8.8373") << strdup("884.82921"); + + double result; + + if(useQLocale) { + QLocale c(QLocale::C); + QBENCHMARK { + Q_FOREACH(const char* str, l) { + result = c.toDouble(QString(str)); + } + } + } else { + locale_t c = newlocale(LC_NUMERIC_MASK, "C", NULL); + QBENCHMARK { + Q_FOREACH(const char* str, l) { + result = strtod_l(str, NULL, c); + } + } + } + + + Q_FOREACH(char* str, l) { + free(str); + } +} + +void QLocaleVsStrtod_l::benchmark_data() { + QTest::addColumn("useQLocale"); + + QTest::newRow("using QLocale") << true; + QTest::newRow("using strtod_l") << false; +} + +QTEST_MAIN(QLocaleVsStrtod_l); +#include "qlocalevsstrtod_l.moc" diff --git a/tests/cmdline_tester/.gitignore b/tests/cmdline_tester/.gitignore new file mode 100644 index 000000000..1347175f2 --- /dev/null +++ b/tests/cmdline_tester/.gitignore @@ -0,0 +1,4 @@ +Makefile +*.o +*.moc +cmdline_tester diff --git a/tests/cmdline_tester/CMakeLists.txt b/tests/cmdline_tester/CMakeLists.txt new file mode 100644 index 000000000..c7cf4cd0b --- /dev/null +++ b/tests/cmdline_tester/CMakeLists.txt @@ -0,0 +1,35 @@ +##### Probably don't want to edit below this line ##### + +IF (WIN32 AND Qt5Core_FOUND) + FIND_PACKAGE( Qt5Widgets REQUIRED ) + + INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) + ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") +ENDIF() + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +ADD_EXECUTABLE( + cmdline_tester + cmdline_tester.cpp + cmdlineparser.cpp +) + +TARGET_LINK_LIBRARIES( + cmdline_tester + ${QT_LIBRARIES} + ${Qt5Widgets_LIBRARIES} + qjson +) diff --git a/tests/cmdline_tester/cmdline_tester.cpp b/tests/cmdline_tester/cmdline_tester.cpp new file mode 100644 index 000000000..81289f12d --- /dev/null +++ b/tests/cmdline_tester/cmdline_tester.cpp @@ -0,0 +1,99 @@ +/* This file is part of QJson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "cmdlineparser.h" + +using namespace QJson; + +int main(int argc, char *argv[]) { + QCoreApplication app (argc, argv); + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + QTextCodec *codec = QTextCodec::codecForName("UTF-8"); + QTextCodec::setCodecForCStrings(codec); +#endif + + QTime time; + int duration; + + + CmdLineParser cmd (app.arguments()); + CmdLineParser::Result res = cmd.parse(); + if (res == CmdLineParser::Help) + return 0; + else if (res == CmdLineParser::Error) + return -1; + + QString filename = cmd.file(); + if (!QFile::exists ( filename )) { + qCritical ("The file you specified doesn't exist!"); + exit (1); + } + + Parser parser; + bool ok; + + QFile file (filename); + time.start(); + QVariant data = parser.parse (&file, &ok); + duration = time.elapsed(); + if (!ok) { + qCritical("%s:%i - Error: %s", filename.toLatin1().data(), parser.errorLine(), qPrintable(parser.errorString())); + exit (1); + } + else { + qDebug() << "Parsing of" << filename << "took" << duration << "ms"; + if (!cmd.quiet()) + qDebug() << data; + } + + if (cmd.serialize()) { + // serializer tests + qDebug() << "Serializing... "; + QJson::Serializer serializer; + serializer.setIndentMode(cmd.indentationMode()); + time.start(); + QByteArray b = serializer.serialize(data, &ok); + if (!ok) { + qCritical() << "Serialization failed:" << serializer.errorMessage(); + exit(1); + } else { + duration = time.elapsed(); + qDebug() << "Serialization took:" << duration << "ms"; + if (!cmd.quiet()) + qDebug() << b; + } + } + + qDebug() << "JOB DONE, BYE"; + return 0; +} + diff --git a/tests/cmdline_tester/cmdlineparser.cpp b/tests/cmdline_tester/cmdlineparser.cpp new file mode 100644 index 000000000..289fe0d4a --- /dev/null +++ b/tests/cmdline_tester/cmdlineparser.cpp @@ -0,0 +1,170 @@ +/* This file is part of qjson + * + * Copyright (C) 2010 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#ifdef Q_OS_WIN +//using Qt5 +#ifdef QT_WIDGETS_LIB +#include +#else +//using Qt4 +#include +#endif +#endif + +#include "cmdlineparser.h" + +using namespace QJson; + +const QString CmdLineParser::m_helpMessage = QLatin1String( + "Usage: cmdline_tester [options] file\n\n" + "This program converts the json data read from 'file' to a QVariant object.\n" + "--quiet Do not print output generated by parser and serializer.\n" + "--serialize Parses the QVariant object back to json.\n" + "--indent Sets the indentation level used by the 'serialize' option.\n" + " Allowed values:\n" + " - none [default]\n" + " - compact\n" + " - minimum\n" + " - medium\n" + " - full\n" + "--help Displays this help.\n" + ); + + +CmdLineParser::CmdLineParser(const QStringList &arguments) + : m_pos(0), + m_indentationMode(IndentNone), + m_serialize(false), + m_quiet(false) +{ + for (int i = 1; i < arguments.count(); ++i) { + const QString &arg = arguments.at(i); + m_arguments.append(arg); + } +} + +CmdLineParser::Result CmdLineParser::parse() +{ + bool showHelp = false; + + while (m_error.isEmpty() && hasMoreArgs()) { + const QString &arg = nextArg(); + if (arg.toLower() == QLatin1String("--indent")) + handleSetIndentationMode(); + else if (arg.toLower() == QLatin1String("--help")) + showHelp = true; + else if (arg.toLower() == QLatin1String("--serialize")) + m_serialize = true; + else if (arg.toLower() == QLatin1String("--quiet")) + m_quiet = true; + else if (!arg.startsWith(QLatin1String("--"))) + m_file = arg; + else + m_error = QString(QLatin1String("Unknown option: %1")).arg(arg); + } + + if (m_file.isEmpty()) { + m_error = QLatin1String("You have to specify the file containing the json data."); + } + + if (!m_error.isEmpty()) { + showMessage(m_error + QLatin1String("\n\n\n") + m_helpMessage, true); + return Error; + } else if (showHelp) { + showMessage(m_helpMessage, false); + return Help; + } + return Ok; +} + +bool CmdLineParser::hasMoreArgs() const +{ + return m_pos < m_arguments.count(); +} + +const QString &CmdLineParser::nextArg() +{ + Q_ASSERT(hasMoreArgs()); + return m_arguments.at(m_pos++); +} + +void CmdLineParser::handleSetIndentationMode() +{ + if (hasMoreArgs()) { + const QString &indentationMode = nextArg(); + if (indentationMode.compare(QLatin1String("none"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentNone; + else if (indentationMode.compare(QLatin1String("compact"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentCompact; + else if (indentationMode.compare(QLatin1String("minimum"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentMinimum; + else if (indentationMode.compare(QLatin1String("medium"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentMedium; + else if (indentationMode.compare(QLatin1String("full"), Qt::CaseInsensitive) == 0) + m_indentationMode = IndentFull; + else + m_error = QString(QLatin1String("Unknown indentation mode '%1'.")). + arg(indentationMode); + } else { + m_error = QLatin1String("Missing indentation level."); + } +} + +void CmdLineParser::showMessage(const QString &msg, bool error) +{ +#ifdef Q_OS_WIN + QString message = QLatin1String("
") % msg % QLatin1String("
"); + if (error) + QMessageBox::critical(0, QLatin1String("Error"), message); + else + QMessageBox::information(0, QLatin1String("Notice"), message); +#else + fprintf(error ? stderr : stdout, "%s\n", qPrintable(msg)); +#endif +} + +void CmdLineParser::setIndentationMode(const IndentMode &mode) +{ + m_indentationMode = mode; +} + +IndentMode CmdLineParser::indentationMode() const +{ + return m_indentationMode; +} + +QString CmdLineParser::file() const +{ + return m_file; +} + +bool CmdLineParser::serialize() +{ + return m_serialize; +} + +bool CmdLineParser::quiet() +{ + return m_quiet; +} + diff --git a/tests/cmdline_tester/cmdlineparser.h b/tests/cmdline_tester/cmdlineparser.h new file mode 100644 index 000000000..994a2692f --- /dev/null +++ b/tests/cmdline_tester/cmdlineparser.h @@ -0,0 +1,64 @@ +/* This file is part of qjson + * + * Copyright (C) 2010 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef CMDLINEPARSER_H +#define CMDLINEPARSER_H + +#include +#include + +#include + +namespace QJson { + class CmdLineParser + { + public: + enum Result {Ok, Help, Error}; + + CmdLineParser(const QStringList &arguments); + Result parse(); + + void setIndentationMode(const IndentMode &mode); + IndentMode indentationMode() const; + QString helpFile() const; + QString file() const; + bool serialize(); + bool quiet(); + + void showMessage(const QString &msg, bool error); + + private: + bool hasMoreArgs() const; + const QString &nextArg(); + void handleSetIndentationMode(); + + QStringList m_arguments; + int m_pos; + IndentMode m_indentationMode; + QString m_file; + bool m_serialize; + bool m_quiet; + static const QString m_helpMessage; + QString m_error; + }; +} + +#endif + diff --git a/tests/cmdline_tester/example.txt b/tests/cmdline_tester/example.txt new file mode 100644 index 000000000..eacfbf5e6 --- /dev/null +++ b/tests/cmdline_tester/example.txt @@ -0,0 +1,22 @@ +{ + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": ["GML", "XML"] + }, + "GlossSee": "markup" + } + } + } + } +} diff --git a/tests/parser/.gitignore b/tests/parser/.gitignore new file mode 100644 index 000000000..46e5733e2 --- /dev/null +++ b/tests/parser/.gitignore @@ -0,0 +1,4 @@ +Makefile +*.o +*.moc +parser diff --git a/tests/parser/CMakeLists.txt b/tests/parser/CMakeLists.txt new file mode 100644 index 000000000..bd86cee9b --- /dev/null +++ b/tests/parser/CMakeLists.txt @@ -0,0 +1,46 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + testparser +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/parser/testparser.cpp b/tests/parser/testparser.cpp new file mode 100644 index 000000000..e1923a7f3 --- /dev/null +++ b/tests/parser/testparser.cpp @@ -0,0 +1,456 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include + +#include + +#include +#include + +#include + +class TestParser: public QObject +{ + Q_OBJECT + private slots: + void parseNonAsciiString(); + void parseSimpleObject(); + void parseEmptyObject(); + void parseEmptyValue(); + void parseUrl(); + void parseMultipleObject(); + + void parseSimpleArray(); + void parseInvalidObject(); + void parseInvalidObject_data(); + void parseMultipleArray(); + + void reuseSameParser(); + + void testTrueFalseNullValues(); + void testEscapeChars(); + void testNumbers(); + void testNumbers_data(); + void testDoubleParsingWithDifferentLocale(); + void testTopLevelValues(); + void testTopLevelValues_data(); + void testReadWrite(); + void testReadWrite_data(); +}; + +Q_DECLARE_METATYPE(QVariant) +Q_DECLARE_METATYPE(QVariant::Type) + +using namespace QJson; + +void TestParser::parseSimpleObject() { + QByteArray json = "{\"foo\":\"bar\"}"; + QVariantMap map; + map.insert (QLatin1String("foo"), QLatin1String("bar")); + QVariant expected(map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseEmptyObject() { + QByteArray json = "{}"; + QVariantMap map; + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseEmptyValue() { + QByteArray json = "{\"value\": \"\"}"; + + QVariantMap map; + map.insert (QLatin1String("value"), QString(QLatin1String(""))); + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); + QVERIFY (result.toMap().value(QLatin1String("value")).type() == QVariant::String); + + QString value = result.toMap().value(QLatin1String("value")).toString(); + QVERIFY (value.isEmpty()); +} + +void TestParser::parseInvalidObject() { + QFETCH(QByteArray, json); + + Parser parser; + bool ok; + parser.parse (json, &ok); + QVERIFY (!ok); + QVERIFY(!parser.errorString().isEmpty()); +} + +void TestParser::parseInvalidObject_data() { + QTest::addColumn("json"); + + QTest::newRow("unclosed object") << QByteArray("{\"foo\":\"bar\""); + QTest::newRow("infinum (disallow") << QByteArray("Infinum"); + QTest::newRow("Nan (disallow") << QByteArray("NaN"); + QTest::newRow("no data") << QByteArray(""); +} + + +void TestParser::parseNonAsciiString() { + QByteArray json = "{\"artist\":\"Queensr\\u00ffche\"}"; + QVariantMap map; + + QChar unicode_char (0x00ff); + QString unicode_string; + unicode_string.setUnicode(&unicode_char, 1); + unicode_string = QLatin1String("Queensr") + unicode_string + QLatin1String("che"); + + map.insert (QLatin1String("artist"), unicode_string); + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseMultipleObject() { + //put also some extra spaces inside the json string + QByteArray json = "{ \"foo\":\"bar\",\n\"number\" : 51.3 , \"array\":[\"item1\", 123]}"; + QVariantMap map; + map.insert (QLatin1String("foo"), QLatin1String("bar")); + map.insert (QLatin1String("number"), 51.3); + QVariantList list; + list.append (QLatin1String("item1")); + list.append (QLatin1String("123")); + map.insert (QLatin1String("array"), list); + QVariant expected (map); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); + QVERIFY (result.toMap().value(QLatin1String("number")).canConvert()); + QVERIFY (result.toMap().value(QLatin1String("array")).canConvert()); +} + +void TestParser::parseUrl(){ + //"http:\/\/www.last.fm\/venue\/8926427" + QByteArray json = "[\"http:\\/\\/www.last.fm\\/venue\\/8926427\"]"; + QVariantList list; + list.append (QVariant(QLatin1String("http://www.last.fm/venue/8926427"))); + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + + void TestParser::parseSimpleArray() { + QByteArray json = "[\"foo\",\"bar\"]"; + QVariantList list; + list.append (QLatin1String("foo")); + list.append (QLatin1String("bar")); + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::parseMultipleArray() { + //put also some extra spaces inside the json string + QByteArray json = "[ {\"foo\":\"bar\"},\n\"number\",51.3 , [\"item1\", 123]]"; + QVariantMap map; + map.insert (QLatin1String("foo"), QLatin1String("bar")); + + QVariantList array; + array.append (QLatin1String("item1")); + array.append (123); + + QVariantList list; + list.append (map); + list.append (QLatin1String("number")); + list.append (QLatin1String("51.3")); + list.append ((QVariant) array); + + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); +} + +void TestParser::testTrueFalseNullValues() { + QByteArray json = "[true,false, null, {\"foo\" : true}]"; + QVariantList list; + list.append (QVariant(true)); + list.append (QVariant(false)); + list.append (QVariant()); + QVariantMap map; + map.insert (QLatin1String("foo"), true); + list.append (map); + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result, expected); + QCOMPARE (result.toList().at(0).toBool(), true); + QCOMPARE (result.toList().at(1).toBool(), false); + QVERIFY (result.toList().at(2).isNull()); +} + +void TestParser::testEscapeChars() { + QByteArray json = "[\"\\b \\f \\n \\r \\t \", \" \\\\ \\/ \\\\\", \"http:\\/\\/foo.com\"]"; + + QVariantList list; + list.append (QLatin1String("\b \f \n \r \t ")); + list.append (QLatin1String(" \\ / \\")); + list.append (QLatin1String("http://foo.com")); + + QVariant expected (list); + + Parser parser; + bool ok; + QVariant result = parser.parse (json, &ok); + QVERIFY (ok); + QCOMPARE(result.toList().size(), expected.toList().size() ); + QCOMPARE(result, expected); +} + +void TestParser::testNumbers() { + QFETCH(QByteArray, input); + QFETCH(QVariant, expected); + QFETCH(QVariant::Type, type); + + Parser parser; + bool ok; + QVariant result = parser.parse ('[' + input + ']', &ok); + QVERIFY (ok); + + QVariant value = result.toList().at(0); + QCOMPARE(value, expected); + QCOMPARE( value.type(), type); +} + +void TestParser::testNumbers_data() { + QTest::addColumn( "input" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "type" ); + + QByteArray input; + QVariant output; + + // simple ulonglong + input = QByteArray("1"); + output = QVariant(QVariant::ULongLong); + output.setValue(1); + + QTest::newRow("simple ulonglong") << input << output << QVariant::ULongLong; + + // big number + input = QByteArray("12345678901234567890"); + output = QVariant(QVariant::ULongLong); + output.setValue(12345678901234567890ull); + + QTest::newRow("big number") << input << output << QVariant::ULongLong; + + // simple double + input = QByteArray("2.004"); + output = QVariant(QVariant::Double); + output.setValue(2.004); + + QTest::newRow("simple double") << input << output << QVariant::Double; + + // negative int + input = QByteArray("-100"); + output = QVariant(QVariant::LongLong); + output.setValue(-100); + + QTest::newRow("negative int") << input << output << QVariant::LongLong; + + // negative double + input = QByteArray("-3.4"); + output = QVariant(QVariant::Double); + output.setValue(-3.4); + + QTest::newRow("negative double") << input << output << QVariant::Double; +} + +void TestParser::testTopLevelValues() { + QFETCH(QByteArray, input); + QFETCH(QVariant, expected); + QFETCH(QVariant::Type, type); + + Parser parser; + bool ok; + QVariant result = parser.parse (input, &ok); + QVERIFY (ok); + + QCOMPARE(result, expected); + QCOMPARE(result.type(), type); +} + +void TestParser::testTopLevelValues_data() { + QTest::addColumn( "input" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "type" ); + + QByteArray input; + QVariant output; + + // string + input = QByteArray("\"foo bar\""); + output = QVariant(QLatin1String("foo bar")); + QTest::newRow("string") << input << output << QVariant::String; + + // number + input = QByteArray("2.4"); + output = QVariant(QVariant::Double); + output.setValue(2.4); + QTest::newRow("simple double") << input << output << QVariant::Double; + + // boolean + input = QByteArray("true"); + output = QVariant(QVariant::Bool); + output.setValue(true); + QTest::newRow("bool") << input << output << QVariant::Bool; + + // null + input = QByteArray("null"); + output = QVariant(); + QTest::newRow("null") << input << output << QVariant::Invalid; + + // array + input = QByteArray("[1,2,3]"); + QVariantList list; + list << QVariant(1) << QVariant(2) << QVariant(3); + output = QVariant(QVariant::List); + output.setValue(list); + QTest::newRow("array") << input << output << QVariant::List; + + // object + input = QByteArray("{\"foo\" : \"bar\"}"); + QVariantMap map; + map.insert(QLatin1String("foo"), QLatin1String("bar")); + output = QVariant(QVariant::Map); + output.setValue(map); + QTest::newRow("object") << input << output << QVariant::Map; +} + +void TestParser::testDoubleParsingWithDifferentLocale() { + QLocale oldLocale; + QLocale itLocale(QLatin1String("it_IT.utf8")); + + QCOMPARE(itLocale.name(), QLatin1String("it_IT") ); + + // the Italian locale uses ',' as digit separator. + QLocale::setDefault(itLocale); + + Parser parser; + bool ok; + QVariant result = parser.parse ("12.3", &ok); + QVERIFY (ok); + + QCOMPARE(result.toDouble(), 12.3); + + QLocale::setDefault(oldLocale); +} + +void TestParser::testReadWrite() +{ + QFETCH( QVariant, variant ); + Serializer serializer; + bool ok; + + QByteArray json = serializer.serialize(variant, &ok); + QVERIFY(ok); + + Parser parser; + QVariant result = parser.parse( json, &ok ); + QVERIFY(ok); + QCOMPARE( result, variant ); +} + +void TestParser::testReadWrite_data() +{ + QTest::addColumn( "variant" ); + + // array tests + QTest::newRow( "empty array" ) << QVariant(QVariantList()); + + // basic array + QVariantList list; + list << QString(QLatin1String("hello")); + list << 12; + QTest::newRow( "basic array" ) << QVariant(list); + + // simple map + QVariantMap map; + map[QString(QLatin1String("Name"))] = 32; + QTest::newRow( "complicated array" ) << QVariant(map); +} + +void TestParser::reuseSameParser() +{ + Parser parser; + bool ok; + + parser.parse ("12.3", &ok); + QVERIFY (ok); + + parser.parse ("wrong entry", &ok); + QVERIFY (!ok); + + parser.parse ("12.3", &ok); + QVERIFY (ok); +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestParser) +#include "moc_testparser.cxx" +#else +QTEST_GUILESS_MAIN(TestParser) +#include "testparser.moc" +#endif diff --git a/tests/qobjecthelper/.gitignore b/tests/qobjecthelper/.gitignore new file mode 100644 index 000000000..e64e23248 --- /dev/null +++ b/tests/qobjecthelper/.gitignore @@ -0,0 +1,5 @@ +Makefile +*.o +*.moc +moc_* +qobjecthelper diff --git a/tests/qobjecthelper/CMakeLists.txt b/tests/qobjecthelper/CMakeLists.txt new file mode 100644 index 000000000..d1636e6fb --- /dev/null +++ b/tests/qobjecthelper/CMakeLists.txt @@ -0,0 +1,55 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET (qjson_test_support_SRCS person.cpp) +IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(qjson_test_support_MOC_SRCS person.h) +ENDIF() + +ADD_LIBRARY (qjson_test_support STATIC ${qjson_test_support_SRCS} + ${qjson_test_support_MOC_SRCS}) + +SET( UNIT_TESTS + testqobjecthelper +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + qjson_test_support + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/qobjecthelper/person.cpp b/tests/qobjecthelper/person.cpp new file mode 100644 index 000000000..23291798b --- /dev/null +++ b/tests/qobjecthelper/person.cpp @@ -0,0 +1,75 @@ +#include "person.h" + +Person::Person(QObject* parent) + : QObject(parent), + m_name(), + m_phoneNumber(0), + m_gender(Female), + m_luckyNumber(0) +{ +} + +Person::~Person() +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString& name) +{ + m_name = name; +} + +int Person::phoneNumber() const +{ + return m_phoneNumber; +} + +void Person::setPhoneNumber(const int phoneNumber) +{ + m_phoneNumber = phoneNumber; +} + +void Person::setGender(Gender gender) +{ + m_gender = gender; +} + +Person::Gender Person::gender() const +{ + return m_gender; +} + +QDate Person::dob() const +{ + return m_dob; +} + +void Person::setDob(const QDate& dob) +{ + m_dob = dob; +} + +QVariant Person::customField() const +{ + return m_customField; +} + +void Person::setCustomField(const QVariant& customField) +{ + m_customField = customField; +} + +const quint16 Person::luckyNumber() const +{ + return m_luckyNumber; +} + +void Person::setLuckyNumber(const quint16 luckyNumber) +{ + m_luckyNumber = luckyNumber; +} + diff --git a/tests/qobjecthelper/person.h b/tests/qobjecthelper/person.h new file mode 100644 index 000000000..3026bf782 --- /dev/null +++ b/tests/qobjecthelper/person.h @@ -0,0 +1,73 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PERSON_H +#define PERSON_H + +#include +#include +#include +#include + +class Person : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) + Q_PROPERTY(Gender gender READ gender WRITE setGender) + Q_PROPERTY(QDate dob READ dob WRITE setDob) + Q_PROPERTY(QVariant customField READ customField WRITE setCustomField) + Q_PROPERTY(quint16 luckyNumber READ luckyNumber WRITE setLuckyNumber) + Q_ENUMS(Gender) + + public: + Person(QObject* parent = 0); + ~Person(); + + QString name() const; + void setName(const QString& name); + + int phoneNumber() const; + void setPhoneNumber(const int phoneNumber); + + enum Gender {Male, Female}; + void setGender(Gender gender); + Gender gender() const; + + QDate dob() const; + void setDob(const QDate& dob); + + QVariant customField() const; + void setCustomField(const QVariant& customField); + + const quint16 luckyNumber() const; + void setLuckyNumber(const quint16 luckyNumber); + + private: + QString m_name; + int m_phoneNumber; + Gender m_gender; + QDate m_dob; + QVariant m_customField; + quint16 m_luckyNumber; +}; + +#endif diff --git a/tests/qobjecthelper/testqobjecthelper.cpp b/tests/qobjecthelper/testqobjecthelper.cpp new file mode 100644 index 000000000..2abb9e91e --- /dev/null +++ b/tests/qobjecthelper/testqobjecthelper.cpp @@ -0,0 +1,126 @@ + +/* This file is part of QJson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include + +#include + +#include +#include +#include + +#include "person.h" + +class TestQObjectHelper: public QObject +{ + Q_OBJECT + private slots: + void testQObject2QVariant(); + void testQVariant2QObject(); +}; + +using namespace QJson; + +void TestQObjectHelper::testQObject2QVariant() +{ + QString name = QLatin1String("Flavio Castelli"); + int phoneNumber = 123456; + Person::Gender gender = Person::Male; + QDate dob (1982, 7, 12); + QVariantList nicknames; + nicknames << QLatin1String("nickname1") << QLatin1String("nickname2"); + quint16 luckyNumber = 123; + + Person person; + person.setName(name); + person.setPhoneNumber(phoneNumber); + person.setGender(gender); + person.setDob(dob); + person.setCustomField(nicknames); + person.setLuckyNumber(luckyNumber); + + QVariantMap expected; + expected[QLatin1String("name")] = QVariant(name); + expected[QLatin1String("phoneNumber")] = QVariant(phoneNumber); + expected[QLatin1String("gender")] = QVariant(gender); + expected[QLatin1String("dob")] = QVariant(dob); + expected[QLatin1String("customField")] = nicknames; + expected[QLatin1String("luckyNumber")] = luckyNumber; + + QVariantMap result = QObjectHelper::qobject2qvariant(&person); + QCOMPARE(result, expected); +} + +void TestQObjectHelper::testQVariant2QObject() +{ + bool ok; + QString name = QLatin1String("Flavio Castelli"); + int phoneNumber = 123456; + Person::Gender gender = Person::Male; + QDate dob (1982, 7, 12); + QVariantList nicknames; + nicknames << QLatin1String("nickname1") << QLatin1String("nickname2"); + quint16 luckyNumber = 123; + + Person expected_person; + expected_person.setName(name); + expected_person.setPhoneNumber(phoneNumber); + expected_person.setGender(gender); + expected_person.setDob(dob); + expected_person.setCustomField(nicknames); + expected_person.setLuckyNumber(luckyNumber); + + QVariantMap variant = QObjectHelper::qobject2qvariant(&expected_person); + + Serializer serializer; + QByteArray json = serializer.serialize(variant, &ok); + qDebug() << "json is" << json; + QVERIFY(ok); + + Parser parser; + QVariant parsedVariant = parser.parse(json,&ok); + QVERIFY(ok); + qDebug() << parsedVariant; + QVERIFY(parsedVariant.canConvert(QVariant::Map)); + + Person person; + QCOMPARE(Person::Female, person.gender()); + QObjectHelper::qvariant2qobject(parsedVariant.toMap(), &person); + + QCOMPARE(person.name(), name); + QCOMPARE(person.phoneNumber(), phoneNumber); + QCOMPARE(person.gender(), gender); + QCOMPARE(person.dob(), dob); + QCOMPARE(person.customField(), QVariant(nicknames)); + QCOMPARE(person.luckyNumber(), luckyNumber); +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestQObjectHelper) +#include "moc_testqobjecthelper.cxx" +#else +QTEST_GUILESS_MAIN(TestQObjectHelper) +#include "testqobjecthelper.moc" +#endif diff --git a/tests/scanner/CMakeLists.txt b/tests/scanner/CMakeLists.txt new file mode 100644 index 000000000..185231e6b --- /dev/null +++ b/tests/scanner/CMakeLists.txt @@ -0,0 +1,47 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../src + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + testscanner +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/scanner/testscanner.cpp b/tests/scanner/testscanner.cpp new file mode 100644 index 000000000..456c12fe7 --- /dev/null +++ b/tests/scanner/testscanner.cpp @@ -0,0 +1,256 @@ +/* This file is part of QJson + * + * Copyright (C) 2013 Silvio Moioli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include + +#include + +#include "json_scanner.h" +#include "json_parser.hh" +#include "location.hh" + +#define TOKEN(type) (int)yy::json_parser::token::type + +class TestScanner: public QObject +{ + Q_OBJECT + private slots: + void scanClosedDevice(); + void scanTokens(); + void scanTokens_data(); + void scanSpecialNumbers(); + void scanSpecialNumbers_data(); +}; + +Q_DECLARE_METATYPE(QVariant) +Q_DECLARE_METATYPE(QVariant::Type) + +using namespace QJson; + +void TestScanner::scanClosedDevice() { + QBuffer buffer; + int expectedResult = -1; + + JSonScanner scanner(&buffer); + QVariant yylval; + yy::location location; + int result = scanner.yylex(&yylval, &location); + QCOMPARE(result, expectedResult); +} + +void TestScanner::scanTokens() { + QFETCH(QByteArray, input); + QFETCH(bool, allowSpecialNumbers); + QFETCH(bool, skipFirstToken); + QFETCH(int, expectedResult); + QFETCH(QVariant, expectedYylval); + QFETCH(int, expectedLocationBeginLine); + QFETCH(int, expectedLocationBeginColumn); + QFETCH(int, expectedLocationEndLine); + QFETCH(int, expectedLocationEndColumn); + + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(input); + buffer.seek(0); + JSonScanner scanner(&buffer); + scanner.allowSpecialNumbers(allowSpecialNumbers); + + QVariant yylval; + yy::position position(YY_NULL, 1, 0); + yy::location location(position, position); + int result = scanner.yylex(&yylval, &location); + + if (skipFirstToken) { + result = scanner.yylex(&yylval, &location); + } + + QCOMPARE(result, expectedResult); + QCOMPARE(yylval, expectedYylval); + QCOMPARE(location.begin.line, (uint)expectedLocationBeginLine); + QCOMPARE(location.begin.column, (uint)expectedLocationBeginColumn); + QCOMPARE(location.end.line, (uint)expectedLocationEndLine); + QCOMPARE(location.end.column, (uint)expectedLocationEndColumn); +} + +void TestScanner::scanTokens_data() { + QTest::addColumn("input"); + QTest::addColumn("allowSpecialNumbers"); + QTest::addColumn("skipFirstToken"); + QTest::addColumn("expectedResult"); + QTest::addColumn("expectedYylval"); + QTest::addColumn("expectedLocationBeginLine"); + QTest::addColumn("expectedLocationBeginColumn"); + QTest::addColumn("expectedLocationEndLine"); + QTest::addColumn("expectedLocationEndColumn"); + + QTest::newRow("empty string") << QByteArray("") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 0; + + QTest::newRow("carriage return") << QByteArray("\r") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 2 << 1; + QTest::newRow("new line") << QByteArray("\n") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 2 << 1; + QTest::newRow("formfeed") << QByteArray("\f") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("vertical tab") << QByteArray("\v") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("space") << QByteArray(" ") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("tab") << QByteArray("\t") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("all spaces") << QByteArray("\r\n\f\v \t") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 3 << 5; + + QTest::newRow("true") << QByteArray("true") << true << false << TOKEN(TRUE_VAL) << QVariant(true) << 1 << 0 << 1 << 4; + QTest::newRow("false") << QByteArray("false") << true << false << TOKEN(FALSE_VAL) << QVariant(false) << 1 << 0 << 1 << 5; + QTest::newRow("null") << QByteArray("null") << true << false << TOKEN(NULL_VAL) << QVariant() << 1 << 0 << 1 << 4; + + QTest::newRow("alphabetic string") << QByteArray("\"abcde\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("abcde")) << 1 << 0 << 1 << 2; + QTest::newRow("ecaped string") << QByteArray("\"abcde\\b\\f\\n\\r\\t\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("abcde\b\f\n\r\t")) << 1 << 0 << 1 << 2; + QTest::newRow("invalid ecaped string") << QByteArray("\"\\x\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("x")) << 1 << 0 << 1 << 2; + QTest::newRow("escaped unicode sequence") << QByteArray("\"\\u005A\"") << true << false << TOKEN(STRING) << QVariant(QLatin1String("Z")) << 1 << 0 << 1 << 2; + QTest::newRow("invalid unicode sequence") << QByteArray("\"\\u005Z\"") << true << false << TOKEN(INVALID) << QVariant(QLatin1String("")) << 1 << 0 << 1 << 2; + QTest::newRow("empty string") << QByteArray("\"") << true << false << TOKEN(END) << QVariant() << 1 << 0 << 1 << 1; + + QTest::newRow("single digit") << QByteArray("0") << true << false << TOKEN(NUMBER) << QVariant(0u) << 1 << 0 << 1 << 1; + QTest::newRow("multiple digits") << QByteArray("123456789") << true << false << TOKEN(NUMBER) << QVariant(123456789u) << 1 << 0 << 1 << 9; + QTest::newRow("negative single digit") << QByteArray("-0") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 2; + QTest::newRow("negative multiple digits") << QByteArray("-123456789") << true << false << TOKEN(NUMBER) << QVariant(-123456789) << 1 << 0 << 1 << 10; + QTest::newRow("fractional single digit") << QByteArray("0.1") << true << false << TOKEN(NUMBER) << QVariant(0.1) << 1 << 0 << 1 << 3; + QTest::newRow("fractional multiple digits") << QByteArray("123456789.12") << true << false << TOKEN(NUMBER) << QVariant(123456789.12) << 1 << 0 << 1 << 12; + QTest::newRow("fractional negative single digit") << QByteArray("-0.3") << true << false << TOKEN(NUMBER) << QVariant(-0.3) << 1 << 0 << 1 << 4; + QTest::newRow("fractional negative multiple digits") << QByteArray("-123456789.23") << true << false << TOKEN(NUMBER) << QVariant(-123456789.23) << 1 << 0 << 1 << 13; + QTest::newRow("exponential single digit") << QByteArray("10e2") << true << false << TOKEN(NUMBER) << QVariant(1000) << 1 << 0 << 1 << 4; + QTest::newRow("exponential multiple digits") << QByteArray("10e23") << true << false << TOKEN(NUMBER) << QVariant(10e23) << 1 << 0 << 1 << 5; + QTest::newRow("exponential zero") << QByteArray("0e23") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 4; + QTest::newRow("exponential fractional") << QByteArray("0.12354e23") << true << false << TOKEN(NUMBER) << QVariant(0.12354e23) << 1 << 0 << 1 << 10; + QTest::newRow("exponential fractional multiple digits") << QByteArray("120.12354e23") << true << false << TOKEN(NUMBER) << QVariant(120.12354e23) << 1 << 0 << 1 << 12; + QTest::newRow("uppercase exponential") << QByteArray("120.12354E23") << true << false << TOKEN(NUMBER) << QVariant(120.12354E23) << 1 << 0 << 1 << 12; + QTest::newRow("negative exponential single digit") << QByteArray("-10e2") << true << false << TOKEN(NUMBER) << QVariant(-1000) << 1 << 0 << 1 << 5; + QTest::newRow("negative exponential multiple digits") << QByteArray("-10e23") << true << false << TOKEN(NUMBER) << QVariant(-10e23) << 1 << 0 << 1 << 6; + QTest::newRow("negative exponential zero") << QByteArray("-0e23") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 5; + QTest::newRow("negative exponential fractional") << QByteArray("-0.12354e23") << true << false << TOKEN(NUMBER) << QVariant(-0.12354e23) << 1 << 0 << 1 << 11; + QTest::newRow("negative exponential fractional multiple digits") << QByteArray("-120.12354e23") << true << false << TOKEN(NUMBER) << QVariant(-120.12354e23) << 1 << 0 << 1 << 13; + QTest::newRow("negative exponent") << QByteArray("10e-2") << true << false << TOKEN(NUMBER) << QVariant(10e-2) << 1 << 0 << 1 << 5; + QTest::newRow("positive exponent with plus") << QByteArray("10e+2") << true << false << TOKEN(NUMBER) << QVariant(1000) << 1 << 0 << 1 << 5; + + QTest::newRow("invalid multiple digits") << QByteArray("001") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 1; + QTest::newRow("invalid negative multiple digits") << QByteArray("-001") << true << false << TOKEN(NUMBER) << QVariant(0) << 1 << 0 << 1 << 2; + QTest::newRow("invalid fractional") << QByteArray("12.") << true << true << TOKEN(INVALID) << QVariant(12) << 1 << 2 << 1 << 3; + QTest::newRow("invalid exponential 1") << QByteArray("-5e+") << true << true << TOKEN(INVALID) << QVariant(-5) << 1 << 2 << 1 << 3; + QTest::newRow("invalid exponential 2") << QByteArray("2e") << true << true << TOKEN(INVALID) << QVariant(2) << 1 << 1 << 1 << 2; + QTest::newRow("invalid exponential 3") << QByteArray("3e+") << true << true << TOKEN(INVALID) << QVariant(3) << 1 << 1 << 1 << 2; + QTest::newRow("invalid exponential 4") << QByteArray("4.3E") << true << true << TOKEN(INVALID) << QVariant(4.3) << 1 << 3 << 1 << 4; + QTest::newRow("invalid exponential 5") << QByteArray("5.4E-") << true << true << TOKEN(INVALID) << QVariant(5.4) << 1 << 3 << 1 << 4; + + QTest::newRow("colon") << QByteArray(":") << true << false << TOKEN(COLON) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("comma") << QByteArray(",") << true << false << TOKEN(COMMA) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("square bracket open") << QByteArray("[") << true << false << TOKEN(SQUARE_BRACKET_OPEN) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("square bracket close") << QByteArray("]") << true << false << TOKEN(SQUARE_BRACKET_CLOSE) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("curly bracket open") << QByteArray("{") << true << false << TOKEN(CURLY_BRACKET_OPEN) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("curly bracket close") << QByteArray("}") << true << false << TOKEN(CURLY_BRACKET_CLOSE) << QVariant() << 1 << 0 << 1 << 1; + + QTest::newRow("too large unsinged number") << QByteArray("18446744073709551616") << false << false << TOKEN(INVALID) << QVariant(ULLONG_MAX) << 1 << 0 << 1 << 20; + QTest::newRow("too large signed number") << QByteArray("-9223372036854775808") << false << false << TOKEN(INVALID) << QVariant(LLONG_MIN) << 1 << 0 << 1 << 20; + QTest::newRow("too large exponential") << QByteArray("1.7976931348623157e309") << false << false << TOKEN(INVALID) << QVariant(0) << 1 << 0 << 1 << 22; + QTest::newRow("not allowed nan") << QByteArray("nan") << false << false << TOKEN(INVALID) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("not allowed infinity") << QByteArray("Infinity") << false << false << TOKEN(INVALID) << QVariant() << 1 << 0 << 1 << 1; + QTest::newRow("unknown") << QByteArray("*") << true << false << TOKEN(INVALID) << QVariant() << 1 << 0 << 1 << 1; +} + + +void TestScanner::scanSpecialNumbers() { + QFETCH(QByteArray, input); + QFETCH(bool, isInfinity); + QFETCH(bool, isNegative); + QFETCH(bool, isNan); + QFETCH(int, expectedLocationBeginLine); + QFETCH(int, expectedLocationBeginColumn); + QFETCH(int, expectedLocationEndLine); + QFETCH(int, expectedLocationEndColumn); + + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(input); + buffer.seek(0); + JSonScanner scanner(&buffer); + scanner.allowSpecialNumbers(true); + + QVariant yylval; + yy::position position(YY_NULL, 1, 0); + yy::location location(position, position); + int result = scanner.yylex(&yylval, &location); + + QCOMPARE(result, TOKEN(NUMBER)); + QVERIFY(yylval.type() == QVariant::Double); + + double doubleResult = yylval.toDouble(); + + #if defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) + QCOMPARE(bool(isinf(doubleResult)), isInfinity); + #else + // skip this test for MSVC, because there is no "isinf" function. + #ifndef Q_CC_MSVC + QCOMPARE(bool(std::isinf(doubleResult)), isInfinity); + #endif + #endif + + QCOMPARE(doubleResult<0, isNegative); + + #if defined(Q_OS_SYMBIAN) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) + QCOMPARE(bool(isnan(doubleResult)), isNan); + #else + // skip this test for MSVC, because there is no "isinf" function. + #ifndef Q_CC_MSVC + QCOMPARE(bool(std::isnan(doubleResult)), isNan); + #endif + #endif + + QCOMPARE(location.begin.line, (uint)expectedLocationBeginLine); + QCOMPARE(location.begin.column, (uint)expectedLocationBeginColumn); + QCOMPARE(location.end.line, (uint)expectedLocationEndLine); + QCOMPARE(location.end.column, (uint)expectedLocationEndColumn); +} + +void TestScanner::scanSpecialNumbers_data() { + QTest::addColumn("input"); + QTest::addColumn("isInfinity"); + QTest::addColumn("isNegative"); + QTest::addColumn("isNan"); + QTest::addColumn("expectedLocationBeginLine"); + QTest::addColumn("expectedLocationBeginColumn"); + QTest::addColumn("expectedLocationEndLine"); + QTest::addColumn("expectedLocationEndColumn"); + + QTest::newRow("nan") << QByteArray("nan") << false << false << true << 1 << 0 << 1 << 3; + QTest::newRow("NAN") << QByteArray("NAN") << false << false << true << 1 << 0 << 1 << 3; + QTest::newRow("NaN") << QByteArray("NaN") << false << false << true << 1 << 0 << 1 << 3; + + QTest::newRow("infinity") << QByteArray("infinity") << true << false << false << 1 << 0 << 1 << 8; + QTest::newRow("Infinity") << QByteArray("infinity") << true << false << false << 1 << 0 << 1 << 8; + + QTest::newRow("-infinity") << QByteArray("-infinity") << true << true << false << 1 << 0 << 1 << 9; + QTest::newRow("-Infinity") << QByteArray("-Infinity") << true << true << false << 1 << 0 << 1 << 9; +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestScanner) +#include "moc_testscanner.cxx" +#else +QTEST_GUILESS_MAIN(TestScanner) +#include "testscanner.moc" +#endif diff --git a/tests/serializer/.gitignore b/tests/serializer/.gitignore new file mode 100644 index 000000000..4a080f160 --- /dev/null +++ b/tests/serializer/.gitignore @@ -0,0 +1,4 @@ +Makefile +*.o +*.moc +serializer diff --git a/tests/serializer/CMakeLists.txt b/tests/serializer/CMakeLists.txt new file mode 100644 index 000000000..c3411bc75 --- /dev/null +++ b/tests/serializer/CMakeLists.txt @@ -0,0 +1,46 @@ +##### Probably don't want to edit below this line ##### + +SET( QT_USE_QTTEST TRUE ) + +IF (NOT Qt5Core_FOUND) + # Use it + INCLUDE( ${QT_USE_FILE} ) +ENDIF() + +INCLUDE(AddFileDependencies) + +# Include the library include directories, and the current build directory (moc) +INCLUDE_DIRECTORIES( + ../../include + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( UNIT_TESTS + testserializer +) + +# Build the tests +FOREACH(test ${UNIT_TESTS}) + MESSAGE(STATUS "Building ${test}") + IF (NOT Qt5Core_FOUND) + QT4_WRAP_CPP(MOC_SOURCE ${test}.cpp) + ENDIF() + ADD_EXECUTABLE( + ${test} + ${test}.cpp + ) + + ADD_FILE_DEPENDENCIES(${test}.cpp ${MOC_SOURCE}) + TARGET_LINK_LIBRARIES( + ${test} + ${QT_LIBRARIES} + ${TEST_LIBRARIES} + qjson + ) + if (QJSON_TEST_OUTPUT STREQUAL "xml") + # produce XML output + add_test( ${test} ${test} -xml -o ${test}.tml ) + else (QJSON_TEST_OUTPUT STREQUAL "xml") + add_test( ${test} ${test} ) + endif (QJSON_TEST_OUTPUT STREQUAL "xml") +ENDFOREACH() diff --git a/tests/serializer/testserializer.cpp b/tests/serializer/testserializer.cpp new file mode 100644 index 000000000..9a6e8fb34 --- /dev/null +++ b/tests/serializer/testserializer.cpp @@ -0,0 +1,542 @@ +/* This file is part of QJson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include + +#include + +#include +#include + +class TestSerializer: public QObject +{ + Q_OBJECT + private slots: + void testReadWriteEmptyDocument(); + void testReadWrite(); + void testReadWrite_data(); + void testValueNull(); + void testValueString(); + void testValueString_data(); + void testValueStringList(); + void testValueStringList_data(); + void testValueHashMap(); + void testValueInteger(); + void testValueInteger_data(); + void testValueDouble(); + void testValueDouble_data(); + void testSetDoublePrecision(); + void testValueFloat(); + void testValueFloat_data(); + void testValueBoolean(); + void testValueBoolean_data(); + void testSpecialNumbers(); + void testSpecialNumbers_data(); + void testIndentation(); + void testIndentation_data(); + void testSerializetoQIODevice(); + void testSerializeWithoutOkParam(); + + private: + void valueTest( const QVariant& value, const QString& expectedRegExp, bool errorExpected = false ); + void valueTest( const QObject* object, const QString& expectedRegExp ); +}; + +Q_DECLARE_METATYPE(QVariant) + +using namespace QJson; + +void TestSerializer::testReadWriteEmptyDocument() +{ + QByteArray json = ""; + Parser parser; + bool ok; + QVariant result = parser.parse( json, &ok ); + QVERIFY(!ok); + QVERIFY( ! result.isValid() ); + Serializer serializer; + const QByteArray serialized = serializer.serialize( result, &ok); + QVERIFY( ok ); + QByteArray expected = "null"; + QCOMPARE(expected, serialized); +} + +void TestSerializer::testReadWrite() +{ + QFETCH( QByteArray, json ); + Parser parser; + bool ok; + QVariant result = parser.parse( json, &ok ); + QVERIFY(ok); + Serializer serializer; + const QByteArray serialized = serializer.serialize( result, &ok); + QVERIFY(ok); + QVariant writtenThenRead = parser.parse( serialized, &ok ); + QVERIFY(ok); + QCOMPARE( result, writtenThenRead ); +} + +void TestSerializer::testReadWrite_data() +{ + QTest::addColumn( "json" ); + + // array tests + QTest::newRow( "empty array" ) << QByteArray("[]"); + QTest::newRow( "basic array" ) << QByteArray("[\"person\",\"bar\"]"); + QTest::newRow( "single int array" ) << QByteArray("[6]"); + QTest::newRow( "int array" ) << QByteArray("[6,5,6,7]"); + const QByteArray json = "[1,2.4, -100, -3.4, -5e+0, 2e0,3e+0,4.3E0,5.4E-0]"; + QTest::newRow( QByteArray("array of various numbers") ) << json; + + // document tests + QTest::newRow( "empty object" ) << QByteArray("{}"); + QTest::newRow( "basic document" ) << QByteArray("{\"person\":\"bar\"}"); + QTest::newRow( "object with ints" ) << QByteArray("{\"person\":6}"); + const QByteArray json2 = "{ \"person\":\"bar\",\n\"number\" : 51.3 , \"array\":[\"item1\", 123]}"; + QTest::newRow( "complicated document" ) << json2; + + // more complex cases + const QByteArray json3 = "[ {\"person\":\"bar\"},\n\"number\",51.3 , [\"item1\", 123]]"; + QTest::newRow( "complicated array" ) << json3; +} + +void TestSerializer::testIndentation() +{ + QFETCH( QByteArray, json ); + QFETCH( QByteArray, expected_compact ); + QFETCH( QByteArray, expected_min ); + QFETCH( QByteArray, expected_med ); + QFETCH( QByteArray, expected_full ); + + // parse + Parser parser; + bool ok; + QVariant parsed = parser.parse( json, &ok ); + QVERIFY(ok); + + Serializer serializer; + QVariant reparsed; + QByteArray serialized; + + // serialize with indent compact and reparse + serializer.setIndentMode(QJson::IndentCompact); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_compact); + reparsed = parser.parse( serialized, &ok); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); + + // serialize with indent minimum and reparse + serializer.setIndentMode(QJson::IndentMinimum); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_min); + reparsed = parser.parse( serialized, &ok); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); + + // serialize with indent medium and reparse + serializer.setIndentMode(QJson::IndentMedium); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_med); + reparsed = parser.parse( serialized, &ok ); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); + + // serialize with indent full and reparse + serializer.setIndentMode(QJson::IndentFull); + serialized = serializer.serialize( parsed, &ok); + QVERIFY(ok); + QCOMPARE( serialized, expected_full); + reparsed = parser.parse( serialized, &ok ); + QVERIFY(ok); + QCOMPARE( parsed, reparsed); +} + +void TestSerializer::testIndentation_data() +{ + QTest::addColumn( "json" ); + QTest::addColumn( "expected_compact" ); + QTest::addColumn( "expected_min" ); + QTest::addColumn( "expected_med" ); + QTest::addColumn( "expected_full" ); + const QByteArray json = " { \"foo\" : 0, \"foo1\" : 1, \"foo2\" : [ { \"bar\" : 1, \"foo\" : 0, \"foobar\" : 0 }, { \"bar\" : 1, \"foo\" : 1, \"foobar\" : 1 } ], \"foo3\" : [ 1, 2, 3, 4, 5, 6 ] }"; + const QByteArray ex_compact = "{\"foo\":0,\"foo1\":1,\"foo2\":[{\"bar\":1,\"foo\":0,\"foobar\":0},{\"bar\":1,\"foo\":1,\"foobar\":1}],\"foo3\":[1,2,3,4,5,6]}"; + const QByteArray ex_min = "{ \"foo\" : 0, \"foo1\" : 1, \"foo2\" : [\n { \"bar\" : 1, \"foo\" : 0, \"foobar\" : 0 },\n { \"bar\" : 1, \"foo\" : 1, \"foobar\" : 1 }\n ], \"foo3\" : [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ] }"; + const QByteArray ex_med = "{\n \"foo\" : 0, \"foo1\" : 1, \"foo2\" : [\n {\n \"bar\" : 1, \"foo\" : 0, \"foobar\" : 0\n },\n {\n \"bar\" : 1, \"foo\" : 1, \"foobar\" : 1\n }\n ], \"foo3\" : [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ]\n}"; + const QByteArray ex_full = "{\n \"foo\" : 0,\n \"foo1\" : 1,\n \"foo2\" : [\n {\n \"bar\" : 1,\n \"foo\" : 0,\n \"foobar\" : 0\n },\n {\n \"bar\" : 1,\n \"foo\" : 1,\n \"foobar\" : 1\n }\n ],\n \"foo3\" : [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ]\n}"; + QTest::newRow( "test indents" ) << json << ex_compact << ex_min << ex_med << ex_full; +} + +void TestSerializer::valueTest( const QVariant& value, const QString& expectedRegExp, bool errorExpected ) +{ + Serializer serializer; + bool ok; + const QByteArray serialized = serializer.serialize( value, &ok); + QCOMPARE(ok, !errorExpected); + QCOMPARE(serialized.isNull(), errorExpected); + const QString serializedUnicode = QString::fromUtf8( serialized ); + if (!errorExpected) { + QRegExp expected( expectedRegExp ); + QVERIFY( expected.isValid() ); + QVERIFY2( expected.exactMatch( serializedUnicode ), + qPrintable( QString( QLatin1String( "Expected regexp \"%1\" but got \"%2\"." ) ) + .arg( expectedRegExp ).arg( serializedUnicode ) ) ); + } else { + QVERIFY(!serializer.errorMessage().isEmpty()); + } +} + +void TestSerializer::valueTest( const QObject* object, const QString& expectedRegExp ) +{ + Serializer serializer; + bool ok; + const QByteArray serialized = serializer.serialize( object, &ok); + QVERIFY(ok); + const QString serializedUnicode = QString::fromUtf8( serialized ); + QRegExp expected( expectedRegExp ); + QVERIFY( expected.isValid() ); + QVERIFY2( expected.exactMatch( serializedUnicode ), + qPrintable( QString( QLatin1String( "Expected regexp \"%1\" but got \"%2\"." ) ) + .arg( expectedRegExp ).arg( serializedUnicode ) ) ); +} + +void TestSerializer::testValueNull() +{ + valueTest( QVariant(), QLatin1String( "\\s*null\\s*" ) ); + QVariantMap map; + map[QLatin1String("value")] = QVariant(); + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:\\s*null\\s*\\}\\s*" ) ); +} + +void TestSerializer::testValueString() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueString_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + QTest::newRow( "null string" ) << QVariant( QString() ) << QString( QLatin1String( "\\s*\"\"\\s*" ) ); + QTest::newRow( "empty string" ) << QVariant( QString( QLatin1String( "" ) ) ) << QString( QLatin1String( "\\s*\"\"\\s*" ) ); + QTest::newRow( "Simple String" ) << QVariant( QString( QLatin1String( "simpleString" ) ) ) << QString( QLatin1String( "\\s*\"simpleString\"\\s*" ) ); + QTest::newRow( "string with tab" ) << QVariant( QString( QLatin1String( "string\tstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\tstring\"\\s*" ) ); + QTest::newRow( "string with newline" ) << QVariant( QString( QLatin1String( "string\nstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\nstring\"\\s*" ) ); + QTest::newRow( "string with bell" ) << QVariant( QString( QLatin1String( "string\bstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\bstring\"\\s*" ) ); + QTest::newRow( "string with return" ) << QVariant( QString( QLatin1String( "string\rstring" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\rstring\"\\s*" ) ); + QTest::newRow( "string with double quote" ) << QVariant( QString( QLatin1String( "string\"string" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\\"string\"\\s*" ) ); + QTest::newRow( "string with backslash" ) << QVariant( QString( QLatin1String( "string\\string" ) ) ) << QString( QLatin1String( "\\s*\"string\\\\\\\\string\"\\s*" ) ); + QString testStringWithUnicode = QString( QLatin1String( "string" ) ) + QChar( 0x2665 ) + QLatin1String( "string" ); + QString testEscapedString = QString( QLatin1String( "string" ) ) + QLatin1String("\\\\u2665") + QLatin1String( "string" ); + QTest::newRow( "string with unicode" ) << QVariant( testStringWithUnicode ) << QLatin1String( "\\s*\"" ) + testEscapedString + QLatin1String( "\"\\s*" ); +} + +void TestSerializer::testValueStringList() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueStringList_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QStringList stringlist; + QString expected; + + // simple QStringList + stringlist << QLatin1String("hello") << QLatin1String("world"); + expected = QLatin1String( "\\s*\\[\\s*\"hello\"\\s*,\\s*\"world\"\\s*\\]\\s*" ); + QTest::newRow( "simple QStringList" ) << QVariant( stringlist) << expected; +} + +void TestSerializer::testValueInteger() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueInteger_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QTest::newRow( "int 0" ) << QVariant( static_cast( 0 ) ) << QString( QLatin1String( "\\s*0\\s*" ) ); + QTest::newRow( "uint 0" ) << QVariant( static_cast( 0 ) ) << QString( QLatin1String( "\\s*0\\s*" ) ); + QTest::newRow( "int -1" ) << QVariant( static_cast( -1 ) ) << QString( QLatin1String( "\\s*-1\\s*" ) ); + QTest::newRow( "int 2133149800" ) << QVariant( static_cast(2133149800) ) << QString( QLatin1String( "\\s*2133149800\\s*" ) ); + QTest::newRow( "uint 4133149800" ) << QVariant( static_cast(4133149800u) ) << QString( QLatin1String( "\\s*4133149800\\s*" ) ); + QTest::newRow( "uint64 932838457459459" ) << QVariant( Q_UINT64_C(932838457459459) ) << QString( QLatin1String( "\\s*932838457459459\\s*" ) ); + QTest::newRow( "max unsigned long long" ) << QVariant( std::numeric_limits::max() ) << QString( QLatin1String( "\\s*%1\\s*" ) ).arg(std::numeric_limits::max()); +} + +void TestSerializer::testValueDouble() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + QFETCH( bool, errorExpected ); + valueTest( value, expected, errorExpected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ), errorExpected ); +} + +void TestSerializer::testValueDouble_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "errorExpected" ); + + QTest::newRow( "double 0" ) << QVariant( 0.0 ) << QString( QLatin1String( "\\s*0.0\\s*" ) ) << false; + QTest::newRow( "double -1" ) << QVariant( -1.0 ) << QString( QLatin1String( "\\s*-1.0\\s*" ) ) << false; + QTest::newRow( "double 1.5E-20" ) << QVariant( 1.5e-20 ) << QString( QLatin1String( "\\s*1.5[Ee]-20\\s*" ) ) << false; + QTest::newRow( "double -1.5E-20" ) << QVariant( -1.5e-20 ) << QString( QLatin1String( "\\s*-1.5[Ee]-20\\s*" ) ) << false; + QTest::newRow( "double 2.0E-20" ) << QVariant( 2.0e-20 ) << QString( QLatin1String( "\\s*2(?:.0)?[Ee]-20\\s*" ) ) << false; + QTest::newRow( "double infinity" ) << QVariant( std::numeric_limits< double >::infinity() ) << QString( ) << true; + QTest::newRow( "double -infinity" ) << QVariant( -std::numeric_limits< double >::infinity() ) << QString( ) << true; + QTest::newRow( "double NaN" ) << QVariant( std::numeric_limits< double >::quiet_NaN() ) << QString( ) << true; +} + +void TestSerializer::testSetDoublePrecision() +{ + bool ok; + Serializer serializer; + QByteArray actual; + QString expected, actualUnicode; + + double num = 0.12345678; + + // Set 1 as double precision + serializer.setDoublePrecision(1); + expected = QString(QLatin1String("0.1")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); + + // Set 2 as double precision + serializer.setDoublePrecision(2); + expected = QString(QLatin1String("0.12")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); + + // Set 4 as double precision + serializer.setDoublePrecision(4); + expected = QString(QLatin1String("0.1235")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); + + // Set 14 as double precision + serializer.setDoublePrecision(14); + expected = QString(QLatin1String("0.12345678")); + actual = serializer.serialize( QVariant(num), &ok); + QVERIFY(ok); + actualUnicode = QString::fromUtf8(actual); + + QVERIFY2( QString::compare(expected, actualUnicode ) == 0, + qPrintable( QString( QLatin1String( "Expected \"%1\" but got \"%2\"." ) ) + .arg( expected ).arg( actualUnicode ) ) ); +} + +void TestSerializer::testValueFloat() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + QFETCH( bool, errorExpected ); + valueTest( value, expected, errorExpected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ), errorExpected ); +} + +void TestSerializer::testValueFloat_data() +{ + QVariant v; + float value; + + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + QTest::addColumn( "errorExpected" ); + + value = 0; + v.setValue(value); + QTest::newRow( "float 0" ) << v << QString( QLatin1String( "\\s*0.0\\s*" ) ) << false; + + value = -1; + v.setValue(value); + QTest::newRow( "float -1" ) << v << QString( QLatin1String( "\\s*-1.0\\s*" ) ) << false; + + value = 1.12f; + v.setValue(value); + QTest::newRow( "float 1.12" ) << v << QString( QLatin1String( "\\s*1.12\\s*" ) ) << false; +} + +void TestSerializer::testValueBoolean() +{ + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + valueTest( value, expected ); + + QVariantMap map; + map[QLatin1String("value")] = value; + valueTest( QVariant(map), QLatin1String( "\\s*\\{\\s*\"value\"\\s*:" ) + expected + QLatin1String( "\\}\\s*" ) ); +} + +void TestSerializer::testValueBoolean_data() +{ + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QTest::newRow( "bool false" ) << QVariant( false ) << QString( QLatin1String( "\\s*false\\s*" ) ); + QTest::newRow( "bool true" ) << QVariant( true ) << QString( QLatin1String( "\\s*true\\s*" ) ); +} + +void TestSerializer::testSpecialNumbers() { + bool ok; + QFETCH( QVariant, value ); + QFETCH( QString, expected ); + Serializer specialSerializer; + QVERIFY(!specialSerializer.specialNumbersAllowed()); + specialSerializer.allowSpecialNumbers(true); + QVERIFY(specialSerializer.specialNumbersAllowed()); + QByteArray serialized = specialSerializer.serialize(value, &ok); + QVERIFY(ok); + QCOMPARE(QString::fromLocal8Bit(serialized), expected); +} + +void TestSerializer::testSpecialNumbers_data() { + QTest::addColumn( "value" ); + QTest::addColumn( "expected" ); + + QTest::newRow( "Infinity" ) << QVariant( std::numeric_limits< double >::infinity() ) << QString::fromLocal8Bit("Infinity"); + QTest::newRow( "-Infinity" ) << QVariant( -std::numeric_limits< double >::infinity() ) << QString::fromLocal8Bit("-Infinity"); + QTest::newRow( "Infinity" ) << QVariant( std::numeric_limits< double >::quiet_NaN() ) << QString::fromLocal8Bit("NaN"); +} + +void TestSerializer::testSerializetoQIODevice() { + QBuffer buffer; + QVariantList variant; + variant << QVariant(QLatin1String("Hello")); + variant << QVariant(QLatin1String("world!")); + + Serializer serializer; + bool ok; + + serializer.serialize(variant, &buffer, &ok); + + QCOMPARE(QString(QLatin1String(buffer.data())), + QString(QLatin1String("[ \"Hello\", \"world!\" ]"))); + QVERIFY(ok); +} + +void TestSerializer::testSerializeWithoutOkParam() { + QBuffer buffer; + QVariantList variant; + variant << QVariant(QLatin1String("Hello")); + variant << QVariant(QLatin1String("world!")); + + Serializer serializer; + + const QByteArray serialized = serializer.serialize(variant); + const QByteArray expected = "[ \"Hello\", \"world!\" ]"; + QCOMPARE(expected, serialized); + + + // test a serialization which produces an error + QVariant brokenVariant ( std::numeric_limits< double >::quiet_NaN() ); + QVERIFY(serializer.serialize(brokenVariant).isEmpty()); +} + +void TestSerializer::testValueHashMap() +{ + Serializer serializer; + bool ok; + + QVariantHash hash; + hash[QLatin1String("one")] = 1; + hash[QLatin1String("three")] = 3; + hash[QLatin1String("seven")] = 7; + + QByteArray json = serializer.serialize(hash, &ok); + QVERIFY(ok); + + Parser parser; + QVariant var = parser.parse(json, &ok); + QVERIFY(ok); + + QVariantMap vmap = var.toMap(); + QHashIterator hIt( hash ); + while ( hIt.hasNext() ) { + hIt.next(); + QString key = hIt.key(); + QVariant value = hIt.value(); + + QMap::const_iterator mIt = vmap.constFind(key); + QVERIFY(mIt != vmap.constEnd()); + QCOMPARE(mIt.value(), value); + } + +} + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +// using Qt4 rather then Qt5 +QTEST_MAIN(TestSerializer) +#include "moc_testserializer.cxx" +#else +QTEST_GUILESS_MAIN(TestSerializer) +#include "testserializer.moc" +#endif