[asycxx-devel] SF.net SVN: asycxx:[9] trunk
Status: Alpha
Brought to you by:
joe_steeve
From: <joe...@us...> - 2009-03-12 09:45:27
|
Revision: 9 http://asycxx.svn.sourceforge.net/asycxx/?rev=9&view=rev Author: joe_steeve Date: 2009-03-12 09:45:10 +0000 (Thu, 12 Mar 2009) Log Message: ----------- removed XMLParser.* this is not relevant to asycxx * removed references of XMLParser.* from the build system * removed the dependance on hdb-tinyxml * added a .gitignore to ignore un-necessary stuff From: Joe Steeve <js...@hi...> Modified Paths: -------------- trunk/configure.ac trunk/src/Makefile.am Added Paths: ----------- trunk/.gitignore Removed Paths: ------------- trunk/include/asycxx/XMLParser.h trunk/src/XMLParser.cxx Added: trunk/.gitignore =================================================================== --- trunk/.gitignore (rev 0) +++ trunk/.gitignore 2009-03-12 09:45:10 UTC (rev 9) @@ -0,0 +1,39 @@ +*~ +*.o +Makefile +Makefile.in +*.lo +stamp-h1 +aclocal.m4 +config.* +.deps +.libs +missing +ltmain.sh +install-sh +libtool +autom4te.cache +*.pc +asycxx-config.h +configure +depcomp +*.la +src/DataBuffer.h +src/Deferred.h +src/Error.h +src/Factory.h +src/GimpleMsgBus.h +src/Listener.h +src/Logger.h +src/MsgBus.h +src/MsgHandler.h +src/Protocol.h +src/Reactor.h +src/RefCounter.h +src/SelectReactor.h +src/TCPLLTransport.h +src/TCPListener.h +src/TCPTransport.h +src/Timer.h +src/Transport.h +src/_asycxx.h Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-03-12 09:42:31 UTC (rev 8) +++ trunk/configure.ac 2009-03-12 09:45:10 UTC (rev 9) @@ -6,10 +6,10 @@ CFLAGS="-Wall -Werror" CXXFLAGS="-Wall -Werror" -dnl setup the debug level +dnl setup the verbosity level AC_ARG_WITH(verbose-level, AS_HELP_STRING([--with-verbose-level], - [Use the given debug level (0 to 3) 0=disable]), + [Use the given verbosity level (0 to 3) 0=disable]), [asycxx_with_verbose_level=$withval],) if test $asycxx_with_verbose_level; then @@ -55,11 +55,6 @@ AC_DEFINE_UNQUOTED(ENABLE_SANITY_CHECKS, $ASYCXX_sanity_checks, [Enable/Disable sanity checks]) -dnl check for libhdb-tinyxml -PKG_CHECK_MODULES(HDB_TINYXML, hdb-tinyxml-1.0) -AC_SUBST(HDB_TINYXML_CFLAGS) -AC_SUBST(HDB_TINYXML_LIBS) - AC_SUBST(CFLAGS) AC_SUBST(CXXFLAGS) @@ -93,6 +88,5 @@ src/MsgBus.h:include/asycxx/MsgBus.h src/MsgHandler.h:include/asycxx/MsgHandler.h src/GimpleMsgBus.h:include/asycxx/GimpleMsgBus.h - src/XMLParser.h:include/asycxx/XMLParser.h src/_asycxx.h:include/asycxx/_asycxx.h) AC_OUTPUT Deleted: trunk/include/asycxx/XMLParser.h =================================================================== --- trunk/include/asycxx/XMLParser.h 2009-03-12 09:42:31 UTC (rev 8) +++ trunk/include/asycxx/XMLParser.h 2009-03-12 09:45:10 UTC (rev 9) @@ -1,54 +0,0 @@ - -/******************************************************************** - * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All - * rights reserved. - * - * This program and the accompanying materials are made available - * under the terms described in the LICENSE file which accompanies - * this distribution. If the LICENSE file was not attached to this - * distribution or for further clarifications, please contact - * le...@hi... - * - *******************************************************************/ - -#ifndef __HIPRO_ACW__XML_PARSER_H__ -#define __HIPRO_ACW__XML_PARSER_H__ - -#include <vector> -#include <hdb-tinyxml/tinyxml.h> - -#include "_asycxx.h" - -class XMLParser -{ -public: - XMLParser (const char *file_name); - ~XMLParser (); - - Result GetValue (const char *xpath, const char **value); - Result GetValue (const char *xpath, int *value); - -protected: - char m_FileName[HMI_CTRL_MAX_URL_LEN]; - TiXmlDocument *m_txDoc; - -private: - - Result ParseXPath (const char *xpath); - - /* used by the xpath parser */ - char m_XPath[HMI_CTRL_MAX_XPATH_LEN]; - std::vector<char *> m_XPathComponents; - -}; - -#endif /* __HIPRO_ACW__XML_PARSER_H__ */ - -/* - Local Variables: - mode: c++ - indent-tabs-mode: nil - tab-width: 4 - c-file-style: "gnu" - End: -*/ Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-12 09:42:31 UTC (rev 8) +++ trunk/src/Makefile.am 2009-03-12 09:45:10 UTC (rev 9) @@ -21,8 +21,7 @@ MsgBus.cxx \ MsgHandler.cxx \ GimpleMsgBus.cxx \ - XMLParser.cxx \ core.cxx -libasycxx_0_1_la_CXXFLAGS = -O2 $(HDB_TINYXML_CFLAGS) +libasycxx_0_1_la_CXXFLAGS = -O2 libasycxx_0_1_la_LDFLAGS = -version-info 0:1:0 Deleted: trunk/src/XMLParser.cxx =================================================================== --- trunk/src/XMLParser.cxx 2009-03-12 09:42:31 UTC (rev 8) +++ trunk/src/XMLParser.cxx 2009-03-12 09:45:10 UTC (rev 9) @@ -1,296 +0,0 @@ - -/******************************************************************** - * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All - * rights reserved. - * - * This program and the accompanying materials are made available - * under the terms described in the LICENSE file which accompanies - * this distribution. If the LICENSE file was not attached to this - * distribution or for further clarifications, please contact - * le...@hi... - * - *******************************************************************/ - -#ifdef HAVE_CONFIG_H -#include <asycxx-config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> - -#include "asycxx-common.h" -#include "XMLParser.h" -#include "Error.h" - -#include <hdb-tinyxml/tinyxml.h> - -/** - * \class XMLParser - * - * \details The xpath used here is not the standard xpath defined by - * the W3C but a smaller subset of it. It does not have all query - * features contained in the standard XPath. - * - * The XPath is the denotation of a node in an XML file in the form of - * a file-system path. In the following, XML file: - * - * <pre> - * - * \<config\> - * \<name\>Joe\</name\> - * \</config\> - * - * </pre> - * - * The node named 'name' can be referred to using the string - * "/config/name". The W3C standard XPath notation has more complex - */ - -XMLParser::XMLParser (const char *file_name) -{ - ASSERT ((file_name != NULL), "bad parameters"); - ASSERT ((strnlen (file_name, HMI_CTRL_MAX_URL_LEN) < HMI_CTRL_MAX_URL_LEN), - "bad parameters"); - - m_txDoc = NULL; - memset (m_FileName, 0, sizeof(m_FileName)); - memset (m_XPath, 0, sizeof(m_XPath)); - - strncpy (m_FileName, file_name, HMI_CTRL_MAX_URL_LEN); - m_txDoc = new TiXmlDocument (m_FileName); - if (m_txDoc->LoadFile() == false) - { - THROW (RunTimeError, "failed to load (parse) XML file=%s", m_FileName); - } -} - - -XMLParser::~XMLParser () -{ - if (m_txDoc != NULL) - { - delete m_txDoc; - } -} - - -/** - * \brief Get the string value pointed by the x-path - * - * \param[in] XPath A string containing the path to the node - * \param[out] value A pointer to a string pointer to take a pointer - * to the string value in the node. - * - * \details This method gets the value contained in the node pointed to - * by the 'xpath' string. On success, value should point to a const - * string which contains the value. - */ -Result -XMLParser::GetValue (const char *xpath, const char **value) -{ - Result ret; - - ASSERT ((xpath != NULL), "bad parameters"); - ASSERT ((value != NULL), "bad parameters"); - - *value = NULL; - if (strnlen (xpath, HMI_CTRL_MAX_XPATH_LEN) == HMI_CTRL_MAX_XPATH_LEN) - { - ERR ("XPath string is too long (max=%d bytes)", HMI_CTRL_MAX_XPATH_LEN); - return Result_Error; - } - - ret = ParseXPath (xpath); - if (ret != Result_Success) - { - ERR ("bad xpath. cannot fetch value"); - return Result_Error; - } - - /* loop through the children and obtain the node pointed to by the - xpath */ - TiXmlNode *pChild, *pParent; - pParent = m_txDoc; - bool bFound; - unsigned int i; - const char *strValue; - - for (i=0; i<m_XPathComponents.size(); i++) - { - pChild = pParent->FirstChild(m_XPathComponents[i]); - if (pChild == NULL) - { - ERR ("node=%s does not have a child=%s. bad xpath=%s", - pParent->Value(), m_XPathComponents[i], m_XPath); - return Result_Error; - } - pParent = pChild; - } - - /* If everything went well, then the child of this node should have - the requested value */ - bFound = false; - for (pChild = pParent->FirstChild(); pChild != NULL; - pChild = pChild->NextSibling()) - { - if (pChild->Type() == TiXmlNode::TEXT) - { - strValue = pChild->Value(); - if (strValue != NULL) - { - bFound = true; - break; - } - else - { - LOG3 ("TiXMLNode->Value() returned NULL"); - } - } - } - if (bFound == false) - { - ERR ("xpath=%s does not contain any 'text' value", m_XPath); - return Result_Error; - } - - /* Found the value */ - *value = strValue; - return Result_Success; -} - - -/** - * \brief Get the int value pointed by the x-path - * - * \param[in] XPath A string containing the path to the node - * \param[out] value A pointer to an integer to take the integer value - * in the node. - * - * \details This method gets the value contained in the node pointed to - * by the 'xpath' string and stores it into 'value'. - */ -Result -XMLParser::GetValue (const char *xpath, int *value) -{ - Result ret; - const char *strValue; - int intValue; - - ASSERT ((xpath != NULL), "bad parameters"); - ASSERT ((value != NULL), "bad parameters"); - - *value = 0; - - ret = GetValue (xpath, &strValue); - if (ret != Result_Success) - { - ERR ("failed to retrieve value from given xpath"); - return Result_Error; - } -#ifdef ENABLE_SANITY_CHECKS - if (strValue == NULL) - { - ERR ("a successfull GetValue gave NULL value"); - return Result_Error; - } -#endif - - intValue = atoi (strValue); - *value = intValue; - - return Result_Success; -} - - -/** - * \brief Break a xpath string into individual components - * - * \param[in] xpath A string containing the x-path to be broken down. - * - * \details This method breaks an xpath of the form '/doc/node1/node' - * into a vector of node-names arranged in the same order. - */ -Result -XMLParser::ParseXPath (const char *xpath) -{ - ASSERT ((xpath != NULL), "bad parameters"); - ASSERT ((strnlen (xpath, HMI_CTRL_MAX_XPATH_LEN) < HMI_CTRL_MAX_XPATH_LEN), - "xpath string is too long (max=%d bytes)", HMI_CTRL_MAX_XPATH_LEN); - - /* a clean start */ - memset (m_XPath, 0, sizeof(m_XPath)); - m_XPathComponents.clear(); - - if (xpath[0] != '/') - { - ERR ("xpath=%s is not absolute. should start with /", xpath); - return Result_Error; - } - - /* Break the 'xpath' string into seperate components. */ - char *tmpStr; bool foundStr; - unsigned int i; - - strncpy (m_XPath, xpath, HMI_CTRL_MAX_XPATH_LEN); - foundStr = false; - tmpStr = NULL; - for (i=0; i<HMI_CTRL_MAX_XPATH_LEN; i++) - { - if (m_XPath[i] == '\0') - { - /* We reached end of string. If we have a valid component in - the tmpStr, then we should save it before breaking out of - here */ - if (foundStr == true) - { - m_XPathComponents.push_back (tmpStr); - } - break; - } - - if (m_XPath[i] == '/') - { - /* We found a delimiter. */ - if (foundStr == true) - { - /* Looks like we already found a component. Then this is - the end of that component. We should save the - component and mark this location with a \0. */ - m_XPath[i] = '\0'; - m_XPathComponents.push_back (tmpStr); - foundStr = false; - } - /* If we did not find a valid component string before - finding this delimiter, then it is just consequtive - delimiters. We'll ignore them. */ - } - else - { - /* we found a normal character */ - if (foundStr == false) - { - /* Start of a valid component string */ - tmpStr = &m_XPath[i]; - foundStr = true; - } - } - } - - if (m_XPathComponents.empty() == true) - { - ERR ("no valid path components in xpath=%s", xpath); - return Result_Error; - } - - return Result_Success; -} - -/* - Local Variables: - mode: c++ - indent-tabs-mode: nil - tab-width: 4 - c-file-style: "gnu" - End: -*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |