]> git.cworth.org Git - apitrace/commitdiff
Update bundled QJson
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 27 Oct 2012 09:13:08 +0000 (10:13 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 27 Oct 2012 09:13:08 +0000 (10:13 +0100)
To upstream commit 11e743c61e18e49d77c94e9568ccb6f0c2b4f0ac.

23 files changed:
thirdparty/qjson/.gitignore [new file with mode: 0644]
thirdparty/qjson/CMakeLists.txt
thirdparty/qjson/COPYING [deleted file]
thirdparty/qjson/COPYING.lib [new file with mode: 0644]
thirdparty/qjson/README
thirdparty/qjson/json_parser.cc
thirdparty/qjson/json_parser.hh
thirdparty/qjson/json_parser.yy
thirdparty/qjson/json_scanner.cpp
thirdparty/qjson/json_scanner.h
thirdparty/qjson/parser.cpp
thirdparty/qjson/parser.h
thirdparty/qjson/parser_p.h
thirdparty/qjson/parserrunnable.cpp
thirdparty/qjson/parserrunnable.h
thirdparty/qjson/qjson_debug.h
thirdparty/qjson/qjson_export.h
thirdparty/qjson/qobjecthelper.cpp
thirdparty/qjson/qobjecthelper.h
thirdparty/qjson/serializer.cpp
thirdparty/qjson/serializer.h
thirdparty/qjson/serializerrunnable.cpp
thirdparty/qjson/serializerrunnable.h

diff --git a/thirdparty/qjson/.gitignore b/thirdparty/qjson/.gitignore
new file mode 100644 (file)
index 0000000..b2b8eb2
--- /dev/null
@@ -0,0 +1 @@
+moc_*.cxx
index 14bda2c2dcf2b5cd197c1bd328dd5890c5614e8a..567cb79c3896e647ac8cf464ea36192809852653 100644 (file)
@@ -1,4 +1,9 @@
-add_definitions (-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG_OUTPUT)
+add_definitions (
+    -DQT_NO_CAST_FROM_ASCII
+    -DQT_NO_CAST_TO_ASCII
+    -DQT_NO_DEBUG_OUTPUT
+    -DQJSON_EXPORT=
+)
 
 set (QT_DONT_USE_QTGUI TRUE)
 
@@ -8,11 +13,19 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR})
 
 set (qjson_MOC_HDRS
     parserrunnable.h
-    serializerrunnable.h
+    #serializerrunnable.h
 )
 
 qt4_wrap_cpp (qjson_MOC_SRCS ${qjson_MOC_HDRS})
 
-set (qjson_SRCS parser.cpp qobjecthelper.cpp json_scanner.cpp json_parser.cc parserrunnable.cpp serializer.cpp serializerrunnable.cpp)
+set (qjson_SRCS
+    parser.cpp
+    qobjecthelper.cpp
+    json_scanner.cpp
+    json_parser.cc
+    parserrunnable.cpp
+    #serializer.cpp
+    #serializerrunnable.cpp
+)
 
 add_library (qjson_bundled STATIC ${qjson_SRCS} ${qjson_MOC_SRCS})
diff --git a/thirdparty/qjson/COPYING b/thirdparty/qjson/COPYING
deleted file mode 100644 (file)
index 5ab7695..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-                 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.
-\f
-  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.
-\f
-                 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.
-\f
-  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.
-\f
-  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.
-\f
-  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.
-\f
-  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.
-\f
-  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.
-\f
-  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
-\f
-           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.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    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.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/thirdparty/qjson/COPYING.lib b/thirdparty/qjson/COPYING.lib
new file mode 100644 (file)
index 0000000..08f25cd
--- /dev/null
@@ -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.
+\f
+  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.
+\f
+                 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.
+\f
+  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.
+\f
+  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.
+\f
+  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.
+\f
+  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.
+\f
+  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.
+\f
+  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
+\f
+           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.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
index 9e7b037c9d1bdea24e74afa27ea7a6ec9ccda5b3..fe4853de1f7ef3e6c80d24e020c47bc9989afde0 100644 (file)
@@ -1,6 +1,5 @@
-QJson version 0.5.0
+QJson
 -------------------------------------------------
-Date: April 3rd, 2009
 Website: http://qjson.sourceforge.net/
 Mailing List: https://lists.sourceforge.net/mailman/listinfo/qjson-devel
 
@@ -13,8 +12,8 @@ Install
 
 License
 -------
-  This library is licensed under the Lesser GNU General Public License.  See
-  the COPYING file for more information.
+  This library is licensed under the Lesser GNU General Public License version 2.1.
+  See the COPYING.lib file for more information.
 
 Description
 -----------
index a99be6c6f2d07ccfd8180a64194b4540beea48cb..620e135a85bb50ed23d56fdf31249ec387f2293e 100644 (file)
@@ -42,7 +42,7 @@
 #line 43 "json_parser.cc"
 
 #ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
+# if YYENABLE_NLS
 #  if ENABLE_NLS
 #   include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -384,7 +384,7 @@ namespace yy
     switch (yyn)
       {
          case 2:
-#line 80 "json_parser.yy"
+#line 84 "json_parser.yy"
     {
               driver->m_result = (yysemantic_stack_[(1) - (1)]);
               qjsonDebug() << "json_parser - parsing finished";
@@ -392,36 +392,31 @@ namespace yy
     break;
 
   case 3:
-#line 85 "json_parser.yy"
-    {(yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+#line 89 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
     break;
 
   case 4:
-#line 86 "json_parser.yy"
-    {(yyval) = (yysemantic_stack_[(1) - (1)]); ;}
-    break;
-
-  case 5:
-#line 88 "json_parser.yy"
+#line 91 "json_parser.yy"
     {
             qCritical()<< "json_parser - syntax error found, "
-                    << "forcing abort";
+                    << "forcing abort, Line" << (yyloc).begin.line << "Column" << (yyloc).begin.column;
             YYABORT;
           ;}
     break;
 
-  case 7:
-#line 95 "json_parser.yy"
+  case 6:
+#line 98 "json_parser.yy"
     { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
     break;
 
-  case 8:
-#line 97 "json_parser.yy"
+  case 7:
+#line 100 "json_parser.yy"
     { (yyval) = QVariant (QVariantMap()); ;}
     break;
 
-  case 9:
-#line 98 "json_parser.yy"
+  case 8:
+#line 101 "json_parser.yy"
     {
             QVariantMap members = (yysemantic_stack_[(2) - (2)]).toMap();
             (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of map
@@ -429,13 +424,13 @@ namespace yy
           ;}
     break;
 
-  case 10:
-#line 104 "json_parser.yy"
+  case 9:
+#line 107 "json_parser.yy"
     { (yyval) = QVariant (QVariantMap()); ;}
     break;
 
-  case 11:
-#line 105 "json_parser.yy"
+  case 10:
+#line 108 "json_parser.yy"
     {
           QVariantMap members = (yysemantic_stack_[(3) - (3)]).toMap();
           (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of map
@@ -443,8 +438,8 @@ namespace yy
           ;}
     break;
 
-  case 12:
-#line 111 "json_parser.yy"
+  case 11:
+#line 114 "json_parser.yy"
     {
             QVariantMap pair;
             pair.insert ((yysemantic_stack_[(3) - (1)]).toString(), QVariant((yysemantic_stack_[(3) - (3)])));
@@ -452,18 +447,18 @@ namespace yy
           ;}
     break;
 
-  case 13:
-#line 117 "json_parser.yy"
+  case 12:
+#line 120 "json_parser.yy"
     { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
     break;
 
-  case 14:
-#line 119 "json_parser.yy"
+  case 13:
+#line 122 "json_parser.yy"
     { (yyval) = QVariant (QVariantList()); ;}
     break;
 
-  case 15:
-#line 120 "json_parser.yy"
+  case 14:
+#line 123 "json_parser.yy"
     {
           QVariantList members = (yysemantic_stack_[(2) - (2)]).toList();
           (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of list
@@ -472,13 +467,13 @@ namespace yy
         ;}
     break;
 
-  case 16:
-#line 127 "json_parser.yy"
+  case 15:
+#line 130 "json_parser.yy"
     { (yyval) = QVariant (QVariantList()); ;}
     break;
 
-  case 17:
-#line 128 "json_parser.yy"
+  case 16:
+#line 131 "json_parser.yy"
     {
             QVariantList members = (yysemantic_stack_[(3) - (3)]).toList();
             (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of list
@@ -487,46 +482,61 @@ namespace yy
           ;}
     break;
 
+  case 17:
+#line 138 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+    break;
+
   case 18:
-#line 135 "json_parser.yy"
+#line 139 "json_parser.yy"
     { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
     break;
 
   case 19:
-#line 136 "json_parser.yy"
+#line 140 "json_parser.yy"
     { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
     break;
 
   case 20:
-#line 137 "json_parser.yy"
+#line 141 "json_parser.yy"
     { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
     break;
 
   case 21:
-#line 138 "json_parser.yy"
-    { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
-    break;
-
-  case 22:
-#line 139 "json_parser.yy"
+#line 142 "json_parser.yy"
     { (yyval) = QVariant (true); ;}
     break;
 
-  case 23:
-#line 140 "json_parser.yy"
+  case 22:
+#line 143 "json_parser.yy"
     { (yyval) = QVariant (false); ;}
     break;
 
-  case 24:
-#line 141 "json_parser.yy"
+  case 23:
+#line 144 "json_parser.yy"
     {
           QVariant null_variant;
           (yyval) = null_variant;
         ;}
     break;
 
+  case 24:
+#line 149 "json_parser.yy"
+    { (yyval) = QVariant(QVariant::Double); (yyval).setValue( -std::numeric_limits<double>::infinity() ); ;}
+    break;
+
   case 25:
-#line 146 "json_parser.yy"
+#line 150 "json_parser.yy"
+    { (yyval) = QVariant(QVariant::Double); (yyval).setValue( std::numeric_limits<double>::infinity() ); ;}
+    break;
+
+  case 26:
+#line 151 "json_parser.yy"
+    { (yyval) = QVariant(QVariant::Double); (yyval).setValue( std::numeric_limits<double>::quiet_NaN() ); ;}
+    break;
+
+  case 28:
+#line 154 "json_parser.yy"
     {
             if ((yysemantic_stack_[(1) - (1)]).toByteArray().startsWith('-')) {
               (yyval) = QVariant (QVariant::LongLong);
@@ -539,8 +549,8 @@ namespace yy
           ;}
     break;
 
-  case 26:
-#line 156 "json_parser.yy"
+  case 29:
+#line 164 "json_parser.yy"
     {
             const QByteArray value = (yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray();
             (yyval) = QVariant(QVariant::Double);
@@ -548,65 +558,65 @@ namespace yy
           ;}
     break;
 
-  case 27:
-#line 161 "json_parser.yy"
+  case 30:
+#line 169 "json_parser.yy"
     { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
     break;
 
-  case 28:
-#line 162 "json_parser.yy"
+  case 31:
+#line 170 "json_parser.yy"
     {
             const QByteArray value = (yysemantic_stack_[(3) - (1)]).toByteArray() + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray();
             (yyval) = QVariant (value);
           ;}
     break;
 
-  case 29:
-#line 167 "json_parser.yy"
+  case 32:
+#line 175 "json_parser.yy"
     { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
     break;
 
-  case 30:
-#line 168 "json_parser.yy"
+  case 33:
+#line 176 "json_parser.yy"
     { (yyval) = QVariant (QByteArray("-") + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray()); ;}
     break;
 
-  case 31:
-#line 170 "json_parser.yy"
+  case 34:
+#line 178 "json_parser.yy"
     { (yyval) = QVariant (QByteArray("")); ;}
     break;
 
-  case 32:
-#line 171 "json_parser.yy"
+  case 35:
+#line 179 "json_parser.yy"
     {
           (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray());
         ;}
     break;
 
-  case 33:
-#line 175 "json_parser.yy"
+  case 36:
+#line 183 "json_parser.yy"
     {
           (yyval) = QVariant(QByteArray(".") + (yysemantic_stack_[(2) - (2)]).toByteArray());
         ;}
     break;
 
-  case 34:
-#line 179 "json_parser.yy"
+  case 37:
+#line 187 "json_parser.yy"
     { (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
     break;
 
-  case 35:
-#line 181 "json_parser.yy"
+  case 38:
+#line 189 "json_parser.yy"
     { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
     break;
 
-  case 36:
-#line 183 "json_parser.yy"
+  case 39:
+#line 191 "json_parser.yy"
     { (yyval) = QVariant (QString(QLatin1String(""))); ;}
     break;
 
-  case 37:
-#line 184 "json_parser.yy"
+  case 40:
+#line 192 "json_parser.yy"
     {
                 (yyval) = (yysemantic_stack_[(1) - (1)]);
               ;}
@@ -614,7 +624,7 @@ namespace yy
 
 
     /* Line 675 of lalr1.cc.  */
-#line 618 "json_parser.cc"
+#line 628 "json_parser.cc"
        default: break;
       }
     YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
@@ -821,16 +831,16 @@ namespace yy
 
   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
      STATE-NUM.  */
-  const signed char json_parser::yypact_ninf_ = -18;
+  const signed char json_parser::yypact_ninf_ = -21;
   const signed char
   json_parser::yypact_[] =
   {
-         5,   -18,   -18,     1,    -2,    19,   -18,   -18,   -18,     2,
-      20,    17,    21,    16,    18,   -18,   -18,   -18,   -18,   -18,
-      24,    23,   -18,    -8,   -18,   -18,   -18,    15,   -18,     1,
-     -18,    -2,    18,    18,   -18,   -18,    -2,   -18,    18,    18,
-      22,   -18,   -18,    17,   -18,   -18,   -18,    23,   -18,   -18,
-     -18,   -18,   -18
+         3,   -21,   -21,    -6,    31,   -10,     0,   -21,   -21,   -21,
+       6,   -21,   -21,    25,   -21,   -21,   -21,   -21,   -21,   -21,
+      -5,   -21,    22,    19,    21,    23,    24,     0,   -21,     0,
+     -21,   -21,    13,   -21,     0,     0,    29,   -21,   -21,    -6,
+     -21,    31,   -21,    31,   -21,   -21,   -21,   -21,   -21,   -21,
+     -21,    19,   -21,    24,   -21,   -21
   };
 
   /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
@@ -839,28 +849,28 @@ namespace yy
   const unsigned char
   json_parser::yydefact_[] =
   {
-         0,     6,     5,     8,    14,     0,     2,     3,     4,    36,
-       0,    10,     0,     0,    31,    22,    23,    24,    20,    21,
-       0,    16,    19,    25,    18,     1,    37,     0,     7,     0,
-       9,     0,    31,    31,    29,    13,     0,    15,    31,    31,
-      26,    27,    35,    10,    12,    30,    32,    16,    33,    34,
-      28,    11,    17
+         0,     5,     4,     7,    13,     0,    34,    21,    22,    23,
+      39,    25,    26,     0,     2,    19,    20,     3,    18,    27,
+      28,    17,     0,     9,     0,     0,    15,    34,    24,    34,
+      32,    40,     0,     1,    34,    34,    29,    30,     6,     0,
+       8,     0,    12,     0,    14,    33,    35,    38,    36,    37,
+      31,     9,    11,    15,    10,    16
   };
 
   /* YYPGOTO[NTERM-NUM].  */
   const signed char
   json_parser::yypgoto_[] =
   {
-       -18,   -18,   -18,    33,   -18,    -7,     6,    37,   -18,    -9,
-     -13,   -18,   -18,   -17,   -18,    -1,    -3,   -18
+       -21,   -21,   -21,   -21,   -21,   -20,     4,   -21,   -21,   -18,
+      -4,   -21,   -21,   -21,   -14,   -21,    -3,    -1,   -21
   };
 
   /* YYDEFGOTO[NTERM-NUM].  */
   const signed char
   json_parser::yydefgoto_[] =
   {
-        -1,     5,     6,    18,    10,    30,    11,    19,    20,    37,
-      21,    22,    23,    34,    40,    41,    24,    27
+        -1,    13,    14,    15,    22,    40,    23,    16,    25,    44,
+      17,    18,    19,    20,    30,    36,    37,    21,    32
   };
 
   /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -870,20 +880,24 @@ namespace yy
   const unsigned char
   json_parser::yytable_[] =
   {
-        12,     3,    38,     4,    39,     1,     2,    13,     3,    14,
-       4,    15,    16,    17,     9,    45,    46,     9,    44,    25,
-      26,    48,    49,    47,    28,    29,    12,    32,    31,    33,
-      35,    36,    42,     7,    39,    43,    51,     8,    52,    50
+        26,    27,    24,     1,     2,    34,     3,    35,     4,    28,
+      10,    29,     5,    45,     6,    46,     7,     8,     9,    10,
+      48,    49,    11,    12,    31,    33,    38,    39,    41,    42,
+      47,    54,    43,    50,     3,    55,     4,    52,    24,    53,
+       5,    35,     6,    51,     7,     8,     9,    10,     0,     0,
+      11,    12
   };
 
   /* YYCHECK.  */
-  const unsigned char
+  const signed char
   json_parser::yycheck_[] =
   {
-         3,     3,    10,     5,    12,     0,     1,     9,     3,    11,
-       5,    13,    14,    15,    16,    32,    33,    16,    31,     0,
-      18,    38,    39,    36,     4,     8,    29,    11,     7,    11,
-       6,     8,    17,     0,    12,    29,    43,     0,    47,    40
+         4,    11,     3,     0,     1,    10,     3,    12,     5,    19,
+      16,    11,     9,    27,    11,    29,    13,    14,    15,    16,
+      34,    35,    19,    20,    18,     0,     4,     8,     7,     6,
+      17,    51,     8,    36,     3,    53,     5,    41,    39,    43,
+       9,    12,    11,    39,    13,    14,    15,    16,    -1,    -1,
+      19,    20
   };
 
   /* STOS_[STATE-NUM] -- The (internal number of the) accessing
@@ -891,12 +905,12 @@ namespace yy
   const unsigned char
   json_parser::yystos_[] =
   {
-         0,     0,     1,     3,     5,    20,    21,    22,    26,    16,
-      23,    25,    35,     9,    11,    13,    14,    15,    22,    26,
-      27,    29,    30,    31,    35,     0,    18,    36,     4,     8,
-      24,     7,    11,    11,    32,     6,     8,    28,    10,    12,
-      33,    34,    17,    25,    29,    32,    32,    29,    32,    32,
-      34,    24,    28
+         0,     0,     1,     3,     5,     9,    11,    13,    14,    15,
+      16,    19,    20,    22,    23,    24,    28,    31,    32,    33,
+      34,    38,    25,    27,    38,    29,    31,    11,    19,    11,
+      35,    18,    39,     0,    10,    12,    36,    37,     4,     8,
+      26,     7,     6,     8,    30,    35,    35,    17,    35,    35,
+      37,    27,    31,    31,    26,    30
   };
 
 #if YYDEBUG
@@ -906,7 +920,8 @@ namespace yy
   json_parser::yytoken_number_[] =
   {
          0,   256,   257,     1,     2,     3,     4,     5,     6,     7,
-       8,     9,    10,    11,    12,    13,    14,    15,    16
+       8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
+      18
   };
 #endif
 
@@ -914,20 +929,22 @@ namespace yy
   const unsigned char
   json_parser::yyr1_[] =
   {
-         0,    19,    20,    21,    21,    21,    21,    22,    23,    23,
-      24,    24,    25,    26,    27,    27,    28,    28,    29,    29,
-      29,    29,    29,    29,    29,    30,    30,    30,    30,    31,
-      31,    32,    32,    33,    34,    35,    36,    36
+         0,    21,    22,    23,    23,    23,    24,    25,    25,    26,
+      26,    27,    28,    29,    29,    30,    30,    31,    31,    31,
+      31,    31,    31,    31,    32,    32,    32,    32,    33,    33,
+      33,    33,    34,    34,    35,    35,    36,    37,    38,    39,
+      39
   };
 
   /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
   const unsigned char
   json_parser::yyr2_[] =
   {
-         0,     2,     1,     1,     1,     1,     1,     3,     0,     2,
-       0,     3,     3,     3,     0,     2,     0,     3,     1,     1,
-       1,     1,     1,     1,     1,     1,     2,     2,     3,     2,
-       3,     0,     2,     2,     2,     3,     0,     1
+         0,     2,     1,     1,     1,     1,     3,     0,     2,     0,
+       3,     3,     3,     0,     2,     0,     3,     1,     1,     1,
+       1,     1,     1,     1,     2,     1,     1,     1,     1,     2,
+       2,     3,     2,     3,     0,     2,     2,     2,     3,     0,
+       1
   };
 
 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
@@ -940,9 +957,10 @@ namespace yy
   "\"]\"", "\":\"", "\",\"", "\"-\"", "\".\"", "\"digit\"",
   "\"exponential\"", "\"true\"", "\"false\"", "\"null\"",
   "\"open quotation mark\"", "\"close quotation mark\"", "\"string\"",
-  "$accept", "start", "data", "object", "members", "r_members", "pair",
-  "array", "values", "r_values", "value", "number", "int", "digits",
-  "fract", "exp", "string", "string_arg", 0
+  "\"Infinity\"", "\"NaN\"", "$accept", "start", "data", "object",
+  "members", "r_members", "pair", "array", "values", "r_values", "value",
+  "special_or_number", "number", "int", "digits", "fract", "exp", "string",
+  "string_arg", 0
   };
 #endif
 
@@ -951,16 +969,16 @@ namespace yy
   const json_parser::rhs_number_type
   json_parser::yyrhs_[] =
   {
-        20,     0,    -1,    21,    -1,    22,    -1,    26,    -1,     1,
-      -1,     0,    -1,     3,    23,     4,    -1,    -1,    25,    24,
-      -1,    -1,     8,    25,    24,    -1,    35,     7,    29,    -1,
-       5,    27,     6,    -1,    -1,    29,    28,    -1,    -1,     8,
-      29,    28,    -1,    35,    -1,    30,    -1,    22,    -1,    26,
-      -1,    13,    -1,    14,    -1,    15,    -1,    31,    -1,    31,
-      33,    -1,    31,    34,    -1,    31,    33,    34,    -1,    11,
-      32,    -1,     9,    11,    32,    -1,    -1,    11,    32,    -1,
-      10,    32,    -1,    12,    32,    -1,    16,    36,    17,    -1,
-      -1,    18,    -1
+        22,     0,    -1,    23,    -1,    31,    -1,     1,    -1,     0,
+      -1,     3,    25,     4,    -1,    -1,    27,    26,    -1,    -1,
+       8,    27,    26,    -1,    38,     7,    31,    -1,     5,    29,
+       6,    -1,    -1,    31,    30,    -1,    -1,     8,    31,    30,
+      -1,    38,    -1,    32,    -1,    24,    -1,    28,    -1,    13,
+      -1,    14,    -1,    15,    -1,     9,    19,    -1,    19,    -1,
+      20,    -1,    33,    -1,    34,    -1,    34,    36,    -1,    34,
+      37,    -1,    34,    36,    37,    -1,    11,    35,    -1,     9,
+      11,    35,    -1,    -1,    11,    35,    -1,    10,    35,    -1,
+      12,    35,    -1,    16,    39,    17,    -1,    -1,    18,    -1
   };
 
   /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
@@ -968,20 +986,22 @@ namespace yy
   const unsigned char
   json_parser::yyprhs_[] =
   {
-         0,     0,     3,     5,     7,     9,    11,    13,    17,    18,
-      21,    22,    26,    30,    34,    35,    38,    39,    43,    45,
-      47,    49,    51,    53,    55,    57,    59,    62,    65,    69,
-      72,    76,    77,    80,    83,    86,    90,    91
+         0,     0,     3,     5,     7,     9,    11,    15,    16,    19,
+      20,    24,    28,    32,    33,    36,    37,    41,    43,    45,
+      47,    49,    51,    53,    55,    58,    60,    62,    64,    66,
+      69,    72,    76,    79,    83,    84,    87,    90,    93,    97,
+      98
   };
 
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
   const unsigned char
   json_parser::yyrline_[] =
   {
-         0,    80,    80,    85,    86,    87,    93,    95,    97,    98,
-     104,   105,   111,   117,   119,   120,   127,   128,   135,   136,
-     137,   138,   139,   140,   141,   146,   156,   161,   162,   167,
-     168,   170,   171,   175,   179,   181,   183,   184
+         0,    84,    84,    89,    90,    96,    98,   100,   101,   107,
+     108,   114,   120,   122,   123,   130,   131,   138,   139,   140,
+     141,   142,   143,   144,   149,   150,   151,   152,   154,   164,
+     169,   170,   175,   176,   178,   179,   183,   187,   189,   191,
+     192
   };
 
   // Print the state stack on the debug stream.
@@ -1022,7 +1042,7 @@ namespace yy
     translate_table[] =
     {
            0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
-      12,    13,    14,    15,    16,    17,    18,     2,     2,     2,
+      12,    13,    14,    15,    16,    17,    18,    19,    20,     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,
@@ -1055,20 +1075,20 @@ namespace yy
   }
 
   const int json_parser::yyeof_ = 0;
-  const int json_parser::yylast_ = 39;
-  const int json_parser::yynnts_ = 18;
+  const int json_parser::yylast_ = 51;
+  const int json_parser::yynnts_ = 19;
   const int json_parser::yyempty_ = -2;
-  const int json_parser::yyfinal_ = 25;
+  const int json_parser::yyfinal_ = 33;
   const int json_parser::yyterror_ = 1;
   const int json_parser::yyerrcode_ = 256;
-  const int json_parser::yyntokens_ = 19;
+  const int json_parser::yyntokens_ = 21;
 
   const unsigned int json_parser::yyuser_token_number_max_ = 257;
   const json_parser::token_number_type json_parser::yyundef_token_ = 2;
 
 } // namespace yy
 
-#line 188 "json_parser.yy"
+#line 196 "json_parser.yy"
 
 
 int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver)
index 673923d9e385be51813417b509705889d63ee992..e61ca7c644c6434670257ca6f013bdec1162cab3 100644 (file)
@@ -59,6 +59,8 @@ namespace yy
   #include <QtCore/QString>
   #include <QtCore/QVariant>
 
+  #include <limits>
+
   class JSonScanner;
 
   namespace QJson {
@@ -68,8 +70,8 @@ namespace yy
   #define YYERROR_VERBOSE 1
 
 
-/* Line 303 of lalr1.cc.  */
-#line 73 "json_parser.hh"
+/* Line 35 of lalr1.cc.  */
+#line 75 "json_parser.hh"
 
 #include "location.hh"
 
@@ -146,7 +148,9 @@ namespace yy
      NULL_VAL = 13,
      QUOTMARKOPEN = 14,
      QUOTMARKCLOSE = 15,
-     STRING = 16
+     STRING = 16,
+     INFINITY_VAL = 17,
+     NAN_VAL = 18
    };
 
     };
@@ -241,7 +245,7 @@ namespace yy
     static const unsigned char yytable_[];
     static const signed char yytable_ninf_;
 
-    static const unsigned char yycheck_[];
+    static const signed char yycheck_[];
 
     /// For a state, its accessing symbol.
     static const unsigned char yystos_[];
index ad8e105b73c4488ebd99209ae638ddeb1f56b7ca..2540889bae2647c133bc5daac766262ac83eba3c 100644 (file)
@@ -3,16 +3,16 @@
   * Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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.
@@ -32,6 +32,8 @@
   #include <QtCore/QString>
   #include <QtCore/QVariant>
 
+  #include <limits>
+
   class JSonScanner;
 
   namespace QJson {
@@ -69,6 +71,8 @@
 %token QUOTMARKCLOSE 15 "close quotation mark"
 
 %token STRING 16 "string"
+%token INFINITY_VAL 17 "Infinity"
+%token NAN_VAL 18 "NaN"
 
 // define the initial token
 %start start
@@ -82,12 +86,11 @@ start: data {
               qjsonDebug() << "json_parser - parsing finished";
             };
 
-data: object {$$ = $1; }
-      | array {$$ = $1; }
+data: value { $$ = $1; }
       | error
           {
             qCritical()<< "json_parser - syntax error found, "
-                    << "forcing abort";
+                    << "forcing abort, Line" << @$.begin.line << "Column" << @$.begin.column;
             YYABORT;
           }
       | END;
@@ -133,7 +136,7 @@ r_values: /* empty */ { $$ = QVariant (QVariantList()); }
           };
 
 value: string { $$ = $1; }
-        | number { $$ = $1; }
+        | special_or_number { $$ = $1; }
         | object { $$ = $1; }
         | array { $$ = $1; }
         | TRUE_VAL { $$ = QVariant (true); }
@@ -143,6 +146,11 @@ value: string { $$ = $1; }
           $$ = null_variant;
         };
 
+special_or_number: MINUS INFINITY_VAL { $$ = QVariant(QVariant::Double); $$.setValue( -std::numeric_limits<double>::infinity() ); }
+                   | INFINITY_VAL { $$ = QVariant(QVariant::Double); $$.setValue( std::numeric_limits<double>::infinity() ); }
+                   | NAN_VAL { $$ = QVariant(QVariant::Double); $$.setValue( std::numeric_limits<double>::quiet_NaN() ); }
+                   | number;
+
 number: int {
             if ($1.toByteArray().startsWith('-')) {
               $$ = QVariant (QVariant::LongLong);
index 7f7b88fa0a74fe75c41a3af29d5cfb221e2517f1..de0ddc23c53c94cfd1122c8f7248b5a30b0dedb3 100644 (file)
@@ -3,16 +3,16 @@
  * Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public License
+ * 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.
@@ -38,12 +38,17 @@ bool ishexnstring(const QString& string) {
 }
 
 JSonScanner::JSonScanner(QIODevice* io)
-  : m_io (io)
+  : m_allowSpecialNumbers(false),
+    m_io (io)
 {
   m_quotmarkClosed = true;
   m_quotmarkCount = 0;
 }
 
+void JSonScanner::allowSpecialNumbers(bool allow) {
+  m_allowSpecialNumbers = allow;
+}
+
 static QString unescape( const QByteArray& ba, bool* ok ) {
   assert( ok );
   *ok = false;
@@ -125,7 +130,7 @@ static QString unescape( const QByteArray& ba, bool* ok ) {
 int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc)
 {
   char ch;
-  
+
   if (!m_io->isOpen()) {
     qCritical() << "JSonScanner::yylex - io device is not open";
     return -1;
@@ -148,32 +153,34 @@ int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc)
     }
 
     qjsonDebug() << "JSonScanner::yylex - got |" << ch << "|";
-    
     yylloc->columns();
-    
+
     if (ch == '\n' || ch == '\r')
       yylloc->lines();
-      
   } while (m_quotmarkClosed && (isspace(ch) != 0));
 
-  if (m_quotmarkClosed && ((ch == 't') || (ch == 'T')
-      || (ch == 'n') || (ch == 'N'))) {
-    // check true & null value
+  if (m_quotmarkClosed && ((ch == 't') || (ch == 'T'))) {
     const QByteArray buf = m_io->peek(3).toLower();
+    if (buf == "rue") {
+      m_io->read (3);
+      yylloc->columns(3);
+      qjsonDebug() << "JSonScanner::yylex - TRUE_VAL";
+      return yy::json_parser::token::TRUE_VAL;
+    }
+  }
+  else if (m_quotmarkClosed && ((ch == 'n') || (ch == 'N'))) {
+    const QByteArray buf = m_io->peek(3).toLower();
+    if (buf == "ull") {
+      m_io->read (3);
+      yylloc->columns(3);
+      qjsonDebug() << "JSonScanner::yylex - NULL_VAL";
+      return yy::json_parser::token::NULL_VAL;
+    } else if (buf.startsWith("an") && m_allowSpecialNumbers) {
+      m_io->read(2);
+      yylloc->columns(2);
+      qjsonDebug() << "JSonScanner::yylex - NAN_VAL";
+      return yy::json_parser::token::NAN_VAL;
 
-    if (buf.length() == 3) {
-      if (buf == "rue") {
-        m_io->read (3);
-        yylloc->columns(3);
-        qjsonDebug() << "JSonScanner::yylex - TRUE_VAL";
-        return yy::json_parser::token::TRUE_VAL;
-      }
-      else if (buf == "ull") {
-        m_io->read (3);
-        yylloc->columns(3);
-        qjsonDebug() << "JSonScanner::yylex - NULL_VAL";
-        return yy::json_parser::token::NULL_VAL;
-      }
     }
   }
   else if (m_quotmarkClosed && ((ch == 'f') || (ch == 'F'))) {
@@ -193,14 +200,24 @@ int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc)
     const QByteArray buf = m_io->peek(1);
     if (!buf.isEmpty()) {
       if ((buf[0] == '+' ) || (buf[0] == '-' )) {
-        ret += m_io->read (1);  
+        ret += m_io->read (1);
         yylloc->columns();
       }
     }
     *yylval = QVariant(QString::fromUtf8(ret));
     return yy::json_parser::token::E;
   }
-  
+  else if (m_allowSpecialNumbers && m_quotmarkClosed && ((ch == 'I') || (ch == 'i'))) {
+    QByteArray ret(1, ch);
+    const QByteArray buf = m_io->peek(7);
+    if (buf == "nfinity") {
+      m_io->read(7);
+      yylloc->columns(7);
+      qjsonDebug() << "JSonScanner::yylex - INFINITY_VAL";
+      return yy::json_parser::token::INFINITY_VAL;
+    }
+  }
+
   if (ch != '"' && !m_quotmarkClosed) {
     // we're inside a " " block
     QByteArray raw;
@@ -259,7 +276,38 @@ int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc)
     }
   }
   else if (isdigit(ch) != 0 && m_quotmarkClosed) {
-    *yylval = QVariant(QString::fromLatin1(QByteArray(&ch,1)));
+    bool ok;
+    QByteArray numArray = QByteArray::fromRawData( &ch, 1 * sizeof(char) );
+    qulonglong number = numArray.toULongLong(&ok);
+    if (!ok) {
+      //This shouldn't happen
+      qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1";
+      return -1;
+    }
+    if (number == 0) {
+      // we have to return immediately otherwise numbers like
+      // 2.04 will be converted to 2.4
+      *yylval = QVariant(number);
+      qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT";
+      return yy::json_parser::token::DIGIT;
+    }
+
+    char nextCh;
+    qint64 ret = m_io->peek(&nextCh, 1);
+    while (ret == 1 && isdigit(nextCh)) {
+      m_io->read(1); //consume
+      yylloc->columns(1);
+      numArray = QByteArray::fromRawData( &nextCh, 1 * sizeof(char) );
+      number = number * 10 + numArray.toULongLong(&ok);
+      if (!ok) {
+        //This shouldn't happen
+        qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1";
+        return -1;
+      }
+      ret = m_io->peek(&nextCh, 1);
+    }
+
+    *yylval = QVariant(number);
     qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT";
     return yy::json_parser::token::DIGIT;
   }
index 593426b9636a32db62216c7c140283e4dde383d9..f13e565f5845b1eaa21e8af2d77d306269c11780 100644 (file)
@@ -3,16 +3,16 @@
  * Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public License
+ * 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.
@@ -41,9 +41,11 @@ class JSonScanner
     public:
         explicit JSonScanner(QIODevice* io);
         int yylex(YYSTYPE* yylval, yy::location *yylloc);
-        
+        void allowSpecialNumbers(bool allow);
+
     protected:
         bool m_quotmarkClosed;
+        bool m_allowSpecialNumbers;
         unsigned int m_quotmarkCount;
         QIODevice* m_io;
 };
index 3096d177a378b16e55bf78deb6e3c2bdc941a025..e203b876f76bef989f8b551ac5f11ed6be5fb161 100644 (file)
@@ -3,16 +3,16 @@
  * Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public License
+ * 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.
@@ -34,6 +34,8 @@ ParserPrivate::ParserPrivate() :
     m_scanner(0)
   , m_negate(false)
   , m_error(false)
+  , m_errorLine(0)
+  , m_specialNumbersAllowed(false)
 {
 }
 
@@ -82,6 +84,7 @@ QVariant Parser::parse (QIODevice* io, bool* ok)
   }
 
   d->m_scanner = new JSonScanner (io);
+  d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed);
   yy::json_parser parser(d);
   parser.parse();
 
@@ -112,3 +115,11 @@ 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;
+}
index 8d323cd4d5ece52e06f06fc0cbae8348c5c5e57b..6fb58d89f24cce4907349bbb73a068887beffae0 100644 (file)
@@ -3,16 +3,16 @@
  * Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public License
+ * 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.
@@ -71,6 +71,20 @@ namespace QJson {
       */
       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;
index e12b565721c7ae1c32e195b3937e59c3b231e6a4..aae86a124c9c92e35c1b2e0fcfcc21874fcb470a 100644 (file)
@@ -4,16 +4,16 @@
  * Copyright (C) 2009 Michael Leupold <lemma@confuego.org>
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public License
+ * 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.
@@ -49,6 +49,7 @@ namespace QJson {
       int m_errorLine;
       QString m_errorMsg;
       QVariant m_result;
+      bool m_specialNumbersAllowed;
   };
 }
 
index d09423e4cbb6c1ab5a7ea697062dedc4ffabc10e..88baf4cf68e24ac3f7ab3385a6e199fdcc660f85 100644 (file)
@@ -3,16 +3,16 @@
   * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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.
@@ -61,7 +61,7 @@ void ParserRunnable::run()
     qDebug() << "successfully converted json item to QVariant object";
     emit parsingFinished(result, true, QString());
   } else {
-    const QString errorText = tr("An error occured while parsing json: %1").arg(parser.errorString());
+    const QString errorText = tr("An error occurred while parsing json: %1").arg(parser.errorString());
     qCritical() << errorText;
     emit parsingFinished(QVariant(), false, errorText);
   }
index 822e1fdba8f047a1ac78c05eeea7bcea57d92f1e..2badeb64b74635c5b4cf4a21d80e63c360a85ca7 100644 (file)
@@ -3,16 +3,16 @@
   * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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.
index 5ae1da3a771f82f1ba8317a8425d7544fc7fdfa5..0a511aeef08f29e03598d5f30f8e72375a09dc84 100644 (file)
@@ -3,16 +3,16 @@
   * Copyright (C) 2009 Michael Leupold <lemma@confuego.org>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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.
index 67355f5fae125bbbdef19935f93e35e07d67e50b..9a807b91b282ded6dfd62930e976b3ec918d1007 100644 (file)
@@ -2,16 +2,16 @@
     Copyright (C) 2009 Pino Toscano <pino@kde.org>
 
     This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
+    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
-    Library General Public License for more details.
+    Lesser General Public License for more details.
 
-    You should have received a copy of the GNU Library General Public License
+    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 <QtCore/qglobal.h>
 
-#define QJSON_EXPORT
+#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
index 8bba181b706774dc2b23d0bf56c0db3df3ddfdbe..b756488f07773dbe0fe2b7859a68c07ab1d4cdcc 100644 (file)
@@ -4,16 +4,16 @@
   * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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.
@@ -62,20 +62,24 @@ QVariantMap QObjectHelper::qobject2qvariant( const QObject* object,
 
 void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object)
 {
-  QStringList properies;
   const QMetaObject *metaobject = object->metaObject();
-  int count = metaobject->propertyCount();
-  for (int i=0; i<count; ++i) {
-    QMetaProperty metaproperty = metaobject->property(i);
-    if (metaproperty.isWritable()) {
-      properies << QLatin1String( metaproperty.name());
-    }
-  }
 
   QVariantMap::const_iterator iter;
-  for (iter = variant.constBegin(); iter != variant.end(); iter++) {
-    if (properies.contains(iter.key())) {
-      object->setProperty(iter.key().toAscii(), iter.value());
+  for (iter = variant.constBegin(); iter != variant.constEnd(); ++iter) {
+    int pIdx = metaobject->indexOfProperty( iter.key().toAscii() );
+
+    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 );
     }
   }
 }
index 7bf6b03570e581db4f05eb778c06d9c55d080c58..514ca1fa1b4b7f09b9688a173e09bbd2fb2b13e1 100644 (file)
@@ -3,16 +3,16 @@
   * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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.
@@ -34,6 +34,7 @@ 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
index f012246d43f1cded564751922bdb29253928ff13..41407c2745940b7580b31b221a34f2d505fc9b47 100644 (file)
@@ -4,16 +4,16 @@
   * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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 <QtCore/QStringList>
 #include <QtCore/QVariant>
 
+#include <cmath>
+
+#ifdef _MSC_VER  // using MSVC compiler
+#include <float.h>
+#endif
+
 using namespace QJson;
 
 class Serializer::SerializerPrivate {
+  public:
+    SerializerPrivate() :
+      specialNumbersAllowed(false),
+      indentMode(QJson::IndentNone),
+      doublePrecision(6) {
+      }
+    bool specialNumbersAllowed;
+    IndentMode indentMode;
+    int doublePrecision;
+    QByteArray buildIndent(int spaces);
+    QByteArray serialize( const QVariant &v, int reserved = 0);
+    QString sanitizeString( QString str );
+    QByteArray join( const QList<QByteArray>& list, const QByteArray& sep );
 };
 
-Serializer::Serializer() : d( new SerializerPrivate ) {
-}
-
-Serializer::~Serializer() {
-  delete d;
-}
-
-void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok )
-{
-  Q_ASSERT( io );
-  if (!io->isOpen()) {
-    if (!io->open(QIODevice::WriteOnly)) {
-      if ( ok != 0 )
-        *ok = false;
-      qCritical ("Error opening device");
-      return;
-    }
-  }
-
-  if (!io->isWritable()) {
-    if (ok != 0)
-      *ok = false;
-    qCritical ("Device is not readable");
-    io->close();
-    return;
-  }
-
-  const QByteArray str = serialize( v );
-  if ( !str.isNull() ) {
-    QDataStream stream( io );
-    stream << str;
-  } else {
-    if ( ok )
-      *ok = false;
-  }
-}
-
-static QString sanitizeString( QString str )
-{
-  str.replace( QLatin1String( "\\" ), QLatin1String( "\\\\" ) );
-  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 );
-}
-
-static QByteArray join( const QList<QByteArray>& list, const QByteArray& sep ) {
+QByteArray Serializer::SerializerPrivate::join( const QList<QByteArray>& list, const QByteArray& sep ) {
   QByteArray res;
   Q_FOREACH( const QByteArray& i, list ) {
     if ( !res.isEmpty() )
@@ -89,48 +59,141 @@ static QByteArray join( const QList<QByteArray>& list, const QByteArray& sep ) {
   return res;
 }
 
-QByteArray Serializer::serialize( const QVariant &v )
+QByteArray Serializer::SerializerPrivate::serialize( const QVariant &v, int reserved )
 {
   QByteArray str;
   bool error = false;
+  QByteArray indent;
 
   if ( ! v.isValid() ) { // invalid or null?
     str = "null";
-  } else if ( v.type() == QVariant::List ) { // variant is a list?
+  } else if (( v.type() == QVariant::List ) || ( v.type() == QVariant::StringList )){ // an array or a stringlist?
     const QVariantList list = v.toList();
     QList<QByteArray> values;
-    Q_FOREACH( const QVariant& v, list )
+    Q_FOREACH( const QVariant& var, list )
     {
-      QByteArray serializedValue = serialize( v );
+      reserved++;
+      QByteArray serializedValue = serialize( var,reserved );
+      reserved--;
       if ( serializedValue.isNull() ) {
         error = true;
         break;
       }
       values << serializedValue;
     }
-    str = "[ " + join( values, ", " ) + " ]";
+
+    if (indentMode == QJson::IndentMinimum) {
+      QByteArray indent = buildIndent(reserved - 1);
+      str = "[\n" + join( values, ",\n" ) + "\n" + indent + "]";
+    }
+    else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) {
+      QByteArray indent = buildIndent(reserved);
+      str = "[\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<QString, QVariant> it( vmap );
-    str = "{ ";
+
+    if (indentMode == QJson::IndentMinimum) {
+      QByteArray indent = buildIndent(reserved);
+      str = indent + "{ ";
+    }
+    else if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) {
+      QByteArray indent = buildIndent(reserved);
+      QByteArray nextindent = buildIndent(reserved + 1);
+      str = indent + "{\n" + nextindent;
+    }
+    else if (indentMode == QJson::IndentCompact) {
+      str = "{";
+    }
+    else {
+      str = "{ ";
+    }
+
     QList<QByteArray> pairs;
     while ( it.hasNext() ) {
       it.next();
-      QByteArray serializedValue = serialize( it.value() );
+      reserved++;
+      QByteArray serializedValue = serialize( it.value() , reserved);
+      reserved--;
       if ( serializedValue.isNull() ) {
         error = true;
         break;
       }
-      pairs << sanitizeString( it.key() ).toUtf8() + " : " + serializedValue;
+      QByteArray key   = sanitizeString( it.key() ).toUtf8();
+      QByteArray value = serializedValue;
+      if (indentMode == QJson::IndentCompact) {
+        pairs << key + ":" + value;
+      } else {
+        pairs << key + " : " + value;
+      }
+    }
+
+    if (indentMode == QJson::IndentFull) {
+      QByteArray indent = buildIndent(reserved + 1);
+      str += join( pairs, ",\n" + indent);
+    }
+    else if (indentMode == QJson::IndentCompact) {
+      str += join( pairs, "," );
     }
-    str += join( pairs, ", " );
-    str += " }";
+    else {
+      str += join( pairs, ", " );
+    }
+
+    if (indentMode == QJson::IndentMedium || indentMode == QJson::IndentFull) {
+      QByteArray indent = buildIndent(reserved);
+      str += "\n" + indent + "}";
+    }
+    else if (indentMode == QJson::IndentCompact) {
+      str += "}";
+    }
+    else {
+      str += " }";
+    }
+
   } else 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 ) { // a double?
-    str = QByteArray::number( v.toDouble() );
-    if( ! str.contains( "." ) && ! str.contains( "e" ) ) {
-      str += ".0";
+  } 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)
+    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)
+        if (isnan(value)) {
+#else
+        if (std::isnan(value)) {
+#endif
+          str += "NaN";
+        } else {
+          if (value<0) {
+            str += '-';
+          }
+          str += "Infinity";
+        }
+      } else {
+        qCritical("Attempt to write NaN or infinity, which is not supported by json");
+        error = true;
+    }
+    } 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" );
@@ -146,7 +209,114 @@ QByteArray Serializer::serialize( const QVariant &v )
     error = true;
   }
   if ( !error )
+  {
     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 );
+  if (ok)
+      *ok = false;
+
+  if (!io->isOpen()) {
+    if (!io->open(QIODevice::WriteOnly)) {
+      qCritical ("Error opening device");
+      return;
+    }
+  }
+
+  if (!io->isWritable()) {
+    qCritical ("Device is not readable");
+    io->close();
+    return;
+  }
+
+  const QByteArray str = serialize( v );
+  if (io->write(str) == str.count()) {
+    if (ok)
+      *ok = true;
+  }
+}
+
+QByteArray Serializer::serialize( const QVariant &v)
+{
+  return d->serialize(v);
+}
+
+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;
+}
index fd301b21c052a4df8c8eaa4b7d97a8d3b3097aad..66b349cf7e5ac226f7a33d369c43328c1439aee5 100644 (file)
@@ -3,16 +3,16 @@
   * Copyright (C) 2009 Till Adam <adam@kde.org>
   *
   * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-  * License as published by the Free Software Foundation; either
-  * version 2 of the License, or (at your option) any later version.
+  * 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
-  * Library General Public License for more details.
+  * Lesser General Public License for more details.
   *
-  * You should have received a copy of the GNU Library General Public License
+  * 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.
@@ -28,6 +28,42 @@ class QString;
 class QVariant;
 
 namespace QJson {
+  /**
+  * @brief How the indentation should work.
+  *
+  * none (default) : { "foo" : 0, "foo1" : 1, "foo2" : [ { "foo3" : 3, "foo4" : 4 } ] }
+  *
+  * compact : {"foo":0,"foo1":1,"foo2":[{"foo3":3,"foo4":4}]}
+  *
+  * minimum : { "foo" : 0, "foo1" : 1, "foo2" : [
+  *             { "foo3" : 3, "foo4" : 4 }
+  *           ] }
+  *
+  * medium : {
+  *           "foo" : 0, "foo1" : 1, "foo2" : [
+  *            {
+  *             "foo3" : 3, "foo4" : 4
+  *            }
+  *           ]
+  *          }
+  * full : {
+  *         "foo" : 0,
+  *         "foo1" : 1,
+  *         "foo2" : [
+  *          {
+  *           "foo3" : 3,
+  *           "foo4" : 4
+  *          }
+  *         ]
+  *        }
+  */
+  enum IndentMode {
+    IndentNone,
+    IndentCompact,
+    IndentMinimum,
+    IndentMedium,
+    IndentFull
+  };
   /**
   * @brief Main class used to convert QVariant objects to JSON data.
   *
@@ -47,7 +83,7 @@ namespace QJson {
       * @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 = 0 );
+    void serialize( const QVariant& variant, QIODevice* out, bool* ok = 0);
 
     /**
       * This is a method provided for convenience. It turns the passed in in-memory
@@ -59,7 +95,34 @@ namespace QJson {
       * parser.
       */
 
-    QByteArray serialize( const QVariant& variant );
+    QByteArray serialize( const QVariant& variant);
+
+    /**
+     * 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;
 
   private:
     Q_DISABLE_COPY(Serializer)
index 2e57c4517e05ea3934c54dda8f78f2548df5907f..9ebf68b7225f952ad9fbe531530ea708c1988973 100644 (file)
@@ -6,16 +6,16 @@
  *               2009 Frank Osterfeld <osterfeld@kde.org>
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public License
+ * 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.
index c6b5fe1175d4ffb23a6c25edb05fd385239b9ca6..d665fc5138f15a60770e2ab743aafeef9da906ba 100644 (file)
@@ -3,16 +3,16 @@
  * Copyright (C) 2009 Frank Osterfeld <osterfeld@kde.org>
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public License
+ * 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.