[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r3986: Added QJSON library to HerdictWeb source tree. Used that to (in vidalia/branches/extension-api: . src/vidalia/HerdictWebReporterPlugin)



Author: tyree731
Date: 2009-07-29 22:02:46 -0400 (Wed, 29 Jul 2009)
New Revision: 3986

Added:
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.cc
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.hh
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.yy
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.cpp
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/location.hh
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.cpp
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser_p.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.cpp
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/position.hh
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_debug.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_export.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.cpp
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.cpp
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.h
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/stack.hh
Modified:
   vidalia/branches/extension-api/CMakeLists.txt
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/CMakeLists.txt
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.cpp
   vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.h
Log:
Added QJSON library to HerdictWeb source tree. Used that to handle JSON responses from HerdictWeb. Interface populates itself dynamically and submit possibly works. Plugin is close to completion.


Modified: vidalia/branches/extension-api/CMakeLists.txt
===================================================================
--- vidalia/branches/extension-api/CMakeLists.txt	2009-07-28 23:40:14 UTC (rev 3985)
+++ vidalia/branches/extension-api/CMakeLists.txt	2009-07-30 02:02:46 UTC (rev 3986)
@@ -43,6 +43,7 @@
 
 if (USE_HERDICTWEB)
   set(QT_USE_QTWEBKIT true)
+  set(QT_USE_QTSCRIPT true)
 endif(USE_HERDICTWEB)
 
 if (USE_MARBLE)

Modified: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/CMakeLists.txt
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/CMakeLists.txt	2009-07-28 23:40:14 UTC (rev 3985)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/CMakeLists.txt	2009-07-30 02:02:46 UTC (rev 3986)
@@ -18,10 +18,20 @@
 set(herdictwebreporterplugin_SRCS
   HerdictWebReporterPlugin.cpp
   HerdictWebReporterPanel.cpp
+## QJSON Files ##
+  parser.cpp 
+  json_scanner.cpp 
+  json_parser.cc 
+  parserrunnable.cpp 
+  serializer.cpp 
+  serializerrunnable.cpp
 )
 qt4_wrap_cpp(herdictwebreporterplugin_SRCS
   HerdictWebReporterPlugin.h
   HerdictWebReporterPanel.h
+## QJSON files ##
+  parserrunnable.h
+  serializerrunnable.h
 )
 qt4_wrap_ui(herdictwebreporterplugin_SRCS
   HerdictWebReporterPanel.ui

Modified: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.cpp	2009-07-28 23:40:14 UTC (rev 3985)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.cpp	2009-07-30 02:02:46 UTC (rev 3986)
@@ -17,18 +17,30 @@
 #include "HerdictWebReporterPanel.h"
 
 #include <QHostAddress>
+#include <QList>
 #include <QNetworkAccessManager>
 #include <QNetworkProxy>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QString>
 #include <QUrl>
+#include <QVariant>
 
+/** QJSON Files */
+#include "parser.h"
+
 HerdictWebReporterPanel::HerdictWebReporterPanel(VidaliaPluginInterface* parent)
-: VidaliaPanel(parent)
+: VidaliaPanel(parent),
+  _accessManager(0)
 {
   ui.setupUi(this);
 
   /* Create the status widget */
   _statusWidget = new QLabel(this);
 
+  /* Populate the left side of the panel */
+  populateHerdictOptions();
+
   /* Proxy hostname and port */
   QHostAddress address(QHostAddress::LocalHost);
   QString hostname = address.toString();
@@ -50,6 +62,10 @@
   /* Connect button actions and URL actions to the WebView widgets. */
   connect(ui.lineUrlEntry, SIGNAL(returnPressed()),
           this, SLOT(loadUrl()));
+  connect(ui.buttonAccessible, SIGNAL(pressed()),
+          this, SLOT(submitAccessible()));
+  connect(ui.buttonInAccessible, SIGNAL(pressed()),
+          this, SLOT(submitInAccessible()));
 
   /* Connect page signals to their respective handlers */
   connect(ui.webViewPlain, SIGNAL(loadStarted()),
@@ -125,6 +141,146 @@
 }
 
 void
+HerdictWebReporterPanel::requestFinished(QNetworkReply* reply)
+{
+  /* If there was an error, do nothing */
+  if (reply->error() != QNetworkReply::NoError)
+    return;
+
+  /* Create the json parser */
+  bool result;
+  QJson::Parser jsonParser;
+
+  /* Figure out which request it was */
+  QString url = reply->url().toString();
+
+  if (url == "http://www.herdict.org/web/action/ajax/plugin/init-categories/";) {
+    /* Retrieve all of the tuples */
+    QList<QVariant> jsonResultList = 
+      jsonParser.parse(reply, &result).toList();
+    /* If invalid json, do nothing */
+    if (!result)
+      return;
+
+    /* Evaluate each tuple as a map to obtain the necessary values */
+    QList<QVariant>::iterator it = jsonResultList.begin();
+    while (it != jsonResultList.end()) {
+      QVariantMap valueMap = (*it).toMap();
+      ui.comboCategoryEntry->addItem(valueMap["label"].toString(), 
+                                     valueMap["value"]);
+      it++;
+    }
+  }
+  else if (url == "http://www.herdict.org/web/action/ajax/plugin/init-countries/";) {
+    /* Retrieve all of the tuples */
+    QList<QVariant> jsonResultList =
+      jsonParser.parse(reply, &result).toList();
+    /* If invalid json, do nothing */
+    if (!result)
+      return;
+
+    /* Evaluate each tuple as a map to obtain the necessary values */
+    QList<QVariant>::iterator it = jsonResultList.begin();
+    while (it != jsonResultList.end()) {
+      QVariantMap valueMap = (*it).toMap();
+      ui.comboCountryEntry->addItem(valueMap["label"].toString(),
+                                     valueMap["value"]);
+      it++;
+    }
+
+  }
+  else if (url == "http://www.herdict.org/web/action/ajax/plugin/init-locations/";) {
+    /* Retrieve all of the tuples */
+    QList<QVariant> jsonResultList =
+      jsonParser.parse(reply, &result).toList();
+    /* If invalid json, do nothing */
+    if (!result)
+      return;
+
+    /* Evaluate each tuple as a map to obtain the necessary values */
+    QList<QVariant>::iterator it = jsonResultList.begin();
+    while (it != jsonResultList.end()) {
+      QVariantMap valueMap = (*it).toMap();
+      ui.comboLocationEntry->addItem(valueMap["label"].toString(),
+                                     valueMap["value"]);
+      it++;
+    }
+
+  }
+  else if (url == "http://www.herdict.org/web/action/ajax/plugin/init-interests/";) {
+    /* Retrieve all of the tuples */
+    QList<QVariant> jsonResultList =
+      jsonParser.parse(reply, &result).toList();
+    /* If invalid json, do nothing */
+    if (!result)
+      return;
+
+    /* Evaluate each tuple as a map to obtain the necessary values */
+    QList<QVariant>::iterator it = jsonResultList.begin();
+    while (it != jsonResultList.end()) {
+      QVariantMap valueMap = (*it).toMap();
+      ui.comboUsefulnessEntry->addItem(valueMap["label"].toString(),
+                                     valueMap["value"]);
+      it++;
+    }
+
+}
+  else if (url == "http://www.herdict.org/web/action/ajax/plugin/init-reasons/";) {
+    /* Retrieve all of the tuples */
+    QList<QVariant> jsonResultList =
+      jsonParser.parse(reply, &result).toList();
+    /* If invalid json, do nothing */
+    if (!result)
+      return;
+
+    /* Evaluate each tuple as a map to obtain the necessary values */
+    QList<QVariant>::iterator it = jsonResultList.begin();
+    while (it != jsonResultList.end()) {
+      QVariantMap valueMap = (*it).toMap();
+      ui.comboCauseEntry->addItem(valueMap["label"].toString(),
+                                     valueMap["value"]);
+      it++;
+    }
+
+}
+  else if (url == "http://www.herdict.org/web/action/ajax/plugin/init-currentLocation/FF1.0";) {
+    /* Handle the json as a map */
+    QVariantMap jsonResultMap = jsonParser.parse(reply, &result).toMap();
+    /* If invalid json, do nothing */
+    if (!result)
+      return;
+
+    _defaultISP = jsonResultMap["ispName"].toString();
+    _defaultCountryCode = jsonResultMap["countryShort"].toString();
+
+    ui.lineISPEntry->setText(jsonResultMap["ispName"].toString());
+    ui.comboCountryEntry->setCurrentIndex(ui.comboCountryEntry->findText(
+                                   jsonResultMap["countryLong"].toString()));
+}
+
+  /* Close the network reply */
+  reply->close();
+}
+
+void
+HerdictWebReporterPanel::submitAccessible()
+{
+  /* Construct request */
+  QString request = constructRequest(HerdictWebReporterPanel::Accessible);
+  /* Send request */
+  QNetworkReply* reply = _accessManager->get(QNetworkRequest(QUrl(request)));
+}
+
+void
+HerdictWebReporterPanel::submitInAccessible()
+{
+  /* Construct request */
+  QString request = constructRequest(HerdictWebReporterPanel::InAccessible);
+  /* Send request */
+  QNetworkReply* reply = _accessManager->get(QNetworkRequest(QUrl(request)));
+}
+
+void
 HerdictWebReporterPanel::torLoadFinished(bool result)
 {
   /* Hide the statusbar */
@@ -132,3 +288,63 @@
   if (!result)
     ui.webViewTor->load(QUrl("about:blank"));
 }
+
+QString
+HerdictWebReporterPanel::constructRequest(
+  HerdictWebReporterPanel::ReportPageType type)
+{
+  QString request = "http://www.herdict.org/web/action/ajax/plugin/report?";;
+  if (type == HerdictWebReporterPanel::Accessible) {
+    request += "siteAccessible";
+  }
+  else {
+    request += "siteInaccessible";
+  }
+  request += (QString("&report.url=") + ui.lineUrlEntry->text());
+  request += (QString("&report.country.shortName=") +
+              ui.comboCountryEntry->itemData(
+                           ui.comboCountryEntry->currentIndex()).toString());
+  request += (QString("&report.ispName=") + ui.lineISPEntry->text());
+  request += (QString("&report.location=") + ui.comboLocationEntry->itemData(
+                           ui.comboLocationEntry->currentIndex()).toString());
+  request += (QString("&report.interest=") + ui.comboUsefulnessEntry->itemData(
+                           ui.comboUsefulnessEntry->currentIndex()).toString());
+  request += (QString("&report.reason=") + ui.comboCauseEntry->itemData(
+                           ui.comboCauseEntry->currentIndex()).toString());
+  request += (QString("&report.tag=") + ui.comboCategoryEntry->itemData(
+                           ui.comboCategoryEntry->currentIndex()).toString());
+  request += (QString("&report.comments=") +ui.textCommentEntry->toPlainText());
+  request += (QString("&report.defaultCountryCode=") + _defaultCountryCode);
+  request += (QString("&report.defaultISPName=") + _defaultISP);
+  request += (QString("&report.rot13=VidaliaPlugin"));
+
+  return request;
+}
+
+void
+HerdictWebReporterPanel::populateHerdictOptions()
+{
+  /* If no access manager, create one */
+  if (!_accessManager)
+    _accessManager = new QNetworkAccessManager(this);
+
+  /* When access manager finishes a request, will send signal to handler */
+  connect(_accessManager, SIGNAL(finished(QNetworkReply*)), 
+          this, SLOT(requestFinished(QNetworkReply*)));
+
+  /* Create each network request */
+  QNetworkRequest categoriesRequest(QUrl("http://www.herdict.org/web/action/ajax/plugin/init-categories/";));
+  QNetworkRequest countriesRequest(QUrl("http://www.herdict.org/web/action/ajax/plugin/init-countries/";));
+  QNetworkRequest locationsRequest(QUrl("http://www.herdict.org/web/action/ajax/plugin/init-locations/";));
+  QNetworkRequest interestsRequest(QUrl("http://www.herdict.org/web/action/ajax/plugin/init-interests/";));
+  QNetworkRequest reasonsRequest(QUrl("http://www.herdict.org/web/action/ajax/plugin/init-reasons/";));
+  QNetworkRequest currentLocationRequest(QUrl("http://www.herdict.org/web/action/ajax/plugin/init-currentLocation/FF1.0";));
+
+  /* Now make the requests */
+  _accessManager->get(categoriesRequest);
+  _accessManager->get(countriesRequest);
+  _accessManager->get(locationsRequest);
+  _accessManager->get(interestsRequest);
+  _accessManager->get(reasonsRequest);
+  _accessManager->get(currentLocationRequest);
+}

Modified: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.h	2009-07-28 23:40:14 UTC (rev 3985)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/HerdictWebReporterPanel.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -24,6 +24,7 @@
 #include "ui_HerdictWebReporterPanel.h"
 
 class HerdictWebReporterPlugin;
+class QNetworkAccessManager;
 
 class HerdictWebReporterPanel : public VidaliaPanel
 {
@@ -49,13 +50,37 @@
   void loadUrl();
   /* Handle webViewPlain finishing */
   void plainLoadFinished(bool result);
+  /* Handle web request from the access manager */
+  void requestFinished(QNetworkReply* reply);
+  /* Handles submitting a website accessible request */
+  void submitAccessible();
+  /* Handles submitted a website inaccessible request */
+  void submitInAccessible();
   /* Handle webViewTor finishing. */
   void torLoadFinished(bool result);
 private:
+  /** The two types of requests possible */
+  enum ReportPageType {
+    Accessible,
+    InAccessible
+  };
+
+  /** Takes in what type of request is being constructed and returns the
+   * HerdictWeb report page request */
+  QString constructRequest(HerdictWebReporterPanel::ReportPageType type);
+  /** Function used to populate the left side of the Herdict Plugin panel */
+  void populateHerdictOptions();
+
   /** Qt Designer Object */
   Ui::HerdictWebReporterPanel ui;
   /** The status bar widget */
   QLabel* _statusWidget;
+  /** Access manager. Used for HerdictWeb requests */
+  QNetworkAccessManager* _accessManager;
+
+  /** Needed for the HerdictWeb API */
+  QString _defaultCountryCode;
+  QString _defaultISP;
 };
 
 #endif

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.cc
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.cc	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.cc	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,1087 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Skeleton implementation for Bison LALR(1) parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+
+#include "json_parser.hh"
+
+/* User implementation prologue.  */
+
+
+/* Line 317 of lalr1.cc.  */
+#line 43 "json_parser.cc"
+
+#ifndef YY_
+# if YYENABLE_NLS
+#  if ENABLE_NLS
+#   include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
+#   define YY_(msgid) dgettext ("bison-runtime", msgid)
+#  endif
+# endif
+# ifndef YY_
+#  define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E.  */
+#define YYUSE(e) ((void) (e))
+
+/* A pseudo ostream that takes yydebug_ into account.  */
+# define YYCDEBUG							\
+  for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false)	\
+    (*yycdebug_)
+
+/* Enable debugging if requested.  */
+#if YYDEBUG
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)	\
+do {							\
+  if (yydebug_)						\
+    {							\
+      *yycdebug_ << Title << ' ';			\
+      yy_symbol_print_ ((Type), (Value), (Location));	\
+      *yycdebug_ << std::endl;				\
+    }							\
+} while (false)
+
+# define YY_REDUCE_PRINT(Rule)		\
+do {					\
+  if (yydebug_)				\
+    yy_reduce_print_ (Rule);		\
+} while (false)
+
+# define YY_STACK_PRINT()		\
+do {					\
+  if (yydebug_)				\
+    yystack_print_ ();			\
+} while (false)
+
+#else /* !YYDEBUG */
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_REDUCE_PRINT(Rule)
+# define YY_STACK_PRINT()
+
+#endif /* !YYDEBUG */
+
+#define YYACCEPT	goto yyacceptlab
+#define YYABORT		goto yyabortlab
+#define YYERROR		goto yyerrorlab
+
+namespace yy
+{
+#if YYERROR_VERBOSE
+
+  /* Return YYSTR after stripping away unnecessary quotes and
+     backslashes, so that it's suitable for yyerror.  The heuristic is
+     that double-quoting is unnecessary unless the string contains an
+     apostrophe, a comma, or backslash (other than backslash-backslash).
+     YYSTR is taken from yytname.  */
+  std::string
+  json_parser::yytnamerr_ (const char *yystr)
+  {
+    if (*yystr == '"')
+      {
+        std::string yyr = "";
+        char const *yyp = yystr;
+
+        for (;;)
+          switch (*++yyp)
+            {
+            case '\'':
+            case ',':
+              goto do_not_strip_quotes;
+
+            case '\\':
+              if (*++yyp != '\\')
+                goto do_not_strip_quotes;
+              /* Fall through.  */
+            default:
+              yyr += *yyp;
+              break;
+
+            case '"':
+              return yyr;
+            }
+      do_not_strip_quotes: ;
+      }
+
+    return yystr;
+  }
+
+#endif
+
+  /// Build a parser object.
+  json_parser::json_parser (QJson::ParserPrivate* driver_yyarg)
+    : yydebug_ (false),
+      yycdebug_ (&std::cerr),
+      driver (driver_yyarg)
+  {
+  }
+
+  json_parser::~json_parser ()
+  {
+  }
+
+#if YYDEBUG
+  /*--------------------------------.
+  | Print this symbol on YYOUTPUT.  |
+  `--------------------------------*/
+
+  inline void
+  json_parser::yy_symbol_value_print_ (int yytype,
+			   const semantic_type* yyvaluep, const location_type* yylocationp)
+  {
+    YYUSE (yylocationp);
+    YYUSE (yyvaluep);
+    switch (yytype)
+      {
+         default:
+	  break;
+      }
+  }
+
+
+  void
+  json_parser::yy_symbol_print_ (int yytype,
+			   const semantic_type* yyvaluep, const location_type* yylocationp)
+  {
+    *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
+	       << ' ' << yytname_[yytype] << " ("
+	       << *yylocationp << ": ";
+    yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
+    *yycdebug_ << ')';
+  }
+#endif /* ! YYDEBUG */
+
+  void
+  json_parser::yydestruct_ (const char* yymsg,
+			   int yytype, semantic_type* yyvaluep, location_type* yylocationp)
+  {
+    YYUSE (yylocationp);
+    YYUSE (yymsg);
+    YYUSE (yyvaluep);
+
+    YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+    switch (yytype)
+      {
+  
+	default:
+	  break;
+      }
+  }
+
+  void
+  json_parser::yypop_ (unsigned int n)
+  {
+    yystate_stack_.pop (n);
+    yysemantic_stack_.pop (n);
+    yylocation_stack_.pop (n);
+  }
+
+  std::ostream&
+  json_parser::debug_stream () const
+  {
+    return *yycdebug_;
+  }
+
+  void
+  json_parser::set_debug_stream (std::ostream& o)
+  {
+    yycdebug_ = &o;
+  }
+
+
+  json_parser::debug_level_type
+  json_parser::debug_level () const
+  {
+    return yydebug_;
+  }
+
+  void
+  json_parser::set_debug_level (debug_level_type l)
+  {
+    yydebug_ = l;
+  }
+
+
+  int
+  json_parser::parse ()
+  {
+    /// Look-ahead and look-ahead in internal form.
+    int yychar = yyempty_;
+    int yytoken = 0;
+
+    /* State.  */
+    int yyn;
+    int yylen = 0;
+    int yystate = 0;
+
+    /* Error handling.  */
+    int yynerrs_ = 0;
+    int yyerrstatus_ = 0;
+
+    /// Semantic value of the look-ahead.
+    semantic_type yylval;
+    /// Location of the look-ahead.
+    location_type yylloc;
+    /// The locations where the error started and ended.
+    location yyerror_range[2];
+
+    /// $$.
+    semantic_type yyval;
+    /// @$.
+    location_type yyloc;
+
+    int yyresult;
+
+    YYCDEBUG << "Starting parse" << std::endl;
+
+
+    /* Initialize the stacks.  The initial state will be pushed in
+       yynewstate, since the latter expects the semantical and the
+       location values to have been already stored, initialize these
+       stacks with a primary value.  */
+    yystate_stack_ = state_stack_type (0);
+    yysemantic_stack_ = semantic_stack_type (0);
+    yylocation_stack_ = location_stack_type (0);
+    yysemantic_stack_.push (yylval);
+    yylocation_stack_.push (yylloc);
+
+    /* New state.  */
+  yynewstate:
+    yystate_stack_.push (yystate);
+    YYCDEBUG << "Entering state " << yystate << std::endl;
+    goto yybackup;
+
+    /* Backup.  */
+  yybackup:
+
+    /* Try to take a decision without look-ahead.  */
+    yyn = yypact_[yystate];
+    if (yyn == yypact_ninf_)
+      goto yydefault;
+
+    /* Read a look-ahead token.  */
+    if (yychar == yyempty_)
+      {
+	YYCDEBUG << "Reading a token: ";
+	yychar = yylex (&yylval, &yylloc, driver);
+      }
+
+
+    /* Convert token to internal form.  */
+    if (yychar <= yyeof_)
+      {
+	yychar = yytoken = yyeof_;
+	YYCDEBUG << "Now at end of input." << std::endl;
+      }
+    else
+      {
+	yytoken = yytranslate_ (yychar);
+	YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+      }
+
+    /* If the proper action on seeing token YYTOKEN is to reduce or to
+       detect an error, take that action.  */
+    yyn += yytoken;
+    if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
+      goto yydefault;
+
+    /* Reduce or error.  */
+    yyn = yytable_[yyn];
+    if (yyn <= 0)
+      {
+	if (yyn == 0 || yyn == yytable_ninf_)
+	goto yyerrlab;
+	yyn = -yyn;
+	goto yyreduce;
+      }
+
+    /* Accept?  */
+    if (yyn == yyfinal_)
+      goto yyacceptlab;
+
+    /* Shift the look-ahead token.  */
+    YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+    /* Discard the token being shifted unless it is eof.  */
+    if (yychar != yyeof_)
+      yychar = yyempty_;
+
+    yysemantic_stack_.push (yylval);
+    yylocation_stack_.push (yylloc);
+
+    /* Count tokens shifted since error; after three, turn off error
+       status.  */
+    if (yyerrstatus_)
+      --yyerrstatus_;
+
+    yystate = yyn;
+    goto yynewstate;
+
+  /*-----------------------------------------------------------.
+  | yydefault -- do the default action for the current state.  |
+  `-----------------------------------------------------------*/
+  yydefault:
+    yyn = yydefact_[yystate];
+    if (yyn == 0)
+      goto yyerrlab;
+    goto yyreduce;
+
+  /*-----------------------------.
+  | yyreduce -- Do a reduction.  |
+  `-----------------------------*/
+  yyreduce:
+    yylen = yyr2_[yyn];
+    /* If YYLEN is nonzero, implement the default value of the action:
+       `$$ = $1'.  Otherwise, use the top of the stack.
+
+       Otherwise, the following line sets YYVAL to garbage.
+       This behavior is undocumented and Bison
+       users should not rely upon it.  */
+    if (yylen)
+      yyval = yysemantic_stack_[yylen - 1];
+    else
+      yyval = yysemantic_stack_[0];
+
+    {
+      slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
+      YYLLOC_DEFAULT (yyloc, slice, yylen);
+    }
+    YY_REDUCE_PRINT (yyn);
+    switch (yyn)
+      {
+	  case 2:
+#line 81 "json_parser.yy"
+    {
+              driver->m_result = (yysemantic_stack_[(1) - (1)]);
+              qjsonDebug() << "json_parser - parsing finished";
+            ;}
+    break;
+
+  case 3:
+#line 86 "json_parser.yy"
+    {(yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+    break;
+
+  case 4:
+#line 87 "json_parser.yy"
+    {(yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+    break;
+
+  case 5:
+#line 89 "json_parser.yy"
+    {
+            qCritical()<< "json_parser - syntax error found, "
+                    << "forcing abort";
+            YYABORT;
+          ;}
+    break;
+
+  case 7:
+#line 96 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
+    break;
+
+  case 8:
+#line 98 "json_parser.yy"
+    { (yyval) = QVariant (QVariantMap()); ;}
+    break;
+
+  case 9:
+#line 99 "json_parser.yy"
+    {
+            QVariantMap members = (yysemantic_stack_[(2) - (2)]).toMap();
+            (yyval) = QVariant(members.unite ((yysemantic_stack_[(2) - (1)]).toMap()));
+          ;}
+    break;
+
+  case 10:
+#line 104 "json_parser.yy"
+    { (yyval) = QVariant (QVariantMap()); ;}
+    break;
+
+  case 11:
+#line 105 "json_parser.yy"
+    {
+          QVariantMap members = (yysemantic_stack_[(3) - (3)]).toMap();
+          
+          (yyval) = QVariant(members.unite ((yysemantic_stack_[(3) - (2)]).toMap()));
+          ;}
+    break;
+
+  case 12:
+#line 111 "json_parser.yy"
+    {
+            QVariantMap pair;
+            pair.insert ((yysemantic_stack_[(3) - (1)]).toString(), QVariant((yysemantic_stack_[(3) - (3)])));
+            (yyval) = QVariant (pair);
+          ;}
+    break;
+
+  case 13:
+#line 117 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
+    break;
+
+  case 14:
+#line 119 "json_parser.yy"
+    { (yyval) = QVariant (QVariantList()); ;}
+    break;
+
+  case 15:
+#line 120 "json_parser.yy"
+    {
+          QVariantList members = (yysemantic_stack_[(2) - (2)]).toList();
+          members.prepend ((yysemantic_stack_[(2) - (1)]));
+          (yyval) = QVariant(members);
+        ;}
+    break;
+
+  case 16:
+#line 126 "json_parser.yy"
+    { (yyval) = QVariant (QVariantList()); ;}
+    break;
+
+  case 17:
+#line 127 "json_parser.yy"
+    {
+            QVariantList members = (yysemantic_stack_[(3) - (3)]).toList();
+            members.prepend ((yysemantic_stack_[(3) - (2)]));
+            (yyval) = QVariant(members);
+          ;}
+    break;
+
+  case 18:
+#line 133 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+    break;
+
+  case 19:
+#line 134 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+    break;
+
+  case 20:
+#line 135 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+    break;
+
+  case 21:
+#line 136 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
+    break;
+
+  case 22:
+#line 137 "json_parser.yy"
+    { (yyval) = QVariant (true); ;}
+    break;
+
+  case 23:
+#line 138 "json_parser.yy"
+    { (yyval) = QVariant (false); ;}
+    break;
+
+  case 24:
+#line 139 "json_parser.yy"
+    {
+          QVariant null_variant;
+          (yyval) = null_variant;
+        ;}
+    break;
+
+  case 25:
+#line 144 "json_parser.yy"
+    {
+            (yyval) = QVariant (QVariant::Int);
+            (yyval).setValue((yysemantic_stack_[(1) - (1)]).toInt());
+          ;}
+    break;
+
+  case 26:
+#line 148 "json_parser.yy"
+    {
+            const QByteArray value = (yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray();
+            (yyval) = QVariant(QVariant::Double);
+            (yyval).setValue(value.toDouble());
+          ;}
+    break;
+
+  case 27:
+#line 153 "json_parser.yy"
+    {  (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
+    break;
+
+  case 28:
+#line 154 "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 159 "json_parser.yy"
+    { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
+    break;
+
+  case 30:
+#line 160 "json_parser.yy"
+    { (yyval) = QVariant (QByteArray("-") + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray()); ;}
+    break;
+
+  case 31:
+#line 162 "json_parser.yy"
+    { (yyval) = QVariant (QByteArray("")); ;}
+    break;
+
+  case 32:
+#line 163 "json_parser.yy"
+    {
+          (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray());
+        ;}
+    break;
+
+  case 33:
+#line 167 "json_parser.yy"
+    {
+          (yyval) = QVariant(QByteArray(".") + (yysemantic_stack_[(2) - (2)]).toByteArray());
+        ;}
+    break;
+
+  case 34:
+#line 171 "json_parser.yy"
+    { (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
+    break;
+
+  case 35:
+#line 173 "json_parser.yy"
+    { (yyval) = (yysemantic_stack_[(3) - (2)]) ;}
+    break;
+
+  case 36:
+#line 175 "json_parser.yy"
+    { (yyval) = QVariant (QByteArray("")); ;}
+    break;
+
+  case 37:
+#line 176 "json_parser.yy"
+    {
+                (yyval) = (yysemantic_stack_[(1) - (1)]);
+              ;}
+    break;
+
+
+    /* Line 675 of lalr1.cc.  */
+#line 609 "json_parser.cc"
+	default: break;
+      }
+    YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
+
+    yypop_ (yylen);
+    yylen = 0;
+    YY_STACK_PRINT ();
+
+    yysemantic_stack_.push (yyval);
+    yylocation_stack_.push (yyloc);
+
+    /* Shift the result of the reduction.  */
+    yyn = yyr1_[yyn];
+    yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
+    if (0 <= yystate && yystate <= yylast_
+	&& yycheck_[yystate] == yystate_stack_[0])
+      yystate = yytable_[yystate];
+    else
+      yystate = yydefgoto_[yyn - yyntokens_];
+    goto yynewstate;
+
+  /*------------------------------------.
+  | yyerrlab -- here on detecting error |
+  `------------------------------------*/
+  yyerrlab:
+    /* If not already recovering from an error, report this error.  */
+    if (!yyerrstatus_)
+      {
+	++yynerrs_;
+	error (yylloc, yysyntax_error_ (yystate, yytoken));
+      }
+
+    yyerror_range[0] = yylloc;
+    if (yyerrstatus_ == 3)
+      {
+	/* If just tried and failed to reuse look-ahead token after an
+	 error, discard it.  */
+
+	if (yychar <= yyeof_)
+	  {
+	  /* Return failure if at end of input.  */
+	  if (yychar == yyeof_)
+	    YYABORT;
+	  }
+	else
+	  {
+	    yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
+	    yychar = yyempty_;
+	  }
+      }
+
+    /* Else will try to reuse look-ahead token after shifting the error
+       token.  */
+    goto yyerrlab1;
+
+
+  /*---------------------------------------------------.
+  | yyerrorlab -- error raised explicitly by YYERROR.  |
+  `---------------------------------------------------*/
+  yyerrorlab:
+
+    /* Pacify compilers like GCC when the user code never invokes
+       YYERROR and the label yyerrorlab therefore never appears in user
+       code.  */
+    if (false)
+      goto yyerrorlab;
+
+    yyerror_range[0] = yylocation_stack_[yylen - 1];
+    /* Do not reclaim the symbols of the rule which action triggered
+       this YYERROR.  */
+    yypop_ (yylen);
+    yylen = 0;
+    yystate = yystate_stack_[0];
+    goto yyerrlab1;
+
+  /*-------------------------------------------------------------.
+  | yyerrlab1 -- common code for both syntax error and YYERROR.  |
+  `-------------------------------------------------------------*/
+  yyerrlab1:
+    yyerrstatus_ = 3;	/* Each real token shifted decrements this.  */
+
+    for (;;)
+      {
+	yyn = yypact_[yystate];
+	if (yyn != yypact_ninf_)
+	{
+	  yyn += yyterror_;
+	  if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
+	    {
+	      yyn = yytable_[yyn];
+	      if (0 < yyn)
+		break;
+	    }
+	}
+
+	/* Pop the current state because it cannot handle the error token.  */
+	if (yystate_stack_.height () == 1)
+	YYABORT;
+
+	yyerror_range[0] = yylocation_stack_[0];
+	yydestruct_ ("Error: popping",
+		     yystos_[yystate],
+		     &yysemantic_stack_[0], &yylocation_stack_[0]);
+	yypop_ ();
+	yystate = yystate_stack_[0];
+	YY_STACK_PRINT ();
+      }
+
+    if (yyn == yyfinal_)
+      goto yyacceptlab;
+
+    yyerror_range[1] = yylloc;
+    // Using YYLLOC is tempting, but would change the location of
+    // the look-ahead.  YYLOC is available though.
+    YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
+    yysemantic_stack_.push (yylval);
+    yylocation_stack_.push (yyloc);
+
+    /* Shift the error token.  */
+    YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
+		   &yysemantic_stack_[0], &yylocation_stack_[0]);
+
+    yystate = yyn;
+    goto yynewstate;
+
+    /* Accept.  */
+  yyacceptlab:
+    yyresult = 0;
+    goto yyreturn;
+
+    /* Abort.  */
+  yyabortlab:
+    yyresult = 1;
+    goto yyreturn;
+
+  yyreturn:
+    if (yychar != yyeof_ && yychar != yyempty_)
+      yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
+
+    /* Do not reclaim the symbols of the rule which action triggered
+       this YYABORT or YYACCEPT.  */
+    yypop_ (yylen);
+    while (yystate_stack_.height () != 1)
+      {
+	yydestruct_ ("Cleanup: popping",
+		   yystos_[yystate_stack_[0]],
+		   &yysemantic_stack_[0],
+		   &yylocation_stack_[0]);
+	yypop_ ();
+      }
+
+    return yyresult;
+  }
+
+  // Generate an error message.
+  std::string
+  json_parser::yysyntax_error_ (int yystate, int tok)
+  {
+    std::string res;
+    YYUSE (yystate);
+#if YYERROR_VERBOSE
+    int yyn = yypact_[yystate];
+    if (yypact_ninf_ < yyn && yyn <= yylast_)
+      {
+	/* Start YYX at -YYN if negative to avoid negative indexes in
+	   YYCHECK.  */
+	int yyxbegin = yyn < 0 ? -yyn : 0;
+
+	/* Stay within bounds of both yycheck and yytname.  */
+	int yychecklim = yylast_ - yyn + 1;
+	int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
+	int count = 0;
+	for (int x = yyxbegin; x < yyxend; ++x)
+	  if (yycheck_[x + yyn] == x && x != yyterror_)
+	    ++count;
+
+	// FIXME: This method of building the message is not compatible
+	// with internationalization.  It should work like yacc.c does it.
+	// That is, first build a string that looks like this:
+	// "syntax error, unexpected %s or %s or %s"
+	// Then, invoke YY_ on this string.
+	// Finally, use the string as a format to output
+	// yytname_[tok], etc.
+	// Until this gets fixed, this message appears in English only.
+	res = "syntax error, unexpected ";
+	res += yytnamerr_ (yytname_[tok]);
+	if (count < 5)
+	  {
+	    count = 0;
+	    for (int x = yyxbegin; x < yyxend; ++x)
+	      if (yycheck_[x + yyn] == x && x != yyterror_)
+		{
+		  res += (!count++) ? ", expecting " : " or ";
+		  res += yytnamerr_ (yytname_[x]);
+		}
+	  }
+      }
+    else
+#endif
+      res = YY_("syntax error");
+    return res;
+  }
+
+
+  /* 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_[] =
+  {
+         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
+  };
+
+  /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
+     doesn't specify something else to do.  Zero means the default is an
+     error.  */
+  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
+  };
+
+  /* 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
+  };
+
+  /* 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
+  };
+
+  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
+     positive, shift that token.  If negative, reduce the rule which
+     number is the opposite.  If zero, do what YYDEFACT says.  */
+  const signed char json_parser::yytable_ninf_ = -1;
+  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
+  };
+
+  /* YYCHECK.  */
+  const unsigned 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
+  };
+
+  /* STOS_[STATE-NUM] -- The (internal number of the) accessing
+     symbol of state STATE-NUM.  */
+  const unsigned char
+  json_parser::yystos_[] =
+  {
+         0,     0,     1,     3,     5,    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
+  };
+
+#if YYDEBUG
+  /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
+     to YYLEX-NUM.  */
+  const unsigned short int
+  json_parser::yytoken_number_[] =
+  {
+         0,   256,   257,     1,     2,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,    12,    13,    14,    15,    16
+  };
+#endif
+
+  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
+  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
+  };
+
+  /* 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
+  };
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+  /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+     First, the terminals, then, starting at \a yyntokens_, nonterminals.  */
+  const char*
+  const json_parser::yytname_[] =
+  {
+    "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"",
+  "\"]\"", "\":\"", "\",\"", "\"-\"", "\".\"", "\"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
+  };
+#endif
+
+#if YYDEBUG
+  /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
+  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
+  };
+
+  /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+     YYRHS.  */
+  const unsigned char
+  json_parser::yyprhs_[] =
+  {
+         0,     0,     3,     5,     7,     9,    11,    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
+  };
+
+  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
+  const unsigned char
+  json_parser::yyrline_[] =
+  {
+         0,    81,    81,    86,    87,    88,    94,    96,    98,    99,
+     104,   105,   111,   117,   119,   120,   126,   127,   133,   134,
+     135,   136,   137,   138,   139,   144,   148,   153,   154,   159,
+     160,   162,   163,   167,   171,   173,   175,   176
+  };
+
+  // Print the state stack on the debug stream.
+  void
+  json_parser::yystack_print_ ()
+  {
+    *yycdebug_ << "Stack now";
+    for (state_stack_type::const_iterator i = yystate_stack_.begin ();
+	 i != yystate_stack_.end (); ++i)
+      *yycdebug_ << ' ' << *i;
+    *yycdebug_ << std::endl;
+  }
+
+  // Report on the debug stream that the rule \a yyrule is going to be reduced.
+  void
+  json_parser::yy_reduce_print_ (int yyrule)
+  {
+    unsigned int yylno = yyrline_[yyrule];
+    int yynrhs = yyr2_[yyrule];
+    /* Print the symbols being reduced, and their result.  */
+    *yycdebug_ << "Reducing stack by rule " << yyrule - 1
+	       << " (line " << yylno << "), ";
+    /* The symbols being reduced.  */
+    for (int yyi = 0; yyi < yynrhs; yyi++)
+      YY_SYMBOL_PRINT ("   $" << yyi + 1 << " =",
+		       yyrhs_[yyprhs_[yyrule] + yyi],
+		       &(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
+		       &(yylocation_stack_[(yynrhs) - (yyi + 1)]));
+  }
+#endif // YYDEBUG
+
+  /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
+  json_parser::token_number_type
+  json_parser::yytranslate_ (int t)
+  {
+    static
+    const token_number_type
+    translate_table[] =
+    {
+           0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
+      12,    13,    14,    15,    16,    17,    18,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     1,     2
+    };
+    if ((unsigned int) t <= yyuser_token_number_max_)
+      return translate_table[t];
+    else
+      return yyundef_token_;
+  }
+
+  const int json_parser::yyeof_ = 0;
+  const int json_parser::yylast_ = 39;
+  const int json_parser::yynnts_ = 18;
+  const int json_parser::yyempty_ = -2;
+  const int json_parser::yyfinal_ = 25;
+  const int json_parser::yyterror_ = 1;
+  const int json_parser::yyerrcode_ = 256;
+  const int json_parser::yyntokens_ = 19;
+
+  const unsigned int json_parser::yyuser_token_number_max_ = 257;
+  const json_parser::token_number_type json_parser::yyundef_token_ = 2;
+
+} // namespace yy
+
+#line 180 "json_parser.yy"
+
+
+int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver)
+{
+  JSonScanner* scanner = driver->m_scanner;
+  yylval->clear();
+  int ret = scanner->yylex(yylval, yylloc);
+
+  qjsonDebug() << "json_parser::yylex - calling scanner yylval==|"
+           << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|";
+  
+  return ret;
+}
+
+void yy::json_parser::error (const yy::location& yyloc,
+                                 const std::string& error)
+{
+  /*qjsonDebug() << yyloc.begin.line;
+  qjsonDebug() << yyloc.begin.column;
+  qjsonDebug() << yyloc.end.line;
+  qjsonDebug() << yyloc.end.column;*/
+  qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ;
+  driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line);
+}
+


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.cc
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.hh
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.hh	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.hh	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,322 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Skeleton interface for Bison LALR(1) parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/* C++ LALR(1) parser skeleton written by Akim Demaille.  */
+
+#ifndef PARSER_HEADER_H
+# define PARSER_HEADER_H
+
+#include <string>
+#include <iostream>
+#include "stack.hh"
+
+namespace yy
+{
+  class position;
+  class location;
+}
+
+/* First part of user declarations.  */
+#line 25 "json_parser.yy"
+
+  #include "parser_p.h"
+  #include "json_scanner.h"
+  #include "qjson_debug.h"
+
+  #include <QtCore/QByteArray>
+  #include <QtCore/QDebug>
+  #include <QtCore/QMap>
+  #include <QtCore/QString>
+  #include <QtCore/QVariant>
+
+  class JSonScanner;
+
+  namespace QJson {
+    class Parser;
+  }
+
+  #define YYERROR_VERBOSE 1
+
+
+/* Line 35 of lalr1.cc.  */
+#line 74 "json_parser.hh"
+
+#include "location.hh"
+
+/* Enabling traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG 1
+#endif
+
+/* Enabling verbose error messages.  */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 1
+#endif
+
+/* Enabling the token table.  */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+   If N is 0, then set CURRENT to the empty location which ends
+   the previous symbol: RHS[0] (always defined).  */
+
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N)		\
+do {							\
+  if (N)						\
+    {							\
+      (Current).begin = (Rhs)[1].begin;			\
+      (Current).end   = (Rhs)[N].end;			\
+    }							\
+  else							\
+    {							\
+      (Current).begin = (Current).end = (Rhs)[0].end;	\
+    }							\
+} while (false)
+#endif
+
+namespace yy
+{
+
+  /// A Bison parser.
+  class json_parser
+  {
+  public:
+    /// Symbol semantic values.
+#ifndef YYSTYPE
+    typedef int semantic_type;
+#else
+    typedef YYSTYPE semantic_type;
+#endif
+    /// Symbol locations.
+    typedef location location_type;
+    /// Tokens.
+    struct token
+    {
+      /* Tokens.  */
+   enum yytokentype {
+     END = 0,
+     CURLY_BRACKET_OPEN = 1,
+     CURLY_BRACKET_CLOSE = 2,
+     SQUARE_BRACKET_OPEN = 3,
+     SQUARE_BRACKET_CLOSE = 4,
+     COLON = 5,
+     COMMA = 6,
+     MINUS = 7,
+     DOT = 8,
+     DIGIT = 9,
+     E = 10,
+     TRUE_VAL = 11,
+     FALSE_VAL = 12,
+     NULL_VAL = 13,
+     QUOTMARKOPEN = 14,
+     QUOTMARKCLOSE = 15,
+     STRING = 16
+   };
+
+    };
+    /// Token type.
+    typedef token::yytokentype token_type;
+
+    /// Build a parser object.
+    json_parser (QJson::ParserPrivate* driver_yyarg);
+    virtual ~json_parser ();
+
+    /// Parse.
+    /// \returns  0 iff parsing succeeded.
+    virtual int parse ();
+
+    /// The current debugging stream.
+    std::ostream& debug_stream () const;
+    /// Set the current debugging stream.
+    void set_debug_stream (std::ostream &);
+
+    /// Type for debugging levels.
+    typedef int debug_level_type;
+    /// The current debugging level.
+    debug_level_type debug_level () const;
+    /// Set the current debugging level.
+    void set_debug_level (debug_level_type l);
+
+  private:
+    /// Report a syntax error.
+    /// \param loc    where the syntax error is found.
+    /// \param msg    a description of the syntax error.
+    virtual void error (const location_type& loc, const std::string& msg);
+
+    /// Generate an error message.
+    /// \param state   the state where the error occurred.
+    /// \param tok     the look-ahead token.
+    virtual std::string yysyntax_error_ (int yystate, int tok);
+
+#if YYDEBUG
+    /// \brief Report a symbol value on the debug stream.
+    /// \param yytype       The token type.
+    /// \param yyvaluep     Its semantic value.
+    /// \param yylocationp  Its location.
+    virtual void yy_symbol_value_print_ (int yytype,
+					 const semantic_type* yyvaluep,
+					 const location_type* yylocationp);
+    /// \brief Report a symbol on the debug stream.
+    /// \param yytype       The token type.
+    /// \param yyvaluep     Its semantic value.
+    /// \param yylocationp  Its location.
+    virtual void yy_symbol_print_ (int yytype,
+				   const semantic_type* yyvaluep,
+				   const location_type* yylocationp);
+#endif /* ! YYDEBUG */
+
+
+    /// State numbers.
+    typedef int state_type;
+    /// State stack type.
+    typedef stack<state_type>    state_stack_type;
+    /// Semantic value stack type.
+    typedef stack<semantic_type> semantic_stack_type;
+    /// location stack type.
+    typedef stack<location_type> location_stack_type;
+
+    /// The state stack.
+    state_stack_type yystate_stack_;
+    /// The semantic value stack.
+    semantic_stack_type yysemantic_stack_;
+    /// The location stack.
+    location_stack_type yylocation_stack_;
+
+    /// Internal symbol numbers.
+    typedef unsigned char token_number_type;
+    /* Tables.  */
+    /// For a state, the index in \a yytable_ of its portion.
+    static const signed char yypact_[];
+    static const signed char yypact_ninf_;
+
+    /// For a state, default rule to reduce.
+    /// Unless\a  yytable_ specifies something else to do.
+    /// Zero means the default is an error.
+    static const unsigned char yydefact_[];
+
+    static const signed char yypgoto_[];
+    static const signed char yydefgoto_[];
+
+    /// What to do in a state.
+    /// \a yytable_[yypact_[s]]: what to do in state \a s.
+    /// - if positive, shift that token.
+    /// - if negative, reduce the rule which number is the opposite.
+    /// - if zero, do what YYDEFACT says.
+    static const unsigned char yytable_[];
+    static const signed char yytable_ninf_;
+
+    static const unsigned char yycheck_[];
+
+    /// For a state, its accessing symbol.
+    static const unsigned char yystos_[];
+
+    /// For a rule, its LHS.
+    static const unsigned char yyr1_[];
+    /// For a rule, its RHS length.
+    static const unsigned char yyr2_[];
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+    /// For a symbol, its name in clear.
+    static const char* const yytname_[];
+#endif
+
+#if YYERROR_VERBOSE
+    /// Convert the symbol name \a n to a form suitable for a diagnostic.
+    virtual std::string yytnamerr_ (const char *n);
+#endif
+
+#if YYDEBUG
+    /// A type to store symbol numbers and -1.
+    typedef signed char rhs_number_type;
+    /// A `-1'-separated list of the rules' RHS.
+    static const rhs_number_type yyrhs_[];
+    /// For each rule, the index of the first RHS symbol in \a yyrhs_.
+    static const unsigned char yyprhs_[];
+    /// For each rule, its source line number.
+    static const unsigned char yyrline_[];
+    /// For each scanner token number, its symbol number.
+    static const unsigned short int yytoken_number_[];
+    /// Report on the debug stream that the rule \a r is going to be reduced.
+    virtual void yy_reduce_print_ (int r);
+    /// Print the state stack on the debug stream.
+    virtual void yystack_print_ ();
+#endif
+
+    /// Convert a scanner token number \a t to a symbol number.
+    token_number_type yytranslate_ (int t);
+
+    /// \brief Reclaim the memory associated to a symbol.
+    /// \param yymsg        Why this token is reclaimed.
+    /// \param yytype       The symbol type.
+    /// \param yyvaluep     Its semantic value.
+    /// \param yylocationp  Its location.
+    inline void yydestruct_ (const char* yymsg,
+			     int yytype,
+			     semantic_type* yyvaluep,
+			     location_type* yylocationp);
+
+    /// Pop \a n symbols the three stacks.
+    inline void yypop_ (unsigned int n = 1);
+
+    /* Constants.  */
+    static const int yyeof_;
+    /* LAST_ -- Last index in TABLE_.  */
+    static const int yylast_;
+    static const int yynnts_;
+    static const int yyempty_;
+    static const int yyfinal_;
+    static const int yyterror_;
+    static const int yyerrcode_;
+    static const int yyntokens_;
+    static const unsigned int yyuser_token_number_max_;
+    static const token_number_type yyundef_token_;
+
+    /* Debugging.  */
+    int yydebug_;
+    std::ostream* yycdebug_;
+
+
+    /* User arguments.  */
+    QJson::ParserPrivate* driver;
+  };
+}
+
+
+#endif /* ! defined PARSER_HEADER_H */


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.hh
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.yy
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.yy	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.yy	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,203 @@
+/* This file is part of QJSon
+  *
+  * Copyright (C) 2008 Flavio Castelli <flavio.castelli@xxxxxxxxx>
+  *
+  * 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.
+  *
+  * 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.
+  *
+  * You should have received a copy of the GNU Library General Public License
+  * along with this library; see the file COPYING.LIB.  If not, write to
+  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+
+%skeleton "lalr1.cc"
+%defines
+%define "parser_class_name" "json_parser"
+
+%{
+  #include "parser_p.h"
+  #include "json_scanner.h"
+  #include "qjson_debug.h"
+
+  #include <QtCore/QByteArray>
+  #include <QtCore/QDebug>
+  #include <QtCore/QMap>
+  #include <QtCore/QString>
+  #include <QtCore/QVariant>
+
+  class JSonScanner;
+
+  namespace QJson {
+    class Parser;
+  }
+
+  #define YYERROR_VERBOSE 1
+%}
+
+%parse-param { QJson::ParserPrivate* driver }
+%lex-param { QJson::ParserPrivate* driver }
+
+%locations
+
+%debug
+%error-verbose
+
+%token END 0 "end of file"
+
+%token CURLY_BRACKET_OPEN 1 "{"
+%token CURLY_BRACKET_CLOSE 2 "}"
+%token SQUARE_BRACKET_OPEN 3 "["
+%token SQUARE_BRACKET_CLOSE 4 "]"
+
+%token COLON 5 ":"
+%token COMMA 6 ","
+%token MINUS 7 "-"
+%token DOT 8 "."
+%token DIGIT 9 "digit"
+%token E 10 "exponential"
+%token TRUE_VAL 11 "true"
+%token FALSE_VAL 12 "false"
+%token NULL_VAL 13 "null"
+%token QUOTMARKOPEN 14 "open quotation mark"
+%token QUOTMARKCLOSE 15 "close quotation mark"
+
+%token STRING 16 "string"
+
+// define the initial token
+%start start
+
+%%
+
+// grammar rules
+
+start: data {
+              driver->m_result = $1;
+              qjsonDebug() << "json_parser - parsing finished";
+            };
+
+data: object {$$ = $1; }
+      | array {$$ = $1; }
+      | error
+          {
+            qCritical()<< "json_parser - syntax error found, "
+                    << "forcing abort";
+            YYABORT;
+          }
+      | END;
+
+object: CURLY_BRACKET_OPEN members CURLY_BRACKET_CLOSE { $$ = $2; };
+
+members: /* empty */ { $$ = QVariant (QVariantMap()); }
+        | pair r_members {
+            QVariantMap members = $2.toMap();
+            $$ = QVariant(members.unite ($1.toMap()));
+          };
+
+r_members: /* empty */ { $$ = QVariant (QVariantMap()); }
+        | COMMA pair r_members {
+          QVariantMap members = $3.toMap();
+          
+          $$ = QVariant(members.unite ($2.toMap()));
+          };
+
+pair:   string COLON value {
+            QVariantMap pair;
+            pair.insert ($1.toString(), QVariant($3));
+            $$ = QVariant (pair);
+          };
+
+array: SQUARE_BRACKET_OPEN values SQUARE_BRACKET_CLOSE { $$ = $2; };
+
+values: /* empty */ { $$ = QVariant (QVariantList()); }
+        | value r_values {
+          QVariantList members = $2.toList();
+          members.prepend ($1);
+          $$ = QVariant(members);
+        };
+
+r_values: /* empty */ { $$ = QVariant (QVariantList()); }
+          | COMMA value r_values {
+            QVariantList members = $3.toList();
+            members.prepend ($2);
+            $$ = QVariant(members);
+          };
+
+value: string { $$ = $1; }
+        | number { $$ = $1; }
+        | object { $$ = $1; }
+        | array { $$ = $1; }
+        | TRUE_VAL { $$ = QVariant (true); }
+        | FALSE_VAL { $$ = QVariant (false); }
+        | NULL_VAL {
+          QVariant null_variant;
+          $$ = null_variant;
+        };
+
+number: int {
+            $$ = QVariant (QVariant::Int);
+            $$.setValue($1.toInt());
+          }
+        | int fract {
+            const QByteArray value = $1.toByteArray() + $2.toByteArray();
+            $$ = QVariant(QVariant::Double);
+            $$.setValue(value.toDouble());
+          }
+        | int exp {  $$ = QVariant ($1.toByteArray() + $2.toByteArray()); }
+        | int fract exp {
+            const QByteArray value = $1.toByteArray() + $2.toByteArray() + $3.toByteArray();
+            $$ = QVariant (value);
+          };
+
+int:  DIGIT digits { $$ = QVariant ($1.toByteArray() + $2.toByteArray()); }
+      | MINUS DIGIT digits { $$ = QVariant (QByteArray("-") + $2.toByteArray() + $3.toByteArray()); };
+
+digits: /* empty */ { $$ = QVariant (QByteArray("")); }
+        | DIGIT digits {
+          $$ = QVariant($1.toByteArray() + $2.toByteArray());
+        };
+
+fract: DOT digits {
+          $$ = QVariant(QByteArray(".") + $2.toByteArray());
+        };
+
+exp: E digits { $$ = QVariant($1.toByteArray() + $2.toByteArray()); };
+
+string: QUOTMARKOPEN string_arg QUOTMARKCLOSE { $$ = $2 };
+
+string_arg: /*empty */ { $$ = QVariant (QByteArray("")); }
+            | STRING {
+                $$ = $1;
+              };
+
+%%
+
+int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver)
+{
+  JSonScanner* scanner = driver->m_scanner;
+  yylval->clear();
+  int ret = scanner->yylex(yylval, yylloc);
+
+  qjsonDebug() << "json_parser::yylex - calling scanner yylval==|"
+           << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|";
+  
+  return ret;
+}
+
+void yy::json_parser::error (const yy::location& yyloc,
+                                 const std::string& error)
+{
+  /*qjsonDebug() << yyloc.begin.line;
+  qjsonDebug() << yyloc.begin.column;
+  qjsonDebug() << yyloc.end.line;
+  qjsonDebug() << yyloc.end.column;*/
+  qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ;
+  driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line);
+}


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_parser.yy
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.cpp	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.cpp	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,320 @@
+/* This file is part of QJson
+ *
+ * Copyright (C) 2008 Flavio Castelli <flavio.castelli@xxxxxxxxx>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Library 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 "qjson_debug.h"
+#include "json_scanner.h"
+#include "json_parser.hh"
+
+#include <ctype.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QRegExp>
+
+#include <cassert>
+
+bool ishexnstring(const QString& string) {
+  for (int i = 0; i < string.length(); i++) {
+    if (isxdigit(string[i] == 0))
+      return false;
+  }
+  return true;
+}
+
+JSonScanner::JSonScanner(QIODevice* io)
+  : m_io (io)
+{
+  m_quotmarkClosed = true;
+  m_quotmarkCount = 0;
+}
+
+static QString unescape( const QByteArray& ba, bool* ok ) {
+  assert( ok );
+  *ok = false;
+  QString res;
+  QByteArray seg;
+  bool bs = false;
+  for ( int i = 0, size = ba.size(); i < size; ++i ) {
+    const char ch = ba[i];
+    if ( !bs ) {
+      if ( ch == '\\' )
+        bs = true;
+      else
+        seg += ch;
+    } else {
+      bs = false;
+      switch ( ch ) {
+        case 'b':
+          seg += '\b';
+          break;
+        case 'f':
+          seg += '\f';
+          break;
+        case 'n':
+          seg += '\n';
+          break;
+        case 'r':
+          seg += '\r';
+          break;
+        case 't':
+          seg += '\t';
+          break;
+        case 'u':
+        {
+          res += QString::fromUtf8( seg );
+          seg.clear();
+
+          if ( i > size - 5 ) {
+            //error
+            return QString();
+          }
+
+          const QString hex_digit1 = QString::fromUtf8( ba.mid( i + 1, 2 ) );
+          const QString hex_digit2 = QString::fromUtf8( ba.mid( i + 3, 2 ) );
+          i += 4;
+
+          if ( !ishexnstring( hex_digit1 ) || !ishexnstring( hex_digit2 ) ) {
+            qCritical() << "Not an hex string:" << hex_digit1 << hex_digit2;
+            return QString();
+          }
+          bool hexOk;
+          const ushort hex_code1 = hex_digit1.toShort( &hexOk, 16 );
+          if (!hexOk) {
+            qCritical() << "error converting hex value to short:" << hex_digit1;
+            return QString();
+          }
+          const ushort hex_code2 = hex_digit2.toShort( &hexOk, 16 );
+          if (!hexOk) {
+            qCritical() << "error converting hex value to short:" << hex_digit2;
+            return QString();
+          }
+
+          res += QChar(hex_code2, hex_code1);
+          break;
+        }
+        case '\\':
+          seg  += '\\';
+          break;
+        default:
+          seg += ch;
+          break;
+      }
+    }
+  }
+  res += QString::fromUtf8( seg );
+  *ok = true;
+  return res;
+}
+
+int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc)
+{
+  char ch;
+  
+  if (!m_io->isOpen()) {
+    qCritical() << "JSonScanner::yylex - io device is not open";
+    return -1;
+  }
+
+  yylloc->step();
+
+  do {
+    bool ret;
+    if (m_io->atEnd()) {
+      qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::END";
+      return yy::json_parser::token::END;
+    }
+    else
+      ret = m_io->getChar(&ch);
+
+    if (!ret) {
+      qCritical() << "JSonScanner::yylex - error reading from io device";
+      return -1;
+    }
+
+    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
+    const QByteArray buf = m_io->peek(3).toLower();
+
+    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'))) {
+    // check false value
+    const QByteArray buf = m_io->peek(4).toLower();
+    if (buf.length() == 4) {
+      if (buf == "alse") {
+        m_io->read (4);
+        yylloc->columns(4);
+        qjsonDebug() << "JSonScanner::yylex - FALSE_VAL";
+        return yy::json_parser::token::FALSE_VAL;
+      }
+    }
+  }
+  else if (m_quotmarkClosed && ((ch == 'e') || (ch == 'E'))) {
+    QByteArray ret(1, ch);
+    const QByteArray buf = m_io->peek(1);
+    if (!buf.isEmpty()) {
+      if ((buf[0] == '+' ) || (buf[0] == '-' )) {
+        ret += m_io->read (1);  
+        yylloc->columns();
+      }
+    }
+    *yylval = QVariant(QString::fromUtf8(ret));
+    return yy::json_parser::token::E;
+  }
+  
+  if (ch != '"' && !m_quotmarkClosed) {
+    // we're inside a " " block
+
+    QByteArray raw;
+    raw += ch;
+    char prevCh = ch;
+    while ( true ) {
+      char nextCh;
+      m_io->peek(&nextCh, 1);
+
+      if ( prevCh != '\\' && nextCh == '\"' ) {
+        bool ok;
+        const QString str = unescape( raw, &ok );
+        *yylval = ok ? str : QString();
+        return ok ? yy::json_parser::token::STRING : -1;
+      }
+#if 0
+      if ( prevCh == '\\' && nextCh != '"' && nextCh != '\\' && nextCh != '/' &&
+           nextCh != 'b' && nextCh != 'f' && nextCh != 'n' &&
+           nextCh != 'r' && nextCh != 't' && nextCh != 'u') {
+        qjsonDebug() << "Just read" << nextCh;
+        qjsonDebug() << "JSonScanner::yylex - error decoding escaped sequence";
+        return -1;
+       }
+#endif
+      m_io->read(1); // consume
+      raw += nextCh;
+      prevCh = nextCh;
+#if 0
+      if (nextCh == '\\') {
+        char buf;
+        if (m_io->getChar (&buf)) {
+          yylloc->columns();
+          if (((buf != '"') && (buf != '\\') && (buf != '/') &&
+              (buf != 'b') && (buf != 'f') && (buf != 'n') &&
+              (buf != 'r') && (buf != 't') && (buf != 'u'))) {
+                qjsonDebug() << "Just read" << buf;
+                qjsonDebug() << "JSonScanner::yylex - error decoding escaped sequence";
+                return -1;
+          }
+        } else {
+          qCritical() << "JSonScanner::yylex - error decoding escaped sequence : io error";
+          return -1;
+        }
+      }
+#endif
+    }
+  }
+  else if (isdigit(ch) != 0 && m_quotmarkClosed) {
+    *yylval = QVariant(QString::fromLatin1(QByteArray(&ch,1)));
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT";
+    return yy::json_parser::token::DIGIT;
+  }
+  else if (isalnum(ch) != 0) {
+    *yylval = QVariant(QString(QChar::fromLatin1(ch)));
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::WORD ("
+             << ch << ")";
+    return yy::json_parser::token::STRING;
+  }
+  else if (ch == ':') {
+    // set yylval
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::COLON";
+    return yy::json_parser::token::COLON;
+  }
+  else if (ch == '"') {
+    // yy::json_parser::token::QUOTMARK (")
+
+    // set yylval
+    m_quotmarkCount++;
+    if (m_quotmarkCount %2 == 0) {
+      m_quotmarkClosed = true;
+      m_quotmarkCount = 0;
+      qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::QUOTMARKCLOSE";
+      return yy::json_parser::token::QUOTMARKCLOSE;
+    }
+    else {
+      m_quotmarkClosed = false;
+      qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::QUOTMARKOPEN";
+      return yy::json_parser::token::QUOTMARKOPEN;
+    }
+  }
+  else if (ch == ',') {
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::COMMA";
+    return yy::json_parser::token::COMMA;
+  }
+  else if (ch == '.') {
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DOT";
+    return yy::json_parser::token::DOT;
+  }
+  else if (ch == '-') {
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::MINUS";
+    return yy::json_parser::token::MINUS;
+  }
+  else if (ch == '[') {
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::SQUARE_BRACKET_OPEN";
+    return yy::json_parser::token::SQUARE_BRACKET_OPEN;
+  }
+  else if (ch == ']') {
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::SQUARE_BRACKET_CLOSE";
+    return yy::json_parser::token::SQUARE_BRACKET_CLOSE;
+  }
+  else if (ch == '{') {
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::CURLY_BRACKET_OPEN";
+    return yy::json_parser::token::CURLY_BRACKET_OPEN;
+  }
+  else if (ch == '}') {
+    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::CURLY_BRACKET_CLOSE";
+    return yy::json_parser::token::CURLY_BRACKET_CLOSE;
+  }
+
+  //unknown char!
+  //TODO yyerror?
+  qCritical() << "JSonScanner::yylex - unknown char, returning -1";
+  return -1;
+}
+
+


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,52 @@
+/* This file is part of QJson
+ *
+ * Copyright (C) 2008 Flavio Castelli <flavio.castelli@xxxxxxxxx>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _JSON_SCANNER
+#define _JSON_SCANNER
+
+#include <fstream>
+#include <string>
+
+#include <QtCore/QIODevice>
+#include <QtCore/QVariant>
+
+#define YYSTYPE QVariant
+
+#include "parser_p.h"
+
+namespace yy {
+  class location;
+  int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver);
+}
+
+class JSonScanner
+{
+    public:
+        explicit JSonScanner(QIODevice* io);
+        int yylex(YYSTYPE* yylval, yy::location *yylloc);
+        
+    protected:
+        bool m_quotmarkClosed;
+        unsigned int m_quotmarkCount;
+        QIODevice* m_io;
+};
+
+#endif
+


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/json_scanner.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/location.hh
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/location.hh	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/location.hh	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,145 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Locations for Bison parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/**
+ ** \file location.hh
+ ** Define the yy::location class.
+ */
+
+#ifndef BISON_LOCATION_HH
+# define BISON_LOCATION_HH
+
+# include <iostream>
+# include <string>
+# include "position.hh"
+
+namespace yy
+{
+
+  /// Abstract a location.
+  class location
+  {
+  public:
+
+    /// Construct a location.
+    location ()
+      : begin (), end ()
+    {
+    }
+
+
+    /// Initialization.
+    inline void initialize (std::string* fn)
+    {
+      begin.initialize (fn);
+      end = begin;
+    }
+
+    /** \name Line and Column related manipulators
+     ** \{ */
+  public:
+    /// Reset initial location to final location.
+    inline void step ()
+    {
+      begin = end;
+    }
+
+    /// Extend the current location to the COUNT next columns.
+    inline void columns (unsigned int count = 1)
+    {
+      end += count;
+    }
+
+    /// Extend the current location to the COUNT next lines.
+    inline void lines (unsigned int count = 1)
+    {
+      end.lines (count);
+    }
+    /** \} */
+
+
+  public:
+    /// Beginning of the located region.
+    position begin;
+    /// End of the located region.
+    position end;
+  };
+
+  /// Join two location objects to create a location.
+  inline const location operator+ (const location& begin, const location& end)
+  {
+    location res = begin;
+    res.end = end.end;
+    return res;
+  }
+
+  /// Add two location objects.
+  inline const location operator+ (const location& begin, unsigned int width)
+  {
+    location res = begin;
+    res.columns (width);
+    return res;
+  }
+
+  /// Add and assign a location.
+  inline location& operator+= (location& res, unsigned int width)
+  {
+    res.columns (width);
+    return res;
+  }
+
+  /** \brief Intercept output stream redirection.
+   ** \param ostr the destination output stream
+   ** \param loc a reference to the location to redirect
+   **
+   ** Avoid duplicate information.
+   */
+  inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
+  {
+    position last = loc.end - 1;
+    ostr << loc.begin;
+    if (last.filename
+	&& (!loc.begin.filename
+	    || *loc.begin.filename != *last.filename))
+      ostr << '-' << last;
+    else if (loc.begin.line != last.line)
+      ostr << '-' << last.line  << '.' << last.column;
+    else if (loc.begin.column != last.column)
+      ostr << '-' << last.column;
+    return ostr;
+  }
+
+}
+
+#endif // not BISON_LOCATION_HH


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/location.hh
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.cpp	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.cpp	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,113 @@
+/* This file is part of QJson
+ *
+ * Copyright (C) 2008 Flavio Castelli <flavio.castelli@xxxxxxxxx>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "parser.h"
+#include "parser_p.h"
+#include "json_parser.hh"
+
+#include <QtCore/QBuffer>
+#include <QtCore/QStringList>
+#include <QtCore/QTextStream>
+#include <QtCore/QDebug>
+
+using namespace QJson;
+
+ParserPrivate::ParserPrivate() :
+    m_scanner(0)
+  , m_negate(false)
+  , m_error(false)
+{
+}
+
+ParserPrivate::~ParserPrivate()
+{
+  delete m_scanner;
+}
+
+void ParserPrivate::setError(QString errorMsg, int errorLine) {
+  m_error = true;
+  m_errorMsg = errorMsg;
+  m_errorLine = errorLine;
+}
+
+Parser::Parser() :
+    d(new ParserPrivate)
+{
+}
+
+Parser::~Parser()
+{
+  delete d;
+}
+
+QVariant Parser::parse (QIODevice* io, bool* ok)
+{
+  d->m_errorMsg.clear();
+  delete d->m_scanner;
+  d->m_scanner = 0;
+
+  if (!io->isOpen()) {
+    if (!io->open(QIODevice::ReadOnly)) {
+      if (ok != 0)
+        *ok = false;
+      qCritical ("Error opening device");
+      return QVariant();
+    }
+  }
+
+  if (!io->isReadable()) {
+    if (ok != 0)
+      *ok = false;
+    qCritical ("Device is not readable");
+    io->close();
+    return QVariant();
+  }
+
+  d->m_scanner = new JSonScanner (io);
+  yy::json_parser parser(d);
+  parser.parse();
+
+  delete d->m_scanner;
+  d->m_scanner = 0;
+
+  if (ok != 0)
+    *ok = !d->m_error;
+
+  io->close();
+  return d->m_result;
+}
+
+QVariant Parser::parse(const QByteArray& jsonString, bool* ok) {
+  QBuffer buffer;
+  buffer.open(QBuffer::ReadWrite);
+  buffer.write(jsonString);
+  buffer.seek(0);
+  return parse (&buffer, ok);
+}
+
+QString Parser::errorString() const
+{
+  return d->m_errorMsg;
+}
+
+int Parser::errorLine() const
+{
+  return d->m_errorLine;
+}


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,80 @@
+/* This file is part of QJson
+ *
+ * Copyright (C) 2008 Flavio Castelli <flavio.castelli@xxxxxxxxx>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef QJSON_PARSER_H
+#define QJSON_PARSER_H
+
+#include "qjson_export.h"
+
+class QIODevice;
+class QVariant;
+
+namespace QJson {
+
+  class ParserPrivate;
+
+  /**
+  * @brief Main class used for converting JSON data to QVariant objects
+  */
+  class QJSON_EXPORT Parser
+  {
+    public:
+      Parser();
+      ~Parser();
+
+      /**
+      * Read JSON string from the I/O Device and converts it to a QVariant object
+      * @param io Input output device
+      * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
+      * @returns a QVariant object generated from the JSON string
+      */
+      QVariant parse(QIODevice* io, bool* ok = 0);
+
+      /**
+      * This is a method provided for convenience.
+      * @param jsonData data containing the JSON object representation
+      * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
+      * @returns a QVariant object generated from the JSON string
+      * @sa errorString
+      * @sa errorLine
+      */
+      QVariant parse(const QByteArray& jsonData, bool* ok = 0);
+
+      /**
+      * This method returns the error message
+      * @returns a QString object containing the error message of the last parse operation
+      * @sa errorLine
+      */
+      QString errorString() const;
+
+      /**
+      * This method returns line number where the error occurred
+      * @returns the line number where the error occurred
+      * @sa errorString
+      */
+      int errorLine() const;
+
+    private:
+      Q_DISABLE_COPY(Parser)
+      ParserPrivate* const d;
+  };
+}
+
+#endif // QJSON_PARSER_H


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser_p.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser_p.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser_p.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,55 @@
+/* This file is part of QJson
+ *
+ * Copyright (C) 2008 Flavio Castelli <flavio.castelli@xxxxxxxxx>
+ * Copyright (C) 2009 Michael Leupold <lemma@xxxxxxxxxxxx>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef QJSON_PARSER_P_H
+#define QJSON_PARSER_P_H
+
+#include "parser.h"
+
+#include <QtCore/QString>
+#include <QtCore/QVariant>
+
+class JSonScanner;
+
+namespace yy {
+  class json_parser;
+}
+
+namespace QJson {
+
+  class ParserPrivate
+  {
+    public:
+      ParserPrivate();
+      ~ParserPrivate();
+
+      void setError(QString errorMsg, int line);
+
+      JSonScanner* m_scanner;
+      bool m_negate;
+      bool m_error;
+      int m_errorLine;
+      QString m_errorMsg;
+      QVariant m_result;
+  };
+}
+
+#endif // QJSON_PARSER_H


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parser_p.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.cpp	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.cpp	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,68 @@
+/* This file is part of qjson
+  *
+  * Copyright (C) 2009 Flavio Castelli <flavio@xxxxxxxxxxxxx>
+  *
+  * 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.
+  *
+  * 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.
+  *
+  * You should have received a copy of the GNU Library General Public License
+  * along with this library; see the file COPYING.LIB.  If not, write to
+  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+
+#include "parserrunnable.h"
+
+#include "parser.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QVariant>
+
+using namespace QJson;
+
+class QJson::ParserRunnable::Private
+{
+  public:
+    QByteArray m_data;
+};
+
+ParserRunnable::ParserRunnable(QObject* parent)
+    : QObject(parent),
+      QRunnable(),
+      d(new Private)
+{
+  qRegisterMetaType<QVariant>("QVariant");
+}
+
+ParserRunnable::~ParserRunnable()
+{
+  delete d;
+}
+
+void ParserRunnable::setData( const QByteArray& data ) {
+  d->m_data = data;
+}
+
+void ParserRunnable::run()
+{
+  qDebug() << Q_FUNC_INFO;
+
+  bool ok;
+  Parser parser;
+  QVariant result = parser.parse (d->m_data, &ok);
+  if (ok) {
+    qDebug() << "successfully converted json item to QVariant object";
+    emit parsingFinished(result, true, QString());
+  } else {
+    const QString errorText = tr("An error occured while parsing json: %1").arg(parser.errorString());
+    qCritical() << errorText;
+    emit parsingFinished(QVariant(), false, errorText);
+  }
+}


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,67 @@
+/* This file is part of qjson
+  *
+  * Copyright (C) 2009 Flavio Castelli <flavio@xxxxxxxxxxxxx>
+  *
+  * 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.
+  *
+  * 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.
+  *
+  * You should have received a copy of the GNU Library General Public License
+  * along with this library; see the file COPYING.LIB.  If not, write to
+  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+
+#ifndef PARSERRUNNABLE_H
+#define PARSERRUNNABLE_H
+
+#include "qjson_export.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QRunnable>
+
+class QVariant;
+
+namespace QJson {
+  /**
+  * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread
+  */
+  class QJSON_EXPORT ParserRunnable  : public QObject, public QRunnable
+  {
+    Q_OBJECT
+    public:
+      /**
+      * This signal is emitted when the conversion process has been completed
+      * @param data contains the JSON data that has to be converted
+      * @param parent parent of the object
+      **/
+      explicit ParserRunnable(QObject* parent = 0);
+      ~ParserRunnable();
+
+      void setData( const QByteArray& data );
+
+      void run();
+
+    Q_SIGNALS:
+      /**
+      * This signal is emitted when the parsing process has been completed
+      * @param json contains the result of the parsing
+      * @param ok if a parsing error occurs ok is set to false, otherwise it's set to true.
+      * @param error_msg contains a string explaining the failure reason
+      **/
+      void parsingFinished(const QVariant& json, bool ok, const QString& error_msg);
+
+    private:
+      Q_DISABLE_COPY(ParserRunnable)
+      class Private;
+      Private* const d;
+  };
+}
+
+#endif // PARSERRUNNABLE_H


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/parserrunnable.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/position.hh
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/position.hh	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/position.hh	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,142 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Positions for Bison parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/**
+ ** \file position.hh
+ ** Define the yy::position class.
+ */
+
+#ifndef BISON_POSITION_HH
+# define BISON_POSITION_HH
+
+# include <iostream>
+# include <string>
+
+namespace yy
+{
+  /// Abstract a position.
+  class position
+  {
+  public:
+
+    /// Construct a position.
+    position ()
+      : filename (0), line (1), column (0)
+    {
+    }
+
+
+    /// Initialization.
+    inline void initialize (std::string* fn)
+    {
+      filename = fn;
+      line = 1;
+      column = 0;
+    }
+
+    /** \name Line and Column related manipulators
+     ** \{ */
+  public:
+    /// (line related) Advance to the COUNT next lines.
+    inline void lines (int count = 1)
+    {
+      column = 0;
+      line += count;
+    }
+
+    /// (column related) Advance to the COUNT next columns.
+    inline void columns (int count = 1)
+    {
+      int leftmost = 0;
+      int current  = column;
+      if (leftmost <= current + count)
+	column += count;
+      else
+	column = 0;
+    }
+    /** \} */
+
+  public:
+    /// File name to which this position refers.
+    std::string* filename;
+    /// Current line number.
+    unsigned int line;
+    /// Current column number.
+    unsigned int column;
+  };
+
+  /// Add and assign a position.
+  inline const position&
+  operator+= (position& res, const int width)
+  {
+    res.columns (width);
+    return res;
+  }
+
+  /// Add two position objects.
+  inline const position
+  operator+ (const position& begin, const int width)
+  {
+    position res = begin;
+    return res += width;
+  }
+
+  /// Add and assign a position.
+  inline const position&
+  operator-= (position& res, const int width)
+  {
+    return res += -width;
+  }
+
+  /// Add two position objects.
+  inline const position
+  operator- (const position& begin, const int width)
+  {
+    return begin + -width;
+  }
+
+  /** \brief Intercept output stream redirection.
+   ** \param ostr the destination output stream
+   ** \param pos a reference to the position to redirect
+   */
+  inline std::ostream&
+  operator<< (std::ostream& ostr, const position& pos)
+  {
+    if (pos.filename)
+      ostr << *pos.filename << ':';
+    return ostr << pos.line << '.' << pos.column;
+  }
+
+}
+#endif // not BISON_POSITION_HH


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/position.hh
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_debug.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_debug.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_debug.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,33 @@
+/* This file is part of qjson
+  *
+  * Copyright (C) 2009 Michael Leupold <lemma@xxxxxxxxxxxx>
+  *
+  * 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.
+  *
+  * 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.
+  *
+  * You should have received a copy of the GNU Library General Public License
+  * along with this library; see the file COPYING.LIB.  If not, write to
+  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+
+#ifndef QJSON_DEBUG_H
+#define QJSON_DEBUG_H
+
+#include <QtCore/QDebug>
+
+// define qjsonDebug()
+#ifdef QJSON_VERBOSE_DEBUG_OUTPUT
+  inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); }
+#else
+  inline QNoDebug qjsonDebug() { return QNoDebug(); }
+#endif
+
+#endif


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_debug.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_export.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_export.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_export.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,35 @@
+/*  This file is part of the KDE project
+    Copyright (C) 2009 Pino Toscano <pino@xxxxxxx>
+
+    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.
+
+    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.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef QJSON_EXPORT_H
+#define QJSON_EXPORT_H
+
+#include <QtCore/qglobal.h>
+
+#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


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/qjson_export.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.cpp	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.cpp	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,126 @@
+/* This file is part of qjson
+  *
+  * Copyright (C) 2009 Till Adam <adam@xxxxxxx>
+  *
+  * 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.
+  *
+  * 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.
+  *
+  * You should have received a copy of the GNU Library General Public License
+  * along with this library; see the file COPYING.LIB.  If not, write to
+  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+
+#include "serializer.h"
+
+#include <QDataStream>
+#include <QStringList>
+#include <QVariant>
+
+using namespace QJson;
+
+class Serializer::SerializerPrivate {
+
+};
+
+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( const QString& s )
+{
+  const QString str = QLatin1String("\"") + s + QLatin1String("\"");
+  return str;
+}
+
+static QByteArray join( const QList<QByteArray>& list, const QByteArray& sep ) {
+  QByteArray res;
+  Q_FOREACH( const QByteArray& i, list ) {
+    if ( !res.isEmpty() )
+      res += sep;
+    res += i;
+  }
+  return res;
+}
+
+QByteArray Serializer::serialize( const QVariant &v )
+{
+  if ( !v.isValid() )
+    return ""; // no parse error
+  QByteArray str;
+  bool error = false;
+
+  // two major cases, either it's an array or ... not
+  if ( v.canConvert<QVariantList>() ) {
+    const QVariantList list = v.toList();
+    QList<QByteArray> values;
+    Q_FOREACH( const QVariant& v, list )
+      values << serialize( v );
+    str = "[ " + join( values, ", " ) + " ]";
+  } else {
+    // not a list, so it must be an object
+    if ( !v.canConvert<QVariantMap>() ) {
+      // not a map, so it must be a value
+      if ( v.type() == QVariant::String )
+        str = sanitizeString( v.toString() ).toUtf8();
+      else
+        str = v.toByteArray();
+    } else {
+      const QVariantMap vmap = v.toMap();
+      QMapIterator<QString, QVariant> it( vmap );
+      str = "{ ";
+      QList<QByteArray> pairs;
+      while ( it.hasNext() ) {
+        it.next();
+        pairs << sanitizeString(it.key()).toUtf8() + " : " + serialize(it.value() );
+      }
+      str += join( pairs, ", " );
+      str += " }";
+    }
+  }
+  if ( !error )
+    return str;
+  else
+    return QByteArray();
+}
+


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,65 @@
+/* This file is part of qjson
+  *
+  * Copyright (C) 2009 Till Adam <adam@xxxxxxx>
+  *
+  * 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.
+  *
+  * 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.
+  *
+  * You should have received a copy of the GNU Library General Public License
+  * along with this library; see the file COPYING.LIB.  If not, write to
+  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+
+#ifndef QJSON_SERIALIZER_H
+#define QJSON_SERIALIZER_H
+
+#include "qjson_export.h"
+
+class QIODevice;
+class QString;
+class QVariant;
+
+namespace QJson {
+  class QJSON_EXPORT Serializer {
+  public:
+    Serializer();
+    ~Serializer();
+
+     /**
+      * This method generates a textual JSON representation and outputs it to the
+      * passed in I/O Device.
+      * @param variant The JSON document in its in-memory representation as generated by the
+      * parser.
+      * @param out Input output device
+      * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true
+      */
+    void serialize( const QVariant& variant, QIODevice* out, bool* ok = 0 );
+
+    /**
+      * This is a method provided for convenience. It turns the passed in in-memory
+      * representation of the JSON document into a textual one, which is returned.
+      * If the returned string is empty, the document was empty. If it was null, there
+      * was a parsing error.
+      *
+      * @param variant The JSON document in its in-memory representation as generated by the
+      * parser.
+      */
+
+    QByteArray serialize( const QVariant& variant );
+
+  private:
+    Q_DISABLE_COPY(Serializer)
+    class SerializerPrivate;
+    SerializerPrivate* const d;
+  };
+}
+
+#endif // QJSON_SERIALIZER_H


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializer.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.cpp	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.cpp	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,60 @@
+#include "serializerrunnable.h"
+
+/* This file is part of qjson
+ *
+ * Copyright (C) 2009 Flavio Castelli <flavio@xxxxxxxxxxxxx>
+ *               2009 Frank Osterfeld <osterfeld@xxxxxxx>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "parserrunnable.h"
+#include "serializer.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QVariant>
+
+using namespace QJson;
+
+class SerializerRunnable::Private
+{
+public:
+  QVariant json;
+};
+
+SerializerRunnable::SerializerRunnable(QObject* parent)
+    : QObject(parent),
+      QRunnable(),
+      d(new Private)
+{
+  qRegisterMetaType<QVariant>("QVariant");
+}
+
+SerializerRunnable::~SerializerRunnable()
+{
+  delete d;
+}
+
+void SerializerRunnable::setJsonObject( const QVariant& json )
+{
+  d->json = json;
+}
+
+void SerializerRunnable::run()
+{
+  Serializer serializer;
+  emit parsingFinished( Serializer().serialize( d->json ), true, QString() );
+}


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.h	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.h	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,72 @@
+/* This file is part of qjson
+ *
+ * Copyright (C) 2009 Frank Osterfeld <osterfeld@xxxxxxx>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SERIALIZERRUNNABLE_H
+#define SERIALIZERRUNNABLE_H
+
+#include "qjson_export.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QRunnable>
+
+class QByteArray;
+class QString;
+class QVariant;
+
+/**
+* @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread
+*/
+class QJSON_EXPORT SerializerRunnable  : public QObject, public QRunnable
+{
+  Q_OBJECT
+  public:
+    /**
+    * This signal is emitted when the conversion process has been completed
+    * @param data contains the JSON data that has to be converted
+    * @param parent parent of the object
+    **/
+    explicit SerializerRunnable(QObject* parent = 0);
+    ~SerializerRunnable();
+
+    /**
+     * Sets the json object to serialize.
+     * 
+     * @param json QVariant containing the json representation to be serialized
+     */
+    void setJsonObject( const QVariant& json );
+    
+    /* reimp */ void run();
+
+  Q_SIGNALS:
+    /**
+    * This signal is emitted when the serialization process has been completed
+    * @param serialized contains the result of the serialization
+    * @param ok if a serialization error occurs ok is set to false, otherwise it's set to true.
+    * @param error_msg contains a string explaining the failure reason
+    **/
+    void parsingFinished(const QByteArray& serialized, bool ok, const QString& error_msg);
+
+  private:
+    Q_DISABLE_COPY(SerializerRunnable)
+    class Private;
+    Private* const d;
+};
+
+#endif // SERIALIZERRUNNABLE_H


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/serializerrunnable.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/stack.hh
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/stack.hh	                        (rev 0)
+++ vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/stack.hh	2009-07-30 02:02:46 UTC (rev 3986)
@@ -0,0 +1,129 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Stack handling for Bison parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+#ifndef BISON_STACK_HH
+# define BISON_STACK_HH
+
+#include <deque>
+
+namespace yy
+{
+  template <class T, class S = std::deque<T> >
+  class stack
+  {
+  public:
+
+    // Hide our reversed order.
+    typedef typename S::reverse_iterator iterator;
+    typedef typename S::const_reverse_iterator const_iterator;
+
+    stack () : seq_ ()
+    {
+    }
+
+    stack (unsigned int n) : seq_ (n)
+    {
+    }
+
+    inline
+    T&
+    operator [] (unsigned int i)
+    {
+      return seq_[i];
+    }
+
+    inline
+    const T&
+    operator [] (unsigned int i) const
+    {
+      return seq_[i];
+    }
+
+    inline
+    void
+    push (const T& t)
+    {
+      seq_.push_front (t);
+    }
+
+    inline
+    void
+    pop (unsigned int n = 1)
+    {
+      for (; n; --n)
+	seq_.pop_front ();
+    }
+
+    inline
+    unsigned int
+    height () const
+    {
+      return seq_.size ();
+    }
+
+    inline const_iterator begin () const { return seq_.rbegin (); }
+    inline const_iterator end () const { return seq_.rend (); }
+
+  private:
+
+    S seq_;
+  };
+
+  /// Present a slice of the top of a stack.
+  template <class T, class S = stack<T> >
+  class slice
+  {
+  public:
+
+    slice (const S& stack,
+	   unsigned int range) : stack_ (stack),
+				 range_ (range)
+    {
+    }
+
+    inline
+    const T&
+    operator [] (unsigned int i) const
+    {
+      return stack_[range_ - i];
+    }
+
+  private:
+
+    const S& stack_;
+    unsigned int range_;
+  };
+}
+
+#endif // not BISON_STACK_HH


Property changes on: vidalia/branches/extension-api/src/vidalia/HerdictWebReporterPlugin/stack.hh
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native