init repo
This commit is contained in:
137
ActiveX/Common/ASCDocxFormat/Source/Utility/ASCStlUtils.h
Normal file
137
ActiveX/Common/ASCDocxFormat/Source/Utility/ASCStlUtils.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* (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 ASC_STL_UTILS_INCLUDE_H_
|
||||
#define ASC_STL_UTILS_INCLUDE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
|
||||
namespace StlUtils
|
||||
{
|
||||
static inline std::wstring ReplaceString(std::wstring subject, const std::wstring& search, const std::wstring& replace)
|
||||
{
|
||||
size_t pos = 0;
|
||||
|
||||
while ((pos = subject.find(search, pos)) != std::string::npos)
|
||||
{
|
||||
subject.replace(pos, search.length(), replace);
|
||||
pos += replace.length();
|
||||
}
|
||||
|
||||
return subject;
|
||||
}
|
||||
|
||||
static inline std::string ReplaceString(std::string subject, const std::string& search, const std::string& replace)
|
||||
{
|
||||
size_t pos = 0;
|
||||
|
||||
while ((pos = subject.find(search, pos)) != std::string::npos)
|
||||
{
|
||||
subject.replace(pos, search.length(), replace);
|
||||
pos += replace.length();
|
||||
}
|
||||
|
||||
return subject;
|
||||
}
|
||||
|
||||
static inline std::vector<std::string>& Split(const std::string& s, char delim, std::vector<std::string>& elems)
|
||||
{
|
||||
std::stringstream ss(s);
|
||||
std::string item;
|
||||
|
||||
while (std::getline(ss, item, delim))
|
||||
elems.push_back(item);
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
||||
static inline bool SplitStrings(std::vector<std::string>& elems, const std::string& s, char delim)
|
||||
{
|
||||
StlUtils::Split(s, delim, elems);
|
||||
return (0 != elems.size());
|
||||
}
|
||||
|
||||
|
||||
static inline std::wstring IntToWideString(int value, int radix = 10)
|
||||
{
|
||||
wchar_t strValue[256];
|
||||
_itow_s(value, strValue, 256, radix);
|
||||
return std::wstring(strValue);
|
||||
}
|
||||
|
||||
static inline std::wstring DoubleToWideString(double value)
|
||||
{
|
||||
wchar_t strValue[256];
|
||||
swprintf_s(strValue, 256, L"%f", value);
|
||||
return std::wstring(strValue);
|
||||
}
|
||||
|
||||
static inline std::string IntToString(int value, int radix = 10)
|
||||
{
|
||||
char strValue[256];
|
||||
_itoa_s(value, strValue, 256, radix);
|
||||
return std::string(strValue);
|
||||
}
|
||||
|
||||
static inline std::string DoubleToString(double value)
|
||||
{
|
||||
char strValue[256];
|
||||
sprintf_s(strValue, 256, "%f", value);
|
||||
return std::string(strValue);
|
||||
}
|
||||
|
||||
static int ToInteger(const std::string& strValue)
|
||||
{
|
||||
return atoi(strValue.c_str());
|
||||
}
|
||||
|
||||
static int ToInteger(const std::wstring& strValue)
|
||||
{
|
||||
return _wtoi(strValue.c_str());
|
||||
}
|
||||
|
||||
static double ToDouble(const std::string& strValue)
|
||||
{
|
||||
return atof(strValue.c_str());
|
||||
}
|
||||
|
||||
static double ToDouble(const std::wstring& strValue)
|
||||
{
|
||||
return _wtof(strValue.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ASC_STL_UTILS_INCLUDE_H_
|
||||
54
ActiveX/Common/ASCDocxFormat/Source/Utility/CallTraits.h
Normal file
54
ActiveX/Common/ASCDocxFormat/Source/Utility/CallTraits.h
Normal 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 CALL_TRAITS_INCLUDE_H_
|
||||
#define CALL_TRAITS_INCLUDE_H_
|
||||
|
||||
template <typename T>
|
||||
struct NSCT_IMP
|
||||
{
|
||||
typedef const T& param_type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct NSCallTraits
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
typedef typename NSCT_IMP<T>::param_type param_type;
|
||||
};
|
||||
|
||||
#endif // CALL_TRAITS_INCLUDE_H_
|
||||
115
ActiveX/Common/ASCDocxFormat/Source/Utility/DateTime.cpp
Normal file
115
ActiveX/Common/ASCDocxFormat/Source/Utility/DateTime.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "DateTime.h"
|
||||
#include "ASCStlUtils.h"
|
||||
|
||||
DateTime::DateTime()
|
||||
{
|
||||
time_t now;
|
||||
tm local;
|
||||
time(&now);
|
||||
localtime_s(&local, &now);
|
||||
|
||||
m_year = local.tm_year + 1900;
|
||||
m_month = local.tm_mon + 1;
|
||||
m_day = local.tm_mday;
|
||||
m_hour = local.tm_hour;
|
||||
m_minute = local.tm_min;
|
||||
m_second = local.tm_sec;
|
||||
m_millisecond = 0;
|
||||
}
|
||||
|
||||
DateTime::DateTime(const std::string& value, const std::string& pattern)
|
||||
:
|
||||
m_year (ParseValue(value, pattern, "%YYYY")),
|
||||
m_month (ParseValue(value, pattern, "%MM")),
|
||||
m_day (ParseValue(value, pattern, "%DD")),
|
||||
m_hour (ParseValue(value, pattern, "%hh")),
|
||||
m_minute (ParseValue(value, pattern, "%mm")),
|
||||
m_second (ParseValue(value, pattern, "%ss")),
|
||||
m_millisecond (ParseValue(value, pattern, "%ms"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const std::string DateTime::ToString(const std::string& pattern) const
|
||||
{
|
||||
std::string result = pattern;
|
||||
|
||||
char buffer[12];
|
||||
|
||||
sprintf_s(buffer, 12, "%04d", m_year);
|
||||
StlUtils::ReplaceString(result, "%YYYY", std::string(buffer));
|
||||
|
||||
sprintf_s(buffer, 12, "%02d", m_month);
|
||||
StlUtils::ReplaceString(result, "%MM", std::string(buffer));
|
||||
|
||||
sprintf_s(buffer, 12, "%02d", m_day);
|
||||
StlUtils::ReplaceString(result, "%DD", std::string(buffer));
|
||||
|
||||
sprintf_s(buffer, 12, "%02d", m_hour);
|
||||
StlUtils::ReplaceString(result, "%hh", std::string(buffer));
|
||||
|
||||
sprintf_s(buffer, 12, "%02d", m_minute);
|
||||
StlUtils::ReplaceString(result, "%mm", std::string(buffer));
|
||||
|
||||
sprintf_s(buffer, 12, "%02d", m_second);
|
||||
StlUtils::ReplaceString(result, "%ss", std::string(buffer));
|
||||
|
||||
sprintf_s(buffer, 12, "%02d", m_millisecond);
|
||||
StlUtils::ReplaceString(result, "%ms", std::string(buffer));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const DateTime DateTime::Parse(const std::string& value, const std::string& pattern)
|
||||
{
|
||||
return DateTime(value, pattern);
|
||||
}
|
||||
|
||||
const int DateTime::ParseValue(const std::string& value, const std::string& pattern, const std::string& element)
|
||||
{
|
||||
const int pos = pattern.find(element);
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
const int sepCount = std::count(pattern.begin(), pattern.begin() + pos, '%');
|
||||
const std::string numeric = value.substr(pos - sepCount , element.size() - 1);
|
||||
|
||||
return StlUtils::ToInteger(numeric);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
65
ActiveX/Common/ASCDocxFormat/Source/Utility/DateTime.h
Normal file
65
ActiveX/Common/ASCDocxFormat/Source/Utility/DateTime.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* (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 UTILITY_DATE_TIME_INCLUDE_H_
|
||||
#define UTILITY_DATE_TIME_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
|
||||
class DateTime
|
||||
{
|
||||
public:
|
||||
DateTime();
|
||||
DateTime(const std::string& value, const std::string& pattern);
|
||||
|
||||
public:
|
||||
const std::string ToString(const std::string& pattern) const;
|
||||
|
||||
public:
|
||||
static const DateTime Parse(const std::string& value, const std::string& pattern);
|
||||
|
||||
private:
|
||||
static const int ParseValue(const std::string& value, const std::string& pattern, const std::string& element);
|
||||
|
||||
private:
|
||||
int m_year;
|
||||
int m_month;
|
||||
int m_day;
|
||||
int m_hour;
|
||||
int m_minute;
|
||||
int m_second;
|
||||
int m_millisecond;
|
||||
};
|
||||
|
||||
#endif // UTILITY_DATE_TIME_INCLUDE_H_
|
||||
109
ActiveX/Common/ASCDocxFormat/Source/Utility/Encoding.cpp
Normal file
109
ActiveX/Common/ASCDocxFormat/Source/Utility/Encoding.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "Encoding.h"
|
||||
#include <windows.h>
|
||||
#include "Utility.h"
|
||||
|
||||
const std::string Encoding::ansi2utf8(const std::string& line)
|
||||
{
|
||||
return wstring2string(string2wstring(line, CP_ACP), CP_UTF8);
|
||||
}
|
||||
|
||||
const std::string Encoding::cp2utf8(const std::string& line, const unsigned int codePage)
|
||||
{
|
||||
return wstring2string(string2wstring(line, codePage), CP_UTF8);
|
||||
}
|
||||
|
||||
const std::wstring Encoding::ansi2unicode(const std::string& line)
|
||||
{
|
||||
return string2wstring(line, CP_ACP);
|
||||
}
|
||||
|
||||
const std::wstring Encoding::cp2unicode(const std::string& line, const unsigned int codePage)
|
||||
{
|
||||
return string2wstring(line, codePage);
|
||||
}
|
||||
|
||||
const std::string Encoding::utf82ansi(const std::string& line)
|
||||
{
|
||||
return wstring2string(string2wstring(line, CP_UTF8), CP_ACP);
|
||||
}
|
||||
|
||||
const std::wstring Encoding::utf82unicode(const std::string& line)
|
||||
{
|
||||
return string2wstring(line, CP_UTF8);
|
||||
}
|
||||
|
||||
const std::string Encoding::unicode2ansi(const std::wstring& line)
|
||||
{
|
||||
return wstring2string(line, CP_ACP);
|
||||
}
|
||||
|
||||
const std::string Encoding::unicode2utf8(const std::wstring& line)
|
||||
{
|
||||
return wstring2string(line, CP_UTF8);
|
||||
}
|
||||
|
||||
const std::string Encoding::wstring2string(const std::wstring& sLine, const unsigned int codePage)
|
||||
{
|
||||
const int nSize = WideCharToMultiByte(codePage, 0, sLine.c_str(), sLine.length(), NULL, 0, NULL, NULL);
|
||||
char *sTemp = new char[nSize];
|
||||
if (!sTemp)
|
||||
return std::string();
|
||||
|
||||
int size = WideCharToMultiByte(codePage, 0, sLine.c_str(), sLine.length(), sTemp, nSize, NULL, NULL);
|
||||
|
||||
std::string sResult(sTemp, size);
|
||||
delete []sTemp;
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
const std::wstring Encoding::string2wstring(const std::string& sline, const unsigned int codePage)
|
||||
{
|
||||
const int nSize = MultiByteToWideChar(codePage, 0, sline.c_str(), sline.size(), NULL, 0);
|
||||
|
||||
wchar_t *sTemp = new wchar_t[nSize];
|
||||
if (!sTemp)
|
||||
return std::wstring();
|
||||
|
||||
int size = MultiByteToWideChar(codePage, 0, sline.c_str(), sline.size(), sTemp, nSize);
|
||||
|
||||
std::wstring sResult(sTemp, size);
|
||||
delete []sTemp;
|
||||
|
||||
return sResult;
|
||||
}
|
||||
54
ActiveX/Common/ASCDocxFormat/Source/Utility/Encoding.h
Normal file
54
ActiveX/Common/ASCDocxFormat/Source/Utility/Encoding.h
Normal 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 UTILITY_ENCODING_INCLUDE_H_
|
||||
#define UTILITY_ENCODING_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class Encoding
|
||||
{
|
||||
public:
|
||||
static const std::string ansi2utf8(const std::string& line);
|
||||
static const std::string cp2utf8(const std::string& line, const unsigned int codePage);
|
||||
static const std::wstring ansi2unicode(const std::string& line);
|
||||
static const std::wstring cp2unicode(const std::string& line, const unsigned int codePage);
|
||||
static const std::string utf82ansi(const std::string& line);
|
||||
static const std::wstring utf82unicode(const std::string& line);
|
||||
static const std::string unicode2ansi(const std::wstring& line);
|
||||
static const std::string unicode2utf8(const std::wstring& line);
|
||||
|
||||
private:
|
||||
static const std::string wstring2string(const std::wstring& line, const unsigned int codePage);
|
||||
static const std::wstring string2wstring(const std::string& line, const unsigned int codePage);
|
||||
};
|
||||
#endif // UTILITY_ENCODING_INCLUDE_H_
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "UnitError.h"
|
||||
|
||||
|
||||
UnitError::UnitError(const std::string& message)
|
||||
: log_invalid_argument(message)
|
||||
{
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef UNIT_ERROR_INCLUDE_H_
|
||||
#define UNIT_ERROR_INCLUDE_H_
|
||||
|
||||
#include "log_invalid_argument.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
class UnitError : public log_invalid_argument
|
||||
{
|
||||
public:
|
||||
UnitError(const std::string& message);
|
||||
};
|
||||
|
||||
#endif // UNIT_ERROR_INCLUDE_H_
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "log_invalid_argument.h"
|
||||
#include "./../Log.h"
|
||||
|
||||
|
||||
log_invalid_argument::log_invalid_argument(const std::string& message)
|
||||
: std::invalid_argument(message)
|
||||
{
|
||||
Log::error(message);
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef LOG_INVALID_ARGUMENT_INCLUDE_H_
|
||||
#define LOG_INVALID_ARGUMENT_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
class log_invalid_argument : public std::invalid_argument
|
||||
{
|
||||
public:
|
||||
explicit log_invalid_argument(const std::string& message);
|
||||
};
|
||||
|
||||
#endif // LOG_INVALID_ARGUMENT_INCLUDE_H_
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "log_not_find.h"
|
||||
|
||||
|
||||
log_not_find::log_not_find(const std::string& what, const std::string& where)
|
||||
: log_runtime_error("not find " + what + " in " + where)
|
||||
{
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef LOG_NOT_FIND_INCLUDE_H_
|
||||
#define LOG_NOT_FIND_INCLUDE_H_
|
||||
|
||||
#include "log_runtime_error.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
class log_not_find : public log_runtime_error
|
||||
{
|
||||
public:
|
||||
log_not_find(const std::string& what, const std::string& where);
|
||||
};
|
||||
|
||||
#endif // LOG_NOT_FIND_INCLUDE_H_
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "log_not_implement.h"
|
||||
#include "./../Log.h"
|
||||
|
||||
|
||||
log_not_implement::log_not_implement(const std::string& message)
|
||||
: std::runtime_error(message)
|
||||
{
|
||||
Log::error(message);
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef LOG_NOT_IMPLEMENT_INCLUDE_H_
|
||||
#define LOG_NOT_IMPLEMENT_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
class log_not_implement : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit log_not_implement(const std::string& message);
|
||||
};
|
||||
|
||||
#endif // LOG_NOT_IMPLEMENT_INCLUDE_H_
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled_utility.h"
|
||||
|
||||
|
||||
#include "log_not_init_nullable.h"
|
||||
#include "./../Log.h"
|
||||
|
||||
|
||||
log_not_init_nullable::log_not_init_nullable()
|
||||
: std::runtime_error("not_init_nullable")
|
||||
{
|
||||
Log::error("not_init_nullable");
|
||||
}
|
||||
|
||||
|
||||
log_not_init_nullable::log_not_init_nullable(const std::string& message)
|
||||
: std::runtime_error(message)
|
||||
{
|
||||
Log::error(message);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* (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 LOG_NOT_INIT_NULLABLE_INCLUDE_H_
|
||||
#define LOG_NOT_INIT_NULLABLE_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
class log_not_init_nullable : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit log_not_init_nullable();
|
||||
explicit log_not_init_nullable(const std::string& message);
|
||||
};
|
||||
|
||||
#endif // LOG_NOT_INIT_NULLABLE_INCLUDE_H_
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled_utility.h"
|
||||
|
||||
|
||||
#include "log_range_error.h"
|
||||
#include "./../Log.h"
|
||||
|
||||
|
||||
log_range_error::log_range_error(const std::string& message)
|
||||
: std::range_error(message)
|
||||
{
|
||||
Log::error(message);
|
||||
}
|
||||
|
||||
|
||||
log_range_error::log_range_error(const std::wstring& message)
|
||||
: std::range_error("")
|
||||
{
|
||||
Log::error(message);
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef LOG_RANGE_ERROR_INCLUDE_H_
|
||||
#define LOG_RANGE_ERROR_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
class log_range_error : public std::range_error
|
||||
{
|
||||
public:
|
||||
explicit log_range_error(const std::string& message);
|
||||
explicit log_range_error(const std::wstring& message);
|
||||
};
|
||||
|
||||
#endif // LOG_RANGE_ERROR_INCLUDE_H_
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "log_runtime_error.h"
|
||||
#include "./../Log.h"
|
||||
|
||||
|
||||
log_runtime_error::log_runtime_error(const std::string& message)
|
||||
: std::runtime_error(message)
|
||||
{
|
||||
Log::error(message);
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef LOG_RUNTIME_ERROR_INCLUDE_H_
|
||||
#define LOG_RUNTIME_ERROR_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
class log_runtime_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit log_runtime_error(const std::string& message);
|
||||
};
|
||||
|
||||
#endif // LOG_RUNTIME_ERROR_INCLUDE_H_
|
||||
@@ -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_utility.h"
|
||||
|
||||
|
||||
#include "not_implement.h"
|
||||
|
||||
|
||||
not_implement::not_implement()
|
||||
: std::runtime_error("")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
not_implement::not_implement(const std::string& message)
|
||||
: std::runtime_error(message)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* (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 NOT_IMPLEMENT_INCLUDE_H_
|
||||
#define NOT_IMPLEMENT_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
class not_implement : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
not_implement();
|
||||
explicit not_implement(const std::string& message);
|
||||
};
|
||||
|
||||
#endif // NOT_IMPLEMENT_INCLUDE_H_
|
||||
@@ -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_utility.h"
|
||||
|
||||
|
||||
#include "not_init_nullable.h"
|
||||
|
||||
|
||||
not_init_nullable::not_init_nullable()
|
||||
: std::runtime_error("not_init_nullable")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
not_init_nullable::not_init_nullable(const std::string& message)
|
||||
: std::runtime_error(message)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* (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 NOT_INIT_NULLABLE_INCLUDE_H_
|
||||
#define NOT_INIT_NULLABLE_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
class not_init_nullable : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit not_init_nullable();
|
||||
explicit not_init_nullable(const std::string& message);
|
||||
};
|
||||
|
||||
#endif // NOT_INIT_NULLABLE_INCLUDE_H_
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "FileNameUtility.h"
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* (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 UTILITY_FILE_NAME_UTILITY_INCLUDE_H_
|
||||
#define UTILITY_FILE_NAME_UTILITY_INCLUDE_H_
|
||||
|
||||
#endif // UTILITY_FILE_NAME_UTILITY_INCLUDE_H_
|
||||
65
ActiveX/Common/ASCDocxFormat/Source/Utility/Getter.h
Normal file
65
ActiveX/Common/ASCDocxFormat/Source/Utility/Getter.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* (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 UTILITY_GETTER_INCLUDE_H_
|
||||
#define UTILITY_GETTER_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "CallTraits.h"
|
||||
|
||||
namespace getter
|
||||
{
|
||||
template<typename Type>
|
||||
class base_getter
|
||||
{
|
||||
protected:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
public:
|
||||
const Type operator()(Parameter _value) const
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class simple : private base_getter<Type>
|
||||
{
|
||||
public:
|
||||
const Type operator ()(Parameter _value) const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // UTILITY_GETTER_INCLUDE_H_
|
||||
67
ActiveX/Common/ASCDocxFormat/Source/Utility/IDictonary.h
Normal file
67
ActiveX/Common/ASCDocxFormat/Source/Utility/IDictonary.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* (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 IDICTONARY_INCLUDE_H_
|
||||
#define IDICTONARY_INCLUDE_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
template<typename Key, typename Value>
|
||||
class IDictonary
|
||||
{
|
||||
public:
|
||||
const size_t size() const {return m_container.size();}
|
||||
void add(const Key& key, const Value& value) {m_container.insert(std::make_pair(key, value));}
|
||||
const bool empty() const {return m_container.empty();}
|
||||
|
||||
public:
|
||||
Value& operator [](const Key& key) {return m_container[key];}
|
||||
const Value& operator [](const Key& key) const {return m_container[key];}
|
||||
|
||||
public:
|
||||
typedef typename std::map<Key, Value>::iterator iterator;
|
||||
typedef typename std::map<Key, Value>::const_iterator const_iterator;
|
||||
|
||||
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();}
|
||||
iterator find(const Key& key) {return m_container.find(key);}
|
||||
const_iterator find(const Key& key) const {return m_container.find(key);}
|
||||
|
||||
protected:
|
||||
std::map<Key, Value> m_container;
|
||||
};
|
||||
|
||||
#endif // IDICTONARY_INCLUDE_H_
|
||||
84
ActiveX/Common/ASCDocxFormat/Source/Utility/IEnumerable.h
Normal file
84
ActiveX/Common/ASCDocxFormat/Source/Utility/IEnumerable.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* (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 IENUMERABLE_INCLUDE_H_
|
||||
#define IENUMERABLE_INCLUDE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
template<typename Type, template<typename Type, typename Allocator> class Container = std::vector, class Allocator = std::allocator<Type> >
|
||||
class IEnumerable
|
||||
{
|
||||
public:
|
||||
IEnumerable() {}
|
||||
~IEnumerable() {}
|
||||
|
||||
public:
|
||||
void add(const Type& value) {push_back(value);}
|
||||
void push_back(const Type& value) {m_items.push_back(value);}
|
||||
void clear() {m_items.clear();}
|
||||
const size_t size() const {return m_items.size();}
|
||||
const bool empty() const {return m_items.empty();}
|
||||
|
||||
public:
|
||||
typedef typename Container<Type, Allocator>::iterator iterator;
|
||||
typedef typename Container<Type, Allocator>::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
iterator begin() {return m_items.begin();}
|
||||
iterator end() {return m_items.end();}
|
||||
const_iterator begin() const {return m_items.begin();}
|
||||
const_iterator end() const {return m_items.end();}
|
||||
|
||||
protected:
|
||||
Container<Type, Allocator> m_items;
|
||||
};
|
||||
|
||||
namespace Odt
|
||||
{
|
||||
template<typename _Iter, typename _Pred>
|
||||
_Iter find_if(_Iter iterBegin, _Iter iterEnd, _Pred pred)
|
||||
{
|
||||
_Iter iter = std::find_if(iterBegin, iterEnd, pred);
|
||||
|
||||
if (iter < iterBegin || iter >= iterEnd)
|
||||
{
|
||||
|
||||
return iterBegin;
|
||||
}
|
||||
|
||||
return iter;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // IENUMERABLE_INCLUDE_H_
|
||||
79
ActiveX/Common/ASCDocxFormat/Source/Utility/IItemable.h
Normal file
79
ActiveX/Common/ASCDocxFormat/Source/Utility/IItemable.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* (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 IITEMABLE_INCLUDE_H_
|
||||
#define IITEMABLE_INCLUDE_H_
|
||||
|
||||
#include "../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
|
||||
|
||||
template<class Item>
|
||||
class IItemable
|
||||
{
|
||||
public:
|
||||
IItemable() {};
|
||||
IItemable(Item* item) : m_item(item) {};
|
||||
~IItemable() {}
|
||||
|
||||
public:
|
||||
template<class T> const bool is() const
|
||||
{
|
||||
return m_item.is<T>();
|
||||
}
|
||||
|
||||
template<class T> T& as()
|
||||
{
|
||||
return static_cast<T&>(*m_item);
|
||||
}
|
||||
|
||||
template<class T> const T& as() const
|
||||
{
|
||||
return static_cast<const T&>(*m_item);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
template<class T> void create()
|
||||
{
|
||||
m_item.reset(new T());
|
||||
}
|
||||
|
||||
template<class T> void create(const T& value)
|
||||
{
|
||||
m_item.reset(new T(value));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
NSCommon::smart_ptr<Item> m_item;
|
||||
};
|
||||
|
||||
#endif // IITEMABLE_INCLUDE_H_
|
||||
69
ActiveX/Common/ASCDocxFormat/Source/Utility/Log.cpp
Normal file
69
ActiveX/Common/ASCDocxFormat/Source/Utility/Log.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
void Log::event(const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void Log::event(const std::wstring& message)
|
||||
{
|
||||
}
|
||||
|
||||
void Log::warning(const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Log::warning(const std::wstring& message)
|
||||
{
|
||||
}
|
||||
|
||||
void Log::error(const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void Log::error(const std::wstring& message)
|
||||
{
|
||||
}
|
||||
|
||||
void Log::message(const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void Log::message(const std::wstring& message)
|
||||
{
|
||||
}
|
||||
51
ActiveX/Common/ASCDocxFormat/Source/Utility/Log.h
Normal file
51
ActiveX/Common/ASCDocxFormat/Source/Utility/Log.h
Normal 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 UTILITY_LOG_INCLUDE_H_
|
||||
#define UTILITY_LOG_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
static void event(const std::string& message);
|
||||
static void event(const std::wstring& message);
|
||||
static void message(const std::string& message);
|
||||
static void message(const std::wstring& message);
|
||||
static void warning(const std::string& message);
|
||||
static void warning(const std::wstring& message);
|
||||
static void error(const std::string& message);
|
||||
static void error(const std::wstring& message);
|
||||
};
|
||||
|
||||
#endif // UTILITY_LOG_INCLUDE_H_
|
||||
141
ActiveX/Common/ASCDocxFormat/Source/Utility/LogDetails.cpp
Normal file
141
ActiveX/Common/ASCDocxFormat/Source/Utility/LogDetails.cpp
Normal 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_utility.h"
|
||||
|
||||
|
||||
#include "LogDetails.h"
|
||||
#include "DateTime.h"
|
||||
|
||||
namespace Details
|
||||
{
|
||||
const std::string Log::s_dtPattern("%hh:%mm:%ss");
|
||||
|
||||
|
||||
Log::Log(const std::string& log_file, const std::string& err_file)
|
||||
#ifdef _DEBUG
|
||||
: m_log(log_file.c_str()),
|
||||
m_err(err_file.c_str())
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
m_log << std::flush;
|
||||
m_err << std::flush;
|
||||
m_log.close();
|
||||
m_err.close();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Log::event(const std::string& message)
|
||||
{
|
||||
toLog(" EVENT: " + message);
|
||||
}
|
||||
|
||||
|
||||
void Log::event(const std::wstring& message)
|
||||
{
|
||||
toLog(L" EVENT: " + message);
|
||||
}
|
||||
|
||||
|
||||
void Log::message(const std::string& message)
|
||||
{
|
||||
toLog(" MESSAGE: " + message);
|
||||
}
|
||||
|
||||
|
||||
void Log::message(const std::wstring& message)
|
||||
{
|
||||
toLog(L" MESSAGE: " + message);
|
||||
}
|
||||
|
||||
|
||||
void Log::warning(const std::string& message)
|
||||
{
|
||||
toLog(" WARNING: " + message);
|
||||
}
|
||||
|
||||
|
||||
void Log::warning(const std::wstring& message)
|
||||
{
|
||||
toLog(L" WARNING: " + message);
|
||||
}
|
||||
|
||||
|
||||
void Log::error(const std::string& message)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DateTime dt;
|
||||
m_log << std::flush;
|
||||
m_err << dt.ToString(s_dtPattern).c_str() << " ERROR: " << message.c_str() << std::endl;
|
||||
std::cout << dt.ToString(s_dtPattern) << " ERROR: " << message << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Log::error(const std::wstring& message)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DateTime dt;
|
||||
m_log << std::flush;
|
||||
m_err << dt.ToString(s_dtPattern).c_str() << L" ERROR: " << message << std::endl;
|
||||
std::wcout << dt.ToString(s_dtPattern).c_str() << L" ERROR: " << message << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Log::toLog(const std::string& str)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DateTime dt;
|
||||
m_log << dt.ToString(s_dtPattern).c_str() << str.c_str() << "\n";
|
||||
std::cout << dt.ToString(s_dtPattern) << str << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Log::toLog(const std::wstring& str)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DateTime dt;
|
||||
m_log << dt.ToString(s_dtPattern).c_str() << str << "\n";
|
||||
std::wcout << dt.ToString(s_dtPattern).c_str() << str << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Details
|
||||
72
ActiveX/Common/ASCDocxFormat/Source/Utility/LogDetails.h
Normal file
72
ActiveX/Common/ASCDocxFormat/Source/Utility/LogDetails.h
Normal 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 UTILITY_LOG_DETAILS_INCLUDE_H_
|
||||
#define UTILITY_LOG_DETAILS_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Details
|
||||
{
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
Log(const std::string& log_file, const std::string& err_file);
|
||||
~Log();
|
||||
|
||||
public:
|
||||
void event(const std::string& message);
|
||||
void event(const std::wstring& message);
|
||||
void message(const std::string& message);
|
||||
void message(const std::wstring& message);
|
||||
void warning(const std::string& message);
|
||||
void warning(const std::wstring& message);
|
||||
void error(const std::string& message);
|
||||
void error(const std::wstring& message);
|
||||
|
||||
private:
|
||||
std::wofstream m_log;
|
||||
std::wofstream m_err;
|
||||
|
||||
private:
|
||||
void toLog(const std::string& str);
|
||||
void toLog(const std::wstring& str);
|
||||
|
||||
private:
|
||||
static const std::string s_dtPattern;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // UTILITY_LOG_DETAILS_INCLUDE_H_
|
||||
122
ActiveX/Common/ASCDocxFormat/Source/Utility/Parse.cpp
Normal file
122
ActiveX/Common/ASCDocxFormat/Source/Utility/Parse.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "Parse.h"
|
||||
#include "Encoding.h"
|
||||
|
||||
#include "ASCStlUtils.h"
|
||||
|
||||
template<> const bool Parse<bool>(const std::string& str)
|
||||
{
|
||||
return str == "true" || str == "1" || str == "t" || str == "on";
|
||||
}
|
||||
|
||||
template<> const int Parse<int>(const std::string& str)
|
||||
{
|
||||
if (str.length() == 0)
|
||||
return 0;
|
||||
|
||||
return StlUtils::ToInteger(str);
|
||||
}
|
||||
|
||||
template<> const size_t Parse<size_t>(const std::string& str)
|
||||
{
|
||||
return (size_t)StlUtils::ToInteger(str);
|
||||
}
|
||||
|
||||
template<> const double Parse<double>(const std::string& str)
|
||||
{
|
||||
return StlUtils::ToDouble(str);
|
||||
}
|
||||
|
||||
template<> const std::wstring Parse<std::wstring>(const std::string& str)
|
||||
{
|
||||
return Encoding::utf82unicode(str);
|
||||
}
|
||||
|
||||
template<> const bool Parse<bool>(const std::wstring& str)
|
||||
{
|
||||
return str == L"true" || str == L"1" || str == L"t" || str == L"on";
|
||||
}
|
||||
|
||||
template<> const int Parse<int>(const std::wstring& str)
|
||||
{
|
||||
return StlUtils::ToInteger(str);
|
||||
}
|
||||
|
||||
template<> const size_t Parse<size_t>(const std::wstring& str)
|
||||
{
|
||||
return (size_t)StlUtils::ToInteger(str);
|
||||
}
|
||||
|
||||
|
||||
template<> const double Parse<double>(const std::wstring& str)
|
||||
{
|
||||
return StlUtils::ToDouble(str);
|
||||
}
|
||||
|
||||
template<> const std::string Parse<std::string>(const std::wstring& str)
|
||||
{
|
||||
return Encoding::unicode2utf8(str);
|
||||
}
|
||||
|
||||
const int HexChar2Int(const char value)
|
||||
{
|
||||
if (value >= '0' && value <= '9')
|
||||
return value - '0';
|
||||
if (value >= 'a' && value <= 'f')
|
||||
return 10 + value - 'a';
|
||||
if (value >= 'A' && value <= 'F')
|
||||
return 10 + value - 'A';
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int HexString2Int(const std::string& value)
|
||||
{
|
||||
int summa = 0;
|
||||
for (int i = 0; i != value.size(); ++i)
|
||||
summa += HexChar2Int(value[i]) << (4 * (value.size() - i - 1));
|
||||
|
||||
return summa;
|
||||
}
|
||||
|
||||
const int HexString2IntW(const std::wstring& value)
|
||||
{
|
||||
int summa = 0;
|
||||
for (int i = 0; i != value.size(); ++i)
|
||||
summa += HexChar2Int(value[i]) << (4 * (value.size() - i - 1));
|
||||
|
||||
return summa;
|
||||
}
|
||||
57
ActiveX/Common/ASCDocxFormat/Source/Utility/Parse.h
Normal file
57
ActiveX/Common/ASCDocxFormat/Source/Utility/Parse.h
Normal 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 UTILITY_PARSE_INCLUDE_H_
|
||||
#define UTILITY_PARSE_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
template<typename T> const T Parse(const std::string& str) {return str;}
|
||||
template<typename T> const T Parse(const std::wstring& str) {return str;}
|
||||
|
||||
template<> const bool Parse<bool>(const std::string& str);
|
||||
template<> const int Parse<int>(const std::string& str);
|
||||
template<> const size_t Parse<size_t>(const std::string& str);
|
||||
template<> const double Parse<double>(const std::string& str);
|
||||
template<> const std::wstring Parse<std::wstring>(const std::string& str);
|
||||
|
||||
template<> const bool Parse<bool>(const std::wstring& str);
|
||||
template<> const int Parse<int>(const std::wstring& str);
|
||||
template<> const size_t Parse<size_t>(const std::wstring& str);
|
||||
template<> const double Parse<double>(const std::wstring& str);
|
||||
template<> const std::string Parse<std::string>(const std::wstring& str);
|
||||
|
||||
const int HexChar2Int(const char value);
|
||||
const int HexString2Int(const std::string& value);
|
||||
const int HexString2IntW(const std::wstring& value);
|
||||
|
||||
#endif // UTILITY_PARSE_INCLUDE_H_
|
||||
211
ActiveX/Common/ASCDocxFormat/Source/Utility/Setter.h
Normal file
211
ActiveX/Common/ASCDocxFormat/Source/Utility/Setter.h
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* (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 UTILITY_SETTER_INCLUDE_H_
|
||||
#define UTILITY_SETTER_INCLUDE_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include "CallTraits.h"
|
||||
|
||||
namespace setter
|
||||
{
|
||||
template<typename Type> class base_setter
|
||||
{
|
||||
protected:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
|
||||
public:
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class none
|
||||
{
|
||||
public:
|
||||
template<typename T, typename E>
|
||||
void operator()(T, E)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class simple : private base_setter<Type>
|
||||
{
|
||||
public:
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
};
|
||||
|
||||
class read_only
|
||||
{
|
||||
public:
|
||||
template<typename T, typename E>
|
||||
void operator()(T, E)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class only_positive : private base_setter<Type>
|
||||
{
|
||||
public:
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
_value = value < static_cast<Type>(0) ? static_cast<Type>(0) : value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Type, int min_value = 0, int max_value = min_value>
|
||||
class between : private base_setter<Type>
|
||||
{
|
||||
public:
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
if (value < min_value)
|
||||
_value = min_value;
|
||||
else if (max_value < value)
|
||||
_value = max_value;
|
||||
else
|
||||
_value = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Type, int min_value = 0, int max_value = min_value>
|
||||
class between_throw : private base_setter<Type>
|
||||
{
|
||||
public:
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
if (value < min_value)
|
||||
throw std::range_error("between error");
|
||||
else if (max_value < value)
|
||||
throw std::range_error("between error");
|
||||
else
|
||||
_value = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Type>
|
||||
class interval : private base_setter<Type>
|
||||
{
|
||||
public:
|
||||
interval(Parameter min, Parameter max)
|
||||
: _min(min),
|
||||
_max(max)
|
||||
{
|
||||
if (_max < _min)
|
||||
std::swap(_min, _max);
|
||||
}
|
||||
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
if (value < _min)
|
||||
_value = _min;
|
||||
else if (_max < value)
|
||||
_value = _max;
|
||||
else
|
||||
_value = value;
|
||||
}
|
||||
|
||||
private:
|
||||
Type _min;
|
||||
Type _max;
|
||||
};
|
||||
|
||||
|
||||
template<typename Type>
|
||||
class interval_throw : private base_setter<Type>
|
||||
{
|
||||
public:
|
||||
interval_throw(Parameter min, Parameter max)
|
||||
: _min(min),
|
||||
_max(max)
|
||||
{
|
||||
if (_max < _min)
|
||||
std::swap(_min, _max);
|
||||
}
|
||||
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
if (value < _min)
|
||||
throw std::range_error("interval error");
|
||||
else if (_max < value)
|
||||
throw std::range_error("interval error");
|
||||
else
|
||||
_value = value;
|
||||
}
|
||||
|
||||
private:
|
||||
Type _min;
|
||||
Type _max;
|
||||
};
|
||||
|
||||
|
||||
template<typename Type>
|
||||
class from : private base_setter<Type>
|
||||
{
|
||||
protected:
|
||||
void add(Parameter value)
|
||||
{
|
||||
_list.insert(value);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual const Type no_find() const = 0;
|
||||
|
||||
public:
|
||||
void operator()(Type& _value, Parameter value)
|
||||
{
|
||||
if (_list.find(value) != _list.end())
|
||||
_value = value;
|
||||
else
|
||||
_value = no_find();
|
||||
}
|
||||
|
||||
private:
|
||||
std::set<Type> _list;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // UTILITY_SETTER_INCLUDE_H_
|
||||
178
ActiveX/Common/ASCDocxFormat/Source/Utility/ToString.cpp
Normal file
178
ActiveX/Common/ASCDocxFormat/Source/Utility/ToString.cpp
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "ToString.h"
|
||||
#include "Encoding.h"
|
||||
#include "ASCStlUtils.h"
|
||||
|
||||
const std::string ToString(const bool value)
|
||||
{
|
||||
if (value)
|
||||
return "true";
|
||||
return "false";
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const bool value)
|
||||
{
|
||||
if (value)
|
||||
return L"true";
|
||||
return L"false";
|
||||
}
|
||||
|
||||
const std::string ToString(const int value)
|
||||
{
|
||||
return StlUtils::IntToString(value);
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const int value)
|
||||
{
|
||||
return StlUtils::IntToWideString(value);
|
||||
}
|
||||
|
||||
const std::string ToString(const size_t value)
|
||||
{
|
||||
return StlUtils::IntToString(value);
|
||||
}
|
||||
|
||||
const std::string ToString(const std::wstring& value)
|
||||
{
|
||||
return Encoding::unicode2utf8(value);
|
||||
}
|
||||
|
||||
const std::string ToString(const wchar_t* value)
|
||||
{
|
||||
return Encoding::unicode2utf8(value);
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const size_t value)
|
||||
{
|
||||
return StlUtils::IntToWideString(value);
|
||||
}
|
||||
|
||||
const std::string ToString(const double value)
|
||||
{
|
||||
return StlUtils::DoubleToString(value);
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const double value)
|
||||
{
|
||||
return StlUtils::DoubleToWideString(value);
|
||||
}
|
||||
|
||||
const std::string ToString(const std::string& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const std::wstring& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const std::string& value)
|
||||
{
|
||||
return Encoding::utf82unicode(value);
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const char* value)
|
||||
{
|
||||
return Encoding::utf82unicode(value);
|
||||
}
|
||||
|
||||
const std::string ToString(const char* value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
const std::wstring ToWString(const wchar_t* value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
const std::string ToUpper(const char* value)
|
||||
{
|
||||
return ToUpper(ToString(value));
|
||||
}
|
||||
|
||||
const std::string ToUpper(const std::string& value)
|
||||
{
|
||||
std::string result = "";
|
||||
result.reserve(value.size());
|
||||
for(size_t i = 0; i < value.size(); i++)
|
||||
result += char(towupper(value[i]));
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::wstring ToUpper(const wchar_t* value)
|
||||
{
|
||||
return ToUpper(ToWString(value));
|
||||
}
|
||||
|
||||
const std::wstring ToUpper(const std::wstring& value)
|
||||
{
|
||||
std::wstring result = L"";
|
||||
result.reserve(value.size());
|
||||
for(size_t i = 0; i < value.size(); i++)
|
||||
result += wchar_t(towupper(value[i]));
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::string ToLower(const char* value)
|
||||
{
|
||||
return ToLower(ToString(value));
|
||||
}
|
||||
|
||||
const std::string ToLower(std::string value)
|
||||
{
|
||||
std::string result = "";
|
||||
result.reserve(value.size());
|
||||
for(size_t i = 0; i < value.size(); i++)
|
||||
result += char(towlower(value[i]));
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::wstring ToLower(const wchar_t* value)
|
||||
{
|
||||
return ToLower(ToWString(value));
|
||||
}
|
||||
|
||||
const std::wstring ToLower(std::wstring value)
|
||||
{
|
||||
std::wstring result = L"";
|
||||
result.reserve(value.size());
|
||||
for(size_t i = 0; i < value.size(); i++)
|
||||
result += wchar_t(towlower(value[i]));
|
||||
return result;
|
||||
}
|
||||
71
ActiveX/Common/ASCDocxFormat/Source/Utility/ToString.h
Normal file
71
ActiveX/Common/ASCDocxFormat/Source/Utility/ToString.h
Normal 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 UTILITY_TO_STRING_INCLUDE_H_
|
||||
#define UTILITY_TO_STRING_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
#include <wchar.h>
|
||||
|
||||
const std::string ToString(const bool value);
|
||||
const std::string ToString(const int value);
|
||||
const std::string ToString(const size_t value);
|
||||
const std::string ToString(const double value);
|
||||
const std::string ToString(const std::string& value);
|
||||
const std::string ToString(const char* value);
|
||||
const std::string ToString(const std::wstring& value);
|
||||
const std::string ToString(const wchar_t* value);
|
||||
|
||||
const std::wstring ToWString(const bool value);
|
||||
const std::wstring ToWString(const int value);
|
||||
const std::wstring ToWString(const size_t value);
|
||||
const std::wstring ToWString(const double value);
|
||||
const std::wstring ToWString(const std::string& value);
|
||||
const std::wstring ToWString(const char* value);
|
||||
const std::wstring ToWString(const std::wstring& value);
|
||||
const std::wstring ToWString(const wchar_t* value);
|
||||
|
||||
template<class T> const std::string ToString(const T& value) {return value.ToString();}
|
||||
template<class T> const std::wstring ToWString(const T& value) {return value.ToWString();}
|
||||
|
||||
|
||||
const std::string ToUpper(const char* value);
|
||||
const std::string ToUpper(const std::string& value);
|
||||
const std::wstring ToUpper(const wchar_t* value);
|
||||
const std::wstring ToUpper(const std::wstring& value);
|
||||
|
||||
const std::string ToLower(const char* value);
|
||||
const std::string ToLower(std::string value);
|
||||
const std::wstring ToLower(const wchar_t* value);
|
||||
const std::wstring ToLower(std::wstring value);
|
||||
|
||||
#endif // UTILITY_TO_STRING_INCLUDE_H_
|
||||
348
ActiveX/Common/ASCDocxFormat/Source/Utility/TxtFile.cpp
Normal file
348
ActiveX/Common/ASCDocxFormat/Source/Utility/TxtFile.cpp
Normal file
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "TxtFile.h"
|
||||
|
||||
#include <streambuf>
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "Utility.h"
|
||||
#include "Exception/log_runtime_error.h"
|
||||
#include "codecvt.h"
|
||||
|
||||
static const std::string BadSymbols = "\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19";
|
||||
|
||||
TxtFile::TxtFile(const OOX::CPath& path) : m_path(path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const std::list<std::string> TxtFile::readAnsi() const
|
||||
{
|
||||
std::ifstream file(m_path.GetFilename());
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
std::list<std::string> result;
|
||||
while (!file.eof() && EOF != file.peek() )
|
||||
{
|
||||
std::string str;
|
||||
std::getline(file, str);
|
||||
|
||||
size_t pos = str.find_first_of(BadSymbols);
|
||||
while(pos != str.npos)
|
||||
{
|
||||
str.erase(pos, 1);
|
||||
pos = str.find_first_of(BadSymbols, pos);
|
||||
}
|
||||
|
||||
|
||||
result.push_back(str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const std::list<std::wstring> TxtFile::readUnicode() const
|
||||
{
|
||||
std::wifstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
file.imbue(std::locale(std::locale(), new ucs2_conversion()));
|
||||
std::list<std::wstring> result;
|
||||
|
||||
while (!file.eof())
|
||||
{
|
||||
std::wstring str;
|
||||
file.ignore();
|
||||
std::getline(file, str, L'\x0D');
|
||||
result.push_back(str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const std::list<std::wstring> TxtFile::readUnicodeWithOutBOM() const
|
||||
{
|
||||
std::wifstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
file.imbue(std::locale(std::locale(), new ucs2_conversion()));
|
||||
std::list<std::wstring> result;
|
||||
|
||||
while (!file.eof())
|
||||
{
|
||||
std::wstring str;
|
||||
std::getline(file, str, L'\x0D');
|
||||
file.ignore();
|
||||
result.push_back(str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const std::list<std::wstring> TxtFile::readBigEndian() const
|
||||
{
|
||||
std::wifstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
file.imbue(std::locale(std::locale(), new ube_conversion()));
|
||||
std::list<std::wstring> result;
|
||||
|
||||
while (!file.eof())
|
||||
{
|
||||
std::wstring str;
|
||||
file.ignore();
|
||||
std::getline(file, str, L'\x0D');
|
||||
result.push_back(str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const std::list<std::string> TxtFile::readUtf8() const
|
||||
{
|
||||
std::ifstream file(m_path.GetFilename());
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
std::list<std::string> result;
|
||||
file.ignore(3);
|
||||
|
||||
while (!file.eof())
|
||||
{
|
||||
std::string str;
|
||||
std::getline(file, str);
|
||||
result.push_back(str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const std::list<std::string> TxtFile::readUtf8withoutPref() const
|
||||
{
|
||||
std::ifstream file(m_path.GetFilename());
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
std::list<std::string> result;
|
||||
|
||||
while (!file.eof())
|
||||
{
|
||||
std::string str;
|
||||
std::getline(file, str);
|
||||
result.push_back(str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void TxtFile::writeAnsi(const std::list<std::string>& content) const
|
||||
{
|
||||
setAnsiStamp();
|
||||
std::ofstream file(m_path.GetFilename());
|
||||
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't create text file");
|
||||
|
||||
for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file << (*iter) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void TxtFile::writeUnicode(const std::list<std::wstring>& content) const
|
||||
{
|
||||
setUnicodeStamp();
|
||||
std::wofstream file(m_path.GetFilename(), std::ios_base::binary | std::ios_base::app);
|
||||
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't create text file");
|
||||
|
||||
file.imbue(std::locale(std::locale(), new ucs2_conversion()));
|
||||
|
||||
for (std::list<std::wstring>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file << (*iter) << L'\x0D' << L'\x0A';
|
||||
}
|
||||
}
|
||||
|
||||
void TxtFile::writeBigEndian(const std::list<std::wstring>& content) const
|
||||
{
|
||||
setBigEndianStamp();
|
||||
std::wofstream file(m_path.GetFilename(), std::ios_base::binary | std::ios_base::app);
|
||||
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't create text file");
|
||||
|
||||
file.imbue(std::locale(std::locale(), new ube_conversion()));
|
||||
|
||||
for (std::list<std::wstring>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file << (*iter) << L'\x0D' << L'\x0A';
|
||||
}
|
||||
}
|
||||
|
||||
void TxtFile::writeUtf8(const std::list<std::string>& content) const
|
||||
{
|
||||
setUtf8Stamp();
|
||||
std::ofstream file(m_path.GetFilename(), std::ios_base::app);
|
||||
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't create text file");
|
||||
|
||||
for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file << (*iter) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TxtFile::writeUtf8withoutPref(const std::list<std::string>& content) const
|
||||
{
|
||||
std::ofstream file(m_path.GetFilename());
|
||||
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't create text file");
|
||||
|
||||
for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
|
||||
{
|
||||
file << (*iter) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
const bool TxtFile::isAnsi() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool TxtFile::isUnicode() const
|
||||
{
|
||||
std::ifstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
char symbol;
|
||||
|
||||
file >> symbol;
|
||||
if (symbol != '\xFF')
|
||||
return false;
|
||||
|
||||
file >> symbol;
|
||||
if (symbol != '\xFE')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool TxtFile::isUnicodeWithOutBOM() const
|
||||
{
|
||||
std::ifstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
std::string str;
|
||||
std::getline(file, str, '\x0A');
|
||||
bool bUnicode = (str.find('\x0') != str.npos);
|
||||
|
||||
return bUnicode;
|
||||
}
|
||||
|
||||
const bool TxtFile::isBigEndian() const
|
||||
{
|
||||
std::ifstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
char symbol;
|
||||
|
||||
file >> symbol;
|
||||
if (symbol != '\xFE')
|
||||
return false;
|
||||
|
||||
file >> symbol;
|
||||
if (symbol != '\xFF')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool TxtFile::isUtf8() const
|
||||
{
|
||||
std::ifstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
if (file.bad())
|
||||
throw log_runtime_error("can't open text file");
|
||||
|
||||
char symbol;
|
||||
|
||||
file >> symbol;
|
||||
if (symbol != '\xEF')
|
||||
return false;
|
||||
|
||||
file >> symbol;
|
||||
if (symbol != '\xBB')
|
||||
return false;
|
||||
|
||||
file >> symbol;
|
||||
if (symbol != '\xBF')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TxtFile::setAnsiStamp() const
|
||||
{
|
||||
}
|
||||
|
||||
void TxtFile::setUnicodeStamp() const
|
||||
{
|
||||
std::wofstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
file << '\xFF' << '\xFE';
|
||||
}
|
||||
|
||||
void TxtFile::setBigEndianStamp() const
|
||||
{
|
||||
std::wofstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
file << '\xFE' << '\xFF';
|
||||
}
|
||||
|
||||
void TxtFile::setUtf8Stamp() const
|
||||
{
|
||||
std::wofstream file(m_path.GetFilename(), std::ios_base::binary);
|
||||
file << '\xEF' << '\xBB' << '\xBF';
|
||||
}
|
||||
78
ActiveX/Common/ASCDocxFormat/Source/Utility/TxtFile.h
Normal file
78
ActiveX/Common/ASCDocxFormat/Source/Utility/TxtFile.h
Normal 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 UTILITY_TXT_FILE_INCLUDE_H_
|
||||
#define UTILITY_TXT_FILE_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "..\..\..\..\Common\DocxFormat\Source\SystemUtility\SystemUtility.h"
|
||||
|
||||
class TxtFile
|
||||
{
|
||||
public:
|
||||
TxtFile(const OOX::CPath& path);
|
||||
|
||||
public:
|
||||
const std::list<std::string> readAnsi() const;
|
||||
const std::list<std::wstring> readUnicode() const;
|
||||
const std::list<std::wstring> readUnicodeWithOutBOM() const;
|
||||
const std::list<std::wstring> readBigEndian() const;
|
||||
const std::list<std::string> readUtf8() const;
|
||||
const std::list<std::string> readUtf8withoutPref() const;
|
||||
|
||||
public:
|
||||
void writeAnsi(const std::list<std::string>& content) const;
|
||||
void writeUnicode(const std::list<std::wstring>& content) const;
|
||||
void writeBigEndian(const std::list<std::wstring>& content) const;
|
||||
void writeUtf8(const std::list<std::string>& content) const;
|
||||
void writeUtf8withoutPref(const std::list<std::string>& content) const;
|
||||
|
||||
public:
|
||||
const bool isAnsi() const;
|
||||
const bool isUnicode() const;
|
||||
const bool isUnicodeWithOutBOM() const;
|
||||
const bool isBigEndian() const;
|
||||
const bool isUtf8() const;
|
||||
|
||||
private:
|
||||
void setAnsiStamp() const;
|
||||
void setUnicodeStamp() const;
|
||||
void setBigEndianStamp() const;
|
||||
void setUtf8Stamp() const;
|
||||
|
||||
private:
|
||||
OOX::CPath m_path;
|
||||
};
|
||||
|
||||
#endif // UTILITY_TXT_FILE_INCLUDE_H_
|
||||
1004
ActiveX/Common/ASCDocxFormat/Source/Utility/Unit.h
Normal file
1004
ActiveX/Common/ASCDocxFormat/Source/Utility/Unit.h
Normal file
File diff suppressed because it is too large
Load Diff
404
ActiveX/Common/ASCDocxFormat/Source/Utility/UniversalUnit.cpp
Normal file
404
ActiveX/Common/ASCDocxFormat/Source/Utility/UniversalUnit.cpp
Normal file
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "UniversalUnit.h"
|
||||
#include "ToString.h"
|
||||
|
||||
const double UniversalUnit::MminEmu = 1.0 / EmuinMm;
|
||||
const double UniversalUnit::CminEmu = 1.0 / EmuinCm;
|
||||
const double UniversalUnit::PtinEmu = 1.0 / EmuinPt;
|
||||
const double UniversalUnit::InchinEmu = 1.0 / EmuinInch;
|
||||
const double UniversalUnit::PercentforRead = 1.0 / PercentforWrite;
|
||||
const double UniversalUnit::DxinEmu = 1.0 / EmuinDx;
|
||||
|
||||
UniversalUnit::UniversalUnit()
|
||||
: m_value(0),
|
||||
Type(Emu),
|
||||
Precesion(3)
|
||||
{
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const int value)
|
||||
: m_value(static_cast<long>(value)),
|
||||
Type(Emu),
|
||||
Precesion(3)
|
||||
{
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const long value)
|
||||
: m_value(value),
|
||||
Type(Emu),
|
||||
Precesion(3)
|
||||
{
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const size_t value)
|
||||
: m_value(static_cast<long>(value)),
|
||||
Type(Emu),
|
||||
Precesion(3)
|
||||
{
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const double value)
|
||||
: m_value(static_cast<long>(value)),
|
||||
Type(Emu),
|
||||
Precesion(3)
|
||||
{
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const std::string& value)
|
||||
: Precesion(3)
|
||||
{
|
||||
fromString(value);
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const char* value)
|
||||
: Precesion(3)
|
||||
{
|
||||
fromString(value);
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const UniversalUnit& rhs)
|
||||
: m_value(rhs.m_value),
|
||||
Type(rhs.Type),
|
||||
Precesion(rhs.Precesion)
|
||||
{
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const UnitType type)
|
||||
: m_value(0),
|
||||
Type(type),
|
||||
Precesion(3)
|
||||
{
|
||||
}
|
||||
|
||||
UniversalUnit::UniversalUnit(const long value, const UnitType type)
|
||||
: m_value(toEmu(value, type)),
|
||||
Type(type),
|
||||
Precesion(3)
|
||||
{
|
||||
}
|
||||
|
||||
const UniversalUnit& UniversalUnit::operator =(const std::string& value)
|
||||
{
|
||||
fromString(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const UniversalUnit& UniversalUnit::operator =(const char* value)
|
||||
{
|
||||
fromString(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const UniversalUnit& UniversalUnit::operator =(const UniversalUnit& rhs)
|
||||
{
|
||||
m_value = rhs.m_value;
|
||||
if (Type == Emu)
|
||||
Type = rhs.Type;
|
||||
return *this;
|
||||
}
|
||||
|
||||
UniversalUnit::operator const double()const
|
||||
{
|
||||
return fromEmu();
|
||||
}
|
||||
|
||||
const bool UniversalUnit::operator ==(const UniversalUnit& rhs) const
|
||||
{
|
||||
return m_value == rhs.m_value;
|
||||
}
|
||||
|
||||
const bool UniversalUnit::operator !=(const UniversalUnit& rhs) const
|
||||
{
|
||||
return m_value != rhs.m_value;
|
||||
}
|
||||
|
||||
const bool UniversalUnit::operator > (const UniversalUnit& rhs) const
|
||||
{
|
||||
return m_value > rhs.m_value;
|
||||
}
|
||||
|
||||
const bool UniversalUnit::operator >=(const UniversalUnit& rhs) const
|
||||
{
|
||||
return m_value >= rhs.m_value;
|
||||
}
|
||||
|
||||
const bool UniversalUnit::operator < (const UniversalUnit& rhs) const
|
||||
{
|
||||
return m_value < rhs.m_value;
|
||||
}
|
||||
|
||||
const bool UniversalUnit::operator <=(const UniversalUnit& rhs) const
|
||||
{
|
||||
return m_value <= rhs.m_value;
|
||||
}
|
||||
|
||||
void UniversalUnit::apply(const UniversalUnit& unit)
|
||||
{
|
||||
if (Type == Percent)
|
||||
{
|
||||
m_value = static_cast<long>((double)unit.m_value * ((double)m_value * PercentforRead / 100.0));
|
||||
Type = unit.Type;
|
||||
}
|
||||
}
|
||||
|
||||
const double UniversalUnit::value(const UnitType& type) const
|
||||
{
|
||||
return fromEmu(m_value, type);
|
||||
}
|
||||
|
||||
|
||||
const std::string UniversalUnit::ToString() const
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
const long UniversalUnit::toEmu(const double value, const UnitType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case Mm:
|
||||
return static_cast<long>(value * EmuinMm);
|
||||
case Cm:
|
||||
return static_cast<long>(value * EmuinCm);
|
||||
case Pt:
|
||||
return static_cast<long>(value * EmuinPt);
|
||||
case Inch:
|
||||
return static_cast<long>(value * EmuinInch);
|
||||
case Percent:
|
||||
return static_cast<long>(value * PercentforWrite);
|
||||
case Multi:
|
||||
return static_cast<long>(value);
|
||||
case Dx:
|
||||
return static_cast<long>(value) * EmuinDx;
|
||||
default:
|
||||
return static_cast<long>(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const double UniversalUnit::fromEmu(const long value, const UnitType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case Mm:
|
||||
return value * MminEmu;
|
||||
case Cm:
|
||||
return value * CminEmu;
|
||||
case Pt:
|
||||
return value * PtinEmu;
|
||||
case Inch:
|
||||
return value * InchinEmu;
|
||||
case Percent:
|
||||
return value * PercentforRead;
|
||||
case Multi:
|
||||
return value;
|
||||
case Dx:
|
||||
return value * DxinEmu;
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UniversalUnit::toEmu(const double value)
|
||||
{
|
||||
m_value = toEmu(value, Type);
|
||||
}
|
||||
|
||||
|
||||
const double UniversalUnit::fromEmu() const
|
||||
{
|
||||
return fromEmu(m_value, Type);
|
||||
}
|
||||
|
||||
|
||||
void UniversalUnit::fromString(const std::string& str)
|
||||
{
|
||||
const size_t pos = str.find_first_not_of("-.0123456789");
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
Type = Emu;
|
||||
if (0 != str.length())
|
||||
m_value = static_cast<long>(atof(str.c_str()));
|
||||
else
|
||||
m_value = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string unit = str.substr(pos, str.size() - pos);
|
||||
double value;
|
||||
|
||||
if (0 != pos)
|
||||
value = atof(str.substr(0, pos).c_str());
|
||||
else
|
||||
value = 0.0;
|
||||
|
||||
if (unit == ToLower("mm"))
|
||||
Type = Mm;
|
||||
else if (unit == ToLower("cm"))
|
||||
Type = Cm;
|
||||
else if (unit == ToLower("pt"))
|
||||
Type = Pt;
|
||||
else if (unit == ToLower("in"))
|
||||
Type = Inch;
|
||||
else if (unit == "%")
|
||||
Type = Percent;
|
||||
else if (unit == "*")
|
||||
Type = Multi;
|
||||
else
|
||||
Type = Emu;
|
||||
|
||||
toEmu(value);
|
||||
}
|
||||
|
||||
const UniversalUnit UniversalUnit::operator -() const
|
||||
{
|
||||
UniversalUnit unit(-m_value);
|
||||
unit.Type = Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit& UniversalUnit::operator +=(const UniversalUnit& rhs)
|
||||
{
|
||||
m_value += rhs.m_value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const UniversalUnit& UniversalUnit::operator -=(const UniversalUnit& rhs)
|
||||
{
|
||||
m_value -= rhs.m_value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const UniversalUnit UniversalUnit::operator +(const UniversalUnit& rhs) const
|
||||
{
|
||||
UniversalUnit unit(m_value + rhs.m_value);
|
||||
unit.Type = Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit UniversalUnit::operator -(const UniversalUnit& rhs) const
|
||||
{
|
||||
UniversalUnit unit(m_value - rhs.m_value);
|
||||
unit.Type = Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator +(const double lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(UniversalUnit::toEmu(lhs, rhs.Type) + rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
|
||||
const UniversalUnit operator -(const double lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(UniversalUnit::toEmu(lhs, rhs.Type) - rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator *(const double lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(lhs * rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator /(const double lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(lhs / rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator +(const int lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(UniversalUnit::toEmu(lhs, rhs.Type) + rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator -(const int lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(UniversalUnit::toEmu(lhs, rhs.Type) - rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator *(const int lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(lhs * rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator /(const int lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(lhs / rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator +(const long lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(UniversalUnit::toEmu(lhs, rhs.Type) + rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator -(const long lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(UniversalUnit::toEmu(lhs, rhs.Type) - rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator *(const long lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(lhs * rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
const UniversalUnit operator /(const long lhs, const UniversalUnit& rhs)
|
||||
{
|
||||
UniversalUnit unit(lhs / rhs.m_value);
|
||||
unit.Type = rhs.Type;
|
||||
return unit;
|
||||
}
|
||||
200
ActiveX/Common/ASCDocxFormat/Source/Utility/UniversalUnit.h
Normal file
200
ActiveX/Common/ASCDocxFormat/Source/Utility/UniversalUnit.h
Normal 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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef UTILITY_UNIVERSAL_UNIT_INCLUDE_H_
|
||||
#define UTILITY_UNIVERSAL_UNIT_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
#include "property.h"
|
||||
#include "setter.h"
|
||||
|
||||
class UniversalUnit
|
||||
{
|
||||
public:
|
||||
enum UnitType {Emu, Cm, Mm, Inch, Pt, Percent, Multi, Dx};
|
||||
|
||||
public:
|
||||
UniversalUnit();
|
||||
UniversalUnit(const int value);
|
||||
UniversalUnit(const long value);
|
||||
UniversalUnit(const size_t value);
|
||||
UniversalUnit(const double value);
|
||||
|
||||
explicit UniversalUnit(const std::string& value);
|
||||
UniversalUnit(const char* value);
|
||||
UniversalUnit(const UniversalUnit& rhs);
|
||||
UniversalUnit(const UnitType type);
|
||||
UniversalUnit(const long value, const UnitType type);
|
||||
|
||||
template<typename T> const UniversalUnit& operator =(const T value) {toEmu(value); return *this;}
|
||||
const UniversalUnit& operator =(const std::string& value);
|
||||
const UniversalUnit& operator =(const char* value);
|
||||
const UniversalUnit& operator =(const UniversalUnit& rhs);
|
||||
|
||||
public:
|
||||
operator const double() const;
|
||||
|
||||
public:
|
||||
const bool operator ==(const UniversalUnit& rhs) const;
|
||||
const bool operator !=(const UniversalUnit& rhs) const;
|
||||
const bool operator > (const UniversalUnit& rhs) const;
|
||||
const bool operator >=(const UniversalUnit& rhs) const;
|
||||
const bool operator < (const UniversalUnit& rhs) const;
|
||||
const bool operator <=(const UniversalUnit& rhs) const;
|
||||
|
||||
template<typename T> const bool operator ==(const T value) const {return m_value == toEmu(value, Type);}
|
||||
template<typename T> const bool operator !=(const T value) const {return m_value != toEmu(value, Type);}
|
||||
template<typename T> const bool operator > (const T value) const {return m_value > toEmu(value, Type);}
|
||||
template<typename T> const bool operator >=(const T value) const {return m_value >= toEmu(value, Type);}
|
||||
template<typename T> const bool operator < (const T value) const {return m_value < toEmu(value, Type);}
|
||||
template<typename T> const bool operator <=(const T value) const {return m_value <= toEmu(value, Type);}
|
||||
|
||||
public:
|
||||
const UniversalUnit operator -() const;
|
||||
const UniversalUnit& operator +=(const UniversalUnit& rhs);
|
||||
const UniversalUnit& operator -=(const UniversalUnit& rhs);
|
||||
template<typename T> const UniversalUnit& operator +=(const T value) {m_value += toEmu(value, Type); return *this;}
|
||||
template<typename T> const UniversalUnit& operator -=(const T value) {m_value -= toEmu(value, Type); return *this;}
|
||||
template<typename T> const UniversalUnit& operator *=(const T value) {m_value *= value; return *this;}
|
||||
template<typename T> const UniversalUnit& operator /=(const T value) {m_value /= value; return *this;}
|
||||
|
||||
const UniversalUnit operator +(const UniversalUnit& rhs) const;
|
||||
const UniversalUnit operator -(const UniversalUnit& rhs) const;
|
||||
template<typename T> const UniversalUnit operator +(const T rhs) const;
|
||||
template<typename T> const UniversalUnit operator -(const T rhs) const;
|
||||
template<typename T> const UniversalUnit operator *(const T rhs) const;
|
||||
template<typename T> const UniversalUnit operator /(const T rhs) const;
|
||||
|
||||
friend const UniversalUnit operator +(const double lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator -(const double lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator *(const double lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator /(const double lhs, const UniversalUnit& rhs);
|
||||
|
||||
friend const UniversalUnit operator +(const int lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator -(const int lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator *(const int lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator /(const int lhs, const UniversalUnit& rhs);
|
||||
|
||||
friend const UniversalUnit operator +(const long lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator -(const long lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator *(const long lhs, const UniversalUnit& rhs);
|
||||
friend const UniversalUnit operator /(const long lhs, const UniversalUnit& rhs);
|
||||
|
||||
public:
|
||||
void apply(const UniversalUnit& unit);
|
||||
const double value(const UnitType& type) const;
|
||||
|
||||
public:
|
||||
const std::string ToString() const;
|
||||
|
||||
public:
|
||||
property<int> Precesion;
|
||||
property<UnitType> Type;
|
||||
|
||||
private:
|
||||
long m_value;
|
||||
|
||||
private:
|
||||
static const long toEmu(const double value, const UnitType type);
|
||||
static const double fromEmu(const long value, const UnitType type);
|
||||
|
||||
void toEmu(const double value);
|
||||
const double fromEmu() const;
|
||||
|
||||
private:
|
||||
void fromString(const std::string& str);
|
||||
|
||||
private:
|
||||
|
||||
#pragma warning(disable:4244)
|
||||
static const long EmuinMm = 72 / 2 * 1000;
|
||||
static const long EmuinCm = 72 / 2 * 1000 * 10;
|
||||
static const long EmuinPt = 1000 * 25.4 / 2;
|
||||
static const long EmuinInch = 72 / 2 * 1000 * 25.4;
|
||||
static const long EmuinDx = 1000 / 4 * 2.54;
|
||||
static const long PercentforWrite = 100;
|
||||
#pragma warning(default:4244)
|
||||
|
||||
static const double MminEmu;
|
||||
static const double CminEmu;
|
||||
static const double PtinEmu;
|
||||
static const double InchinEmu;
|
||||
static const double DxinEmu;
|
||||
static const double PercentforRead;
|
||||
};
|
||||
|
||||
|
||||
const UniversalUnit operator +(const double lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator -(const double lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator *(const double lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator /(const double lhs, const UniversalUnit& rhs);
|
||||
|
||||
const UniversalUnit operator +(const int lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator -(const int lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator *(const int lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator /(const int lhs, const UniversalUnit& rhs);
|
||||
|
||||
const UniversalUnit operator +(const long lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator -(const long lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator *(const long lhs, const UniversalUnit& rhs);
|
||||
const UniversalUnit operator /(const long lhs, const UniversalUnit& rhs);
|
||||
|
||||
|
||||
template<typename T> const UniversalUnit UniversalUnit::operator +(const T rhs) const
|
||||
{
|
||||
UniversalUnit unit(m_value + UniversalUnit::toEmu(rhs, Type));
|
||||
unit.Type = Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
template<typename T> const UniversalUnit UniversalUnit::operator -(const T rhs) const
|
||||
{
|
||||
UniversalUnit unit(m_value - UniversalUnit::toEmu(rhs, Type));
|
||||
unit.Type = Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
template<typename T> const UniversalUnit UniversalUnit::operator *(const T rhs) const
|
||||
{
|
||||
UniversalUnit unit(m_value * rhs);
|
||||
unit.Type = Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
template<typename T> const UniversalUnit UniversalUnit::operator /(const T rhs) const
|
||||
{
|
||||
UniversalUnit unit(m_value / rhs);
|
||||
unit.Type = Type;
|
||||
return unit;
|
||||
}
|
||||
|
||||
#endif // UTILITY_UNIVERSAL_UNIT_INCLUDE_H_
|
||||
78
ActiveX/Common/ASCDocxFormat/Source/Utility/Utility.h
Normal file
78
ActiveX/Common/ASCDocxFormat/Source/Utility/Utility.h
Normal 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 UTILITY_UTILITY_INCLUDE_H_
|
||||
#define UTILITY_UTILITY_INCLUDE_H_
|
||||
|
||||
#include "DateTime.h"
|
||||
#include "Parse.h"
|
||||
#include "ToString.h"
|
||||
#include "Unit.h"
|
||||
#include "Encoding.h"
|
||||
#include "TxtFile.h"
|
||||
#include "UniversalUnit.h"
|
||||
|
||||
template<typename Out, typename In>
|
||||
static const std::vector<Out> transform(const std::vector<In>& lines, const Out(*func)(const In&))
|
||||
{
|
||||
std::vector<Out> result;
|
||||
for (std::vector<Out>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
|
||||
{
|
||||
result.push_back(func(*iter));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Out, typename In>
|
||||
static const std::list<Out> transform(const std::list<In>& lines, const Out(*func)(const In&))
|
||||
{
|
||||
std::list<Out> result;
|
||||
for (std::vector<Out>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
|
||||
{
|
||||
result.push_back(func(*iter));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Out, typename In, typename In2>
|
||||
static const std::list<Out> transform2(const std::list<In>& lines, const int codepage, const Out(*func)(const In&, const In2 codePage))
|
||||
{
|
||||
std::list<Out> result;
|
||||
for (std::vector<Out>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
|
||||
{
|
||||
result.push_back(func(*iter, codepage));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // UTILITY_UTILITY_INCLUDE_H_
|
||||
229
ActiveX/Common/ASCDocxFormat/Source/Utility/codecvt.cpp
Normal file
229
ActiveX/Common/ASCDocxFormat/Source/Utility/codecvt.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "codecvt.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ucs2_conversion::result
|
||||
ucs2_conversion::do_in(mbstate_t&,
|
||||
const char* from, const char* from_end, const char*& from_next,
|
||||
wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) const
|
||||
{
|
||||
const int max_input = (from_end - from) & ~1;
|
||||
const int max_output = (to_limit - to);
|
||||
int count = min(max_input / 2, max_output);
|
||||
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for (;count--; from_next += 2, ++to_next)
|
||||
{
|
||||
unsigned char c1 = *from_next;
|
||||
unsigned char c2 = *(from_next + 1);
|
||||
*to_next = c1 | c2 << 8;
|
||||
}
|
||||
|
||||
if (to_next == to && from_next == from_end - 1)
|
||||
return partial;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
ucs2_conversion::result
|
||||
ucs2_conversion::do_out(mbstate_t&,
|
||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||
char* to, char* to_limit, char*& to_next) const
|
||||
{
|
||||
const int max_input = (from_end - from);
|
||||
const int max_output = (to_limit - to) & ~1;
|
||||
int count = min(max_input, max_output / 2);
|
||||
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for (;count--; ++from_next, to_next += 2)
|
||||
{
|
||||
*(to_next + 0) = *from_next & 0xFF;
|
||||
*(to_next + 1) = *from_next >> 8 & 0xFF;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ube_conversion::result
|
||||
ube_conversion::do_in(mbstate_t&,
|
||||
const char* from, const char* from_end, const char*& from_next,
|
||||
wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) const
|
||||
{
|
||||
const int max_input = (from_end - from) & ~1;
|
||||
const int max_output = (to_limit - to);
|
||||
int count = min(max_input / 2, max_output);
|
||||
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for (;count--; from_next += 2, ++to_next)
|
||||
{
|
||||
unsigned char c1 = *from_next;
|
||||
unsigned char c2 = *(from_next + 1);
|
||||
*to_next = c2 | c1 << 8;
|
||||
}
|
||||
|
||||
if (to_next == to && from_next == from_end - 1)
|
||||
return partial;
|
||||
return ok;
|
||||
}
|
||||
|
||||
ube_conversion::result
|
||||
ube_conversion::do_out(mbstate_t&,
|
||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||
char* to, char* to_limit, char*& to_next) const
|
||||
{
|
||||
const int max_input = (from_end - from);
|
||||
const int max_output = (to_limit - to) & ~1;
|
||||
int count = min(max_input, max_output / 2);
|
||||
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for (;count--; ++from_next, to_next += 2)
|
||||
{
|
||||
*(to_next + 1) = *from_next & 0xFF;
|
||||
*(to_next + 0) = *from_next >> 8 & 0xFF;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
utf8_conversion::result
|
||||
utf8_conversion::do_in(mbstate_t&,
|
||||
const char* from, const char* from_end, const char*& from_next,
|
||||
wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) const
|
||||
{
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for(; to_next < to_limit && from_next < from_end; ++to_next)
|
||||
{
|
||||
if (static_cast<unsigned char>(*from_next) < 0x80)
|
||||
{
|
||||
*to_next = static_cast<unsigned char>(*from_next++);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int zero_bit_pos = most_signifant_bit_position(~*from_next);
|
||||
int extra_bytes = 7 - zero_bit_pos;
|
||||
|
||||
if (from_end - from_next < extra_bytes + 1)
|
||||
return partial;
|
||||
|
||||
*to_next = static_cast<unsigned char>(*from_next++) & ((1 << zero_bit_pos - 1) - 1);
|
||||
for (;extra_bytes--; ++from_next)
|
||||
{
|
||||
*to_next = *to_next << 6 | static_cast<unsigned char>(*from_next) & 63;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
utf8_conversion::result
|
||||
utf8_conversion::do_out(mbstate_t&,
|
||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||
char* to, char* to_limit, char*& to_next) const
|
||||
{
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for (;from_next < from_end; ++from_next)
|
||||
{
|
||||
const unsigned symbol = *from_next;
|
||||
|
||||
if (symbol < 0x7F)
|
||||
{
|
||||
if (to_next < to_limit)
|
||||
*to_next++ = static_cast<unsigned char>(symbol);
|
||||
else
|
||||
return ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
const size_t msb_pos = most_signifant_bit_position(symbol);
|
||||
int extra_bytes = msb_pos / 6;
|
||||
|
||||
if (to_limit - to_next >= extra_bytes + 1)
|
||||
{
|
||||
*to_next = static_cast<unsigned char>(0xFF80 >> extra_bytes);
|
||||
*to_next++ |= take_6_bits(symbol, extra_bytes * 6);
|
||||
|
||||
for(;extra_bytes--;)
|
||||
*to_next++ = 0x80 | take_6_bits(symbol, extra_bytes * 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
const unsigned char
|
||||
utf8_conversion::take_6_bits(const int unsigned value, const size_t right_position) const
|
||||
{
|
||||
return (value >> right_position) & 63;
|
||||
}
|
||||
|
||||
|
||||
const size_t
|
||||
utf8_conversion::most_signifant_bit_position(const unsigned int value) const
|
||||
{
|
||||
size_t result = 0;
|
||||
size_t half = 16;
|
||||
|
||||
for(; half > 0; half >>= 1)
|
||||
{
|
||||
if (1u << (result + half) <= value )
|
||||
result += half;
|
||||
}
|
||||
return result + 1;
|
||||
}
|
||||
101
ActiveX/Common/ASCDocxFormat/Source/Utility/codecvt.h
Normal file
101
ActiveX/Common/ASCDocxFormat/Source/Utility/codecvt.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* (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 UTILITY_CODECVT_INCLUDE_H_
|
||||
#define UTILITY_CODECVT_INCLUDE_H_
|
||||
|
||||
|
||||
#include <locale>
|
||||
|
||||
|
||||
|
||||
class ucs2_conversion : public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
{
|
||||
protected:
|
||||
result do_in(std::mbstate_t& state,
|
||||
const char* from, const char* from_end, const char*& from_next,
|
||||
wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) const;
|
||||
|
||||
result do_out(std::mbstate_t& state,
|
||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||
char* to, char* to_limit, char*& to_next) const;
|
||||
|
||||
bool do_always_noconv() const throw() { return false; }
|
||||
int do_encoding() const throw() { return 2; }
|
||||
};
|
||||
|
||||
|
||||
class ube_conversion : public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
{
|
||||
protected:
|
||||
result do_in(std::mbstate_t& state,
|
||||
const char* from, const char* from_end, const char*& from_next,
|
||||
wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) const;
|
||||
|
||||
result do_out(std::mbstate_t& state,
|
||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||
char* to, char* to_limit, char*& to_next) const;
|
||||
|
||||
bool do_always_noconv() const throw() { return false; }
|
||||
int do_encoding() const throw() { return 2; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class utf8_conversion : public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
{
|
||||
protected:
|
||||
result do_in(std::mbstate_t& state,
|
||||
const char* from, const char* from_end, const char*& from_next,
|
||||
wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) const;
|
||||
|
||||
result in(std::mbstate_t& state,
|
||||
const char* from, const char* from_end, const char*& from_next,
|
||||
wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) const;
|
||||
|
||||
result do_out(std::mbstate_t& state,
|
||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||
char* to, char* to_limit, char*& to_next) const;
|
||||
|
||||
result out(std::mbstate_t& state,
|
||||
const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
|
||||
char* to, char* to_limit, char*& to_next) const;
|
||||
|
||||
bool do_always_noconv() const throw() { return false; }
|
||||
int do_encoding() const throw() { return 2; }
|
||||
|
||||
private:
|
||||
const unsigned char take_6_bits(const unsigned int value, const size_t right_position) const;
|
||||
const size_t most_signifant_bit_position(const unsigned int value) const;
|
||||
};
|
||||
|
||||
#endif // UTILITY_CODECVT_INCLUDE_H_
|
||||
282
ActiveX/Common/ASCDocxFormat/Source/Utility/nullable.h
Normal file
282
ActiveX/Common/ASCDocxFormat/Source/Utility/nullable.h
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* (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 UTILITY_NULLABLE_INCLUDE_H_
|
||||
#define UTILITY_NULLABLE_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "CallTraits.h"
|
||||
#include "Exception/not_init_nullable.h"
|
||||
|
||||
#include "../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
|
||||
|
||||
|
||||
|
||||
template<typename T> class nullable__
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<T>::param_type Parameter;
|
||||
|
||||
private:
|
||||
|
||||
template<class T, bool big_type> class InternalNullable
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<T>::param_type Parameter;
|
||||
|
||||
public:
|
||||
InternalNullable() {}
|
||||
InternalNullable(Parameter value) : _value(new T(value)) {}
|
||||
|
||||
inline void operator =(Parameter value) { _value.reset(new T(value));}
|
||||
inline void operator =(const nullable__<T>& value)
|
||||
{
|
||||
if (value.is_init())
|
||||
_value.reset(new T(value));
|
||||
else
|
||||
_value = NSCommon::smart_ptr<T>();
|
||||
}
|
||||
|
||||
inline Parameter get() const {return *_value;}
|
||||
inline Parameter get_value_or(Parameter value) const {return is_init() ? get() : value;}
|
||||
|
||||
|
||||
inline T const* get_ptr() const {return _value.operator->();}
|
||||
inline T* get_ptr() {return _value.operator->();}
|
||||
|
||||
inline T const* operator->() const {return _value.operator->();}
|
||||
inline T* operator->() {return _value.operator->();}
|
||||
|
||||
inline const T& operator*() const {return (_value.operator*());}
|
||||
inline T& operator*() {return (_value.operator*());}
|
||||
|
||||
inline const bool is_init() const {return _value.is_init();}
|
||||
inline void reset() {_value.reset();}
|
||||
|
||||
private:
|
||||
NSCommon::smart_ptr<T> _value;
|
||||
};
|
||||
|
||||
template<class T> class InternalNullable<T, false>
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<T>::param_type Parameter;
|
||||
|
||||
public:
|
||||
InternalNullable() {}
|
||||
InternalNullable(Parameter value) : _value(new T(value)) {}
|
||||
|
||||
inline void operator =(Parameter value) {_value = value;}
|
||||
inline void operator =(const nullable__<T>& value)
|
||||
{
|
||||
if (value.is_init())
|
||||
_value.reset(new T(value));
|
||||
else
|
||||
_value = NSCommon::smart_ptr<T>();
|
||||
}
|
||||
inline Parameter get() const {return *_value;}
|
||||
inline Parameter get_value_or(Parameter value) const {return is_init() ? get() : value;}
|
||||
|
||||
inline T const* get_ptr() const {return _value.operator->();}
|
||||
inline T* get_ptr() {return _value.operator->();}
|
||||
|
||||
inline T const* operator->() const {return _value.operator->();}
|
||||
inline T* operator->() {return _value.operator->();}
|
||||
|
||||
inline const T& operator*() const {return (_value.operator*());}
|
||||
inline T& operator*() {return (_value.operator*());}
|
||||
|
||||
inline const bool is_init() const {return _value.is_init();}
|
||||
inline void reset() {_value.reset();}
|
||||
|
||||
private:
|
||||
|
||||
NSCommon::smart_ptr<T> _value;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
nullable__() {}
|
||||
nullable__(Parameter value) : _value(value) {}
|
||||
|
||||
template<typename U>
|
||||
const nullable__<T>& operator =(const U& value)
|
||||
{
|
||||
return ::nullable_setter(*this, value);
|
||||
}
|
||||
template<typename U>
|
||||
const nullable__<T>& nullable_setter(const U& value)
|
||||
{
|
||||
_value = static_cast<T>(value);
|
||||
return *this;
|
||||
}
|
||||
inline const nullable__<T>& nullable_setter(const nullable__<T>& value)
|
||||
{
|
||||
_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline operator Parameter() const {return _value.get();}
|
||||
|
||||
inline Parameter get() const
|
||||
{
|
||||
if (!is_init())
|
||||
throw not_init_nullable();
|
||||
return _value.get();
|
||||
}
|
||||
|
||||
inline Parameter get_value_or(Parameter value) const
|
||||
{
|
||||
return _value.get_value_or(value);
|
||||
}
|
||||
|
||||
inline const T get_value_or_default() const
|
||||
{
|
||||
return get_value_or(T());
|
||||
}
|
||||
|
||||
inline T const* operator->() const
|
||||
{
|
||||
if (!is_init())
|
||||
throw not_init_nullable();
|
||||
return _value.get_ptr();
|
||||
}
|
||||
|
||||
inline T* operator->()
|
||||
{
|
||||
if (!is_init())
|
||||
throw not_init_nullable();
|
||||
return _value.get_ptr();
|
||||
}
|
||||
|
||||
inline T const* get_ptr() const
|
||||
{
|
||||
if (!is_init())
|
||||
throw not_init_nullable();
|
||||
return _value.get_ptr();
|
||||
}
|
||||
|
||||
inline T* get_ptr()
|
||||
{
|
||||
if (!is_init())
|
||||
throw not_init_nullable();
|
||||
return _value.get_ptr();
|
||||
}
|
||||
|
||||
inline T const& operator*() const
|
||||
{
|
||||
if (!is_init())
|
||||
throw not_init_nullable();
|
||||
return *_value;
|
||||
}
|
||||
|
||||
inline T& operator*()
|
||||
{
|
||||
if (!is_init())
|
||||
throw not_init_nullable();
|
||||
return *_value;
|
||||
}
|
||||
|
||||
inline const bool is_init() const
|
||||
{
|
||||
return _value.is_init();
|
||||
}
|
||||
|
||||
inline void reset()
|
||||
{
|
||||
_value.reset();
|
||||
}
|
||||
|
||||
inline void init()
|
||||
{
|
||||
if (!is_init())
|
||||
_value = T();
|
||||
}
|
||||
|
||||
inline const std::string ToString() const
|
||||
{
|
||||
return ::ToString(get());
|
||||
}
|
||||
|
||||
inline const bool operator ==(nullable__<T> const& rhs) const {return _value.get() == rhs._value.get();}
|
||||
inline const bool operator !=(nullable__<T> const& rhs) const {return _value.get() != rhs._value.get();}
|
||||
inline const bool operator < (nullable__<T> const& rhs) const {return _value.get() < rhs._value.get();}
|
||||
inline const bool operator > (nullable__<T> const& rhs) const {return _value.get() > rhs._value.get();}
|
||||
inline const bool operator <=(nullable__<T> const& rhs) const {return _value.get() <= rhs._value.get();}
|
||||
inline const bool operator >=(nullable__<T> const& rhs) const {return _value.get() >= rhs._value.get();}
|
||||
|
||||
inline const bool operator ==(Parameter rhs) const {return _value.get() == rhs;}
|
||||
inline const bool operator !=(Parameter rhs) const {return _value.get() != rhs;}
|
||||
inline const bool operator < (Parameter rhs) const {return _value.get() < rhs;}
|
||||
inline const bool operator > (Parameter rhs) const {return _value.get() > rhs;}
|
||||
inline const bool operator <=(Parameter rhs) const {return _value.get() <= rhs;}
|
||||
inline const bool operator >=(Parameter rhs) const {return _value.get() >= rhs;}
|
||||
|
||||
template<typename T> const bool operator ==(const T rhs) const {return _value.get() == rhs;}
|
||||
template<typename T> const bool operator !=(const T rhs) const {return _value.get() != rhs;}
|
||||
template<typename T> const bool operator < (const T rhs) const {return _value.get() < rhs;}
|
||||
template<typename T> const bool operator > (const T rhs) const {return _value.get() > rhs;}
|
||||
template<typename T> const bool operator <=(const T rhs) const {return _value.get() <= rhs;}
|
||||
template<typename T> const bool operator >=(const T rhs) const {return _value.get() >= rhs;}
|
||||
|
||||
private:
|
||||
|
||||
static const int size_of_big_object = 128;
|
||||
|
||||
InternalNullable<T, sizeof(T) / (size_of_big_object + 1) >= 1> _value;
|
||||
};
|
||||
|
||||
template<class T> const bool operator== (const T x, nullable__<T> const& y) {return y == x;}
|
||||
template<class T> const bool operator!= (const T x, nullable__<T> const& y) {return y != x;}
|
||||
template<class T> const bool operator< (const T x, nullable__<T> const& y) {return y >= x;}
|
||||
template<class T> const bool operator> (const T x, nullable__<T> const& y) {return y <= x;}
|
||||
template<class T> const bool operator<= (const T x, nullable__<T> const& y) {return y > x;}
|
||||
template<class T> const bool operator>= (const T x, nullable__<T> const& y) {return y < x;}
|
||||
template<typename V, class T> const bool operator ==(const V x, nullable__<T> const& y) {return y == x;}
|
||||
template<typename V, class T> const bool operator !=(const V x, nullable__<T> const& y) {return y != x;}
|
||||
template<typename V, class T> const bool operator < (const V x, nullable__<T> const& y) {return y < x;}
|
||||
template<typename V, class T> const bool operator > (const V x, nullable__<T> const& y) {return y > x;}
|
||||
template<typename V, class T> const bool operator <=(const V x, nullable__<T> const& y) {return y <= x;}
|
||||
template<typename V, class T> const bool operator >=(const V x, nullable__<T> const& y) {return y >= x;}
|
||||
|
||||
template<typename T, typename U> const nullable__<T>& nullable_setter(nullable__<T>& lhs, const U& rhs)
|
||||
{
|
||||
return lhs.nullable_setter(rhs);
|
||||
}
|
||||
|
||||
template<typename T> const std::string ToString(const nullable__<T>& value)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
#endif // UTILITY_NULLABLE_INCLUDE_H_
|
||||
344
ActiveX/Common/ASCDocxFormat/Source/Utility/nullable_property.h
Normal file
344
ActiveX/Common/ASCDocxFormat/Source/Utility/nullable_property.h
Normal file
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
* (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 UTILITY_NULLABLE_PROPERTY_INCLUDE_H_
|
||||
#define UTILITY_NULLABLE_PROPERTY_INCLUDE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Setter.h"
|
||||
#include "Getter.h"
|
||||
#include "nullable.h"
|
||||
#include "ToString.h"
|
||||
|
||||
#include "CallTraits.h"
|
||||
|
||||
template<typename Type, class Setter = setter::simple<Type>, class Getter = getter::simple<Type> >
|
||||
class nullable_property
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
|
||||
public:
|
||||
nullable_property() {}
|
||||
nullable_property(const Setter& setter, const Getter& getter = Getter()) : _value(setter, getter) {}
|
||||
nullable_property(Parameter value, const Setter& setter = Setter(), const Getter& getter = Getter())
|
||||
: _value (value, setter, getter) {}
|
||||
template<typename U, class S, class G>
|
||||
nullable_property(nullable_property<U, S, G> const& rhs, const Setter& setter = Setter(), const Getter& getter = Getter())
|
||||
: _value(rhs, setter, getter) {}
|
||||
nullable_property(const nullable__<Type>& value) : _value(value) {}
|
||||
|
||||
template<typename U> const nullable_property& operator =(const U& value)
|
||||
{
|
||||
return ::nullable_property_setter(*this, value);
|
||||
}
|
||||
|
||||
const nullable_property& operator =(const nullable_property& value)
|
||||
{
|
||||
return ::nullable_property_setter(*this, value);
|
||||
}
|
||||
|
||||
template<typename U> const nullable_property& nullable_property_setter(const U& value)
|
||||
{
|
||||
_value = static_cast<Type>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const nullable_property& nullable_property_setter(const nullable_property& value)
|
||||
{
|
||||
_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename U, class S, class G> const nullable_property& nullable_property_setter(const nullable_property<U, S, G>& value)
|
||||
{
|
||||
_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const nullable_property& nullable_property_setter(const nullable__<Type>& value)
|
||||
{
|
||||
_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator const Type() const {return get();}
|
||||
operator const nullable__<Type>() const {return _value.get_nullable();}
|
||||
const Type get() const {return _value.get();}
|
||||
const Type operator*() const {return get();}
|
||||
const Type get_value_or(Parameter value) const {return _value.is_init() ? get() : value;}
|
||||
const Type get_value_or_default() const {return get_value_or(Type());}
|
||||
|
||||
Type const* const operator->() const {return _value.get_ptr();}
|
||||
Type* operator->() {return _value.get_ptr();}
|
||||
|
||||
Type& operator*() {return *_value;}
|
||||
|
||||
const bool is_init() const {return _value.is_init();}
|
||||
void reset() {_value.reset();}
|
||||
void init() {_value.init();}
|
||||
|
||||
const std::string ToString() const {return ::ToString(get());}
|
||||
|
||||
const bool operator ==(nullable_property<Type, Setter, Getter> const& rhs) const {return get() == rhs.get()}
|
||||
const bool operator !=(nullable_property<Type, Setter, Getter> const& rhs) const {return get() != rhs.get();}
|
||||
const bool operator < (nullable_property<Type, Setter, Getter> const& rhs) const {return get() < rhs.get();}
|
||||
const bool operator > (nullable_property<Type, Setter, Getter> const& rhs) const {return get() > rhs.get();}
|
||||
const bool operator <=(nullable_property<Type, Setter, Getter> const& rhs) const {return get() <= rhs.get();}
|
||||
const bool operator >=(nullable_property<Type, Setter, Getter> const& rhs) const {return get() >= rhs.get();}
|
||||
|
||||
const bool operator ==(Parameter rhs) const {return get() == rhs;}
|
||||
const bool operator !=(Parameter rhs) const {return get() != rhs;}
|
||||
const bool operator < (Parameter rhs) const {return get() < rhs;}
|
||||
const bool operator > (Parameter rhs) const {return get() > rhs;}
|
||||
const bool operator <=(Parameter rhs) const {return get() <= rhs;}
|
||||
const bool operator >=(Parameter rhs) const {return get() >= rhs;}
|
||||
|
||||
template<typename T> const bool operator ==(const T rhs) const {return get() == rhs;}
|
||||
template<typename T> const bool operator !=(const T rhs) const {return get() != rhs;}
|
||||
template<typename T> const bool operator < (const T rhs) const {return get() < rhs;}
|
||||
template<typename T> const bool operator > (const T rhs) const {return get() > rhs;}
|
||||
template<typename T> const bool operator <=(const T rhs) const {return get() <= rhs;}
|
||||
template<typename T> const bool operator >=(const T rhs) const {return get() >= rhs;}
|
||||
|
||||
private:
|
||||
|
||||
template<typename Type, class Setter, class Getter, bool simple>
|
||||
class InternalNullableProperty
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
|
||||
public:
|
||||
InternalNullableProperty() {}
|
||||
InternalNullableProperty(Parameter value, const Setter&, const Getter&) : _value(value) { Setter()(*_value, value); }
|
||||
InternalNullableProperty(const nullable__<Type>& value)
|
||||
{
|
||||
if (value.is_init())
|
||||
{
|
||||
_value = value;
|
||||
Setter()(*_value, value.get());
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator =(Parameter value)
|
||||
{
|
||||
_value = value;
|
||||
Setter()(*_value, value);
|
||||
}
|
||||
|
||||
template<typename U, class S, class G>
|
||||
void operator =(const nullable_property<U, S, G>& rhs)
|
||||
{
|
||||
if (rhs.is_init())
|
||||
{
|
||||
_value = rhs.get();
|
||||
Setter()(*_value, rhs.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = nullable__<Type>();
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator =(const nullable__<Type>& value)
|
||||
{
|
||||
if (value.is_init())
|
||||
{
|
||||
_value = value;
|
||||
Setter()(*_value, value.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = nullable__<Type>();
|
||||
}
|
||||
}
|
||||
|
||||
inline const Type get() const {return Getter()(*_value);}
|
||||
inline const nullable__<Type> get_nullable() const {return is_init() ? nullable__<Type>(get()) : nullable__<Type>();}
|
||||
inline Type const* const get_ptr() const {return _value.get_ptr();}
|
||||
inline Type* get_ptr() {return _value.get_ptr();}
|
||||
|
||||
inline Type& operator*() {return *_value;}
|
||||
|
||||
inline const bool is_init() const {return _value.is_init();}
|
||||
inline void reset() {_value.reset();}
|
||||
inline void init() {_value.init();}
|
||||
|
||||
private:
|
||||
nullable__<Type> _value;
|
||||
};
|
||||
|
||||
template<typename Type, class Setter, class Getter>
|
||||
class InternalNullableProperty<Type, Setter, Getter, false>
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
|
||||
public:
|
||||
InternalNullableProperty() {}
|
||||
InternalNullableProperty(const Setter& setter, const Getter& getter)
|
||||
:
|
||||
_setter(setter),
|
||||
_getter(getter)
|
||||
{
|
||||
}
|
||||
InternalNullableProperty(Parameter value, const Setter& setter, const Getter& getter)
|
||||
:
|
||||
_value(value),
|
||||
_setter(setter),
|
||||
_getter(getter)
|
||||
{
|
||||
_setter(*_value, value);
|
||||
}
|
||||
template<typename U, class S, class G>
|
||||
InternalNullableProperty(nullable_property<U, S, G> const& rhs, const Setter& setter, const Getter& getter)
|
||||
:
|
||||
_setter(setter),
|
||||
_getter(getter)
|
||||
{
|
||||
if (rhs.is_init())
|
||||
{
|
||||
_value = rhs.get();
|
||||
_setter(*_value, rhs.get());
|
||||
}
|
||||
}
|
||||
|
||||
InternalNullableProperty(const nullable__<Type>& value)
|
||||
{
|
||||
if (value.is_init())
|
||||
{
|
||||
_value = value;
|
||||
_setter(*_value, value.get());
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator =(Parameter value)
|
||||
{
|
||||
_value = value;
|
||||
_setter(*_value, value);
|
||||
}
|
||||
|
||||
template<typename U, class S, class G>
|
||||
void operator =(const nullable_property<U, S, G>& rhs)
|
||||
{
|
||||
if (rhs.is_init())
|
||||
{
|
||||
_value = rhs.get();
|
||||
_setter(*_value, rhs.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = nullable__<Type>();
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator =(const nullable__<Type>& value)
|
||||
{
|
||||
if (value.is_init())
|
||||
{
|
||||
_value = value;
|
||||
_setter(*_value, value.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = nullable__<Type>();
|
||||
}
|
||||
}
|
||||
|
||||
inline const Type get() const {return _getter(*_value);}
|
||||
inline const nullable__<Type> get_nullable() const {return is_init() ? nullable__<Type>(get()) : nullable__<Type>();}
|
||||
inline Type const* const get_ptr() const {return _value.get_ptr();}
|
||||
inline Type* get_ptr() {return _value.get_ptr();}
|
||||
|
||||
inline Type& operator*() {return *_value;}
|
||||
|
||||
inline const bool is_init() const {return _value.is_init();}
|
||||
inline void reset() {_value.reset();}
|
||||
inline void init() {_value.init();}
|
||||
|
||||
private:
|
||||
nullable__<Type> _value;
|
||||
Setter _setter;
|
||||
Getter _getter;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
InternalNullableProperty<Type, Setter, Getter, true> _value;
|
||||
};
|
||||
|
||||
template<class T, class S, class G> const bool operator ==(const T x, nullable_property<T, S, G> const& y) {return y == x;}
|
||||
template<class T, class S, class G> const bool operator !=(const T x, nullable_property<T, S, G> const& y) {return y != x;}
|
||||
template<class T, class S, class G> const bool operator < (const T x, nullable_property<T, S, G> const& y) {return y >= x;}
|
||||
template<class T, class S, class G> const bool operator > (const T x, nullable_property<T, S, G> const& y) {return y <= x;}
|
||||
template<class T, class S, class G> const bool operator <=(const T x, nullable_property<T, S, G> const& y) {return y > x;}
|
||||
template<class T, class S, class G> const bool operator >=(const T x, nullable_property<T, S, G> const& y) {return y < x;}
|
||||
|
||||
template<typename V, class T, class S, class G> const bool operator ==(const V x, nullable_property<T, S, G> const& y) {return y == x;}
|
||||
template<typename V, class T, class S, class G> const bool operator !=(const V x, nullable_property<T, S, G> const& y) {return y != x;}
|
||||
template<typename V, class T, class S, class G> const bool operator < (const V x, nullable_property<T, S, G> const& y) {return y < x;}
|
||||
template<typename V, class T, class S, class G> const bool operator > (const V x, nullable_property<T, S, G> const& y) {return y > x;}
|
||||
template<typename V, class T, class S, class G> const bool operator <=(const V x, nullable_property<T, S, G> const& y) {return y <= x;}
|
||||
template<typename V, class T, class S, class G> const bool operator >=(const V x, nullable_property<T, S, G> const& y) {return y >= x;}
|
||||
|
||||
template<typename T, class S, class G, typename U>
|
||||
const nullable_property<T, S, G>& nullable_property_setter(nullable_property<T, S, G>& lhs, const U& rhs)
|
||||
{
|
||||
return lhs.nullable_property_setter(rhs);
|
||||
}
|
||||
|
||||
template<typename T, typename U, class S, class G>
|
||||
const nullable__<T>& nullable_setter(nullable__<T>& lhs, const nullable_property<U, S, G>& rhs)
|
||||
{
|
||||
if (rhs.is_init())
|
||||
return lhs.nullable_setter(rhs);
|
||||
else
|
||||
return lhs;
|
||||
}
|
||||
|
||||
template<typename T, class S, class G>
|
||||
const std::string ToString(const nullable_property<T, S, G>& value)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
template<typename T, class S, class G>
|
||||
const nullable_property<T, S, G> merge(const nullable_property<T, S, G>& prev, const nullable_property<T, S, G>& current)
|
||||
{
|
||||
if (!current.is_init())
|
||||
return prev;
|
||||
return current;
|
||||
}
|
||||
|
||||
#endif // UTILITY_NULLABLE_PROPERTY_INCLUDE_H_
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* (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_utility.h"
|
||||
|
||||
|
||||
#include "precompiled_utility.h"
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* (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
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
#include <streambuf>
|
||||
#include <locale>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "ASCStlUtils.h"
|
||||
#include "Unit.h"
|
||||
|
||||
#pragma warning( disable : 4554 )
|
||||
267
ActiveX/Common/ASCDocxFormat/Source/Utility/property.h
Normal file
267
ActiveX/Common/ASCDocxFormat/Source/Utility/property.h
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* (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 UTILITY_PROPERTY_INCLUDE_H_
|
||||
#define UTILITY_PROPERTY_INCLUDE_H_
|
||||
|
||||
#include "Setter.h"
|
||||
#include "Getter.h"
|
||||
#include <string>
|
||||
#include "ToString.h"
|
||||
|
||||
#include "CallTraits.h"
|
||||
|
||||
template<typename Type, class Setter = setter::simple<Type>, class Getter = getter::simple<Type> >
|
||||
class property
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
|
||||
public:
|
||||
property() : _value() {}
|
||||
property(const Setter& setter, const Getter& getter = Getter()) : _value(setter, getter) {}
|
||||
property(Parameter value, const Setter& setter = Setter(), const Getter& getter = Getter()) : _value(value, setter, getter) {}
|
||||
template<typename U, class S, class G>
|
||||
property(property<U, S, G> const& rhs, const Setter& setter = Setter(), const Getter& getter = Getter()) : _value(rhs, setter, getter) {}
|
||||
|
||||
template<typename U> const property& operator =(const U& value)
|
||||
{
|
||||
return ::property_setter(*this, value);
|
||||
}
|
||||
const property& operator =(const property& value)
|
||||
{
|
||||
return ::property_setter(*this, value);
|
||||
}
|
||||
|
||||
template<typename U> const property& property_setter(const U& value)
|
||||
{
|
||||
_value = static_cast<Type>(value);
|
||||
return *this;
|
||||
}
|
||||
const property& property_setter(const property& value)
|
||||
{
|
||||
_value = value;
|
||||
return *this;
|
||||
}
|
||||
template<typename U, class S, class G> const property& operator =(const property<U, S, G>& value)
|
||||
{
|
||||
_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator const Type() const {return get();}
|
||||
|
||||
const Type get() const {return _value.get();}
|
||||
Type& get() {return _value.get();}
|
||||
|
||||
const Type operator*() const {return get();}
|
||||
Type& operator*() {return get();}
|
||||
|
||||
Type const* const operator->() const {return _value.get_ptr();}
|
||||
Type* operator->() {return _value.get_ptr();}
|
||||
|
||||
const std::string ToString() const {return ::ToString(get());}
|
||||
|
||||
const bool operator ==(property<Type, Setter, Getter> const& rhs) const {return get() == rhs.get();}
|
||||
const bool operator !=(property<Type, Setter, Getter> const& rhs) const {return get() != rhs.get();}
|
||||
const bool operator < (property<Type, Setter, Getter> const& rhs) const {return get() < rhs.get();}
|
||||
const bool operator > (property<Type, Setter, Getter> const& rhs) const {return get() > rhs.get();}
|
||||
const bool operator <=(property<Type, Setter, Getter> const& rhs) const {return get() <= rhs.get();}
|
||||
const bool operator >=(property<Type, Setter, Getter> const& rhs) const {return get() >= rhs.get();}
|
||||
|
||||
const bool operator ==(Parameter rhs) const {return get() == rhs;}
|
||||
const bool operator !=(Parameter rhs) const {return get() != rhs;}
|
||||
const bool operator < (Parameter rhs) const {return get() < rhs;}
|
||||
const bool operator > (Parameter rhs) const {return get() > rhs;}
|
||||
const bool operator <=(Parameter rhs) const {return get() <= rhs;}
|
||||
const bool operator >=(Parameter rhs) const {return get() >= rhs;}
|
||||
|
||||
template<typename T> const bool operator ==(const T rhs) const {return get() == rhs;}
|
||||
template<typename T> const bool operator !=(const T rhs) const {return get() != rhs;}
|
||||
template<typename T> const bool operator < (const T rhs) const {return get() < rhs;}
|
||||
template<typename T> const bool operator > (const T rhs) const {return get() > rhs;}
|
||||
template<typename T> const bool operator <=(const T rhs) const {return get() <= rhs;}
|
||||
template<typename T> const bool operator >=(const T rhs) const {return get() >= rhs;}
|
||||
|
||||
template<typename T> const property& operator +=(const T value) {_value += value; return *this;}
|
||||
template<typename T> const property& operator -=(const T value) {_value -= value; return *this;}
|
||||
template<typename T> const property& operator *=(const T value) {_value *= value; return *this;}
|
||||
template<typename T> const property& operator /=(const T value) {_value /= value; return *this;}
|
||||
|
||||
template<typename T> const Type operator +(const T rhs) const {return _value + rhs;}
|
||||
template<typename T> const Type operator -(const T rhs) const {return _value - rhs;}
|
||||
template<typename T> const Type operator *(const T rhs) const {return _value * rhs;}
|
||||
template<typename T> const Type operator /(const T rhs) const {return _value / rhs;}
|
||||
|
||||
template<typename T, class S, class G> const Type operator +(const property<T, S, G>& rhs) const {return _value + rhs.get();}
|
||||
template<typename T, class S, class G> const Type operator -(const property<T, S, G>& rhs) const {return _value - rhs.get();}
|
||||
template<typename T, class S, class G> const Type operator *(const property<T, S, G>& rhs) const {return _value * rhs.get();}
|
||||
template<typename T, class S, class G> const Type operator /(const property<T, S, G>& rhs) const {return _value / rhs.get();}
|
||||
|
||||
private:
|
||||
|
||||
template<typename Type, class Setter, class Getter, bool simple>
|
||||
class InternalProperty
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
|
||||
public:
|
||||
InternalProperty() {Setter()(_value, Type());}
|
||||
InternalProperty(Parameter value, const Setter&, const Getter&) : _value(value)
|
||||
{
|
||||
Setter()(_value, value);
|
||||
}
|
||||
|
||||
template<typename U, class S, class G>
|
||||
InternalProperty(property<U, S, G> const& rhs, const Setter&, const Getter&) : _value(rhs.get())
|
||||
{
|
||||
Setter()(_value, rhs.get());
|
||||
}
|
||||
|
||||
void operator =(Parameter value) {Setter()(_value, value);}
|
||||
|
||||
const Type get() const {return Getter()(_value);}
|
||||
Type& get() {return _value;}
|
||||
|
||||
Type const* const get_ptr() const {return &_value;}
|
||||
Type* get_ptr() {return &_value;}
|
||||
|
||||
template<typename T> void operator +=(const T value) {Setter()(_value, _value + value);}
|
||||
template<typename T> void operator -=(const T value) {Setter()(_value, _value - value);}
|
||||
template<typename T> void operator *=(const T value) {Setter()(_value, _value * value);}
|
||||
template<typename T> void operator /=(const T value) {Setter()(_value, _value / value);}
|
||||
|
||||
template<typename T> const Type operator +(const T value) const {return _value + value;}
|
||||
template<typename T> const Type operator -(const T value) const {return _value - value;}
|
||||
template<typename T> const Type operator *(const T value) const {return _value * value;}
|
||||
template<typename T> const Type operator /(const T value) const {return _value / value;}
|
||||
|
||||
private:
|
||||
Type _value;
|
||||
};
|
||||
|
||||
template<typename Type, class Setter, class Getter>
|
||||
class InternalProperty<Type, Setter, Getter, false>
|
||||
{
|
||||
private:
|
||||
typedef typename NSCallTraits<Type>::param_type Parameter;
|
||||
|
||||
public:
|
||||
InternalProperty() {_setter(_value, Type());}
|
||||
|
||||
InternalProperty(const Setter& setter, const Getter& getter) : _setter(setter), _getter(getter)
|
||||
{
|
||||
_setter(_value, Type());
|
||||
}
|
||||
|
||||
InternalProperty(Parameter value, const Setter& setter, const Getter& getter) : _value(value), _setter(setter), _getter(getter)
|
||||
{
|
||||
_setter(_value, value);
|
||||
}
|
||||
|
||||
template<typename U, class S, class G>
|
||||
InternalProperty(property<U, S, G> const& rhs, const Setter& setter, const Getter& getter) : _value(rhs.get()), _setter(setter), _getter(getter)
|
||||
{
|
||||
_setter(_value, rhs.get());
|
||||
}
|
||||
|
||||
inline void operator =(Parameter value) {_setter(_value, value);}
|
||||
inline void operator =(const InternalProperty& rhs)
|
||||
{
|
||||
if(this != &rhs)
|
||||
{
|
||||
_setter(_value, rhs.get());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename U, class S, class G> void operator =(const property<U, S, G> & rhs)
|
||||
{
|
||||
_setter(_value, rhs.get());
|
||||
}
|
||||
|
||||
const Type get() const {return _getter(_value);}
|
||||
Type& get() {return _value;}
|
||||
|
||||
Type const* const get_ptr() const {return &_value;}
|
||||
Type* get_ptr() {return &_value;}
|
||||
|
||||
template<typename T> void operator +=(const T value) {_setter(_value, _value + value);}
|
||||
template<typename T> void operator -=(const T value) {_setter(_value, _value - value);}
|
||||
template<typename T> void operator *=(const T value) {_setter(_value, _value * value);}
|
||||
template<typename T> void operator /=(const T value) {_setter(_value, _value / value);}
|
||||
|
||||
template<typename T> const Type operator +(const T value) const {return _value + value;}
|
||||
template<typename T> const Type operator -(const T value) const {return _value - value;}
|
||||
template<typename T> const Type operator *(const T value) const {return _value * value;}
|
||||
template<typename T> const Type operator /(const T value) const {return _value / value;}
|
||||
|
||||
private:
|
||||
Type _value;
|
||||
Setter _setter;
|
||||
Getter _getter;
|
||||
};
|
||||
|
||||
private:
|
||||
InternalProperty<Type, Setter, Getter, true> _value;
|
||||
};
|
||||
|
||||
template<class T, class S, class G> const bool operator ==(const T x, property<T, S, G> const& y) {return y == x;}
|
||||
template<class T, class S, class G> const bool operator !=(const T x, property<T, S, G> const& y) {return y != x;}
|
||||
template<class T, class S, class G> const bool operator < (const T x, property<T, S, G> const& y) {return y >= x;}
|
||||
template<class T, class S, class G> const bool operator > (const T x, property<T, S, G> const& y) {return y <= x;}
|
||||
template<class T, class S, class G> const bool operator <=(const T x, property<T, S, G> const& y) {return y > x;}
|
||||
template<class T, class S, class G> const bool operator >=(const T x, property<T, S, G> const& y) {return y < x;}
|
||||
|
||||
template<typename V, class T, class S, class G> const bool operator ==(const V x, property<T, S, G> const& y) {return y == x;}
|
||||
template<typename V, class T, class S, class G> const bool operator !=(const V x, property<T, S, G> const& y) {return y != x;}
|
||||
template<typename V, class T, class S, class G> const bool operator < (const V x, property<T, S, G> const& y) {return y < x;}
|
||||
template<typename V, class T, class S, class G> const bool operator > (const V x, property<T, S, G> const& y) {return y > x;}
|
||||
template<typename V, class T, class S, class G> const bool operator <=(const V x, property<T, S, G> const& y) {return y <= x;}
|
||||
template<typename V, class T, class S, class G> const bool operator >=(const V x, property<T, S, G> const& y) {return y >= x;}
|
||||
|
||||
|
||||
template<typename T, class S, class G, typename U>
|
||||
const property<T, S, G>& property_setter(property<T, S, G>& lhs, const U& rhs)
|
||||
{
|
||||
return lhs.property_setter(rhs);
|
||||
}
|
||||
|
||||
|
||||
template<typename T, class S, class G>
|
||||
const std::string ToString(const property<T, S, G>& value)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
#endif // UTILITY_PROPERTY_INCLUDE_H_
|
||||
Reference in New Issue
Block a user