From c3eaaebd67a820207b22b61fed6c626c39245a2f Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Wed, 15 Feb 2006 00:00:29 +0000 Subject: [PATCH] Initial check-in --- .cdtproject | 63 ++++++++++ .gitignore | 2 + .project | 86 ++++++++++++++ config_win32.h | 113 ++++++++++++++++++ cpp-xmltooling.sln | 20 ++++ doxyfile | 259 ++++++++++++++++++++++++++++++++++++++++++ xmltooling/.gitignore | 1 + xmltooling/Namespace.cpp | 110 ++++++++++++++++++ xmltooling/Namespace.h | 132 +++++++++++++++++++++ xmltooling/base.h | 74 ++++++++++++ xmltooling/config_pub_win32.h | 3 + xmltooling/internal.h | 40 +++++++ xmltooling/unicode.h | 154 +++++++++++++++++++++++++ xmltooling/util/NDC.cpp | 45 ++++++++ xmltooling/util/NDC.h | 61 ++++++++++ xmltooling/version.h | 74 ++++++++++++ xmltooling/xmltooling.vcproj | 246 +++++++++++++++++++++++++++++++++++++++ 17 files changed, 1483 insertions(+) create mode 100644 .cdtproject create mode 100644 .project create mode 100644 config_win32.h create mode 100644 cpp-xmltooling.sln create mode 100644 doxyfile create mode 100644 xmltooling/.gitignore create mode 100644 xmltooling/Namespace.cpp create mode 100644 xmltooling/Namespace.h create mode 100644 xmltooling/base.h create mode 100644 xmltooling/config_pub_win32.h create mode 100644 xmltooling/internal.h create mode 100644 xmltooling/unicode.h create mode 100644 xmltooling/util/NDC.cpp create mode 100644 xmltooling/util/NDC.h create mode 100644 xmltooling/version.h create mode 100644 xmltooling/xmltooling.vcproj diff --git a/.cdtproject b/.cdtproject new file mode 100644 index 0000000..74757f5 --- /dev/null +++ b/.cdtproject @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index f786faa..7dc697f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ /.*.swp /.DS_store # Simulated Subversion default ignores end here +# The contents of the svn:ignore property on the branch root. +/debug diff --git a/.project b/.project new file mode 100644 index 0000000..9f5002e --- /dev/null +++ b/.project @@ -0,0 +1,86 @@ + + + XMLTooling-C + + + + + + org.eclipse.cdt.make.core.makeBuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.build.arguments + + + + org.eclipse.cdt.core.errorOutputParser + org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser; + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.environment + + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.build.target.inc + all + + + org.eclipse.cdt.make.core.enabledIncrementalBuild + true + + + org.eclipse.cdt.make.core.build.target.clean + clean + + + org.eclipse.cdt.make.core.build.command + make + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.build.target.full + clean all + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + org.eclipse.cdt.make.core.build.target.auto + all + + + org.eclipse.cdt.make.core.stopOnError + false + + + + + org.eclipse.cdt.make.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.make.core.makeNature + org.eclipse.cdt.make.core.ScannerConfigNature + org.eclipse.cdt.core.ccnature + + diff --git a/config_win32.h b/config_win32.h new file mode 100644 index 0000000..89d112b --- /dev/null +++ b/config_win32.h @@ -0,0 +1,113 @@ +/* config_win32.h. Copied from a ./configure on Unix */ + +/* Define to 1 if you have the header file. +#define HAVE_DLFCN_H 1 +*/ + +/* Define to 1 if you have the `gmtime_r' function. */ +/* #undef HAVE_GMTIME_R */ + +/* Define if you have an STL implementation that supports useful string + specialization. */ +#define HAVE_GOOD_STL 1 + +/* Define to 1 if you have the header file. +#define HAVE_INTTYPES_H 1 +*/ + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#define HAVE_LIBCRYPTO 1 + +/* Define to 1 if you have the `curl' library (-lcurl). */ +#define HAVE_LIBCURL 1 + +/* Define if log4cpp library was found */ +#define HAVE_LIBLOG4CPP 1 + +/* Define to 1 if you have the `ssl' library (-lssl). */ +#define HAVE_LIBSSL 1 + +/* Define if Xerces-C library was found */ +#define HAVE_LIBXERCESC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* define if the compiler implements namespaces */ +#define HAVE_NAMESPACES 1 + +/* Define if you have POSIX threads libraries and header files. +#define HAVE_PTHREAD 1 +*/ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STDINT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +/* #undef HAVE_STRFTIME */ + +/* Define to 1 if you have the header file. +#define HAVE_STRINGS_H 1 +*/ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. +#define HAVE_UNISTD_H 1 +*/ + +/* Name of package */ +#define PACKAGE "xmltooling" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "mace-opensaml-users@internet2.edu" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "xmltooling" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "xmltooling 1.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "xmltooling" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.0" + +/* Define to the necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Version number of package */ +#define VERSION "1.0" + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ diff --git a/cpp-xmltooling.sln b/cpp-xmltooling.sln new file mode 100644 index 0000000..9ff2d25 --- /dev/null +++ b/cpp-xmltooling.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xmltooling", "xmltooling\xmltooling.vcproj", "{06B55A46-D3B3-41AE-B5A5-B57830BA010D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {06B55A46-D3B3-41AE-B5A5-B57830BA010D}.Debug|Win32.ActiveCfg = Debug|Win32 + {06B55A46-D3B3-41AE-B5A5-B57830BA010D}.Debug|Win32.Build.0 = Debug|Win32 + {06B55A46-D3B3-41AE-B5A5-B57830BA010D}.Release|Win32.ActiveCfg = Release|Win32 + {06B55A46-D3B3-41AE-B5A5-B57830BA010D}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/doxyfile b/doxyfile new file mode 100644 index 0000000..035cf62 --- /dev/null +++ b/doxyfile @@ -0,0 +1,259 @@ +# Doxyfile 1.4.6 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = XMLTooling-C +PROJECT_NUMBER = 1.0 +OUTPUT_DIRECTORY = C:/cvs/cpp-xmltooling/doc +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = YES +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = C:/cvs/cpp-xmltooling +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = C:/cvs/cpp-xmltooling/xmltooling +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +USE_HTAGS = NO +VERBATIM_HEADERS = NO +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = C:\cvs\cpp-xmltooling +INCLUDE_FILE_PATTERNS = +PREDEFINED = _MSC_VER +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/xmltooling/.gitignore b/xmltooling/.gitignore new file mode 100644 index 0000000..98bbc31 --- /dev/null +++ b/xmltooling/.gitignore @@ -0,0 +1 @@ +/Debug diff --git a/xmltooling/Namespace.cpp b/xmltooling/Namespace.cpp new file mode 100644 index 0000000..0d7a3f2 --- /dev/null +++ b/xmltooling/Namespace.cpp @@ -0,0 +1,110 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Namespace.cpp + * + * Data structure for representing XML namespace attributes + * + * $Id:$ + */ + +#include "internal.h" +#include "unicode.h" +#include "Namespace.h" + +using namespace std; +using namespace xmltooling; + +Namespace::Namespace() +{ +#ifndef HAVE_GOOD_STL + m_uri=m_prefix=NULL; +#endif +} + +Namespace::Namespace(const XMLCh* uri, const XMLCh* prefix) +{ + setNamespaceURI(uri); + setNamespacePrefix(prefix); +} + +Namespace::~Namespace() +{ +#ifndef HAVE_GOOD_STL + XMLString::release(&m_uri); + XMLString::release(&m_prefix); +#endif +} + +void Namespace::setNamespacePrefix(const XMLCh* prefix) +{ +#ifdef HAVE_GOOD_STL + if (prefix) + m_prefix=prefix; + else + m_prefix.erase(); +#else + if (m_prefix) + XMLString::release(&m_prefix); + m_prefix=XMLString::replicate(prefix); +#endif +} + +void Namespace::setNamespaceURI(const XMLCh* uri) +{ +#ifdef HAVE_GOOD_STL + if (uri) + m_uri=uri; + else + m_uri.erase(); +#else + if (m_uri) + XMLString::release(&m_uri); + m_uri=XMLString::replicate(uri); +#endif +} + +#ifndef HAVE_GOOD_STL +Namespace::Namespace(const Namespace& src) +{ + m_uri=XMLString::replicate(src.getNamespaceURI()); + m_prefix=XMLString::replicate(src.getNamespacePrefix()); +} + +Namespace& Namespace::operator=(const Namespace& src) +{ + m_uri=XMLString::replicate(src.getNamespaceURI()); + m_prefix=XMLString::replicate(src.getNamespacePrefix()); + return *this; +} + +bool xmltooling::operator==(const Namespace& op1, const Namespace& op2) +{ + return (!XMLString::compareString(op1.getNamespaceURI(),op2.getNamespaceURI()) && + !XMLString::compareString(op1.getNamespacePrefix(),op2.getNamespacePrefix())); +} +#endif + +bool xmltooling::operator<(const Namespace& op1, const Namespace& op2) +{ + int i=XMLString::compareString(op1.getNamespaceURI(),op2.getNamespaceURI()); + if (i<0) + return true; + else if (i==0) + return (XMLString::compareString(op1.getNamespacePrefix(),op2.getNamespacePrefix())<0); + else + return false; +} diff --git a/xmltooling/Namespace.h b/xmltooling/Namespace.h new file mode 100644 index 0000000..d94c845 --- /dev/null +++ b/xmltooling/Namespace.h @@ -0,0 +1,132 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file Namespace.h + * + * Representing XML namespace attributes + */ + +#if !defined(__xmltooling_namespace_h__) +#define __xmltooling_namespace_h__ + +#include +#include + +namespace xmltooling { + + /** + * A data structure for encapsulating XML Namespace attributes + */ + class XMLTOOL_API Namespace + { + public: + /** + * Default constructor + */ + Namespace(); + + /** + * Constructor that takes an existing declaration + * @param uri namespace URI + * @param prefix namespace prefix (without the colon) + */ + Namespace(const XMLCh* uri, const XMLCh* prefix); + + ~Namespace(); +#ifndef HAVE_GOOD_STL + /** + * Deep copy constructor + */ + Namespace(const Namespace&); + + /** + * Deep assignment operator + */ + Namespace& operator=(const Namespace&); +#endif + +#ifdef HAVE_GOOD_STL + /** + * Returns the namespace prefix + * @return Null-terminated Unicode string containing the prefix, without the colon + */ + const XMLCh* getNamespacePrefix() const { return m_prefix.c_str(); } + + /** + * Returns the namespace URI + * @return Null-terminated Unicode string containing the URI + */ + const XMLCh* getNamespaceURI() const { return m_uri.c_str(); } +#else + /** + * Returns the namespace prefix + * @return Null-terminated Unicode string containing the prefix, without the colon + */ + const XMLCh* getNamespacePrefix() const { return m_prefix; } + + /** + * Returns the namespace URI + * @return Null-terminated Unicode string containing the URI + */ + const XMLCh* getNamespaceURI() const { return m_uri; } +#endif + + /** + * Sets the namespace prefix + * @param prefix Null-terminated Unicode string containing the prefix, without the colon + */ + void setNamespacePrefix(const XMLCh* prefix); + + /** + * Sets the namespace URI + * @param uri Null-terminated Unicode string containing the URI + */ + void setNamespaceURI(const XMLCh* uri); + + private: +#ifdef HAVE_GOOD_STL + xstring m_uri; + xstring m_prefix; +#else + XMLCh* m_uri; + XMLCh* m_prefix; +#endif + }; + + /** + * Returns true iff op1's namespace lexically compares less than op2's namespace, + * or if equal, iff op1's prefix lexically compares less than op2's prefix. + * + * Needed for use with sorted STL containers. + * + * @param op1 First namspace to compare + * @param op2 Second namespace to compare + */ + extern XMLTOOL_API bool operator<(const Namespace& op1, const Namespace& op2); + +#ifndef HAVE_GOOD_STL + /** + * Returns true iff op1's namespace and prefix are equal to op2's namespace and prefix. + * @param op1 First namspace to compare + * @param op2 Second namespace to compare + */ + extern XMLTOOL_API bool operator==(const Namespace& op1, const Namespace& op2); +#endif + +}; + +#endif /* __xmltooling_namespace_h__ */ diff --git a/xmltooling/base.h b/xmltooling/base.h new file mode 100644 index 0000000..3fe0221 --- /dev/null +++ b/xmltooling/base.h @@ -0,0 +1,74 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file base.h + * + * Base header file definitions + * Must be included prior to including any other header + */ + +#if !defined(__xmltooling_base_h__) +#define __xmltooling_base_h__ + +#if defined (_MSC_VER) || defined(__BORLANDC__) + #include +#else + #include +#endif + +/** + * @namespace xmltooling + * Public namespace of XML Tooling library + */ + +// Windows and GCC4 Symbol Visibility Macros + +#ifdef WIN32 + #define XMLTOOL_IMPORT __declspec(dllimport) + #define XMLTOOL_EXPORT __declspec(dllexport) + #define XMLTOOL_DLLLOCAL + #define XMLTOOL_DLLPUBLIC +#else + #define XMLTOOL_IMPORT + #ifdef GCC_HASCLASSVISIBILITY + #define XMLTOOL_EXPORT __attribute__ ((visibility("default"))) + #define XMLTOOL_DLLLOCAL __attribute__ ((visibility("hidden"))) + #define XMLTOOL_DLLPUBLIC __attribute__ ((visibility("default"))) + #else + #define XMLTOOL_EXPORT + #define XMLTOOL_DLLLOCAL + #define XMLTOOL_DLLPUBLIC + #endif +#endif + +// Define XMLTOOL_API for DLL builds +#ifdef XMLTOOLING_EXPORTS + #define XMLTOOL_API XMLTOOL_EXPORT +#else + #define XMLTOOL_API XMLTOOL_IMPORT +#endif + +// Throwable classes must always be visible on GCC in all binaries +#ifdef WIN32 + #define XMLTOOL_EXCEPTIONAPI(api) api +#elif defined(GCC_HASCLASSVISIBILITY) + #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT +#else + #define XMLTOOL_EXCEPTIONAPI(api) +#endif + +#endif /* __xmltooling_base_h__ */ diff --git a/xmltooling/config_pub_win32.h b/xmltooling/config_pub_win32.h new file mode 100644 index 0000000..9ba556a --- /dev/null +++ b/xmltooling/config_pub_win32.h @@ -0,0 +1,3 @@ +/* Define to 1 if you have an STL implementation that supports useful string + specialization. */ +#define HAVE_GOOD_STL 1 diff --git a/xmltooling/internal.h b/xmltooling/internal.h new file mode 100644 index 0000000..03f6d3d --- /dev/null +++ b/xmltooling/internal.h @@ -0,0 +1,40 @@ +/* + * Copyright 2001-2005 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * internal.h - internally visible classes + */ + +#ifndef __xmltooling_internal_h__ +#define __xmltooling_internal_h__ + +#ifdef WIN32 +# define _CRT_SECURE_NO_DEPRECATE 1 +# define _CRT_NONSTDC_NO_DEPRECATE 1 +#endif + +// eventually we might be able to support autoconf via cygwin... +#if defined (_MSC_VER) || defined(__BORLANDC__) +# include "config_win32.h" +#else +# include "config.h" +#endif + +#include "base.h" + +#define XMLTOOLING_LOGCAT "XMLTooling" + +#endif /* __xmltooling_internal_h__ */ diff --git a/xmltooling/unicode.h b/xmltooling/unicode.h new file mode 100644 index 0000000..311ffb7 --- /dev/null +++ b/xmltooling/unicode.h @@ -0,0 +1,154 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file unicode.h + * + * Helper classes and types for manipulating Unicode + */ + +#if !defined(__xmltooling_unicode_h__) +#define __xmltooling_unicode_h__ + +#include +#include +#include + +using namespace xercesc; + +namespace xmltooling { + + #ifdef HAVE_GOOD_STL + /** + * An STL string type that supports 16-bit Unicode. + * Most compilers support this, but various versions of gcc3 do not. + */ + typedef std::basic_string xstring; + #endif + + /** + * Transcodes a 16-bit Unicode string into UTF-8. + * @param src the 16-bit string to transcode + * @return a UTF-8 string allocated by the Xerces memory manager + */ + extern XMLTOOL_API char* toUTF8(const XMLCh* src); + + /** + * Transcodes a UTF-8 string into 16-bit Unicode. + * @param src the UTF-8 string to transcode + * @return a 16-bit Unicode string allocated by the Xerces memory manager + */ + extern XMLTOOL_API XMLCh* fromUTF8(const char* src); + + /** + * A minimal auto_ptr-like class that can copy or transcode a buffer into + * the local code page and free the result automatically. + * + * Needed because a standard auto_ptr would use delete on the resulting + * pointer. + */ + class XMLTOOL_API auto_ptr_char + { + public: + /** + * Constructor transcodes a 16-bit Unicode string into the local code page (NOT UTF-8) and wraps the result. + * @param src the 16-bit string to transcode and wrap + * @param trim trims leading/trailing whitespace from the result (defaults to true) + */ + auto_ptr_char(const XMLCh* src, bool trim=true) : m_buf(XMLString::transcode(src)) {if (trim && m_buf) XMLString::trim(m_buf);} + + /** + * Constructor copies a local code page (NOT UTF-8) string and wraps the result. + * @param src the local string to copy and wrap + * @param trim trims leading/trailing whitespace from the result (defaults to true) + */ + auto_ptr_char(const char* src, bool trim=true) : m_buf(XMLString::replicate(src)) {if (trim && m_buf) XMLString::trim(m_buf);} + + /** + * Destructor frees the wrapped buffer using the Xerces memory manager. + */ + ~auto_ptr_char() { XMLString::release(&m_buf); } + + /** + * Returns the wrapped buffer. + * @return a null-terminated local code page string + */ + const char* get() const { return m_buf; } + + /** + * Returns the wrapped buffer and transfers ownership of it to the caller. + * @return a null-terminated local code page string + */ + char* release() { char* temp=m_buf; m_buf=NULL; return temp; } + + private: + auto_ptr_char(const auto_ptr_char&); + auto_ptr_char& operator=(const auto_ptr_char&); + + char* m_buf; + }; + + /** + * A minimal auto_ptr-like class that can copy or transcode a buffer into + * 16-bit Unicode and free the result automatically. + * + * Needed because a standard auto_ptr would use delete on the resulting + * pointer. + */ + class XMLTOOL_API auto_ptr_XMLCh + { + public: + /** + * Constructor transcodes a local code page (NOT UTF-8) string into 16-bit Unicode and wraps the result. + * @param src the local string to transcode and wrap + * @param trim trims leading/trailing whitespace from the result (defaults to true) + */ + auto_ptr_XMLCh(const char* src, bool trim=true) : m_buf(XMLString::transcode(src)) {if (trim && m_buf) XMLString::trim(m_buf);} + + /** + * Constructor copies a 16-bit Unicode string and wraps the result. + * @param src the Unicode string to copy and wrap + * @param trim trims leading/trailing whitespace from the result (defaults to true) + */ + auto_ptr_XMLCh(const XMLCh* src, bool trim=true) : m_buf(XMLString::replicate(src)) {if (trim && m_buf) XMLString::trim(m_buf);} + + /** + * Destructor frees the wrapped buffer using the Xerces memory manager. + */ + ~auto_ptr_XMLCh() { XMLString::release(&m_buf); } + + /** + * Returns the wrapped buffer. + * @return a null-terminated Unicode string + */ + const XMLCh* get() const { return m_buf; } + + /** + * Returns the wrapped buffer and transfers ownership of it to the caller. + * @return a null-terminated Unicode string + */ + XMLCh* release() { XMLCh* temp=m_buf; m_buf=NULL; return temp; } + + private: + auto_ptr_XMLCh(const auto_ptr_XMLCh&); + auto_ptr_XMLCh& operator=(const auto_ptr_XMLCh&); + + XMLCh* m_buf; + }; + +}; + +#endif /* __xmltooling_unicode_h__ */ diff --git a/xmltooling/util/NDC.cpp b/xmltooling/util/NDC.cpp new file mode 100644 index 0000000..1886721 --- /dev/null +++ b/xmltooling/util/NDC.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* NDC.cpp + * + * Diagnostic context for logging + * + * $Id:$ + */ + +#include "internal.h" +#include "util/NDC.h" + +#include + +using namespace std; +using namespace xmltooling; + +NDC::NDC(const char* context) +{ + log4cpp::NDC::push(context); +} + +NDC::NDC(const string& context) +{ + log4cpp::NDC::push(context); +} + +NDC::~NDC() +{ + log4cpp::NDC::pop(); +} diff --git a/xmltooling/util/NDC.h b/xmltooling/util/NDC.h new file mode 100644 index 0000000..57ef9d4 --- /dev/null +++ b/xmltooling/util/NDC.h @@ -0,0 +1,61 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file NDC.h + * + * Diagnostic context for logging + */ + +#if !defined(__xmltooling_ndc_h__) +#define __xmltooling_ndc_h__ + +#include +#include + +namespace xmltooling { + + /** + * A portable stack-based context for diagnostic logging + */ + class XMLTOOL_API NDC + { + public: + /** + * Constructor pushes logging context onto diagnostic stack + * @param context null-terminated label for context + */ + NDC(const char* context); + + /** + * Constructor pushes logging context onto diagnostic stack + * @param context string label for context + */ + NDC(const std::string& context); + + /** + * Destructor pops context off of diagnostic stack + */ + ~NDC(); + + private: + NDC(const NDC&); + NDC& operator=(const NDC&); + }; + +}; + +#endif /* __xmltooling_ndc_h__ */ diff --git a/xmltooling/version.h b/xmltooling/version.h new file mode 100644 index 0000000..adf0181 --- /dev/null +++ b/xmltooling/version.h @@ -0,0 +1,74 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file version.h + * + * Library version macros and constants + */ + +#if !defined(__xmltooling_version_h__) +#define __xmltooling_version_h__ + +// This is all based on Xerces, on the theory it might be useful to +// support this kind of stuff in the future. If they ever yank some +// of this stuff, it can be copied into here. + +#include + +// --------------------------------------------------------------------------- +// V E R S I O N S P E C I F I C A T I O N + +/** + * MODIFY THESE NUMERIC VALUES TO COINCIDE WITH XMLTOOLING VERSION + * AND DO NOT MODIFY ANYTHING ELSE IN THIS VERSION HEADER FILE + */ + +#define XMLTOOLING_VERSION_MAJOR 1 +#define XMLTOOLING_VERSION_MINOR 0 +#define XMLTOOLING_VERSION_REVISION 0 + +/** DO NOT MODIFY BELOW THIS LINE */ + +/** + * MAGIC THAT AUTOMATICALLY GENERATES THE FOLLOWING: + * + * gXMLToolingVersionStr, gXMLToolingFullVersionStr, gXMLToolingMajVersion, gXMLToolingMinVersion, gXMLToolingRevision + */ + +// --------------------------------------------------------------------------- +// V E R S I O N I N F O R M A T I O N + +// XMLTooling version strings; these particular macros cannot be used for +// conditional compilation as they are not numeric constants + +#define XMLTOOLING_FULLVERSIONSTR INVK_CAT3_SEP_UNDERSCORE(XMLTOOLING_VERSION_MAJOR,XMLTOOLING_VERSION_MINOR,XMLTOOLING_VERSION_REVISION) +#define XMLTOOLING_FULLVERSIONDOT INVK_CAT3_SEP_PERIOD(XMLTOOLING_VERSION_MAJOR,XMLTOOLING_VERSION_MINOR,XMLTOOLING_VERSION_REVISION) +#define XMLTOOLING_FULLVERSIONNUM INVK_CAT3_SEP_NIL(XMLTOOLING_VERSION_MAJOR,XMLTOOLING_VERSION_MINOR,XMLTOOLING_VERSION_REVISION) +#define XMLTOOLING_VERSIONSTR INVK_CAT2_SEP_UNDERSCORE(XMLTOOLING_VERSION_MAJOR,XMLTOOLING_VERSION_MINOR) + +const char* const gXMLToolingVersionStr = XMLTOOLING_VERSIONSTR; +const char* const gXMLToolingFullVersionStr = XMLTOOLING_FULLVERSIONSTR; +const unsigned int gXMLToolingMajVersion = XMLTOOLING_VERSION_MAJOR; +const unsigned int gXMLToolingMinVersion = XMLTOOLING_VERSION_MINOR; +const unsigned int gXMLToolingRevision = XMLTOOLING_VERSION_REVISION; + +// XMLTooling version numeric constants that can be used for conditional +// compilation purposes. + +#define _XMLTOOLING_VERSION CALC_EXPANDED_FORM (XMLTOOLING_VERSION_MAJOR,XMLTOOLING_VERSION_MINOR,XMLTOOLING_VERSION_REVISION) + +#endif // __xmltooling_version_h__ diff --git a/xmltooling/xmltooling.vcproj b/xmltooling/xmltooling.vcproj new file mode 100644 index 0000000..e65b61e --- /dev/null +++ b/xmltooling/xmltooling.vcproj @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.1.4