init repo

This commit is contained in:
nikolay ivanov
2014-07-05 18:22:49 +00:00
commit a8be6b9e72
17348 changed files with 9229832 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Attribute.h"
#include "Lexigraph.h"
#include "Encoding.h"
namespace XML
{
namespace Private
{
Attribute::Attribute(const XML::XName& xname, const std::string& value)
: XName(xname),
Value(value)
{
}
Attribute::Attribute()
{
}
const bool Attribute::operator ==(const Attribute& rhs) const
{
return (XName->Equal(*rhs.XName));
}
const bool Attribute::operator <(const Attribute& rhs) const
{
return ((*XName->Name) < (*rhs.XName->Name));
}
const bool Attribute::exist() const
{
return true;
}
const std::string Attribute::ToString() const
{
return XName->ToString() + "=\"" + Private::Lexigraph::toSource(Value->ToString()) + "\"";
}
const std::wstring Attribute::ToWString() const
{
return XName->ToWString() + L"=\"" + Encoding::utf82unicode(Private::Lexigraph::toSource(Value->ToString())) + L"\"";
}
void Attribute::SaveToStringList(std::list<std::string>& strList)const
{
XName->SaveToStringList(strList);
strList.push_back("=\"");
strList.push_back(Private::Lexigraph::toSource(Value->ToString()));
strList.push_back("\"");
}
void Attribute::SaveToWStringList(std::list<std::wstring>& strList)const
{
XName->SaveToWStringList(strList);
strList.push_back(L"=\"");
strList.push_back(Encoding::utf82unicode(Private::Lexigraph::toSource(Value->ToString())));
strList.push_back(L"\"");
}
const XString Attribute::value() const
{
return *Value;
}
}
} // namespace XML

View File

@@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XATTRIBUTE_INCLUDE_H_
#define XML_PRIVATE_XATTRIBUTE_INNLUDE_H_
#include <string>
#include "XString.h"
#include "./../XName.h"
#include "property.h"
#include <list>
namespace XML
{
namespace Private
{
class Attribute
{
public:
Attribute(const XName& xname, const std::string& value);
public:
const bool operator ==(const Attribute& rhs) const;
const bool operator <(const Attribute& rhs) const;
virtual const bool exist() const;
public:
const std::string ToString() const;
const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
public:
const XString value() const;
public:
property<XName> XName;
property<Private::XString> Value;
protected:
Attribute();
};
}
}
#endif // XML_PRIVATE_ATTRIBUTE_INCLUDE_H_

View File

@@ -0,0 +1,108 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Comment.h"
#include "Lexigraph.h"
#include "Encoding.h"
namespace XML
{
namespace Private
{
Comment::Comment()
{
}
Comment::Comment(const std::string& value)
: Value(value)
{
}
Comment::~Comment()
{
}
const bool Comment::isElement() const
{
return false;
}
const bool Comment::isText() const
{
return false;
}
const bool Comment::isComment() const
{
return true;
}
const std::string Comment::ToString() const
{
return "<!--" + Private::Lexigraph::toSource(Value.ToString()) + "-->";
}
const std::wstring Comment::ToWString() const
{
return L"<!--" + Private::Lexigraph::toSource(Value.ToWString()) + L"-->";
}
void Comment::SaveToStringList(std::list<std::string>& strList)const
{
strList.push_back("<!--");
strList.push_back(Private::Lexigraph::toSource(Value.ToString()));
strList.push_back("-->");
}
void Comment::SaveToWStringList(std::list<std::wstring>& strList)const
{
strList.push_back(L"<!--");
strList.push_back(Private::Lexigraph::toSource(Value.ToWString()));
strList.push_back(L"-->");
}
}
} // namespace XML

View File

@@ -0,0 +1,72 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_COMMENT_INCLUDE_H_
#define XML_PRIVATE_COMMENT_INCLUDE_H_
#include "Node.h"
#include <string>
#include "XString.h"
#include "property.h"
namespace XML
{
namespace Private
{
class Comment : public Node
{
public:
explicit Comment(const std::string& value);
virtual ~Comment();
public:
virtual const bool isElement() const;
virtual const bool isText() const;
virtual const bool isComment() const;
public:
virtual const std::string ToString() const;
virtual const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
public:
XString Value;
protected:
Comment();
};
}
}
#endif // XML_PRIVATE_COMMENT_INCLUDE_H_

View File

@@ -0,0 +1,491 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Element.h"
#include <utility>
#include <vector>
#include "XList.h"
#include "./../Exception/Parse.h"
#include "./../Exception/Namespace.h"
#include "Namespace.h"
#include "./../XAttribute.h"
#include "./../XAttribute.h"
#include "./../XNode.h"
#include "./../XElement.h"
#include "./../XText.h"
#include "./../XContainer.h"
#include "Exception/not_implement.h"
#include "Utility.h"
namespace XML
{
namespace Private
{
Element::Element()
{
}
Element::Element(const XML::XName& xname)
: XName(xname)
{
}
Element::Element(const XML::XName& xname, const XList& list)
: NodeContainer(list.Nodes),
XName(xname),
Attributes(list.Attributes),
Namespaces(list.Namespaces)
{
}
Element::Element(NSCommon::smart_ptr<XSingleSource> source, const XNamespaceContainer& ns, const XSpace& space)
: Space(space)
{
fromSource(source, ns, Space);
}
Element::Element(NSCommon::smart_ptr<XWideSource> source, const XNamespaceContainer& ns, const XSpace& space)
: Space(space)
{
fromSource(source, ns, Space);
}
Element::~Element()
{
}
const bool Element::isElement() const
{
return true;
}
const bool Element::isText() const
{
return false;
}
const bool Element::isComment() const
{
return false;
}
void Element::fromSource(NSCommon::smart_ptr<XSingleSource> source, const XNamespaceContainer& defineNamespaces, const XSpace& space)
{
Space = space;
source->skipSpace();
const std::pair<const std::string, const std::string> name = source->getName();
source->skipSpace();
std::list<std::pair<std::pair<std::string, std::string>, std::string> > attributes;
while (source->get() != '/' && source->get() != '>')
{
const std::pair<const std::pair<const std::string, const std::string>, const std::string> attribute = source->getAttribute();
if (attribute.first.first == "xmlns" || attribute.first.first.empty() && attribute.first.second == "xmlns")
{
Namespaces->push_back(XNamespace(attribute.first.second, attribute.second));
}
else if (attribute.first.first == "xml")
{
if (attribute.first.second == "space")
{
if (attribute.second == "default")
Space->setDefault();
else if (attribute.second == "preserve")
Space->setPreserve();
else
throw Exception::Parse("bad space parametr");
}
}
else
{
attributes.push_back(attribute);
}
source->skipSpace();
}
typedef std::pair<std::pair<std::string, std::string>, std::string> attribute_type;
for (std::list<attribute_type>::iterator iter = attributes.begin(); iter != attributes.end();++iter)
{
if ((*iter).first.first.empty())
{
Attributes.push_back(XAttribute((*iter).first.second, (*iter).second));
}
else
{
XNamespace thisNs = Namespaces[(*iter).first.first];
XNamespace defineNs = defineNamespaces[(*iter).first.first];
if (thisNs.exist())
Attributes.push_back(XAttribute(thisNs + (*iter).first.second, (*iter).second));
else if (defineNs.exist())
Attributes.push_back(XAttribute(defineNs + (*iter).first.second, (*iter).second));
else
{
}
}
}
XName->Name = name.second;
if (!name.first.empty())
{
XNamespace thisNs = Namespaces[name.first];
XNamespace defineNs = defineNamespaces[name.first];
if (thisNs.exist())
XName->Ns = thisNs;
else if (defineNs.exist())
XName->Ns = defineNs;
else
{
}
}
if (source->get() == '/')
{
source->findAndSkip('>');
}
else
{
source->findAndSkip('>');
XNamespaceContainer summaryNamespaces = Namespaces;
summaryNamespaces.merge(defineNamespaces);
NodeContainer::fromSource(source, summaryNamespaces, Space);
source->skipSpace();
const std::pair<const std::string, const std::string> name = source->getName();
source->findAndSkip('>');
}
}
void Element::fromSource(NSCommon::smart_ptr<XWideSource> source, const XNamespaceContainer& defineNamespaces, const XSpace& space)
{
Space = space;
source->skipSpace();
const std::pair<const std::wstring, const std::wstring> name = source->getName();
source->skipSpace();
std::list<std::pair<std::pair<std::wstring, std::wstring>, std::wstring> > attributes;
while (source->get() != L'/' && source->get() != L'>')
{
const std::pair<const std::pair<const std::wstring, const std::wstring>, const std::wstring> attribute = source->getAttribute();
if ((attribute.first.first == L"xmlns") || ((attribute.first.first.empty()) && (attribute.first.second == L"xmlns")))
{
Namespaces->push_back(XNamespace(Encoding::unicode2utf8(attribute.first.second), Encoding::unicode2utf8(attribute.second)));
}
else if (attribute.first.first == L"xml")
{
if (attribute.first.second == L"space")
{
if (attribute.second == L"default")
Space->setDefault();
else if (attribute.second == L"preserve")
Space->setPreserve();
else
throw Exception::Parse("bad space parametr");
}
}
else
{
attributes.push_back(attribute);
}
source->skipSpace();
}
typedef std::pair<std::pair<std::wstring, std::wstring>, std::wstring> attribute_type;
for (std::list<attribute_type >::iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
{
if ((*iter).first.first.empty())
{
Attributes.push_back(XAttribute(Encoding::unicode2utf8((*iter).first.second), Encoding::unicode2utf8((*iter).second)));
}
else
{
XNamespace thisNs = Namespaces[Encoding::unicode2utf8((*iter).first.first)];
XNamespace defineNs = defineNamespaces[Encoding::unicode2utf8((*iter).first.first)];
if (thisNs.exist())
Attributes.push_back(XAttribute(thisNs + Encoding::unicode2utf8((*iter).first.second), Encoding::unicode2utf8((*iter).second)));
else if (defineNs.exist())
Attributes.push_back(XAttribute(defineNs + Encoding::unicode2utf8((*iter).first.second), Encoding::unicode2utf8((*iter).second)));
else
throw Exception::Namespace("not define namespace");
}
}
XName->Name = Encoding::unicode2utf8(name.second);
if (!name.first.empty())
{
XNamespace thisNs = Namespaces[Encoding::unicode2utf8(name.first)];
XNamespace defineNs = defineNamespaces[Encoding::unicode2utf8(name.first)];
if (thisNs.exist())
XName->Ns = thisNs;
else if (defineNs.exist())
XName->Ns = defineNs;
else
throw Exception::Namespace("not define namespace");
}
if (source->get() == L'/')
{
source->findAndSkip(L'>');
}
else
{
source->findAndSkip(L'>');
XNamespaceContainer summaryNamespaces = Namespaces;
summaryNamespaces.merge(defineNamespaces);
NodeContainer::fromSource(source, summaryNamespaces, Space);
source->skipSpace();
const std::pair<const std::wstring, const std::wstring> name = source->getName();
source->findAndSkip(L'>');
}
}
const std::string Element::ToString() const
{
std::string node;
node += "<" + XName->ToString();
if (Space->isPreserve())
node += " xml:space=\"preserve\" ";
node += Namespaces->ToString();
node += Attributes->ToString();
if (Nodes->empty())
node += "/>";
else
node += ">" + Nodes->ToString() + "</" + XName->ToString() + ">";
return node;
}
const std::wstring Element::ToWString() const
{
std::wstring node;
node += L"<" + XName->ToWString();
if (Space->isPreserve())
node += L" xml:space=\"preserve\" ";
node += Namespaces->ToWString();
node += Attributes->ToWString();
if (Nodes->empty())
node += L"/>";
else
node += L">" + Nodes->ToWString() + L"</" + XName->ToWString() + L">";
return node;
}
void Element::SaveToStringList(std::list<std::string>& strList)const
{
strList.push_back("<");
XName->SaveToStringList(strList);
if (Space->isPreserve())
strList.push_back(" xml:space=\"preserve\" ");
Namespaces->SaveToStringList(strList);
Attributes->SaveToStringList(strList);
if (Nodes->empty())
strList.push_back("/>");
else
{
strList.push_back(">");
Nodes->SaveToStringList(strList);
strList.push_back("</");
XName->SaveToStringList(strList);
strList.push_back(">");
}
}
void Element::SaveToWStringList(std::list<std::wstring>& strList)const
{
strList.push_back(L"<");
XName->SaveToWStringList(strList);
if (Space->isPreserve())
strList.push_back(L" xml:space=\"preserve\" ");
Namespaces->SaveToWStringList(strList);
Attributes->SaveToWStringList(strList);
if (Nodes->empty())
strList.push_back(L"/>");
else
{
strList.push_back(L">");
Nodes->SaveToWStringList(strList);
strList.push_back(L"</");
XName->SaveToWStringList(strList);
strList.push_back(L">");
}
}
const bool Element::exist() const
{
return true;
}
const XString Element::text() const
{
return Texts->text();
}
void Element::Add(const XAttribute& attribute)
{
Attributes.Add(attribute);
}
void Element::Add(const XNamespace& ns)
{
Namespaces.Add(ns);
}
void Element::Add(const XNode& node)
{
Nodes.Add(node);
}
void Element::Add(const XElement& element)
{
Nodes.Add(element);
}
void Element::Add(const XText& text)
{
Nodes.Add(text);
}
void Element::Add(const XML::XContainer& container)
{
Nodes.Add(container);
}
void Element::Add(const XML::Private::XList& list)
{
Attributes->merge(list.Attributes);
Namespaces->merge(list.Namespaces);
Nodes->merge(list.Nodes);
}
const XNamespaceContainer Element::usedNamespace() const
{
XNamespaceContainer container;
if (XName->Ns.is_init())
container.push_back(XName->Ns);
container.merge(Attributes.usedNamespace());
container.merge(Elements.usedNamespace());
return container;
}
XAttribute& Element::attribute(const XML::XName& xname)
{
return Attributes[xname];
}
const XAttribute& Element::attribute(const XML::XName& xname) const
{
return Attributes[xname];
}
XElement Element::element(const XML::XName& xname)
{
return Elements[xname];
}
const XElement Element::element(const XML::XName& xname) const
{
return Elements[xname];
}
XElement Element::element(const XML::XName& xname, const std::string& value)
{
return Elements.get(xname, value);
}
const XElement Element::element(const XML::XName& xname, const std::string& value) const
{
return Elements.get(xname, value);
}
}
} // namespace XML

View File

@@ -0,0 +1,118 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_ELEMENT_INCLUDE_H_
#define XML_PRIVATE_XELEMENT_INCLUDE_H_
#include <list>
#include <string>
#include "NodeContainer.h"
#include "property.h"
#include "XAttributeContainer.h"
#include "XNamespaceContainer.h"
#include "./../XName.h"
#include "XString.h"
#include "XSpace.h"
#include "XSingleSource.h"
#include "XWideSource.h"
namespace XML
{
class XAttribute;
class XNamespace;
class XNode;
class XText;
class XContainer;
namespace Private
{
class XList;
class Element : public NodeContainer
{
public:
Element();
Element(const XML::XName& xname);
Element(const XML::XName& xname, const XList& list);
Element(NSCommon::smart_ptr<XSingleSource> source, const XNamespaceContainer& ns, const XSpace& space);
Element(NSCommon::smart_ptr<XWideSource> source, const XNamespaceContainer& ns, const XSpace& space);
virtual ~Element();
public:
virtual const bool isElement() const;
virtual const bool isText() const;
virtual const bool isComment() const;
public:
void fromSource(NSCommon::smart_ptr<XSingleSource> source, const XNamespaceContainer& defineNamespaces, const XSpace& space);
void fromSource(NSCommon::smart_ptr<XWideSource> source, const XNamespaceContainer& defineNamespaces, const XSpace& space);
virtual const std::string ToString() const;
virtual const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
public:
virtual const bool exist() const;
virtual const XString text() const;
const XNamespaceContainer usedNamespace() const;
public:
void Add(const XAttribute& attribute);
void Add(const XNamespace& ns);
void Add(const XNode& node);
void Add(const XElement& element);
void Add(const XText& text);
void Add(const XML::XContainer& container);
void Add(const XML::Private::XList& list);
public:
XAttribute& attribute(const XName& xname);
const XAttribute& attribute(const XName& xname) const;
XElement element(const XName& xname);
const XElement element(const XName& xname) const;
XElement element(const XName& xname, const std::string& value);
const XElement element(const XName& xname, const std::string& value) const;
public:
property<XName> XName;
XAttributeContainer Attributes;
XNamespaceContainer Namespaces;
property<XSpace> Space;
};
}
}
#endif // XML_XELEMENT_INCLUDE_H_

View File

@@ -0,0 +1,57 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_FILTER_ELEMENT_INCLUDE_H_
#define XML_PRIVATE_FILTER_ELEMENT_INCLUDE_H_
#include <functional>
#include "./../../XNode.h"
namespace XML
{
namespace Private
{
namespace Filter
{
struct Element : public std::unary_function<XNode, const bool>
{
const bool operator ()(const XNode& xnode) const
{
return xnode.isElement();
}
};
}
}
}
#endif // XML_PRIVATE_FILTER_ELEMENT_INCLUDE_H_

View File

@@ -0,0 +1,57 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_FILTER_TEXT_INCLUDE_H_
#define XML_PRIVATE_FILTER_TEXT_INCLUDE_H_
#include <functional>
#include "./../../XNode.h"
namespace XML
{
namespace Private
{
namespace Filter
{
struct Text : public std::unary_function<XNode, const bool>
{
const bool operator ()(const XNode& xnode) const
{
return xnode.isText();
}
};
}
}
}
#endif // XML_PRIVATE_FILTER_TEXT_INCLUDE_H_

View File

@@ -0,0 +1,213 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Lexigraph.h"
namespace XML
{
namespace Private
{
const std::string Lexigraph::fromSource(const std::string& input)
{
std::string output = input;
size_t pos = output.find("&lt;");
while(pos != output.npos)
{
output.replace(pos, 4, "<");
pos = output.find("&lt;", pos + 1);
}
pos = output.find("&gt;");
while(pos != output.npos)
{
output.replace(pos, 4, ">");
pos = output.find("&gt;", pos + 1);
}
pos = output.find("&apos;");
while(pos != output.npos)
{
output.replace(pos, 6, "\'");
pos = output.find("&apos;", pos + 1);
}
pos = output.find("&quot;");
while(pos != output.npos)
{
output.replace(pos, 6, "\"");
pos = output.find("&quot;", pos + 1);
}
pos = output.find("&amp;");
while(pos != output.npos)
{
output.replace(pos, 5, "&");
pos = output.find("&amp;", pos + 1);
}
return output;
}
const std::string Lexigraph::toSource(const std::string& input)
{
std::string output = input;
size_t pos = output.find('&');
while(pos != output.npos)
{
output.replace(pos, 1, "&amp;");
pos = output.find('&', pos + 1);
}
pos = output.find('<');
while(pos != output.npos)
{
output.replace(pos, 1, "&lt;");
pos = output.find('<', pos + 1);
}
pos = output.find('>');
while(pos != output.npos)
{
output.replace(pos, 1, "&gt;");
pos = output.find('>', pos + 1);
}
pos = output.find('\'');
while(pos != output.npos)
{
output.replace(pos, 1, "&apos;");
pos = output.find('\'', pos + 1);
}
pos = output.find('\"');
while(pos != output.npos)
{
output.replace(pos, 1, "&quot;");
pos = output.find('\"', pos + 1);
}
return output;
}
const std::wstring Lexigraph::fromSource(const std::wstring& input)
{
std::wstring output = input;
size_t pos = output.find(L"&lt;");
while(pos != output.npos)
{
output.replace(pos, 4, L"<");
pos = output.find(L"&lt;", pos + 1);
}
pos = output.find(L"&gt;");
while(pos != output.npos)
{
output.replace(pos, 4, L">");
pos = output.find(L"&gt;", pos + 1);
}
pos = output.find(L"&apos;");
while(pos != output.npos)
{
output.replace(pos, 6, L"\'");
pos = output.find(L"&apos;", pos + 1);
}
pos = output.find(L"&quot;");
while(pos != output.npos)
{
output.replace(pos, 6, L"\"");
pos = output.find(L"&quot;", pos + 1);
}
pos = output.find(L"&amp;");
while(pos != output.npos)
{
output.replace(pos, 5, L"&");
pos = output.find(L"&amp;", pos + 1);
}
return output;
}
const std::wstring Lexigraph::toSource(const std::wstring& input)
{
std::wstring output = input;
size_t pos = output.find(L'&');
while(pos != output.npos)
{
output.replace(pos, 1, L"&amp;");
pos = output.find(L'&', pos + 1);
}
pos = output.find(L'<');
while(pos != output.npos)
{
output.replace(pos, 1, L"&lt;");
pos = output.find(L'<', pos + 1);
}
pos = output.find(L'>');
while(pos != output.npos)
{
output.replace(pos, 1, L"&gt;");
pos = output.find(L'>', pos + 1);
}
pos = output.find(L'\'');
while(pos != output.npos)
{
output.replace(pos, 1, L"&apos;");
pos = output.find(L'\'', pos + 1);
}
pos = output.find(L'\"');
while(pos != output.npos)
{
output.replace(pos, 1, L"&quot;");
pos = output.find(L'\"', pos + 1);
}
return output;
}
}
} // namespace XML

View File

@@ -0,0 +1,55 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_LEXIGRAPH_INCLUDE_H_
#define XML_PRIVATE_LEXIGRAPH_INCLUDE_H_
#include <string>
namespace XML
{
namespace Private
{
class Lexigraph
{
public:
static const std::string fromSource(const std::string& input);
static const std::string toSource(const std::string& input);
static const std::wstring fromSource(const std::wstring& input);
static const std::wstring toSource(const std::wstring& input);
};
}
}
#endif // XML_PRIVATE_LEXIGRAPH_INCLUDE_H_

View File

@@ -0,0 +1,141 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Namespace.h"
#include "Lexigraph.h"
#include "Encoding.h"
namespace XML
{
namespace Private
{
Namespace::Namespace()
{
}
Namespace::Namespace(const std::string& prefix, const std::string& name)
: Prefix(prefix),
Name(name)
{
}
const bool Namespace::operator ==(const Namespace& rhs) const
{
return Prefix == rhs.Prefix;
}
const bool Namespace::operator <(const Namespace& rhs) const
{
return Prefix < rhs.Prefix;
}
const bool Namespace::exist() const
{
return true;
}
const std::string Namespace::ToString() const
{
if (Prefix != "xmlns")
return "xmlns:" + (Prefix) + "=\"" + Private::Lexigraph::toSource(Name) + "\"";
return "xmlns=\"" + Private::Lexigraph::toSource(Name) + "\"";
}
const std::wstring Namespace::ToWString() const
{
if (Prefix != "xmlns")
return L"xmlns:" + Encoding::utf82unicode(Prefix) + L"=\""
+ Encoding::utf82unicode(Private::Lexigraph::toSource(Name)) + L"\"";
return L"xmlns=\"" + Encoding::utf82unicode(Private::Lexigraph::toSource(Name)) + L"\"";
}
void Namespace::SaveToStringList(std::list<std::string>& strList)const
{
if (Prefix != "xmlns")
{
strList.push_back("xmlns:");
strList.push_back(Prefix);
strList.push_back("=\"");
strList.push_back(Private::Lexigraph::toSource(Name));
strList.push_back("\"");
return;
}
strList.push_back("xmlns=\"");
strList.push_back(Private::Lexigraph::toSource(Name));
strList.push_back("\"");
}
void Namespace::SaveToWStringList(std::list<std::wstring>& strList)const
{
if (Prefix != "xmlns")
{
strList.push_back(L"xmlns:");
strList.push_back(Encoding::utf82unicode(Prefix));
strList.push_back(L"=\"");
strList.push_back(Encoding::utf82unicode(Private::Lexigraph::toSource(Name)));
strList.push_back(L"\"");
return;
}
strList.push_back(L"xmlns=\"");
strList.push_back(Encoding::utf82unicode(Private::Lexigraph::toSource(Name)));
strList.push_back(L"\"");
}
const std::string Namespace::GetPrefix()const
{
return Prefix;
}
const std::string Namespace::GetName()const
{
return Name;
}
}
} // namespace XML

View File

@@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_INCLUDE_H_
#define XML_PRIVATE_INCLUDE_H_
#include <string>
#include <list>
#include "property.h"
namespace XML
{
namespace Private
{
class Namespace
{
public:
Namespace(const std::string& prefix, const std::string& name);
const bool operator==(const Namespace& rhs) const;
const bool operator<(const Namespace& rhs) const;
public:
virtual const bool exist() const;
const std::string ToString() const;
const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
private:
std::string Prefix;
std::string Name;
public:
const std::string GetPrefix()const;
const std::string GetName()const;
protected:
Namespace();
};
}
}
#endif // XML_PRIVATE_INCLUDE_H_

View File

@@ -0,0 +1,45 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Node.h"
namespace XML
{
namespace Private
{
}
} // namespace XML

View File

@@ -0,0 +1,62 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NODE_INCLUDE_H_
#define XML_PRIVATE_NODE_INCLUDE_H_
#include <string>
#include <list>
namespace XML
{
namespace Private
{
class Node
{
public:
virtual ~Node() = 0 {};
public:
virtual const bool isElement() const = 0;
virtual const bool isText() const = 0;
virtual const bool isComment() const = 0;
public:
virtual const std::string ToString() const = 0;
virtual const std::wstring ToWString() const = 0;
virtual void SaveToStringList(std::list<std::string>& strList)const = 0;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const = 0;
};
}
}
#endif // XML_PRIVATE_NODE_INCLUDE_H_

View File

@@ -0,0 +1,333 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NodeContainer.h"
#include "./../XElement.h"
#include "./../XComment.h"
#include "./../XText.h"
#include "XList.h"
#include "XNamespaceContainer.h"
#include "Exception/not_implement.h"
#include "Utility.h"
namespace XML
{
namespace Private
{
NodeContainer::NodeContainer()
: Nodes(),
Elements(Nodes),
Texts(Nodes)
{
}
NodeContainer::NodeContainer(const XNodeContainer& nodes)
: Nodes(nodes),
Elements(Nodes),
Texts(Nodes)
{
}
NodeContainer::~NodeContainer()
{
}
NodeContainer::NodeContainer(const XElement& element)
: Nodes(),
Elements(Nodes),
Texts(Nodes)
{
Elements.Add(element);
}
NodeContainer::NodeContainer(const XText& text)
: Nodes(),
Elements(Nodes),
Texts(Nodes)
{
Texts.Add(text);
}
NodeContainer::NodeContainer(const XComment& comment)
: Nodes(),
Elements(Nodes),
Texts(Nodes)
{
Nodes.Add(comment);
}
NodeContainer::NodeContainer(const XList& list)
: Nodes(),
Elements(Nodes),
Texts(Nodes)
{
Nodes.merge(list.Nodes);
}
const bool NodeContainer::isElement() const
{
return false;
}
const bool NodeContainer::isText() const
{
return false;
}
const bool NodeContainer::isComment() const
{
return false;
}
void NodeContainer::fromSource(NSCommon::smart_ptr<XSingleSource> source, const XNamespaceContainer& ns, const XSpace& space)
{
if (space.isDefault())
source->skipSpace();
while (true)
{
if (source->get() == '<')
{
source->next();
if (source->get() == '/')
break;
if (isComment(source))
insertComment(source);
else
Nodes.push_back(XElement(source, ns, space));
}
else
{
Nodes.push_back(XText(source->getString('<')));
}
if (space.isDefault())
source->skipSpace();
}
source->next();
}
void NodeContainer::fromSource(NSCommon::smart_ptr<XWideSource> source, const XNamespaceContainer& ns, const XSpace& space)
{
if (space.isDefault())
source->skipSpace();
while (true)
{
if (source->get() == L'<')
{
source->next();
if (source->get() == L'/')
break;
if (isComment(source))
insertComment(source);
else
Nodes.push_back(XElement(source, ns, space));
}
else
{
Nodes.push_back(XText(Encoding::unicode2utf8(source->getString(L'<'))));
}
if (space.isDefault())
source->skipSpace();
}
source->next();
}
const std::string NodeContainer::ToString() const
{
return Nodes.ToString();
}
const std::wstring NodeContainer::ToWString() const
{
throw not_implement();
}
void NodeContainer::SaveToStringList(std::list<std::string>& strList) const
{
Nodes.SaveToStringList(strList);
}
void NodeContainer::SaveToWStringList(std::list<std::wstring>& strList) const
{
Nodes.SaveToWStringList(strList);
}
void NodeContainer::Add(const XNode& node)
{
Nodes.Add(node);
}
void NodeContainer::Add(const XElement& element)
{
Elements.Add(element);
}
void NodeContainer::Add(const XText& text)
{
Texts.Add(text);
}
void NodeContainer::Add(const XComment& comment)
{
Nodes.Add(comment);
}
void NodeContainer::Add(const XList& list)
{
Nodes.merge(list.Nodes);
}
const bool NodeContainer::isComment(NSCommon::smart_ptr<XSingleSource> source)
{
if (source->get() == '!')
{
source->next();
if (source->get() == '-')
{
source->next();
if (source->get() == '-')
{
source->next();
return true;
}
}
}
return false;
}
void NodeContainer::insertComment(NSCommon::smart_ptr<XSingleSource> source)
{
std::string comment;
while(true)
{
comment += source->getString('-');
source->next();
if (source->get() == '-')
{
source->next();
if (source->get() == '>')
{
source->next();
break;
}
else
{
comment += "--";
}
}
else
{
comment += "-";
}
}
Nodes.push_back(XComment(comment));
}
const bool NodeContainer::isComment(NSCommon::smart_ptr<XWideSource> source)
{
if (source->get() == L'!')
{
source->next();
if (source->get() == L'-')
{
source->next();
if (source->get() == L'-')
{
source->next();
return true;
}
}
}
return false;
}
void NodeContainer::insertComment(NSCommon::smart_ptr<XWideSource> source)
{
std::wstring comment;
while(true)
{
comment += source->getString(L'-');
source->next();
if (source->get() == L'-')
{
source->next();
if (source->get() == L'>')
{
source->next();
break;
}
else
{
comment += L"--";
}
}
else
{
comment += L"-";
}
}
Nodes.push_back(XComment(Encoding::unicode2utf8(comment)));
}
}
} // namespace XML

View File

@@ -0,0 +1,116 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NODE_CONTAINER_INCLUDE_H_
#define XML_PRIVATE_NODE_CONTAINER_INCLUDE_H_
#include <string>
#include <list>
#include "Node.h"
#include "XNodeContainer.h"
#include "XElementContainer.h"
#include "XTextContainer.h"
#include "property.h"
#include "XSpace.h"
#include "XSingleSource.h"
#include "XWideSource.h"
#include "../../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
namespace XML
{
class XElement;
class XComment;
class XText;
namespace Private
{
class XNamespaceContainer;
class XList;
class NodeContainer : public Node
{
public:
NodeContainer();
NodeContainer(const XNodeContainer& nodes);
virtual ~NodeContainer();
public:
explicit NodeContainer(const XElement& element);
explicit NodeContainer(const XText& text);
explicit NodeContainer(const XComment& comment);
explicit NodeContainer(const XList& list);
public:
virtual const bool isElement() const;
virtual const bool isText() const;
virtual const bool isComment() const;
public:
void fromSource(NSCommon::smart_ptr<XSingleSource> source, const XNamespaceContainer& ns, const XSpace& space);
void fromSource(NSCommon::smart_ptr<XWideSource> source, const XNamespaceContainer& ns, const XSpace& space);
virtual const std::string ToString() const;
virtual const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
public:
template<template<typename T, typename A> class C, typename T, typename A>
explicit NodeContainer(const C<T, A>& container) : Nodes(), Elements(Nodes), Texts(Nodes)
{
for (C<T, A>::const_iterator i = container.begin(); i != container.end(); ++i)
Nodes.push_back(Write(*i));
}
public:
void Add(const XNode& node);
void Add(const XElement& node);
void Add(const XText& text);
void Add(const XComment& comment);
void Add(const XList& list);
private:
const bool isComment(NSCommon::smart_ptr<XSingleSource> source);
void insertComment(NSCommon::smart_ptr<XSingleSource> source);
const bool isComment(NSCommon::smart_ptr<XWideSource> source);
void insertComment(NSCommon::smart_ptr<XWideSource> source);
public:
XNodeContainer Nodes;
XElementContainer Elements;
XTextContainer Texts;
};
}
}
#endif // XML_PRIVATE_NODE_CONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,52 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Null.h"
#include "NullText.h"
namespace XML
{
namespace Private
{
NullText& Null::Text()
{
static NullText text;
return text;
}
}
} // namespace XML

View File

@@ -0,0 +1,51 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_INCLUDE_H_
#define XML_PRIVATE_NULL_INCLUDE_H_
namespace XML
{
namespace Private
{
class NullText;
class Null
{
public:
static NullText& Text();
};
}
}
#endif // XML_PRIVATE_NULL_INCLUDE_H_

View File

@@ -0,0 +1,48 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NullAttribute.h"
namespace XML
{
namespace Private
{
const bool NullAttribute::exist() const
{
return false;
}
}
} // namespace XML

View File

@@ -0,0 +1,51 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_ATTRIBUTE_INCLUDE_H_
#define XML_PRIVATE_NULL_ATTRIBUTE_INCLUDE_H_
#include "Attribute.h"
namespace XML
{
namespace Private
{
class NullAttribute : public Attribute
{
public:
virtual const bool exist() const;
};
}
}
#endif // XML_PRIVATE_NULL_ATTRIBUTE_INCLUDE_H_

View File

@@ -0,0 +1,56 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NullElement.h"
namespace XML
{
namespace Private
{
const bool NullElement::exist() const
{
return false;
}
const XString NullElement::text() const
{
return XString();
}
}
} // namespace XML

View File

@@ -0,0 +1,53 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_ELEMENT_INCLUDE_H_
#define XML_PRIVATE_NULL_ELEMENT_INCLUDE_H_
#include "Element.h"
namespace XML
{
namespace Private
{
class NullElement : public Element
{
public:
virtual const bool exist() const;
virtual const XString text() const;
};
}
}
#endif // XML_PRIVATE_NULL_ELEMENT_INCLUDE_H_

View File

@@ -0,0 +1,50 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NullNamespace.h"
namespace XML
{
namespace Private
{
const bool NullNamespace::exist() const
{
return false;
}
}
} // namespace XML

View File

@@ -0,0 +1,51 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_NAMESPACE_INCLUDE_H_
#define XML_PRIVATE_NULL_NAMESPACE_INCLUDE_H_
#include "Namespace.h"
namespace XML
{
namespace Private
{
class NullNamespace : public Namespace
{
public:
virtual const bool exist() const;
};
}
}
#endif // XML_PRIVATE_NULL_NAMESPACE_INCLUDE_H_

View File

@@ -0,0 +1,46 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NullText.h"
namespace XML
{
namespace Private
{
}
} // namespace XML

View File

@@ -0,0 +1,52 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_TEXT_INCLUDE_H_
#define XML_PRIVATE_NULL_TEXT_INCLUDE_H_
#include "Text.h"
namespace XML
{
namespace Private
{
class NullText : public Text
{
};
static NullText nullText;
}
}
#endif // XML_PRIVATE_NULL_TEXT_INCLUDE_H_

View File

@@ -0,0 +1,54 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NullXAttribute.h"
#include "NullAttribute.h"
namespace XML
{
namespace Private
{
NullXAttribute::NullXAttribute()
: XAttribute(NullAttribute())
{
}
const bool NullXAttribute::exist() const
{
return false;
}
}
} // namespace XML

View File

@@ -0,0 +1,54 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_XATTRIBUTE_INCLUDE_H_
#define XML_PRIVATE_NULL_XATTRIBUTE_INCLUDE_H_
#include "./../XAttribute.h"
namespace XML
{
namespace Private
{
class NullXAttribute : public XAttribute
{
public:
NullXAttribute();
public:
virtual const bool exist() const;
};
}
}
#endif // XML_PRIVATE_NULL_XATTRIBUTE_INCLUDE_H_

View File

@@ -0,0 +1,53 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NullXElement.h"
namespace XML
{
namespace Private
{
NullXElement::NullXElement() : XElement(*this)
{
}
const bool NullXElement::exist() const
{
return false;
}
}
} // namespace XML

View File

@@ -0,0 +1,54 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_XELEMENT_INCLUDE_H_
#define XML_PRIVATE_NULL_XELEMENT_INCLUDE_H_
#include "./../XElement.h"
namespace XML
{
namespace Private
{
class NullXElement : public XElement
{
public:
NullXElement();
public:
virtual const bool exist() const;
};
}
}
#endif // XML_PRIVATE_NULL_XELEMENT_INCLUDE_H_

View File

@@ -0,0 +1,50 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "NullXNamespace.h"
namespace XML
{
namespace Private
{
const bool NullXNamespace::exist() const
{
return false;
}
}
} // namespace XML

View File

@@ -0,0 +1,50 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_NULL_XNAMESPACE_INCLUDE_H_
#define XML_PRIVATE_NULL_XNAMESPACE_INCLUDE_H_
#include "./../XNamespace.h"
namespace XML
{
namespace Private
{
class NullXNamespace : public XNamespace
{
virtual const bool exist() const;
};
}
}
#endif // XML_PRIVATE_NULL_XNAMESPACE_INCLUDE_H_

View File

@@ -0,0 +1,104 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "Text.h"
#include "Lexigraph.h"
#include "Encoding.h"
namespace XML
{
namespace Private
{
Text::Text()
{
}
Text::Text(const std::string& value)
: Value(value)
{
}
Text::~Text()
{
}
const bool Text::isElement() const
{
return false;
}
const bool Text::isText() const
{
return true;
}
const bool Text::isComment() const
{
return false;
}
const std::string Text::ToString() const
{
return Private::Lexigraph::toSource(Value.ToString());
}
const std::wstring Text::ToWString() const
{
return Private::Lexigraph::toSource(Value.ToWString());
}
void Text::SaveToStringList(std::list<std::string>& strList)const
{
strList.push_back(Private::Lexigraph::toSource(Value.ToString()));
}
void Text::SaveToWStringList(std::list<std::wstring>& strList)const
{
strList.push_back(Private::Lexigraph::toSource(Value.ToWString()));
}
}
} // namespace XML

View File

@@ -0,0 +1,72 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_TEXT_INCLUDE_H_
#define XML_PRIVATE_TEXT_INCLUDE_H_
#include "Node.h"
#include <string>
#include "XString.h"
#include "property.h"
namespace XML
{
namespace Private
{
class Text : public Node
{
public:
explicit Text(const std::string& value);
virtual ~Text();
public:
virtual const bool isElement() const;
virtual const bool isText() const;
virtual const bool isComment() const;
public:
virtual const std::string ToString() const;
virtual const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
public:
XString Value;
protected:
Text();
};
}
}
#endif // XML_XTEXT_INCLUDE_H_

View File

@@ -0,0 +1,127 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XAttributeContainer.h"
#include "./../XName.h"
#include <algorithm>
#include "NullXAttribute.h"
namespace XML
{
namespace Private
{
static NullXAttribute nullXAttribute;
const bool XAttributeContainer::exist(const XName& xname) const
{
for(const_iterator current = begin(); current != end(); current++)
{
if ((*current)->XName->Equal(xname))
return true;
}
for(const_iterator current = begin(); current != end(); current++)
{
if ((*current)->XName == xname)
return true;
}
return false;
}
XAttribute& XAttributeContainer::operator[] (const XName& xname)
{
for(iterator current = begin(); current != end(); current++)
{
if ((*current)->XName->Equal(xname))
return *current;
}
for(iterator current = begin(); current != end(); current++)
{
if ((*current)->XName == xname)
return *current;
}
return nullXAttribute;
}
const XAttribute& XAttributeContainer::operator[] (const XName& xname) const
{
for(const_iterator current = begin(); current != end(); current++)
{
if ((*current)->XName->Equal(xname))
return *current;
}
for(const_iterator current = begin(); current != end(); current++)
{
if ((*current)->XName == xname)
return *current;
}
return nullXAttribute;
}
const XNamespaceContainer XAttributeContainer::usedNamespace() const
{
XNamespaceContainer container;
for(const_iterator current = begin(); current != end(); current++)
{
if ((*current)->XName->Ns.is_init())
container.Add((*current)->XName->Ns);
}
return container;
}
XAttributeContainer::iterator XAttributeContainer:: begin()
{
return m_container.begin();
}
XAttributeContainer::iterator XAttributeContainer::end()
{
return m_container.end();
}
XAttributeContainer::const_iterator XAttributeContainer::begin() const
{
return m_container.begin();
}
XAttributeContainer::const_iterator XAttributeContainer::end() const
{
return m_container.end();
}
}
} // namespace XML

View File

@@ -0,0 +1,73 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XATTRIBUTE_CONTAINER_INCLUDE_H_
#define XML_PRIVATE_XATTRIBUTE_CONTAINER_INCLUDE_H_
#include "XContainer.h"
#include "./../XAttribute.h"
#include "XNamespaceContainer.h"
namespace XML
{
class XName;
namespace Private
{
class XAttributeContainer : public XContainer<XAttribute>
{
public:
const bool exist(const XName& xname) const;
XAttributeContainer const* const operator->() const {return this;}
XAttributeContainer* operator->() {return this;}
XAttribute& operator[] (const XName& xname);
const XAttribute& operator[] (const XName& xname) const;
const XNamespaceContainer usedNamespace() const;
public:
typedef std::list<XAttribute>::iterator iterator;
typedef std::list<XAttribute>::const_iterator const_iterator;
public:
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
};
}
}
#endif // XML_PRIVATE_XATTRIBUTE_CONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,169 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XCONTAINER_INCLUDE_H_
#define XML_PRIVATE_XCONTAINER_INCLUDE_H_
#include <algorithm>
#include <string>
#include <list>
namespace XML
{
namespace Private
{
template<class T>
class XContainer
{
public:
void push_back(const T& value);
void Add(const T& value);
const bool content(const T& other) const;
void merge(const XContainer<T>& other);
const size_t size() const;
const bool empty() const;
XContainer<T> const* const operator->() const {return this;}
XContainer<T>* operator->() {return this;}
public:
const std::string ToString() const;
const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
protected:
std::list<T> m_container;
};
template<class T>
void XContainer<T>::push_back(const T& value)
{
if (value.is_init() && !content(value))
m_container.push_back(value);
}
template<class T>
void XContainer<T>::Add(const T& value)
{
push_back(value);
}
template<class T>
const bool XContainer<T>::content(const T& other) const
{
for(std::list<T>::const_iterator current = m_container.begin(); current != m_container.end(); current++)
{
if(*(*current) == *other)
return true;
}
return false;
}
template<class T>
void XContainer<T>::merge(const XContainer<T>& other)
{
for(std::list<T>::const_iterator current = other.m_container.begin(); current != other.m_container.end(); current++)
push_back(*current);
}
template<class T>
const size_t XContainer<T>::size() const
{
return m_container.size();
}
template<class T>
const bool XContainer<T>::empty() const
{
return m_container.empty();
}
template<class T>
const std::string XContainer<T>::ToString() const
{
std::string result;
for(std::list<T>::const_iterator current = m_container.begin(); current != m_container.end(); current++)
{
result += " ";
result += (*current)->ToString();
}
return result;
}
template<class T>
const std::wstring XContainer<T>::ToWString() const
{
std::wstring result;
for(std::list<T>::const_iterator current = m_container.begin(); current != m_container.end(); current++)
{
result += L" ";
result += (*current)->ToWString();
}
return result;
}
template<class T>
void XContainer<T>::SaveToStringList(std::list<std::string>& strList)const
{
for(std::list<T>::const_iterator current = m_container.begin(); current != m_container.end(); current++)
{
strList.push_back(" ");
(*current)->SaveToStringList(strList);
}
}
template<class T>
void XContainer<T>::SaveToWStringList(std::list<std::wstring>& strList)const
{
for(std::list<T>::const_iterator current = m_container.begin(); current != m_container.end(); current++)
{
strList.push_back(L" ");
(*current)->SaveToWStringList(strList);
}
}
}
}
#endif // XML_PRIVATE_XCONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,102 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XDeclaration.h"
#include "Encoding.h"
namespace XML
{
namespace Private
{
XDeclaration::XDeclaration() : Version("1.0"), Encoding("UTF-8"), Standalone("yes")
{
}
void XDeclaration::fromSource(NSCommon::smart_ptr<XSingleSource> source)
{
source->find('?');
source->next();
source->skipSpace();
while (source->get() != '?')
{
const std::pair<const std::string, const std::string> pair = source->getPair();
setValue(pair.first, pair.second);
source->skipSpace();
}
source->find('>');
source->next();
}
void XDeclaration::fromSource(NSCommon::smart_ptr<XWideSource> source)
{
source->find(L'?');
source->next();
source->skipSpace();
while (source->get() != L'?')
{
const std::pair<const std::wstring, const std::wstring> pair = source->getPair();
setValue(Encoding::unicode2utf8(pair.first), Encoding::unicode2utf8(pair.second));
source->skipSpace();
}
source->find(L'>');
source->next();
}
const std::string XDeclaration::ToString() const
{
return "<?xml version=\"" + Version.ToString() + "\" encoding=\"" + Encoding.ToString() +
(Standalone.is_init() ? ("\" standalone=\"" + Standalone.ToString()) : "") + "\" ?>";
}
const std::wstring XDeclaration::ToWString() const
{
return L"<?xml version=\"" + Encoding::utf82unicode(Version.ToString()) + L"\" encoding=\"" + L"Unicode" +
(Standalone.is_init() ? (L"\" standalone=\"" + Encoding::utf82unicode(Standalone.ToString())) : L"") + L"\" ?>";
}
void XDeclaration::setValue(const std::string& name, const std::string& value)
{
if (name == "version")
Version = value;
else if (name == "encoding")
Encoding = value;
else if (name == "standalone")
Standalone = value;
}
}
} // namespace XML

View File

@@ -0,0 +1,74 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_XDECLARATION_INCLUDE_H_
#define XML_XDECLARATION_INCLUDE_H_
#include <string>
#include "property.h"
#include "nullable_property.h"
#include "./../Limit/Version.h"
#include "./../Limit/Encoding.h"
#include "./../Limit/Standalone.h"
#include "XSingleSource.h"
#include "XWideSource.h"
#include "../../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
namespace XML
{
namespace Private
{
class XDeclaration
{
public:
XDeclaration();
public:
void fromSource(NSCommon::smart_ptr<XSingleSource> source);
void fromSource(NSCommon::smart_ptr<XWideSource> source);
const std::string ToString() const;
const std::wstring ToWString() const;
public:
property<std::string, Limit::Version> Version;
property<std::string, Limit::Encoding> Encoding;
nullable_property<std::string, Limit::Standalone> Standalone;
private:
void setValue(const std::string& name, const std::string& value);
};
}
}
#endif // XML_XDECLARATION_INCLUDE_H_

View File

@@ -0,0 +1,195 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XElementContainer.h"
#include "XNodeContainer.h"
#include "./../XNode.h"
#include "./../XElement.h"
#include "./../XName.h"
#include "NullXElement.h"
namespace XML
{
namespace Private
{
static NullXElement nullXElement;
XElementContainer::XElementContainer(const XNodeContainer& nodes) : m_container(nodes.container())
{
}
const bool XElementContainer::empty() const
{
return size() == 0;
}
const size_t XElementContainer::size() const
{
size_t size = 0;
for (const_iterator i = begin(); i != end(); ++i)
++size;
return size;
}
void XElementContainer::push_back(const XElement& element)
{
if (element.is_init() && element.exist())
{
m_container->push_back(element);
}
}
void XElementContainer::Add(const XElement& element)
{
push_back(element);
}
const bool XElementContainer::exist(const XName& xname) const
{
if (m_container.IsInit())
{
const std::list<XNode>& container = m_container.operator*();
for (std::list<XNode>::const_iterator i = container.begin(); i != container.end(); ++i)
{
if(i->isElement())
{
if (XElement(*i)->XName == xname)
return true;
}
}
}
return false;
}
XElement XElementContainer::operator[] (const XName& xname)
{
const std::list<XNode>& container = m_container.operator*();
for (std::list<XNode>::const_iterator i = container.begin(); i != container.end(); ++i)
{
if(i->isElement())
{
if (XElement(*i)->XName->Equal(xname))
return *i;
}
}
for (std::list<XNode>::const_iterator i = container.begin(); i != container.end(); ++i)
{
if(i->isElement())
{
if (XElement(*i)->XName == xname)
return *i;
}
}
return nullXElement;
}
const XElement XElementContainer::operator[] (const XName& xname) const
{
const std::list<XNode>& container = m_container.operator*();
for (std::list<XNode>::const_iterator i = container.begin(); i != container.end(); ++i)
{
if(i->isElement())
{
if (XElement(*i)->XName->Equal(xname))
return *i;
}
}
for (std::list<XNode>::const_iterator i = container.begin(); i != container.end(); ++i)
{
if(i->isElement())
{
if (XElement(*i)->XName == xname)
return *i;
}
}
return nullXElement;
}
XElement XElementContainer::get(const XName& xname, const std::string& value)
{
for (iterator i = begin(); i != end(); ++i)
{
XElement element(*i);
if (element.Attributes.exist(xname) && element.Attributes[xname].value().ToString() == value)
return *i;
}
return nullXElement;
}
const XElement XElementContainer::get(const XName& xname, const std::string& value) const
{
for (const_iterator i = begin(); i != end(); ++i)
{
XElement element(*i);
if (element.Attributes.exist(xname) && element.Attributes[xname].value().ToString() == value)
return *i;
}
return nullXElement;
}
XElementContainer::iterator XElementContainer:: begin()
{
return m_container->begin();
}
XElementContainer::iterator XElementContainer::end()
{
return m_container->end();
}
XElementContainer::const_iterator XElementContainer::begin() const
{
return m_container->begin();
}
XElementContainer::const_iterator XElementContainer::end() const
{
return m_container->end();
}
const XNamespaceContainer XElementContainer::usedNamespace() const
{
XNamespaceContainer container;
for (const_iterator i = begin(); i != end(); ++i)
container.merge(XElement(*i)->usedNamespace());
return container;
}
}
} // namespace XML

View File

@@ -0,0 +1,95 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XELEMENT_CONTAINER_INCLUDE_H_
#define XML_PRIVATE_XELEMENT_CONTAINER_INCLUDE_H_
#include <list>
#include "Filter/Element.h"
#include "XNamespaceContainer.h"
#include "../../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
namespace XML
{
class XNode;
class XElement;
class XName;
namespace Private
{
class XNodeContainer;
class XElementContainer
{
public:
XElementContainer(const XNodeContainer& nodes);
public:
const bool empty() const;
const size_t size() const;
void push_back(const XElement& element);
void Add(const XElement& element);
public:
typedef std::list<XNode>::iterator iterator;
typedef std::list<XNode>::const_iterator const_iterator;
public:
XElementContainer const* const operator->() const {return this;}
XElementContainer* operator->() {return this;}
const bool exist(const XName& xname) const;
XElement operator[] (const XName& xname);
const XElement operator[] (const XName& xname) const;
XElement get(const XName& xname, const std::string& value);
const XElement get(const XName& xname, const std::string& value) const;
const XNamespaceContainer usedNamespace() const;
public:
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
private:
NSCommon::smart_ptr<std::list<XNode> > m_container;
};
}
}
#endif // XML_PRIVATE_XELEMENT_CONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,62 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XFileSource.h"
#include "Exception\not_implement.h"
namespace XML
{
namespace Private
{
XFileSource::XFileSource(const OOX::CPath& path)
: m_stream(path.GetPath())
{
setBegin();
}
XFileSource::~XFileSource()
{
}
void XFileSource::setBegin()
{
m_iterator = m_stream;
}
}
} // namespace XML

View File

@@ -0,0 +1,61 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XFILE_SOURCE_INCLUDE_H_
#define XML_PRIVATE_XFILE_SOURCE_INCLUDE_H_
#include "XSingleSource.h"
#include <fstream>
#include <iterator>
#include "../../../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace XML
{
namespace Private
{
class XFileSource : public XSingleSource
{
public:
XFileSource(const OOX::CPath& path);
virtual ~XFileSource();
private:
void setBegin();
private:
std::ifstream m_stream;
};
}
}
#endif // XML_PRIVATE_XFILE_SOURCE_INCLUDE_H_

View File

@@ -0,0 +1,153 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XList.h"
#include "./../XText.h"
#include "./../XElement.h"
#include "./../XComment.h"
#include "./../XContainer.h"
namespace XML
{
namespace Private
{
XList::XList()
{
}
XList::XList(const XAttribute& attribute)
{
Attributes->push_back(attribute);
}
XList::XList(const XNamespace& ns)
{
Namespaces->push_back(ns);
}
XList::XList(const XText& text)
{
Nodes->push_back(text);
}
XList::XList(const XElement& element)
{
Nodes->push_back(element);
}
XList::XList(const XComment& comment)
{
Nodes->push_back(comment);
}
XList::XList(const XML::XContainer& container)
{
Nodes = container->Nodes;
}
XList::XList(const XNode& node)
{
Nodes->push_back(node);
}
XList& XList::Add(const XList& list)
{
Attributes->merge(list.Attributes);
Namespaces->merge(list.Namespaces);
Nodes->merge(list.Nodes);
return *this;
}
XList& XList::Add(const XAttribute& attribute)
{
Attributes->push_back(attribute);
return *this;
}
XList& XList::Add(const XNamespace& ns)
{
Namespaces->push_back(ns);
return *this;
}
XList& XList::Add(const XText& text)
{
Nodes->push_back(text);
return *this;
}
XList& XList::Add(const XElement& element)
{
Nodes->push_back(element);
return *this;
}
XList& XList::Add(const XComment& comment)
{
Nodes->push_back(comment);
return *this;
}
XList& XList::Add(const XML::XContainer& container)
{
Nodes->push_back(container);
return *this;
}
XList& XList::Add(const XNode& node)
{
Nodes->push_back(node);
return *this;
}
}
} // namespace XML

View File

@@ -0,0 +1,180 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XLIST_INCLUDE_H_
#define XML_PRIVATE_XLIST_INCLUDE_H_
#include "XAttributeContainer.h"
#include "XNamespaceContainer.h"
#include "XNodeContainer.h"
#include "property.h"
namespace XML
{
class XText;
class XElement;
class XComment;
class XContainer;
class XNode;
namespace Private
{
class XList
{
public:
XList();
XList(const XAttribute& attribute);
XList(const XNamespace& ns);
XList(const XText& text);
XList(const XElement& element);
XList(const XComment& comment);
XList(const XML::XContainer& container);
XList(const XNode& node);
public:
XList& Add(const XList& list);
XList& Add(const XAttribute& attribute);
XList& Add(const XNamespace& ns);
XList& Add(const XText& text);
XList& Add(const XElement& element);
XList& Add(const XComment& comment);
XList& Add(const XML::XContainer& container);
XList& Add(const XNode& node);
public:
property<XAttributeContainer> Attributes;
property<XNamespaceContainer> Namespaces;
property<XNodeContainer> Nodes;
};
}
template<class T>
Private::XList& operator ,(Private::XList& rhs, const T& lhs)
{
return rhs.Add(lhs);
}
template<class T>
Private::XList operator ,(const XNamespace& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator ,(const XAttribute& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator ,(const XText& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator ,(const XElement& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator ,(const XComment& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator ,(const XContainer& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator ,(const XNode& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList& operator +(Private::XList& rhs, const T& lhs)
{
return rhs.Add(lhs);
}
template<class T>
Private::XList operator +(const XAttribute& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator +(const XNamespace& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator +(const XText& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator +(const XElement& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator +(const XComment& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator +(const XContainer& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
template<class T>
Private::XList operator +(const XNode& rhs, const T& lhs)
{
return Private::XList(rhs).Add(lhs);
}
}
#endif // XML_PRIVATE_XLIST_INCLUDE_H_

View File

@@ -0,0 +1,119 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XNamespaceContainer.h"
#include "NullXNamespace.h"
namespace XML
{
namespace Private
{
static NullXNamespace nullXNamespace;
const bool XNamespaceContainer::exist(const std::string& name) const
{
for (std::list<XNamespace>::const_iterator current = m_container.begin(); current != m_container.end(); ++current)
{
if ((*current)->GetPrefix() == name)
return true;
}
return false;
}
XNamespace& XNamespaceContainer::operator[] (const std::string& name)
{
for (std::list<XNamespace>::iterator current = m_container.begin(); current != m_container.end(); ++current)
{
if ((*current)->GetPrefix() == name)
return (*current);
}
return nullXNamespace;
}
const XNamespace& XNamespaceContainer::operator[] (const std::string& name) const
{
for (std::list<XNamespace>::const_iterator current = m_container.begin(); current != m_container.end(); ++current)
{
if ((*current)->GetPrefix() == name)
return (*current);
}
return nullXNamespace;
}
void XNamespaceContainer::erase(const std::string& name)
{
for (std::list<XNamespace>::iterator i = m_container.begin(); i != m_container.end(); ++i)
{
if ((*i)->GetPrefix() == name)
{
m_container.erase(i);
return;
}
}
}
void XNamespaceContainer::erase(const XNamespaceContainer& rhs)
{
for (std::list<XNamespace>::iterator current = m_container.begin(); current != m_container.end(); ++current)
{
erase((*current)->GetPrefix());
}
}
XNamespaceContainer::iterator XNamespaceContainer:: begin()
{
return m_container.begin();
}
XNamespaceContainer::iterator XNamespaceContainer::end()
{
return m_container.end();
}
XNamespaceContainer::const_iterator XNamespaceContainer::begin() const
{
return m_container.begin();
}
XNamespaceContainer::const_iterator XNamespaceContainer::end() const
{
return m_container.end();
}
}
} // namespace XML

View File

@@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XNAMESPACE_CONTAINER_INCLUDE_H_
#define XML_PRIVATE_XNAMESPACE_CONTAINER_INCLUDE_H_
#include <string>
#include "XContainer.h"
#include "./../XNamespace.h"
namespace XML
{
namespace Private
{
class XNamespaceContainer : public XContainer<XNamespace>
{
public:
const bool exist(const std::string& name) const;
XNamespaceContainer const* const operator->() const {return this;}
XNamespaceContainer* operator->() {return this;}
XNamespace& operator[] (const std::string& name);
const XNamespace& operator[] (const std::string& name) const;
void erase(const std::string& name);
void erase(const XNamespaceContainer& rhs);
public:
typedef std::list<XNamespace>::iterator iterator;
typedef std::list<XNamespace>::const_iterator const_iterator;
public:
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
};
}
}
#endif // XML_PRIVATE_XNAMESPACE_CONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,116 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XNodeContainer.h"
#include <algorithm>
#include <numeric>
#include "./../XNode.h"
#include "./../XContainer.h"
namespace XML
{
namespace Private
{
XNodeContainer::XNodeContainer() : m_container(new std::list<XNode>())
{
}
const bool XNodeContainer::empty() const
{
return m_container->empty();
}
const size_t XNodeContainer::size() const
{
return m_container->size();
}
void XNodeContainer::Add(const XNode& node)
{
push_back(node);
}
void XNodeContainer::push_back(const XNode& node)
{
if (node.is_init())
{
if (node.isElement() || node.isText() || node.isComment())
m_container->push_back(node);
else
merge(XML::XContainer(node)->Nodes);
}
}
void XNodeContainer::merge(const XNodeContainer& other)
{
for(std::list<XNode>::const_iterator current = other.m_container->begin(); current != other.m_container->end(); current++)
push_back(*current);
}
const std::string XNodeContainer::ToString() const
{
return std::string();
}
const std::wstring XNodeContainer::ToWString() const
{
return std::wstring();
}
void XNodeContainer::SaveToStringList(std::list<std::string>& strList)const
{
for(std::list<XNode>::const_iterator iter = m_container->begin(); iter != m_container->end(); iter++)
{
iter->SaveToStringList(strList);
}
}
void XNodeContainer::SaveToWStringList(std::list<std::wstring>& strList)const
{
for(std::list<XNode>::const_iterator iter = m_container->begin(); iter != m_container->end(); iter++)
{
iter->SaveToWStringList(strList);
}
}
const NSCommon::smart_ptr<std::list<XNode> > XNodeContainer::container() const
{
return m_container;
}
}
} // namespace XML

View File

@@ -0,0 +1,88 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef XML_PRIVATE_XNODE_CONTAINER_INCLUDE_H_
#define XML_PRIVATE_XNODE_CONTAINER_INCLUDE_H_
#include <vector>
#include <string>
#include <list>
#include "../../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
namespace XML
{
class XNode;
namespace Private
{
class XNodeContainer
{
public:
XNodeContainer();
public:
const bool empty() const;
const size_t size() const;
void Add(const XNode& node);
void push_back(const XNode& node);
void merge(const XNodeContainer& other);
public:
typedef std::list<XNode>::iterator iterator;
typedef std::list<XNode>::const_iterator const_iterator;
public:
XNodeContainer const* const operator->() const {return this;}
XNodeContainer* operator->() {return this;}
public:
const std::string ToString() const;
const std::wstring ToWString() const;
virtual void SaveToStringList(std::list<std::string>& strList)const;
virtual void SaveToWStringList(std::list<std::wstring>& strList)const;
public:
iterator begin() {return m_container->begin();}
iterator end() {return m_container->end();}
const_iterator begin() const {return m_container->begin();}
const_iterator end() const {return m_container->end();}
public:
const NSCommon::smart_ptr<std::list<XNode> > container() const;
private:
NSCommon::smart_ptr<std::list<XNode> > m_container;
};
}
}
#endif // XML_PRIVATE_XNODE_CONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XPOINTER_INCLUDE_H_
#define XML_PRIVATE_XPOINTER_INCLUDE_H_
#include "../../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
namespace XML
{
namespace Private
{
template<class T>
class XPointer
{
public:
XPointer() {}
XPointer(T* ptr) : m_ptr(ptr) {}
XPointer(const NSCommon::smart_ptr<T>& ptr) : m_ptr(ptr) {}
template<class E>
XPointer(const XPointer<E>& rhs)
{
m_ptr = rhs.get_ptr().smart_dynamic_cast<T>();
}
NSCommon::smart_ptr<T> get_ptr() const {return m_ptr;}
public:
T const* const operator->() const {return m_ptr.operator->();}
T* operator->() {return m_ptr.operator->();}
const T& operator*() const {return (m_ptr.operator*());}
T& operator*() {return (m_ptr.operator*());}
const bool is_init() const {return m_ptr.is_init();}
protected:
NSCommon::smart_ptr<T> m_ptr;
protected:
typedef XPointer<T> base;
};
}
}
#endif // XML_PRIVATE_XPOINTER_INCLUDE_H_

View File

@@ -0,0 +1,200 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XSingleSource.h"
#include "Lexigraph.h"
#include "Exception\not_implement.h"
namespace XML
{
namespace Private
{
XSingleSource::~XSingleSource()
{
}
void XSingleSource::next()
{
++m_iterator;
}
void XSingleSource::skipSpace()
{
for (; isSpace() ; ++m_iterator);
}
void XSingleSource::find(const char value)
{
for (; *m_iterator != value; ++m_iterator);
}
void XSingleSource::find(const char value1, const char value2)
{
for (; ((*m_iterator != value1) && (*m_iterator != value2)); ++m_iterator);
}
void XSingleSource::findAndSkip(const char value)
{
find(value);
next();
}
const char XSingleSource::get() const
{
return *m_iterator;
}
const std::string XSingleSource::getString(const char separator)
{
std::string result;
while (*m_iterator != separator)
result += *m_iterator++;
return Lexigraph::fromSource(result);
}
const std::string XSingleSource::getString(const char separator1, const char separator2)
{
std::string result;
while ((*m_iterator != separator1) && (*m_iterator != separator2))
result += *m_iterator++;
return Lexigraph::fromSource(result);
}
const std::pair<const std::string, const std::string> XSingleSource::getName()
{
std::string prefix = getToSeparator(':');
std::string name;
if (get() == ':')
{
next();
name = getToSeparator();
}
else
{
std::swap(prefix, name);
}
return std::make_pair(prefix, name);
}
const std::pair<const std::string, const std::string> XSingleSource::getPair()
{
const std::string name = get(' ', '=');
const std::string value = getValue();
return std::make_pair(name, value);
}
const std::pair<const std::pair<const std::string, const std::string>, const std::string> XSingleSource::getAttribute()
{
const std::pair<const std::string, const std::string> name = getName();
const std::string value = getValue();
return std::make_pair(name, value);
}
const bool XSingleSource::isSpace() const
{
if (*m_iterator == ' ' || *m_iterator == '\n' || *m_iterator == '\r' || *m_iterator == '\t')
return true;
return false;
}
const bool XSingleSource::isSeparator() const
{
if (*m_iterator == '<' || *m_iterator == '>' || *m_iterator == '=' || *m_iterator == '/')
return true;
return false;
}
const std::string XSingleSource::get(const char separator1, const char separator2)
{
skipSpace();
std::string result;
while (*m_iterator != separator1 && *m_iterator != separator2)
result += *m_iterator++;
return result;
}
const std::string XSingleSource::getToSeparator()
{
skipSpace();
std::string result;
while (!isSeparator() && !isSpace())
result += *m_iterator++;
return result;
}
const std::string XSingleSource::getToSeparator(const char separator)
{
skipSpace();
std::string result;
while (!isSeparator() && !isSpace() && *m_iterator != separator)
result += *m_iterator++;
return result;
}
const std::string XSingleSource::getValue()
{
find('"', '\'');
char EndChar = *m_iterator;
next();
const std::string value = getString(EndChar);
next();
return value;
}
}
} // namespace XML

View File

@@ -0,0 +1,78 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XSINGLE_SOURCE_INCLUDE_H_
#define XML_PRIVATE_XSINGLE_SOURCE_INCLUDE_H_
#include <iterator>
#include <string>
namespace XML
{
namespace Private
{
class XSingleSource
{
public:
virtual ~XSingleSource();
public:
virtual void next();
virtual void skipSpace();
virtual void find(const char value);
virtual void find(const char value1, const char value2);
virtual void findAndSkip(const char value);
virtual const char get() const;
virtual const std::string getString(const char separator);
virtual const std::string getString(const char separator1, const char separator2);
public:
virtual const std::pair<const std::string, const std::string> getName();
virtual const std::pair<const std::string, const std::string> getPair();
virtual const std::pair<const std::pair<const std::string, const std::string>, const std::string> getAttribute();
private:
const bool isSpace() const;
const bool isSeparator() const;
const std::string get(const char separator1, const char separator2);
const std::string getToSeparator();
const std::string getToSeparator(const char separator);
const std::string getValue();
protected:
std::istreambuf_iterator<char> m_iterator;
};
}
}
#endif // XML_PRIVATE_XSINGLE_SOURCE_INCLUDE_H_

View File

@@ -0,0 +1,87 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XSpace.h"
namespace XML
{
namespace Private
{
XSpace::XSpace()
: m_space(false)
{
}
XSpace::XSpace(const bool space)
: m_space(space)
{
}
const XSpace& XSpace::operator =(const bool rhs)
{
m_space = rhs;
return *this;
}
void XSpace::setDefault()
{
m_space = false;
}
void XSpace::setPreserve()
{
m_space = true;
}
const bool XSpace::isDefault() const
{
return m_space == false;
}
const bool XSpace::isPreserve() const
{
return m_space == true;
}
}
} // namespace XML

View File

@@ -0,0 +1,63 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XSPACE_INCLUDE_H_
#define XML_PRIVATE_XSPACE_INCLUDE_H_
namespace XML
{
namespace Private
{
class XSpace
{
public:
XSpace();
XSpace(const bool space);
public:
const XSpace& operator =(const bool rhs);
public:
void setDefault();
void setPreserve();
public:
const bool isDefault() const;
const bool isPreserve() const;
private:
bool m_space;
};
}
}
#endif // XML_PRIVATE_XSPACE_INCLUDE_H_

View File

@@ -0,0 +1,198 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XString.h"
#include "Encoding.h"
namespace XML
{
namespace Private
{
XString::XString()
{
}
XString::XString(const char* value)
: m_value(value)
{
}
XString::XString(const std::string& value)
: m_value(value)
{
}
const bool XString::operator ==(const XString& rhs) const
{
return m_value == rhs.m_value;
}
const bool XString::operator !=(const XString& rhs) const
{
return m_value != rhs.m_value;
}
const bool XString::operator ==(const std::string& rhs) const
{
return m_value.get_value_or("") == rhs;
}
const bool XString::operator !=(const std::string& rhs) const
{
return m_value.get_value_or("") != rhs;
}
const bool XString::operator ==(const char* rhs) const
{
return m_value.get_value_or("") == rhs;
}
const bool XString::operator !=(const char* rhs) const
{
return m_value.get_value_or("") != rhs;
}
const bool XString::ToBool() const
{
if (!m_value.is_init())
return false;
if (m_value == "true" || m_value == "t" || m_value == "1")
return true;
return false;
}
const int XString::ToInt() const
{
try
{
std::string str = m_value.get_value_or("0");
return atoi(str.c_str());
}
catch(...)
{
}
return 0;
}
const size_t XString::ToSizet() const
{
try
{
std::string str = m_value.get_value_or("0");
return (size_t)atoi(str.c_str());
}
catch(...)
{
}
return 0;
}
const double XString::ToDouble() const
{
std::string str = m_value.get_value_or("0");
double d = 0;
try
{
sscanf(str.c_str(), "%lf", &d);
}
catch(...)
{
d = 0;
}
return d;
}
const std::string XString::ToString() const
{
return m_value.get_value_or_default();
}
const std::wstring XString::ToWString() const
{
return Encoding::utf82unicode(m_value.get_value_or_default());
}
XString::operator const bool() const
{
return ToBool();
}
XString::operator const int() const
{
return ToInt();
}
XString::operator const size_t() const
{
return ToSizet();
}
XString::operator const double() const
{
return ToDouble();
}
XString::operator const std::string() const
{
return ToString();
}
XString::operator const std::wstring() const
{
return ToWString();
}
}
} // namespace XML

View File

@@ -0,0 +1,240 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XSTRING_INCLUDE_H_
#define XML_PRIVATE_XSTRING_INCLUDE_H_
#include <string>
#include "nullable.h"
#include "property.h"
#include "nullable_property.h"
#include "Parse.h"
#include "../../../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace XML
{
namespace Private
{
class XString
{
public:
XString();
XString(const char* value);
XString(const std::string& value);
public:
const bool operator ==(const XString& rhs) const;
const bool operator !=(const XString& rhs) const;
const bool operator ==(const std::string& rhs) const;
const bool operator !=(const std::string& rhs) const;
const bool operator ==(const char* rhs) const;
const bool operator !=(const char* rhs) const;
public:
const bool ToBool() const;
const int ToInt() const;
const size_t ToSizet() const;
const double ToDouble() const;
const std::string ToString() const;
const std::wstring ToWString() const;
operator const bool() const;
operator const int() const;
operator const size_t() const;
operator const double() const;
operator const std::string() const;
operator const std::wstring() const;
template<typename T>
operator const nullable__<T>() const
{
if (m_value.is_init())
return Parse<T>(m_value);
return nullable__<T>();
}
template<typename T, class S, class G>
operator const nullable_property<T, S, G>() const
{
if (m_value.is_init())
return Parse<T>(m_value);
return nullable_property<T, S, G>();
}
public:
template<typename T> const bool operator ==(const T value) const
{
return static_cast<T>(*this) == value;
}
template<typename T> const bool operator !=(const T value) const
{
return static_cast<T>(*this) != value;
}
template<typename T> const bool operator > (const T value) const
{
return static_cast<T>(*this) > value;
}
template<typename T> const bool operator < (const T value) const
{
return static_cast<T>(*this) < value;
}
template<typename T> const bool operator >=(const T value) const
{
return static_cast<T>(*this) >= value;
}
template<typename T> const bool operator <=(const T value) const
{
return static_cast<T>(*this) <= value;
}
template<typename T, class S, class G> const bool operator ==(const property<T, S, G> value) const
{
return static_cast<T>(*this) == *value;
}
template<typename T, class S, class G> const bool operator !=(const property<T, S, G> value) const
{
return static_cast<T>(*this) != *vlaue;
}
template<typename T, class S, class G> const bool operator > (const property<T, S, G> value) const
{
return static_cast<T>(*this) > *value;
}
template<typename T, class S, class G> const bool operator < (const property<T, S, G> value) const
{
return static_cast<T>(*this) < *value;
}
template<typename T, class S, class G> const bool operator >=(const property<T, S, G> value) const
{
return static_cast<T>(*this) >= *value;
}
template<typename T, class S, class G> const bool operator <=(const property<T, S, G> value) const
{
return static_cast<T>(*this) <= *value;
}
template<typename T> const bool operator ==(const nullable__<T> value) const
{
return static_cast<T>(*this) == *value;
}
template<typename T> const bool operator !=(const nullable__<T> value) const
{
return static_cast<T>(*this) != *value;
}
template<typename T> const bool operator > (const nullable__<T> value) const
{
return static_cast<T>(*this) > *value;
}
template<typename T> const bool operator < (const nullable__<T> value) const
{
return static_cast<T>(*this) < *value;
}
template<typename T> const bool operator >=(const nullable__<T> value) const
{
return static_cast<T>(*this) >= *value;
}
template<typename T> const bool operator <=(const nullable__<T> value) const
{
return static_cast<T>(*this) <= *value;
}
template<typename T, class S, class G> const bool operator ==(const nullable_property<T, S, G> value) const
{
return static_cast<T>(*this) == *value;
}
template<typename T, class S, class G> const bool operator !=(const nullable_property<T, S, G> value) const
{
return static_cast<T>(*this) != *vlaue;
}
template<typename T, class S, class G> const bool operator > (const nullable_property<T, S, G> value) const
{
return static_cast<T>(*this) > *value;
}
template<typename T, class S, class G> const bool operator < (const nullable_property<T, S, G> value) const
{
return static_cast<T>(*this) < *value;
}
template<typename T, class S, class G> const bool operator >=(const nullable_property<T, S, G> value) const
{
return static_cast<T>(*this) >= *value;
}
template<typename T, class S, class G> const bool operator <=(const nullable_property<T, S, G> value) const
{
return static_cast<T>(*this) <= *value;
}
private:
nullable__<std::string> m_value;
};
}
}
template<typename T>
const nullable__<T>& nullable_setter(nullable__<T>& lhs, const XML::Private::XString& rhs)
{
return ::nullable_setter(lhs, nullable__<T>(rhs));
}
template<typename T, class S, class G>
const property<T, S, G>& property_setter(property<T, S, G>& lhs, const XML::Private::XString& rhs)
{
return ::property_setter(lhs, T(rhs));
}
template<typename T, class S, class G>
const nullable_property<T, S, G>& nullable_property_setter(nullable_property<T, S, G>& lhs, const XML::Private::XString& rhs)
{
return ::nullable_property_setter(lhs, nullable_property<T, S, G>(rhs));
}
#endif // XML_PRIVATE_XSTRING_INCLUDE_H_

View File

@@ -0,0 +1,63 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XStringSource.h"
#include "Exception\not_implement.h"
namespace XML
{
namespace Private
{
XStringSource::XStringSource(const std::string& source)
: m_stream(source)
{
setBegin();
}
XStringSource::~XStringSource()
{
}
void XStringSource::setBegin()
{
m_iterator = m_stream;
}
}
} // namespace XML

View File

@@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XSTRING_SOURCE_INCLUDE_H_
#define XML_PRIVATE_XSTRING_SOURCE_INCLUDE_H_
#include "XSingleSource.h"
#include <sstream>
#include <iterator>
namespace XML
{
namespace Private
{
class XStringSource : public XSingleSource
{
public:
XStringSource(const std::string& source);
virtual ~XStringSource();
private:
void setBegin();
private:
std::istringstream m_stream;
};
}
}
#endif // XML_PRIVATE_XSTRING_SOURCE_INCLUDE_H_

View File

@@ -0,0 +1,105 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XTextContainer.h"
#include "XNodeContainer.h"
#include "./../XText.h"
namespace XML
{
namespace Private
{
XTextContainer::XTextContainer(const XNodeContainer& nodes) : m_container(nodes.container())
{
}
const bool XTextContainer::empty() const
{
return size() == 0;
}
const size_t XTextContainer::size() const
{
size_t size = 0;
for (const_iterator i = begin(); i != end(); ++i)
++size;
return size;
}
void XTextContainer::push_back(const XText& text)
{
if (text.is_init())
{
m_container->push_back(text);
}
}
void XTextContainer::Add(const XML::XText& text)
{
push_back(text);
}
const XString XTextContainer::text() const
{
std::string text;
for (const_iterator i = begin(); i != end(); ++i)
{
text += XText(*i)->Value;
}
return text.empty() ? XString() : text;
}
XTextContainer::iterator XTextContainer:: begin()
{
return m_container->begin();
}
XTextContainer::iterator XTextContainer::end()
{
return m_container->end();
}
XTextContainer::const_iterator XTextContainer::begin() const
{
return m_container->begin();
}
XTextContainer::const_iterator XTextContainer::end() const
{
return m_container->end();
}
}
} // namespace XML

View File

@@ -0,0 +1,85 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XTEXT_CONTAINER_INCLUDE_H_
#define XML_PRIVATE_XTEXT_CONTAINER_INCLUDE_H_
#include <vector>
#include <list>
#include "Filter/Text.h"
#include "XString.h"
#include "../../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
namespace XML
{
namespace Private
{
class XNodeContainer;
class XTextContainer
{
public:
XTextContainer(const XNodeContainer& nodes);
public:
const bool empty() const;
const size_t size() const;
void push_back(const XText& text);
void Add(const XText& text);
const XString text() const;
public:
typedef std::list<XNode>::iterator iterator;
typedef std::list<XNode>::const_iterator const_iterator;
public:
XTextContainer const* const operator->() const {return this;}
XTextContainer* operator->() {return this;}
public:
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
private:
NSCommon::smart_ptr<std::list<XNode> > m_container;
};
}
}
#endif // XML_PRIVATE_XTEXT_CONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,64 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XWFileSource.h"
#include "Exception\not_implement.h"
namespace XML
{
namespace Private
{
XWFileSource::XWFileSource(const OOX::CPath& path, XWideSource::eSourceType type)
: m_stream(path.GetPath())
, XWideSource(type)
{
setBegin();
}
XWFileSource::~XWFileSource()
{
}
void XWFileSource::setBegin()
{
m_iterator = m_stream;
}
}
} // namespace XML

View File

@@ -0,0 +1,61 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XWFILE_SOURCE_INCLUDE_H_
#define XML_PRIVATE_XWFILE_SOURCE_INCLUDE_H_
#include "XWideSource.h"
#include <fstream>
#include <iterator>
#include "../../../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace XML
{
namespace Private
{
class XWFileSource : public XWideSource
{
public:
XWFileSource(const OOX::CPath& path, XWideSource::eSourceType type);
virtual ~XWFileSource();
private:
void setBegin();
private:
std::wifstream m_stream;
};
}
}
#endif // XML_PRIVATE_XWFILE_SOURCE_INCLUDE_H_

View File

@@ -0,0 +1,64 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XWStringSource.h"
#include "Exception\not_implement.h"
namespace XML
{
namespace Private
{
XWStringSource::XWStringSource(const std::wstring& source)
: m_stream(source)
, XWideSource(XWideSource::estStringSource)
{
setBegin();
}
XWStringSource::~XWStringSource()
{
}
void XWStringSource::setBegin()
{
m_iterator = m_stream;
}
}
} // namespace XML

View File

@@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XWSTRING_SOURCE_INCLUDE_H_
#define XML_PRIVATE_XWSTRING_SOURCE_INCLUDE_H_
#include "XWideSource.h"
#include <sstream>
#include <iterator>
namespace XML
{
namespace Private
{
class XWStringSource : public XWideSource
{
public:
XWStringSource(const std::wstring& source);
virtual ~XWStringSource();
private:
void setBegin();
private:
std::wistringstream m_stream;
};
}
}
#endif // XML_PRIVATE_XWSTRING_SOURCE_INCLUDE_H_

View File

@@ -0,0 +1,241 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "precompiled_xml.h"
#include "XWideSource.h"
#include "Lexigraph.h"
#include "Encoding.h"
#include "Exception\not_implement.h"
namespace XML
{
namespace Private
{
XWideSource::XWideSource(eSourceType type)
: m_SourceType(type)
, m_current(0)
{
}
XWideSource::~XWideSource()
{
}
void XWideSource::next()
{
if(m_SourceType == estLittleEndian)
{
m_current = *m_iterator;
++m_iterator;
m_current = ((*m_iterator)<<8) + m_current;
++m_iterator;
}
else if(m_SourceType == estBigEndian)
{
m_current = *m_iterator;
++m_iterator;
m_current = (m_current << 8) + (*m_iterator);
++m_iterator;
}
else
{
m_current = *m_iterator;
++m_iterator;
}
}
void XWideSource::skipSpace()
{
for (; isSpace() ; next());
}
void XWideSource::find(const wchar_t value)
{
for (; m_current != value; next());
}
void XWideSource::find(const wchar_t value1, const wchar_t value2)
{
for (; ((m_current != value1) && (m_current != value2)); next());
}
void XWideSource::findAndSkip(const wchar_t value)
{
find(value);
next();
}
const std::pair<const std::wstring, const std::wstring> XWideSource::getName()
{
std::wstring prefix = getToSeparator(L':');
std::wstring name;
if (get() == L':')
{
next();
name = getToSeparator();
}
else
{
std::swap(prefix, name);
}
return std::make_pair(prefix, name);
}
const std::pair<const std::wstring, const std::wstring> XWideSource::getPair()
{
const std::wstring name = get(L' ', L'=');
const std::wstring value = getValue();
return std::make_pair(name, value);
}
const std::pair<const std::pair<const std::wstring, const std::wstring>, const std::wstring> XWideSource::getAttribute()
{
const std::pair<const std::wstring, const std::wstring> name = getName();
const std::wstring value = getValue();
return std::make_pair(name, value);
}
const wchar_t XWideSource::get() const
{
return m_current;
}
const std::wstring XWideSource::getString(const wchar_t separator)
{
std::wstring result;
while (m_current != separator)
{
result += m_current;
next();
}
return Lexigraph::fromSource(result);
}
const std::wstring XWideSource::getString(const wchar_t separator1, const wchar_t separator2)
{
std::wstring result;
while ((m_current != separator1) && (m_current != separator2))
{
result += m_current;
next();
}
return Lexigraph::fromSource(result);
}
const bool XWideSource::isSpace() const
{
if (m_current == L' ' || m_current == L'\n' || m_current == L'\r' || m_current == L'\t')
return true;
return false;
}
const bool XWideSource::isSeparator() const
{
if (m_current == L'<' || m_current == L'>' || m_current == L'=' || m_current == L'/')
return true;
return false;
}
const std::wstring XWideSource::get(const wchar_t separator1, const wchar_t separator2)
{
skipSpace();
std::wstring result;
while (m_current != separator1 && m_current != separator2)
{
result += m_current;
next();
}
return result;
}
const std::wstring XWideSource::getToSeparator()
{
skipSpace();
std::wstring result;
while (!isSeparator() && !isSpace())
{
result += m_current;
next();
}
return result;
}
const std::wstring XWideSource::getToSeparator(const wchar_t separator)
{
skipSpace();
std::wstring result;
while (!isSeparator() && !isSpace() && m_current != separator)
{
result += m_current;
next();
}
return result;
}
const std::wstring XWideSource::getValue()
{
find(L'"', L'\'');
wchar_t EndChar = get();
next();
const std::wstring value = getString(EndChar);
next();
return value;
}
}
} // namespace XML

View File

@@ -0,0 +1,85 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef XML_PRIVATE_XWIDE_SOURCE_INCLUDE_H_
#define XML_PRIVATE_XWIDE_SOURCE_INCLUDE_H_
#include <iterator>
#include <string>
namespace XML
{
namespace Private
{
class XWideSource
{
public:
enum eSourceType {estLittleEndian, estBigEndian, estStringSource};
public:
XWideSource(eSourceType type);
~XWideSource();
public:
virtual void next();
virtual void skipSpace();
virtual void find(const wchar_t value);
virtual void find(const wchar_t value1, const wchar_t value2);
virtual void findAndSkip(const wchar_t value);
public:
virtual const std::pair<const std::wstring, const std::wstring> getName();
virtual const std::pair<const std::wstring, const std::wstring> getPair();
virtual const std::pair<const std::pair<const std::wstring, const std::wstring>, const std::wstring> getAttribute();
public:
virtual const wchar_t get() const;
virtual const std::wstring getString(const wchar_t separator);
virtual const std::wstring getString(const wchar_t separator1, const wchar_t separator2);
private:
const bool isSpace() const;
const bool isSeparator() const;
const std::wstring get(const wchar_t separator1, const wchar_t separator2);
const std::wstring getToSeparator();
const std::wstring getToSeparator(const wchar_t separator);
const std::wstring getValue();
protected:
std::istreambuf_iterator<wchar_t> m_iterator;
wchar_t m_current;
eSourceType m_SourceType;
};
}
}
#endif // XML_PRIVATE_XWIDE_SOURCE_INCLUDE_H_