Commit 3702d71a authored by Sergey.Kirillov's avatar Sergey.Kirillov Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52217 954022d7-b5bf-4e40-9824-e11837661b57
parent 66e17312
// AVSOfficeEpubFile.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you
[ module(dll, uuid = "{18A70273-06FE-4b56-ADB6-B72992B202FD}",
name = "AVSOfficeEpubFile",
helpstring = "AVSOfficeEpubFile 1.0 Type Library",
resource_name = "IDR_AVSOFFICEEPUBFILE") ]
class CAVSOfficeEpubFileModule
{
public:
// Override CAtlDllModuleT members
};
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
#define COMPONENT_NAME "OfficeEpubFile"
#include "../../../../Common/FileInfo.h"
#include "version.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE 25, 1
#pragma code_page(1251)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "LegalTrademarks", LEGAL_COPYRIGHT
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1252
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
IDR_AVSOFFICEEPUBFILE REGISTRY "AVSOfficeEpubFile.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "AVSOfficeEpubFile"
END
/////////////////////////////////////////////////////////////////////////////
#endif
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'AVSOfficeEpubFile'
'AVSOfficeEpubFile.DLL'
{
val AppID = s '%APPID%'
}
}
}

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVSOfficeEpubFile", "AVSOfficeEpubFile.vcproj", "{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}"
ProjectSection(ProjectDependencies) = postProject
{52B37168-F0D9-403D-ADD4-5C07B4602643} = {52B37168-F0D9-403D-ADD4-5C07B4602643}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_regexp", "boost_regexp\boost_regexp.vcproj", "{52B37168-F0D9-403D-ADD4-5C07B4602643}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
ReleaseASC|Win32 = ReleaseASC|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}.Debug|Win32.ActiveCfg = Debug|Win32
{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}.Debug|Win32.Build.0 = Debug|Win32
{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}.Release|Win32.ActiveCfg = Release|Win32
{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}.Release|Win32.Build.0 = Release|Win32
{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}.ReleaseASC|Win32.ActiveCfg = ReleaseASC|Win32
{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}.ReleaseASC|Win32.Build.0 = ReleaseASC|Win32
{52B37168-F0D9-403D-ADD4-5C07B4602643}.Debug|Win32.ActiveCfg = Debug|Win32
{52B37168-F0D9-403D-ADD4-5C07B4602643}.Debug|Win32.Build.0 = Debug|Win32
{52B37168-F0D9-403D-ADD4-5C07B4602643}.Release|Win32.ActiveCfg = Release|Win32
{52B37168-F0D9-403D-ADD4-5C07B4602643}.Release|Win32.Build.0 = Release|Win32
{52B37168-F0D9-403D-ADD4-5C07B4602643}.ReleaseASC|Win32.ActiveCfg = Release|Win32
{52B37168-F0D9-403D-ADD4-5C07B4602643}.ReleaseASC|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="AVSOfficeEpubFile"
ProjectGUID="{CF852DB8-5A50-4C30-B683-5503D8DAF7B3}"
RootNamespace="AVSOfficeEpubFile"
Keyword="AtlProj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/AVSOfficeEpubFile.tlb"
HeaderFileName="AVSOfficeEpubFile.h"
DLLDataFileName=""
InterfaceIdentifierFileName="AVSOfficeEpubFile_i.c"
ProxyFileName="AVSOfficeEpubFile_p.c"
ValidateParameters="false"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\Common;..\..\..\Common;..\..\Common;..\..\AVSImageStudio3\Common"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES;_CRT_NONSTDC_NO_DEPRECATE;ZLIB_WINAPI;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies="gdiplus.lib"
LinkIncremental="2"
IgnoreDefaultLibraryNames=""
MergedIDLBaseFileName="_AVSOfficeEpubFile.idl"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="..\..\..\..\AVS\Redist\VersionControl.exe &quot;$(SolutionDir)\version.h&quot;"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/AVSOfficeEpubFile.tlb"
HeaderFileName="AVSOfficeEpubFile.h"
DLLDataFileName=""
InterfaceIdentifierFileName="AVSOfficeEpubFile_i.c"
ProxyFileName="AVSOfficeEpubFile_p.c"
ValidateParameters="false"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\..\..\Common;..\..\..\Common;..\..\Common;..\..\AVSImageStudio3\Common"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;_CRT_NONSTDC_NO_DEPRECATE;ZLIB_WINAPI;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies="gdiplus.lib zlib.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBC.LIB"
MergedIDLBaseFileName="_AVSOfficeEpubFile.idl"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Copy to redist"
CommandLine="copy $(TargetPath) ..\..\..\..\AVS\Redist\AVSOfficeStudio\AVSOfficeEpubFile.dll"
/>
</Configuration>
<Configuration
Name="ReleaseASC|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="..\..\..\..\AVS\Redist\VersionControl.exe &quot;$(SolutionDir)\version.h&quot;"
ExcludedFromBuild="true"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/AVSOfficeEpubFile.tlb"
HeaderFileName="AVSOfficeEpubFile.h"
DLLDataFileName=""
InterfaceIdentifierFileName="AVSOfficeEpubFile_i.c"
ProxyFileName="AVSOfficeEpubFile_p.c"
ValidateParameters="false"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\..\..\Common;..\..\..\Common;..\..\Common;..\..\AVSImageStudio3\Common"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;_CRT_NONSTDC_NO_DEPRECATE;ZLIB_WINAPI;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG;ASCBUILD"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies="gdiplus.lib zlib.lib"
OutputFile="$(OutDir)\ASCOfficeEpubFile.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBC.LIB"
MergedIDLBaseFileName="_AVSOfficeEpubFile.idl"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Copy to redist"
CommandLine="copy $(TargetPath) ..\..\..\..\ASC\Redist\ASCOfficeStudio\ASCOfficeEpubFile.dll"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AVSOfficeEpubFile.cpp"
>
</File>
<File
RelativePath=".\COfficeEpubFile.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\COfficeEpubFile.h"
>
</File>
<File
RelativePath=".\EpubContainer.h"
>
</File>
<File
RelativePath=".\EpubCrypt.h"
>
</File>
<File
RelativePath=".\EpubPackage.h"
>
</File>
<File
RelativePath=".\EventHandler.h"
>
</File>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\version.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\AVSOfficeEpubFile.rc"
>
</File>
<File
RelativePath=".\AVSOfficeEpubFile.rgs"
>
</File>
</Filter>
<Filter
Name="SHA1"
>
<File
RelativePath=".\SHA1\sha1.cpp"
>
</File>
<File
RelativePath=".\SHA1\sha1.h"
>
</File>
</Filter>
<Filter
Name="zip"
>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\adler32.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\compress.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\crc32.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\deflate.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\contrib\masmx86\gvmat32c.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\gzio.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\infback.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\contrib\masmx64\inffas8664.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\inffast.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\inflate.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\inftrees.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\contrib\minizip\ioapi.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\trees.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\uncompr.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\contrib\minizip\unzip.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\contrib\minizip\zip.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\AVSOfficeUtils\ZLIB\zlib-1.2.3\zutil.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseASC|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
// CAVSOfficeOfficeEpubFile.cpp : Implementation of CAVSOfficeOfficeEpubFile
#include "stdafx.h"
#include "COfficeEpubFile.h"
#include "EpubContainer.h"
#include "EventHandler.h"
#include "StringUtils.h"
#include "../Common/OfficeFileErrorDescription.h"
#include "../Common/OfficeFileFormats.h"
#include "../Common/OfficeDefines.h"
#include "../AVSOfficeUniversalConverter/Utils.h"
#include "../../AVSVideoStudio3/Common/MediaFormatDefine.h"
#define ZLIB_WINAPI
#define CODEPAGE_ISSUE_FIX
#include "..\AVSOfficeUtils\ZLIB\zlib-1.2.3\contrib\minizip\zip.h"
#define ONE_INCH 2.54
// CAVSOfficeOfficeEpubFile
class FolderRemove
{
private: CString m_sFolder;
public: FolderRemove(CString sFolder )
{
m_sFolder = sFolder;
}
public: ~FolderRemove( )
{
Utils::RemoveDirOrFile( m_sFolder );
}
};
// bEnd == true ( '/' '\'), bEnd == false ( '/' '\')
void NormalizePath( CString& sPath, bool bEnd = true )
{
int nPathLen = sPath.GetLength();
if( nPathLen > 0 ) // sPath '/' '\'
{
if( true == bEnd )
{
TCHAR tcLastChar = sPath[ nPathLen - 1 ];
if( '\\' != tcLastChar && '/' != tcLastChar )
sPath.AppendChar( '/' );
}
else
{
TCHAR tcFirstChar = sPath[ 0 ];
if( '\\' == tcFirstChar || '/' == tcFirstChar )
sPath = sPath.Right( sPath.GetLength() - 1 );
}
}
}
void MergeRels( CString sDest, CString sSource, CString sDestDir, CString sSourceDir, CString& sSourceDoc )
{
int nImageCounter = 1;
int nStartRelsIndex = 0;
// document.xml.rels nStartRelsIndex
XmlUtils::CXmlReader oXmlReader;
if( ::GetFileAttributes( sDest ) != INVALID_FILE_ATTRIBUTES )
if( TRUE == oXmlReader.OpenFromFile( sDest ) )
if( TRUE == oXmlReader.ReadRootNode( _T("Relationships") ) )
if( TRUE == oXmlReader.ReadNodeList( _T("Relationship") ) )
{
for( int i = 0; i < oXmlReader.GetLengthList(); i++ )
{
CString sCurRID = oXmlReader.ReadNodeAttribute( i , _T("Id") );
if( 0 == sCurRID.Find( _T("rId") ) )
{
// rId
int nStartIndex = 3;// strlen("rId");
CString sDigitAfter = _T("");
int nCurRIDLen = sCurRID.GetLength();
while( nStartIndex < nCurRIDLen && _istdigit( sCurRID[nStartIndex] ) )
{
sDigitAfter.AppendChar( sCurRID[nStartIndex] );
nStartIndex++;
}
if( _T("") != sDigitAfter )
{
int nDigitAfter = Strings::ToInteger( sDigitAfter );
if( nDigitAfter >= nStartRelsIndex )
nStartRelsIndex = nDigitAfter + 1;
}
}
}
}
if( ::GetFileAttributes( sSource ) != INVALID_FILE_ATTRIBUTES )
if( TRUE == oXmlReader.OpenFromFile( sSource ) )
if( TRUE == oXmlReader.ReadRootNode( _T("Relationships") ) )
if( TRUE == oXmlReader.ReadNodeList( _T("Relationship") ) )
{
for( int i = 0; i < oXmlReader.GetLengthList(); i++ )
{
CString sCurRID = oXmlReader.ReadNodeAttribute( i , _T("Id") );
if( 0 == sCurRID.Find( _T("rId") ) )
{
// rId
int nStartIndex = 3;// strlen("rId");
CString sDigitAfter = _T("");
int nCurRIDLen = sCurRID.GetLength();
while( nStartIndex < nCurRIDLen && _istdigit( sCurRID[nStartIndex] ) )
{
sDigitAfter.AppendChar( sCurRID[nStartIndex] );
nStartIndex++;
}
if( _T("") != sDigitAfter )
{
int nDigitAfter = Strings::ToInteger( sDigitAfter );
if( nDigitAfter >= nStartRelsIndex )
nStartRelsIndex = nDigitAfter + 1;
}
}
}
}
nStartRelsIndex++;
// rels Image Hyperlink
CString sAdditionalRels = _T("");
if( ::GetFileAttributes( sSource ) != INVALID_FILE_ATTRIBUTES )
if( TRUE == oXmlReader.OpenFromFile( sSource ) )
if( TRUE == oXmlReader.ReadRootNode( _T("Relationships") ) )
if( TRUE == oXmlReader.ReadNodeList( _T("Relationship") ) )
{
for( int i = 0; i < oXmlReader.GetLengthList(); i++ )
{
CString sCurType = oXmlReader.ReadNodeAttribute( i , _T("Type") );
CString sCurTarget = oXmlReader.ReadNodeAttribute( i , _T("Target") );
CString sTargetMode = oXmlReader.ReadNodeAttribute( i , _T("TargetMode") );
CString sCurRID = oXmlReader.ReadNodeAttribute( i , _T("Id") );
bool bImage = (-1 != sCurType.Find( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") ));
bool bHyp = (-1 != sCurType.Find( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") ));
if( bImage || bHyp )
{
CString sNewName = _T("");
if( bImage && "External" != sTargetMode )
{
//
NormalizePath( sCurTarget, false );
if( ::GetFileAttributes( sDestDir + _T("media") ) == INVALID_FILE_ATTRIBUTES )
CreateDirectory( sDestDir + _T("media"), NULL );
CString sDestLocation = sDestDir + sCurTarget;
//
TCHAR tDrive[256];
TCHAR tDir[256];
TCHAR tFilename[256];
TCHAR tExt[256];
_tsplitpath( sDestLocation, tDrive, tDir, tFilename, tExt );
CString sNewFilename;
while ( ::GetFileAttributes( sDestLocation ) != INVALID_FILE_ATTRIBUTES)
{
sNewFilename = _T("");sNewFilename.AppendFormat( CString(_T("image%d")) + tExt, nImageCounter++ );
sDestLocation = CString(tDrive) + CString(tDir) + sNewFilename;
}
sNewName = sCurTarget;
if( _T("") != sNewFilename )
sNewName.Replace( CString(tFilename) + CString(tExt), sNewFilename );
//
CopyFile( sSourceDir + sCurTarget, sDestLocation, FALSE );
}
CString sCurXml = oXmlReader.ReadNodeXml( i );
CString sNewRID;sNewRID.AppendFormat( _T("\"rId%d\""), nStartRelsIndex++ );
sCurXml.Replace( CString(_T("\"")) + sCurRID + _T("\""), sNewRID );
sSourceDoc.Replace( CString( _T("\"")) + sCurRID + _T("\""), sNewRID );
if( _T("") != sNewName )
sCurXml.Replace( sCurTarget, sNewName );
sAdditionalRels += sCurXml;
}
}
}
//
if( _T("") != sAdditionalRels )
{
CString sAddition = _T("<root xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">") + sAdditionalRels +_T("</root>");
XML::IXMLDOMDocumentPtr m_pXmlDocument;
m_pXmlDocument.CreateInstance(CLSID_DOMDocument);
if( NULL != m_pXmlDocument )
{
VARIANT vtLoad;
vtLoad.vt = VT_BSTR;
vtLoad.bstrVal = sDest.AllocSysString();
try{
if( VARIANT_TRUE == m_pXmlDocument->load( vtLoad ) )
{
XML::IXMLDOMNodePtr oRootNode = m_pXmlDocument->selectSingleNode( _T("Relationships") );
if( NULL != oRootNode )
{
XmlUtils::CXmlReader oRelationReader;
if( TRUE == oRelationReader.OpenFromXmlString( sAddition ) )
if( TRUE == oRelationReader.ReadNodeList( _T("*") ) )
{
int nLengthList = oRelationReader.GetLengthList();
for( int i = 0; i < nLengthList ; i++ )
{
XML::IXMLDOMNodePtr oCurNode = NULL;
oRelationReader.GetNode( i, oCurNode );
if( NULL != oCurNode )
XML::IXMLDOMNodePtr pBuf = oRootNode->appendChild( oCurNode );
}
}
VARIANT vtSave;
vtSave.vt = VT_BSTR;
vtSave.bstrVal = sDest.AllocSysString();
m_pXmlDocument->save( vtSave );
SysFreeString( vtSave.bstrVal );
}
}
}
catch( ... )
{
}
SysFreeString( vtLoad.bstrVal );
}
}
}
// docx html:
//fontTable.xml, styles.xml .
//
//numbering.xml
void MergeDocx( CString sDest, CString sSource )
{
NormalizePath( sSource, true );
NormalizePath( sDest, true );
// document.xml [Content_Types].xml
CString sDestDocument;
CString sSourceDocument;
XmlUtils::CXmlReader oXmlReader;
if( TRUE == oXmlReader.OpenFromFile( sDest + _T("[Content_Types].xml") ) )
if( TRUE == oXmlReader.ReadRootNode( _T("Types") ) )
if( TRUE == oXmlReader.ReadNodeList( _T("Override") ) )
for( int i = 0; i < oXmlReader.GetLengthList(); i++ )
{
CString sXml = oXmlReader.ReadNodeAttribute( i, _T("ContentType") );
if( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml") == sXml )
{
sDestDocument = oXmlReader.ReadNodeAttribute( i, _T("PartName") );
NormalizePath( sDestDocument, false );
}
}
if( TRUE == oXmlReader.OpenFromFile( sSource + _T("[Content_Types].xml") ) )
if( TRUE == oXmlReader.ReadRootNode( _T("Types") ) )
if( TRUE == oXmlReader.ReadNodeList( _T("Override") ) )
for( int i = 0; i < oXmlReader.GetLengthList(); i++ )
{
if( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml") == oXmlReader.ReadNodeAttribute( i, _T("ContentType") ) )
{
sSourceDocument = oXmlReader.ReadNodeAttribute( i, _T("PartName") );
NormalizePath( sSourceDocument, false );
}
}
if( _T("") == sDestDocument || _T("") == sSourceDocument )
return;
sDestDocument = sDest + sDestDocument;
sSourceDocument = sSource + sSourceDocument;
//
//
CString sSourceContent;
if( TRUE == oXmlReader.OpenFromFile( sSourceDocument ) )
if( TRUE == oXmlReader.ReadRootNode( _T("w:document") ) )
sSourceContent = oXmlReader.ReadNodeXml();
if( _T("") == sSourceContent )
return;
// rels
TCHAR tDrive[256];
TCHAR tDir[256];
TCHAR tFilename[256];
TCHAR tExt[256];
_tsplitpath( sDestDocument, tDrive, tDir, tFilename, tExt );
CString sDestDir = CString(tDrive) + CString(tDir);
CString sDestRels = sDestDir + _T("_rels\\") +CString(tFilename) + CString(tExt) + _T(".rels");
_tsplitpath( sSourceDocument, tDrive, tDir, tFilename, tExt );
CString sSourceDir = CString(tDrive) + CString(tDir);
CString sSourceRels = sSourceDir + _T("_rels\\") +CString(tFilename) + CString(tExt) + _T(".rels");
// rels
MergeRels( sDestRels, sSourceRels, sDestDir, sSourceDir, sSourceContent );
std::wstring sStdSource = sSourceContent;
// numbering, numbering.xml
boost::wregex xRegEx(_T("<w\\:numPr[ >].*?</w\\:numPr>") );
sStdSource = boost::regex_replace( sStdSource, xRegEx, _T("") );
XML::IXMLDOMDocumentPtr pXmlDocument;
pXmlDocument.CreateInstance(CLSID_DOMDocument);
if( NULL != pXmlDocument )
{
VARIANT vtLoad;
vtLoad.vt = VT_BSTR;
vtLoad.bstrVal = sDestDocument.AllocSysString();
try{
if( VARIANT_TRUE == pXmlDocument->load( vtLoad ) )
{
XML::IXMLDOMNodePtr oBodyNode = pXmlDocument->selectSingleNode( _T("w:document/w:body") );
if( NULL != oBodyNode )
{
// w:sectPr,
CComVariant varSectNode(&(*oBodyNode->GetlastChild()));
//
if( oBodyNode->GetchildNodes()->Getlength() > 1 )
{
CString sPageBreak = L"<root xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:p><w:r><w:br w:type=\"page\"/></w:r></w:p></root>";
XmlUtils::CXmlReader oPageBreakReader;
if( TRUE == oPageBreakReader.OpenFromXmlString( sPageBreak ) )
if( TRUE == oPageBreakReader.ReadNode( _T("w:p") ) )
{
XML::IXMLDOMNodePtr oCurNode = NULL;
oPageBreakReader.GetNode( oCurNode );
if( NULL != oCurNode )
oBodyNode->insertBefore( oCurNode, varSectNode );
}
}
XmlUtils::CXmlReader oRelationReader;
if( TRUE == oRelationReader.OpenFromXmlString( sStdSource.c_str() ) )
if( TRUE == oRelationReader.ReadRootNode( _T("w:document") ) )
if( TRUE == oRelationReader.ReadNode( _T("w:body") ) )
if( TRUE == oRelationReader.ReadNodeList( _T("*") ) )
{
int nLengthList = oRelationReader.GetLengthList();
//nLengthList - 1, w:sectPr
for( int i = 0; i < nLengthList - 1 ; i++ )
{
XML::IXMLDOMNodePtr oCurNode = NULL;
oRelationReader.GetNode( i, oCurNode );
if( NULL != oCurNode )
oBodyNode->insertBefore( oCurNode, varSectNode );
}
}
varSectNode.Clear();
VARIANT vtSave;
vtSave.vt = VT_BSTR;
vtSave.bstrVal = sDestDocument.AllocSysString();
pXmlDocument->save( vtSave );
SysFreeString( vtSave.bstrVal );
}
}
}
catch( ... )
{
}
::SysFreeString( vtLoad.bstrVal );
}
}
int _WriteFileToZip( CString sSource, CString sSourceRel, zipFile zf, int nCompressionLevel )
{
int err = 0;
if( Z_NO_COMPRESSION == nCompressionLevel )
err = zipOpenNewFileInZip( zf, Utils::UnicodeToCodepage (sSourceRel, CP_OEMCP), NULL, NULL, 0, NULL, 0, NULL, NULL, nCompressionLevel );
else
err = zipOpenNewFileInZip( zf, Utils::UnicodeToCodepage (sSourceRel, CP_OEMCP), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, nCompressionLevel );
HANDLE hSourceFile = ::CreateFile( sSource, GENERIC_READ, 0, 0, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0);
if( INVALID_HANDLE_VALUE == hSourceFile )
err = -1;
DWORD dwBytesRead = 1;
BYTE bBuffer[ BUFSIZE ];
while( -1 != err && 0 != dwBytesRead )
{
ReadFile( hSourceFile, bBuffer, BUFSIZE, &dwBytesRead, NULL );
if( dwBytesRead > 0 )
err = zipWriteInFileInZip( zf, bBuffer, dwBytesRead );
}
RELEASEHANDLE( hSourceFile );
if( 0 == err )
err = zipCloseFileInZip( zf );
else
zipCloseFileInZip( zf );
return err;
}
int _CompressEpubDir( CString sSource, CString sPathRel, zipFile zf, int nCompresstionLevel )
{
DWORD dwFileAttrib = ::GetFileAttributes( sSource );
if( dwFileAttrib != INVALID_FILE_ATTRIBUTES )
{
DWORD dwResult = 0;
if( 0 != (FILE_ATTRIBUTE_DIRECTORY & dwFileAttrib) )
{
HANDLE Handle;
WIN32_FIND_DATA FindData;
DWORDLONG Result = 0;
Handle = FindFirstFile( ( sSource + _T("\\*.*") ), &FindData );
if ( Handle == INVALID_HANDLE_VALUE )
return 0;
do
{
int nRes = 0;
if( ( CString( FindData.cFileName ) != _T("mimetype") ) && ( CString( FindData.cFileName ) != _T(".") ) && ( CString( FindData.cFileName ) != _T("..") ) )
{
if( FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
if( _T("fonts") == CString( FindData.cFileName ) )
dwResult += _CompressEpubDir( sSource + _T("\\") + FindData.cFileName, sPathRel + FindData.cFileName + _T("/"), zf, Z_NO_COMPRESSION );//
else
dwResult += _CompressEpubDir( sSource + _T("\\") + FindData.cFileName, sPathRel + FindData.cFileName + _T("/"), zf, nCompresstionLevel );
}
else
dwResult += _CompressEpubDir( sSource + _T("\\") + FindData.cFileName, sPathRel, zf, nCompresstionLevel );
}
}
while( FindNextFile( Handle, &FindData ) != 0 );
FindClose( Handle );
}
else
{
TCHAR tExt[256];
TCHAR tFilename[256];
_wsplitpath( sSource, NULL, NULL, tFilename, tExt );
CString sExt = tExt;
CString sFilename = tFilename;
_WriteFileToZip( sSource, sPathRel + sFilename + sExt, zf, nCompresstionLevel );
}
return dwResult;
}// 0 -
return 0;
}
int CompressEpubDir( CString sSource, CString sDestination )
{
int err = 0;
zipFile zf = zipOpen( sDestination, APPEND_STATUS_CREATE );
if( NULL == zf )
return 1;
// mimetype
CString sMimeFile = sSource + _T("\\mimetype");
if( ::GetFileAttributes( sMimeFile ) != INVALID_FILE_ATTRIBUTES )
err = _WriteFileToZip( sMimeFile, _T("mimetype"), zf, Z_NO_COMPRESSION );
if( err == 0 )
{
//
err = _CompressEpubDir( sSource, _T(""), zf, Z_BEST_COMPRESSION );
}
if( 0 == err )
err = zipClose( zf, NULL );
else
zipClose( zf, NULL );
return err;
}
HRESULT COfficeEpubFile::OnProgressHtml( LONG nID, LONG nPercent )
{// 0 c_shMaxProgressPercent
long nNewProgress = ( c_nMaxProgressPercent * m_nTasksComplete + nPercent ) / m_nTasksAll;
OnProgress( nID, nNewProgress );
return S_OK;
}
HRESULT COfficeEpubFile::OnProgressHtmlEx( LONG nID, LONG nPercent, SHORT* Cancel )
{
long nNewProgress = ( c_nMaxProgressPercent * m_nTasksComplete + nPercent ) / m_nTasksAll;
OnProgressEx( nID, nNewProgress, Cancel );
if( c_shProgressCancel == *Cancel )
m_bCancel = true;
return S_OK;
}
STDMETHODIMP COfficeEpubFile::LoadFromFile( BSTR bstrSrcFileName, BSTR bstrDstPath, BSTR bstrXMLOptions)
{
// epub
long nError;
if( FALSE == IsEpubFile( CString(bstrSrcFileName), nError ) )
{
if( NOERROR == nError )
return AVS_ERROR_FILEFORMAT;
else
return nError;
}
HRESULT hRes = S_OK;
//
CString sTempFolder = Utils::CreateTempDir( CString( bstrDstPath ) );
FolderRemove oFolderRemove( sTempFolder );
//
OfficeUtils::IOfficeUtilsPtr piOfficeUtils;
piOfficeUtils.CreateInstance( __uuidof(OfficeUtils::COfficeUtils) );
if( NULL == piOfficeUtils )
return AVS_ERROR_UNEXPECTED;
BSTR bstrTempFolder = sTempFolder.AllocSysString();
hRes = piOfficeUtils->ExtractToDirectory( bstrSrcFileName, bstrTempFolder, NULL, 0 );
SysFreeString( bstrTempFolder );
if( FAILED( hRes ) )
return AVS_ERROR_UNEXPECTED;
//load
EpubContainer oEpubContainer;
if( 0 != oEpubContainer.Load( sTempFolder ) )
return AVS_ERROR_UNEXPECTED;
m_sMetadata = oEpubContainer.m_oEpubPackage.m_sMetadata;
OfficeHtmlFile::IHtmlFilePtr piHtmlFile;
piHtmlFile.CreateInstance( __uuidof(OfficeHtmlFile::CHtmlFile) );
if( NULL == piHtmlFile )
return AVS_ERROR_UNEXPECTED;
//
COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents, COfficeEpubFile >* oHtmlEvents = new COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents, COfficeEpubFile >( this );
oHtmlEvents->AddRef();
oHtmlEvents->Advise( piHtmlFile );
COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents2, COfficeEpubFile >* oHtmlEvents2 = new COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents2, COfficeEpubFile >( this );
oHtmlEvents2->AddRef();
oHtmlEvents2->Advise( piHtmlFile );
//
m_nTasksAll = oEpubContainer.m_oEpubPackage.GetCount();
m_nTasksComplete = 0;
if( oEpubContainer.m_oEpubPackage.GetCount() > 0 )
{// Html docx docx
int nHtmlsCount = oEpubContainer.m_oEpubPackage.GetCount();
CString sDstPath = CString( bstrDstPath );
CString sTempHtml = Utils::CreateTempDir( bstrDstPath );
FolderRemove oTempFolderRemove(sTempHtml);
bool bFirst = true;
for( int i = 0; i < nHtmlsCount; i++ )
{
CString sCurHtml = oEpubContainer.m_oEpubPackage.GetItem( i );
BSTR bstrCurHtml = sCurHtml.AllocSysString();
BSTR bstrDst;
if( true == bFirst )
bstrDst = sDstPath.AllocSysString();
else
bstrDst = sTempHtml.AllocSysString();
CString sOptions;
sOptions.AppendFormat( _T("<Options><FileType>%d</FileType><DefaultCodePage>%d</DefaultCodePage></Options>"), AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML, CP_UTF8 );
BSTR bstrOptions = sOptions.AllocSysString();
hRes = piHtmlFile->LoadFromFile( bstrCurHtml, bstrDst, bstrOptions );
SysFreeString( bstrOptions );
SysFreeString( bstrDst );
SysFreeString( bstrCurHtml );
if( true == m_bCancel )
break;
m_nTasksComplete++;
if( S_OK != hRes )
continue;
if( true == bFirst )
bFirst = false;
else
{
MergeDocx( sDstPath, sTempHtml );
Utils::RemoveDirOrFile( sTempHtml );
CreateDirectory( sTempHtml, NULL );
}
}
}
//
oHtmlEvents->UnAdvise( piHtmlFile );
RELEASEINTERFACE( oHtmlEvents );
oHtmlEvents2->UnAdvise( piHtmlFile );
RELEASEINTERFACE( oHtmlEvents2 );
return hRes;
}
STDMETHODIMP COfficeEpubFile::SaveToFile( BSTR bstrDstFileName, BSTR bstrSrcPath, BSTR bstrXMLOptions)
{
HRESULT hRes = S_OK;
// epub
CString sTempFolder = Utils::CreateTempDir( CString(bstrSrcPath) );
FolderRemove oFolderRemove( sTempFolder );
// epub
EpubContainer oEpubContainer;
oEpubContainer.m_oEpubPackage.m_bEmbedFont = true;
oEpubContainer.Create( sTempFolder );
//
bool bEpubFromHtml = false;
bool bSaveCover = true;
bool bOnePageHtml = true;
bool bLoadInCommandRenderer = false;
CString sSourceHtmlPath = _T("");
XmlUtils::CXmlReader oXmlOptionsReader;
if( TRUE == oXmlOptionsReader.OpenFromXmlString( bstrXMLOptions ) )
{
XML::IXMLDOMNodePtr pXmlSubNode;
if( TRUE ==oXmlOptionsReader.GetNode( pXmlSubNode ) )
{
XmlUtils::CXmlReader oXmlSubReader;
if( TRUE == oXmlSubReader.OpenFromXmlNode( pXmlSubNode ) )
if( TRUE == oXmlSubReader.ReadNode( _T("LoadInCommandRenderer") ) )
{
bLoadInCommandRenderer = true;
}
}
if( TRUE == oXmlOptionsReader.ReadNode( _T("EpubOptions") ) )
{
CString sXml = oXmlOptionsReader.ReadNodeXml();
CString sFontEncryption = oXmlOptionsReader.ReadNodeValue( _T("FontEncryption") );
if( _T("") != sFontEncryption )
oEpubContainer.m_oEpubPackage.m_nFontEncryption = (FontEncription)Strings::ToInteger( sFontEncryption );
CString sFontEmbed = oXmlOptionsReader.ReadNodeValue( _T("FontEmbed") );sFontEmbed.MakeLower();
if( _T("") != sFontEmbed )
{
if( _T("false") != sFontEmbed && _T("0") != sFontEmbed )
oEpubContainer.m_oEpubPackage.m_bEmbedFont = false;
else
oEpubContainer.m_oEpubPackage.m_bEmbedFont = true;
}
CString sSaveCover = oXmlOptionsReader.ReadNodeValue( _T("SaveCover") );sSaveCover.MakeLower();
if( _T("") != sSaveCover )
{
if( _T("false") != sSaveCover && _T("0") != sSaveCover )
bSaveCover = false;
else
bSaveCover = true;
}
XML::IXMLDOMNodePtr pXmlSubNode;
if( TRUE ==oXmlOptionsReader.GetNode( pXmlSubNode ) )
{
XmlUtils::CXmlReader oXmlSubReader;
if( TRUE == oXmlSubReader.OpenFromXmlNode( pXmlSubNode ) )
if( TRUE == oXmlSubReader.ReadNode( _T("OnePageHtml") ) )
{
CString sValue = oXmlSubReader.ReadNodeAttribute( _T("val") );
sValue.MakeLower();
if( _T("true") == sValue )
bOnePageHtml = true;
else if( _T("false") == sValue )
bOnePageHtml = false;
}
}
if( TRUE == oXmlOptionsReader.ReadNode( _T("NoStandartSave") ) )
sSourceHtmlPath = oXmlOptionsReader.ReadNodeAttribute( _T("destinationpath") );
}
}
CString sNewHtml = bstrSrcPath;
// IHtmlFile
OfficeHtmlFile::IHtmlFilePtr piHtmlFile;
piHtmlFile.CreateInstance( __uuidof(OfficeHtmlFile::CHtmlFile) );
if( NULL == piHtmlFile )
return AVS_ERROR_UNEXPECTED;
//
COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents, COfficeEpubFile >* oHtmlEvents = new COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents, COfficeEpubFile >( this );
oHtmlEvents->AddRef();
oHtmlEvents->Advise( piHtmlFile );
COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents2, COfficeEpubFile >* oHtmlEvents2 = new COfficeHtmlEvent< OfficeHtmlFile::_IAVSOfficeFileTemplateEvents2, COfficeEpubFile >( this );
oHtmlEvents2->AddRef();
oHtmlEvents2->Advise( piHtmlFile );
//
m_nTasksAll = 2;
m_nTasksComplete = 0;
if( false == bEpubFromHtml )
{
if( true == bLoadInCommandRenderer && true == bOnePageHtml )
{
m_nTasksAll = 1;
m_nTasksComplete = 0;
long nPageCount = 0;
m_piCommandsRenderer->get_PageCount( &nPageCount );
DocxRenderer::IAVSDocxRendererPtr piDocxRenderer;
piDocxRenderer.CreateInstance( __uuidof( DocxRenderer::CAVSDocxRenderer ) );
if( NULL != piDocxRenderer )
{
for( int i = 0; i < nPageCount; i++ )
{
CString sCurTempDir = Utils::CreateTempDir( bstrSrcPath );
CString sDocxRendererOptions = _T("<DocxRenderer");
sDocxRendererOptions.AppendFormat( _T(" destinationpath=\"%s\""), sCurTempDir );
sDocxRendererOptions.AppendFormat( _T(" textformatting=\"%d\""), TextFormatting::c_nWordProcessing );
sDocxRendererOptions.Append( _T("/>") );
//
BSTR bstrDocxRendererOptions = sDocxRendererOptions.AllocSysString();
piDocxRenderer->Initialize( bstrDocxRendererOptions );
SysFreeString( bstrDocxRendererOptions );
piDocxRenderer->NewPage();
hRes = m_piCommandsRenderer->DrawPage( i, piDocxRenderer );
if( FAILED( hRes ) )
m_bCancel = true;
if( false == m_bCancel )
{
hRes = piDocxRenderer->Save();
if( FAILED( hRes ) )
m_bCancel = true;
if( false == m_bCancel )
{
OfficeHtmlFile::IHtmlFilePtr piCurHtmlFile;
piCurHtmlFile.CreateInstance( __uuidof(OfficeHtmlFile::CHtmlFile) );
// docx html
sNewHtml = oEpubContainer.m_oEpubPackage.m_sPackegePath;
sNewHtml.AppendFormat( _T("Chapter%d.html"), oEpubContainer.m_oEpubPackage.GetCount() + 1 );
BSTR bstrDestHtml = sNewHtml.AllocSysString();
CString sOptions;
sOptions.AppendFormat( _T("<Options><FileType>%d</FileType><ConvertListOptions list2list=\"false\"/></Options>"), AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML );
BSTR bstrDocxDir = sCurTempDir.AllocSysString();
BSTR bstrOptions = sOptions.AllocSysString();
hRes = piCurHtmlFile->SaveToFile( bstrDestHtml, bstrDocxDir, bstrOptions );
SysFreeString( bstrDocxDir );
SysFreeString( bstrOptions );
SysFreeString( bstrDestHtml );
if( FAILED( hRes ) )
m_bCancel = true;
// html
oEpubContainer.m_oEpubPackage.AddHtml( sNewHtml );
}
}
SHORT shCancel = c_shProgressContinue;
OnProgressHtmlEx( 0, long( c_nMaxProgressPercent * ( 1.0 * ( i + 1 ) / nPageCount )), &shCancel );
if( true == m_bCancel )
break;
Utils::RemoveDirOrFile( sCurTempDir );
}
}
}
else
{
if( true == bLoadInCommandRenderer )
{
DocxRenderer::IAVSDocxRendererPtr piDocxRenderer;
piDocxRenderer.CreateInstance( __uuidof( DocxRenderer::CAVSDocxRenderer ) );
if( NULL != piDocxRenderer )
{
CString sDocxRendererOptions = _T("<DocxRenderer");
sDocxRendererOptions.AppendFormat( _T(" destinationpath=\"%s\""), bstrSrcPath );
sDocxRendererOptions.AppendFormat( _T(" textformatting=\"%d\""), TextFormatting::c_nWordProcessing );
sDocxRendererOptions.Append( _T("/>") );
//
BSTR bstrDocxRendererOptions = sDocxRendererOptions.AllocSysString();
piDocxRenderer->Initialize( bstrDocxRendererOptions );
SysFreeString( bstrDocxRendererOptions );
HRESULT hRes = S_OK;
long nPageCount = 0;
m_piCommandsRenderer->get_PageCount( &nPageCount );
for( int i = 0; i < nPageCount; i++ )
{
piDocxRenderer->NewPage();
hRes = m_piCommandsRenderer->DrawPage( i, piDocxRenderer );
if( FAILED( hRes ) )
m_bCancel = true;
SHORT shCancel = c_shProgressContinue;
OnProgressHtmlEx( 0, long( c_nMaxProgressPercent * ( 1.0 * ( i + 1 ) / nPageCount )), &shCancel );
if( c_shProgressContinue != shCancel )
m_bCancel = true;
if( true == m_bCancel )
break;
}
if( false == m_bCancel )
{
hRes = piDocxRenderer->Save();
if( FAILED( hRes ) )
m_bCancel = true;
}
}
}
m_nTasksComplete = 1;
if( false == m_bCancel )
{
// docx html
sNewHtml = oEpubContainer.m_oEpubPackage.m_sPackegePath;
sNewHtml.AppendFormat( _T("Chapter%d.html"), oEpubContainer.m_oEpubPackage.GetCount() + 1 );
BSTR bstrDestHtml = sNewHtml.AllocSysString();
CString sOptions;
sOptions.AppendFormat( _T("<Options><FileType>%d</FileType></Options>"), AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML );
BSTR bstrOptions = sOptions.AllocSysString();
hRes = piHtmlFile->SaveToFile( bstrDestHtml, bstrSrcPath, bstrOptions );
SysFreeString( bstrOptions );
SysFreeString( bstrDestHtml );
// html
oEpubContainer.m_oEpubPackage.AddHtml( sNewHtml );
}
}
}
else
{
// .
TCHAR tExt[256];
TCHAR tFilename[256];
TCHAR tFolder[256];
TCHAR tDrive[256];
_tsplitpath( CString(bstrSrcPath), tDrive, tFolder, tFilename, tExt );
CString sExt = CString(tExt);
CString sFilename = CString(tFilename);
CString sFolder = CString(tFolder);
CString sDrive = CString(tDrive);
// html xhtml
BSTR bstrSourceHtml = sSourceHtmlPath.AllocSysString();
sNewHtml = oEpubContainer.m_oEpubPackage.m_sPackegePath;
sNewHtml.AppendFormat( _T("Chapter%d.html"), oEpubContainer.m_oEpubPackage.GetCount() + 1 );
BSTR bstrDestHtml = sNewHtml.AllocSysString();
CString sOptions;sOptions.AppendFormat( _T("<Options><FileType>%d</FileType><NoStandartOpen destinationtype=\"%d\" destinationpath=\"%s\"/></Options>"), AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML, AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML, sNewHtml );
BSTR bstrOptions = sOptions.AllocSysString();
hRes = piHtmlFile->LoadFromFile( bstrSourceHtml, bstrDestHtml, bstrOptions );
SysFreeString( bstrOptions );
SysFreeString( bstrDestHtml );
SysFreeString( bstrSourceHtml );
//
CString sSourceHtmlDir = sDrive + sFolder + sFilename + _T("_files/");
CString sDestHtmlDir ; sDestHtmlDir.AppendFormat( oEpubContainer.m_oEpubPackage.m_sPackegePath + _T("Chapter%d_files"), oEpubContainer.m_oEpubPackage.GetCount() + 1 );
Utils::CopyDirOrFile( sSourceHtmlDir, sDestHtmlDir );
}
if( FAILED( hRes ) )
return hRes;
//
oHtmlEvents->UnAdvise( piHtmlFile );
RELEASEINTERFACE( oHtmlEvents );
oHtmlEvents2->UnAdvise( piHtmlFile );
RELEASEINTERFACE( oHtmlEvents2 );
if( true == m_bCancel )
return S_OK;
//Title
TCHAR tFilename[256];
_tsplitpath( CString(bstrDstFileName), NULL, NULL, tFilename, NULL );
CString sFilename = CString(tFilename);
oEpubContainer.m_oEpubPackage.m_sTitle = sFilename;
oEpubContainer.m_oEpubPackage.m_sAuthor = _T("Unknown");
//
if( true == bSaveCover && true == SaveCover( oEpubContainer.m_oEpubPackage.m_sPackegePath + _T("cover.jpeg"), oEpubContainer.m_oEpubPackage.m_nCoverWidth, oEpubContainer.m_oEpubPackage.m_nCoverHeight ) )
oEpubContainer.m_oEpubPackage.m_sCover = _T("cover.jpeg");
// epub
oEpubContainer.Save( sTempFolder );
// epub
CompressEpubDir( sTempFolder, bstrDstFileName );
return hRes;
}
STDMETHODIMP COfficeEpubFile::SetAdditionalParam( BSTR ParamName, VARIANT ParamValue)
{
return S_OK;
}
STDMETHODIMP COfficeEpubFile::GetAdditionalParam( BSTR ParamName, VARIANT* ParamValue)
{
CComBSTR ParamStr = ParamName;
if (ParamStr == L"Metadata")
{
(*ParamValue).vt = VT_BSTR;
(*ParamValue).bstrVal = m_sMetadata.AllocSysString();
}
return S_OK;
}
STDMETHODIMP COfficeEpubFile::get_CommandRenderer(IUnknown** ppunkRend)
{
if(NULL == ppunkRend)
return S_FALSE;
(*ppunkRend) = NULL;
if(NULL == m_piCommandsRenderer)
return S_OK;
return m_piCommandsRenderer->QueryInterface(__uuidof(AVSGraphics::IAVSDocumentRenderer), (void**)&ppunkRend);
}
STDMETHODIMP COfficeEpubFile::put_CommandRenderer(IUnknown* ppunkRend)
{
RELEASEINTERFACE(m_piCommandsRenderer);
if(NULL != ppunkRend)
ppunkRend->QueryInterface(__uuidof( AVSGraphics::IAVSDocumentRenderer), (void**)&m_piCommandsRenderer);
return S_OK;
}
BOOL COfficeEpubFile::IsEpubFile(CString sFilename, long& nError )
{
nError = NOERROR;
BOOL bResult = FALSE;
OfficeUtils::IOfficeUtils2Ptr piOfficeUtils;
piOfficeUtils.CreateInstance( __uuidof(OfficeUtils::COfficeUtils) );
if( NULL == piOfficeUtils )
{
nError = AVS_ERROR_UNEXPECTED;
return FALSE;
}
BYTE* pBuffer;
const char *odtFormatLine = "application/epub+zip";
BSTR bstrFilePath = sFilename.AllocSysString();
HRESULT hRes = piOfficeUtils->LoadFileFromArchive(bstrFilePath, L"mimetype", &pBuffer);
SysFreeString( bstrFilePath );
if ( hRes == S_OK && pBuffer != NULL )
{
if (strstr((char*)pBuffer, odtFormatLine))
bResult = TRUE;
}
RELEASEHEAP(pBuffer);
return bResult;
}
bool COfficeEpubFile::SaveCover( CString sFilename, long& nWidth, long& nHeight )
{
if( NULL != m_piCommandsRenderer )
{
long nPageCount = 0;
m_piCommandsRenderer->get_PageCount( &nPageCount );
if( nPageCount > 0 )
{
double dWidthMM = 0;
double dHeightMM = 0;
m_piCommandsRenderer->GetPageSize( 0, &dWidthMM, &dHeightMM );
//
if( 0 != dHeightMM )
{
nHeight = 1186;
nWidth = nHeight * dWidthMM / dHeightMM;
}
AVSMediaCore3::IAVSUncompressedVideoFrame* piImage = NULL;
AVSGraphics::IAVSGraphicsRenderer* piGraphicsRenderer = NULL;
UpdateGdiPlusRenderer( dWidthMM, dHeightMM, &piImage, &piGraphicsRenderer );
if( NULL != piGraphicsRenderer )
{
piGraphicsRenderer->NewPage();
m_piCommandsRenderer->DrawPage( 0, piGraphicsRenderer );
//
ImageFile::IImageFile3Ptr piImageFile = NULL;
piImageFile.CreateInstance( __uuidof(ImageFile::ImageFile3) );
if( NULL != piImageFile )
{
VARIANT_BOOL vbSuccess = VARIANT_TRUE;
BSTR bstrFilename = sFilename.AllocSysString();
piImageFile->SaveImage2( (IUnknown**)&piImage, IMAGEFORMAT_JPE, bstrFilename, &vbSuccess );
SysFreeString( bstrFilename );
if( VARIANT_FALSE != vbSuccess )
return true;
}
}
}
}
return false;
}
void COfficeEpubFile::UpdateGdiPlusRenderer(double dWidthMm, double dHeightMm, AVSMediaCore3::IAVSUncompressedVideoFrame** piImage, AVSGraphics::IAVSGraphicsRenderer** piRend)
{
(*piImage) = NULL;
(*piRend) = NULL;
CoCreateInstance(__uuidof( AVSMediaCore3::CAVSUncompressedVideoFrame), NULL ,CLSCTX_INPROC_SERVER, __uuidof(AVSMediaCore3::IAVSUncompressedVideoFrame), (void **)piImage);
AVSGraphics::IAVSFontManagerPtr piFontManager;
piFontManager.CreateInstance( __uuidof(AVSGraphics::CAVSFontManager) );
piFontManager->Initialize( L"" );
// dpi
int nLOGPIXELSX = 96;
int nLOGPIXELSY = 96;
//
long nWidthPix = (long)(nLOGPIXELSX * dWidthMm / (10 * ONE_INCH));
long nHeightPix = (long)(nLOGPIXELSY * dWidthMm * dHeightMm / (10 * dWidthMm * ONE_INCH));
(*piImage)->Width = nWidthPix;
(*piImage)->Height = nHeightPix;
(*piImage)->put_Stride(0, nWidthPix * 4);
(*piImage)->AspectRatioX = nWidthPix;
(*piImage)->AspectRatioY = nHeightPix;
(*piImage)->DataSize = 4 * nWidthPix * nHeightPix;
(*piImage)->ColorSpace = 64 + (1 << 31);
(*piImage)->AllocateBuffer(-1);
memset((*piImage)->Buffer, 255, (*piImage)->BufferSize);
CoCreateInstance(__uuidof( AVSGraphics::CAVSGraphicsRenderer), NULL ,CLSCTX_INPROC_SERVER, __uuidof(AVSGraphics::IAVSGraphicsRenderer), (void **)piRend);
// FontManager
VARIANT vtVariant;
vtVariant.vt = VT_UNKNOWN;
vtVariant.punkVal = piFontManager;
(*piRend)->SetAdditionalParam( L"FontManager", vtVariant );
(*piRend)->put_Width(dWidthMm);
(*piRend)->put_Height(dHeightMm);
(*piRend)->CreateFromMediaData(*piImage, 0, 0, nWidthPix, nHeightPix );
}
\ No newline at end of file
// AVSDocumentConverter.h : Declaration of the CAVSDocumentConverter
#pragma once
#include "resource.h" // main symbols
#include "..\Common\OfficeFileTemplate.h"
#include "AtlDefine.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
// IAVSDocumentConverter
[
object,
uuid("DA839E4E-A559-4ee1-A863-4A6D44484989"),
dual, helpstring("IAVSOfficeEpubFile Interface"),
pointer_default(unique)
]
__interface IOfficeEpubFile : IAVSOfficeFileTemplate
{
[id(10)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(20)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
[id(30), propget] HRESULT CommandRenderer([out, retval] IUnknown** ppunkRend);
[id(30), propput] HRESULT CommandRenderer([in] IUnknown* punkRend);
};
// CAVSOfficeEpubFile
[
coclass,
default(IOfficeEpubFile),
threading(apartment),
event_source(com),
vi_progid("AVSOfficeEpubFile.AVSDocume"),
progid("AVSOfficeEpubFile.AVSDocu.1"),
version(1.0),
uuid("82506410-0164-459a-A191-381C22F1550E"),
helpstring("AVSOfficeEpubFile Class")
]
class ATL_NO_VTABLE COfficeEpubFile : public IOfficeEpubFile
{
public:
COfficeEpubFile():m_piCommandsRenderer(NULL)
{
m_nTasksAll = 0;
m_nTasksComplete = 0;
m_bCancel = false;
m_sMetadata = _T("");
}
__event __interface _IAVSOfficeFileTemplateEvents;
__event __interface _IAVSOfficeFileTemplateEvents2;
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
RELEASEINTERFACE (m_piCommandsRenderer);
}
public:
STDMETHOD(LoadFromFile)( BSTR bstrSrcFileName, BSTR bstrDstPath, BSTR bstrXMLOptions);
STDMETHOD(SaveToFile)( BSTR bstrDstFileName, BSTR bstrSrcPath, BSTR bstrXMLOptions);
STDMETHOD(SetAdditionalParam)( BSTR ParamName, VARIANT ParamValue);
STDMETHOD(GetAdditionalParam)( BSTR ParamName, VARIANT* ParamValue);
STDMETHOD(get_CommandRenderer)(IUnknown** ppunkRend);
STDMETHOD(put_CommandRenderer)(IUnknown* ppunkRend);
public:
HRESULT OnProgressHtml( LONG nID, LONG nPercent );
HRESULT OnProgressHtmlEx( LONG nID, LONG nPercent, SHORT* Cancel );
private:
BOOL IsEpubFile(CString sFilename, long& nError );
bool SaveCover( CString sFilename, long& nWidth, long& nHeight );
void UpdateGdiPlusRenderer(double dWidthMm, double dHeightMm,AVSMediaCore3::IAVSUncompressedVideoFrame** piImage,AVSGraphics::IAVSGraphicsRenderer** piRend);
private:
AVSGraphics::IAVSDocumentRenderer * m_piCommandsRenderer;
int m_nTasksAll;
int m_nTasksComplete;
bool m_bCancel;
CString m_sMetadata;
};
\ No newline at end of file
#pragma once
#include "EpubPackage.h"
class EpubContainer
{
public: EpubPackage m_oEpubPackage;
public: int Load( CString sFolderPath )
{
CString sContainer = sFolderPath + _T("\\META-INF\\container.xml");
XmlUtils::CXmlReader oXmlReader;
if( TRUE == oXmlReader.OpenFromFile( sContainer ) )
if( TRUE == oXmlReader.ReadRootNode( _T("container") ) )
if( TRUE == oXmlReader.ReadNode( _T("rootfiles") ) )
if( TRUE == oXmlReader.ReadNodeList( _T("rootfile") ) )
{
for( int i = 0; i < oXmlReader.GetLengthList(); i++ )
{
CString sMime = oXmlReader.ReadNodeAttribute( i, _T("media-type") );
CString sPackagePath = oXmlReader.ReadNodeAttribute( i, _T("full-path") );
if( _T("") != sPackagePath && _T("application/oebps-package+xml") == sMime )
return m_oEpubPackage.Load( sFolderPath + _T("\\") + sPackagePath );
}
}
return -1;
}
public: int Create( CString sFolderPath )
{
HANDLE hFile = NULL;
DWORD dwBetysWritten = 0;
// mime
hFile = ::CreateFile( sFolderPath + _T("\\mimetype"), GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
if( INVALID_HANDLE_VALUE == hFile )
return -1;
CStringA sMime = "application/epub+zip";
::WriteFile( hFile, sMime, sMime.GetLength(), &dwBetysWritten, NULL );
RELEASEHANDLE( hFile );
// META-INF
CreateDirectory( sFolderPath + _T("\\META-INF"), NULL );
//container.xml
hFile = ::CreateFile( sFolderPath + _T("\\META-INF\\container.xml"), GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
if( INVALID_HANDLE_VALUE == hFile )
return -1;
CStringA sContainer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
sContainer.Append( "<container xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\" version=\"1.0\"><rootfiles><rootfile full-path=\"OPS/content.opf\" media-type=\"application/oebps-package+xml\"/></rootfiles></container>" );
::WriteFile( hFile, sContainer, sContainer.GetLength(), &dwBetysWritten, NULL );
RELEASEHANDLE( hFile );
// package
CreateDirectory( sFolderPath + _T("\\OPS"), NULL );
return m_oEpubPackage.Create( sFolderPath + _T("\\OPS\\"), _T("OPS/") );
}
public: void Save( CString sFolderPath )
{
m_oEpubPackage.Save();
//encryption.xml
if( m_oEpubPackage.m_aCrypted.GetCount() > 0 )
{
HANDLE hFile = NULL;
DWORD dwBetysWritten = 0;
hFile = ::CreateFile( sFolderPath + _T("\\META-INF\\encryption.xml"), GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
if( INVALID_HANDLE_VALUE == hFile )
return ;
CString sEncryption = _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sEncryption.Append( _T("<encryption xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">") );
for( int i = 0; i < (int)m_oEpubPackage.m_aCrypted.GetCount(); i++ )
sEncryption.Append( m_oEpubPackage.m_aCrypted[i] );
sEncryption.Append( _T("</encryption>") );
// utf-8
CStringA sContentUtf;
int nBufSize = WideCharToMultiByte(CP_UTF8, 0, sEncryption, -1, NULL, NULL, NULL, NULL);
LPSTR p = sContentUtf.GetBuffer( nBufSize );
WideCharToMultiByte(CP_UTF8, 0, sEncryption, -1, p, nBufSize, NULL, NULL);
sContentUtf.ReleaseBuffer();
::WriteFile( hFile, sContentUtf, sContentUtf.GetLength(), &dwBetysWritten, NULL );
RELEASEHANDLE( hFile );
}
}
};
\ No newline at end of file
#pragma once
#include "SHA1/sha1.h"
#include "../AVSOfficeUniversalConverter/Utils.h"
#define ZLIB_WINAPI
#define CODEPAGE_ISSUE_FIX
#include "zlib.h"
#define BUFFER_ENCODE_READ 2048 // 1040
#define BUFFER_ENCODE_WRITE 8196
#define BUFFER_DECODE_READ 2048
#define BUFFER_DECODE_WRITE 8196
CStringA Strip( CStringA sInput )
{
CStringA sResult = sInput;
sResult.Remove( ' ' );
sResult.Remove( 0x20 );
sResult.Remove( 0x09 );
sResult.Remove( 0x0D );
sResult.Remove( 0x0A );
return sResult;
}
//XOR ,
bool CryptFile( CString sSourceFile, CString sDestFilename, CStringA sInit, bool bEncode, bool bIDPF = true )
{
byte* mask = NULL;
int masklength = 0;
int headerLen = 0;
if( true == bIDPF )
{//IDPF
// SHA-1 hash sInit
SHA1 oSha1;
oSha1.Reset();
sInit = Strip( sInit );
oSha1.Input( sInit, sInit.GetLength() );
unsigned int Hash[5];
if( false == oSha1.Result( (unsigned int*)Hash ) )
return false;
//
mask = new byte[ 20 ];
masklength = 20;
headerLen = 1040;
for( int i = 0; i < 5 ; i++ )
{
mask[ i * 4 + 0 ] = (Hash[i] & 0xff000000) >> 24;
mask[ i * 4 + 1 ] = (Hash[i] & 0x00ff0000) >> 16;
mask[ i * 4 + 2 ] = (Hash[i] & 0x0000ff00) >> 8;
mask[ i * 4 + 3 ] = (Hash[i] & 0x000000ff) >> 0;
}
}
else
{//ADOBE
if( -1 != sInit.Find( "urn:uuid:" ) )
sInit.Delete( 0, 9 );
CAtlArray<byte> aTempBytes;
int acc = 0;
int len = sInit.GetLength();
for (int i = 0; i < len; i++)
{
char c = sInit[i];
int n;
if ('0' <= c && c <= '9')
n = c - '0';
else if ('a' <= c && c <= 'f')
n = c - ('a' - 10);
else if ('A' <= c && c <= 'F')
n = c - ('A' - 10);
else
continue;
if (acc == 0)
{
acc = 0x100 | (n << 4);
}
else
{
aTempBytes.Add(acc | n);
acc = 0;
}
}
if (aTempBytes.GetCount() != 16)
return false;
masklength = aTempBytes.GetCount();
mask = new byte[ masklength ];
headerLen = 1024;
for( int i = 0; i < masklength; i++ )
mask[i] = aTempBytes[i];
}
BYTE* byteReadBuffer = NULL;
DWORD dwReadBuffSize = NULL;
if( true == bEncode )
{
byteReadBuffer = new BYTE[ BUFFER_ENCODE_READ ];
dwReadBuffSize = BUFFER_ENCODE_READ;
}
else
{
byteReadBuffer = new BYTE[ BUFFER_DECODE_READ ];
dwReadBuffSize = BUFFER_DECODE_READ;
}
//
HANDLE hFileRead = ::CreateFile( sSourceFile, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
DWORD dwBytesRead = 0;
//
HANDLE hFileWrite = ::CreateFile( sDestFilename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 );
DWORD dwBytesWrite = 0;
if( INVALID_HANDLE_VALUE == hFileRead || INVALID_HANDLE_VALUE == hFileWrite )
return false;
//
BYTE* outBuff = NULL;
DWORD dwOutBuffSize = NULL;
if( true == bEncode )
{
outBuff = new BYTE[ BUFFER_ENCODE_WRITE ];
dwOutBuffSize = BUFFER_ENCODE_WRITE;
}
else
{
outBuff = new BYTE[ BUFFER_DECODE_WRITE ];
dwOutBuffSize = BUFFER_DECODE_WRITE;
}
::ReadFile( hFileRead, byteReadBuffer, dwReadBuffSize, &dwBytesRead, NULL );
long dwRead = 0, dwWritten = 0;
bool bFirst = true;
bool bError = false;
int nRes = 0;
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
if( true == bEncode )
nRes = deflateInit2( &strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY );
else
nRes = inflateInit2( &strm, -15 );
if (nRes != Z_OK)
return false;
nRes = 0;
do
{
if( true == bEncode )
{
strm.next_in = byteReadBuffer;
strm.avail_in = dwBytesRead;
do
{
strm.avail_out = dwOutBuffSize;
strm.next_out = outBuff;
nRes = deflate( &strm, Z_FULL_FLUSH );
if( S_OK != nRes && Z_STREAM_END != nRes )
return false;
long nBytesToWrite = dwOutBuffSize - strm.avail_out;
if( headerLen > 0 )
{
int nMinSize = headerLen;
if( nMinSize > nBytesToWrite )
nMinSize = nBytesToWrite;
headerLen -= nMinSize;
for( int i = 0; i < nMinSize; i++ )
outBuff[ i ] = outBuff[ i ] ^ mask[ i % masklength ];
}
DWORD dwBytesWrittenInFile = 0;
::WriteFile( hFileWrite, outBuff , nBytesToWrite, &dwBytesWrittenInFile, NULL );
}
while( strm.avail_in != 0 );
::ReadFile( hFileRead, byteReadBuffer ,dwReadBuffSize, &dwBytesRead, NULL );
}
else
{
strm.next_in = byteReadBuffer;
strm.avail_in = dwBytesRead;
if( headerLen > 0 )
{
int nMinSize = headerLen;
if( nMinSize > dwBytesRead )
nMinSize = dwBytesRead;
headerLen -= nMinSize;
for( int i = 0; i < nMinSize; i++ )
byteReadBuffer[ i ] = byteReadBuffer[ i ] ^ mask[ i % masklength ];
}
do
{
strm.avail_out = dwOutBuffSize;
strm.next_out = outBuff;
nRes = inflate(&strm, Z_NO_FLUSH);
if( S_OK != nRes && Z_STREAM_END != nRes )
return false;
long nBytesToWrite = dwOutBuffSize - strm.avail_out;
DWORD dwBytesWrittenInFile = 0;
::WriteFile( hFileWrite, outBuff , nBytesToWrite, &dwBytesWrittenInFile, NULL );
}
while( strm.avail_in != 0 );
::ReadFile( hFileRead, byteReadBuffer ,dwReadBuffSize, &dwBytesRead, NULL );
}
}
while( Z_STREAM_END != nRes && dwBytesRead > 0 );
if( true == bEncode )
deflateEnd(&strm);
else
inflateEnd(&strm);
RELEASEARRAYOBJECTS( byteReadBuffer );
RELEASEARRAYOBJECTS( outBuff );
RELEASEARRAYOBJECTS( mask );
CloseHandle( hFileRead );
CloseHandle( hFileWrite );
return true;
}
\ No newline at end of file
#pragma once
#include "XmlUtils.h"
#include "AtlDefine.h"
#include <boost/regex.hpp>
#include "PaintStruct.h"
#include "XmlUtils.h"
#include "../AVSOfficePDFWriter/Consts.h"
#include "../AVSOfficePDFWriter/Utils.h"
#include "../AVSOfficeUniversalConverter/Utils.h"
#include "EpubCrypt.h"
#include "OfficeDrawing/File.h"
using namespace boost::regex_constants;
CString LCID2String( LCID dwID )
{//http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx
switch( dwID )
{
case 0x0436: return _T("af");break;
case 0x041C: return _T("sq");break;
case 0x3801: return _T("ar-ae");break;
case 0x3C01: return _T("ar-bh");break;
case 0x1401: return _T("ar-dz");break;
case 0x0C01: return _T("ar-eg");break;
case 0x0801: return _T("ar-iq");break;
case 0x2C01: return _T("ar-jo");break;
case 0x3401: return _T("ar-kw");break;
case 0x3001: return _T("ar-lb");break;
case 0x1001: return _T("ar-ly");break;
case 0x1801: return _T("ar-ma");break;
case 0x2001: return _T("ar-om");break;
case 0x4001: return _T("ar-qa");break;
case 0x0401: return _T("ar-sa");break;
case 0x2801: return _T("ar-sy");break;
case 0x1C01: return _T("ar-tn");break;
case 0x2401: return _T("ar-ye");break;
case 0x042B: return _T("hy");break;
case 0x042C: return _T("az-az");break;
case 0x082C: return _T("az-az");break;
case 0x042D: return _T("eu");break;
case 0x0423: return _T("be");break;
case 0x0402: return _T("bg");break;
case 0x0403: return _T("ca");break;
case 0x0804: return _T("zh-cn");break;
case 0x0C04: return _T("zh-hk");break;
case 0x1404: return _T("zh-mo");break;
case 0x1004: return _T("zh-sg");break;
case 0x0404: return _T("zh-tw");break;
case 0x041A: return _T("hr");break;
case 0x0405: return _T("cs");break;
case 0x0406: return _T("da");break;
case 0x0413: return _T("nl-nl");break;
case 0x0813: return _T("nl-be");break;
case 0x0C09: return _T("en-au");break;
case 0x2809: return _T("en-bz");break;
case 0x1009: return _T("en-ca");break;
case 0x2409: return _T("en-cb");break;
case 0x1809: return _T("en-ie");break;
case 0x2009: return _T("en-jm");break;
case 0x1409: return _T("en-nz");break;
case 0x3409: return _T("en-ph");break;
case 0x1C09: return _T("en-za");break;
case 0x2C09: return _T("en-tt");break;
case 0x0809: return _T("en-gb");break;
case 0x0409: return _T("en-us");break;
case 0x0425: return _T("et");break;
case 0x0429: return _T("fa");break;
case 0x040B: return _T("fi");break;
case 0x0438: return _T("fo");break;
case 0x040C: return _T("fr-fr");break;
case 0x080C: return _T("fr-be");break;
case 0x0C0C: return _T("fr-ca");break;
case 0x140C: return _T("fr-lu");break;
case 0x100C: return _T("fr-ch");break;
case 0x083C: return _T("gd-ie");break;
case 0x043C: return _T("gd");break;
case 0x0407: return _T("de-de");break;
case 0x0C07: return _T("de-at");break;
case 0x1407: return _T("de-li");break;
case 0x1007: return _T("de-lu");break;
case 0x0807: return _T("de-ch");break;
case 0x0408: return _T("el");break;
case 0x040D: return _T("he");break;
case 0x0439: return _T("hi");break;
case 0x040E: return _T("hu");break;
case 0x040F: return _T("is");break;
case 0x0421: return _T("id");break;
case 0x0410: return _T("it-it");break;
case 0x0810: return _T("it-ch");break;
case 0x0411: return _T("ja");break;
case 0x0412: return _T("ko");break;
case 0x0426: return _T("lv");break;
case 0x0427: return _T("lt");break;
case 0x042F: return _T("mk");break;
case 0x043E: return _T("ms-my");break;
case 0x083E: return _T("ms-bn");break;
case 0x043A: return _T("mt");break;
case 0x044E: return _T("mr");break;
case 0x0414: return _T("no-no");break;
case 0x0814: return _T("no-no");break;
case 0x0415: return _T("pl");break;
case 0x0816: return _T("pt-pt");break;
case 0x0416: return _T("pt-br");break;
case 0x0417: return _T("rm");break;
case 0x0418: return _T("ro");break;
case 0x0818: return _T("ro-mo");break;
case 0x0419: return _T("ru");break;
case 0x0819: return _T("ru-mo");break;
case 0x044F: return _T("sa");break;
case 0x0C1A: return _T("sr-sp");break;
case 0x0432: return _T("tn");break;
case 0x0424: return _T("sl");break;
case 0x041B: return _T("sk");break;
case 0x042E: return _T("sb");break;
case 0x040A: return _T("es-es");break;
case 0x2C0A: return _T("es-ar");break;
case 0x400A: return _T("es-bo");break;
case 0x340A: return _T("es-cl");break;
case 0x240A: return _T("es-co");break;
case 0x140A: return _T("es-cr");break;
case 0x1C0A: return _T("es-do");break;
case 0x300A: return _T("es-ec");break;
case 0x100A: return _T("es-gt");break;
case 0x480A: return _T("es-hn");break;
case 0x080A: return _T("es-mx");break;
case 0x4C0A: return _T("es-ni");break;
case 0x180A: return _T("es-pa");break;
case 0x280A: return _T("es-pe");break;
case 0x500A: return _T("es-pr");break;
case 0x3C0A: return _T("es-py");break;
case 0x440A: return _T("es-sv");break;
case 0x380A: return _T("es-uy");break;
case 0x200A: return _T("es-ve");break;
case 0x0441: return _T("sw");break;
case 0x041D: return _T("sv-se");break;
case 0x081D: return _T("sv-fi");break;
case 0x0449: return _T("ta");break;
case 0x0444: return _T("tt");break;
case 0x041E: return _T("th");break;
case 0x041F: return _T("tr");break;
case 0x0431: return _T("ts");break;
case 0x0422: return _T("uk");break;
case 0x0420: return _T("ur");break;
case 0x0843: return _T("uz-uz");break;
case 0x0443: return _T("uz-uz");break;
case 0x042A: return _T("vi");break;
case 0x0434: return _T("xh");break;
case 0x043D: return _T("yi");break;
case 0x0435: return _T("zu");break;
}
return _T("en-us");
}
#define BUF_SIZE 2048
typedef enum { FE_NONE = 0, FE_ADOBE = 1, FE_IDPF = 2 } FontEncription;
class IdGenerator
{
public: IdGenerator()
{
m_nId = 1;
}
private: int m_nId;
public: CString GenerateId()
{
CString sId;
sId.AppendFormat( _T("id%d"), m_nId++ );
return sId;
}
};
class EpubPackage
{
public: EpubPackage()
{
TCHAR tBuffer[256];
GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, tBuffer, 256 );
m_sLanguage = LCID2String( _tcstol( tBuffer, NULL, 16 ) );
m_nFontEncryption = FE_NONE;
m_bEmbedFont = false;
m_piFontManager = NULL;
m_sMetadata = _T("");
}
public: ~EpubPackage()
{
RELEASEINTERFACE( m_piFontManager );
}
public: CString m_sPackegePath;
public: CString m_sPackegePathRel;
public: FontEncription m_nFontEncryption;
public: bool m_bEmbedFont;
public: CString m_sMetadata;
private: void CorrectString(CString& strValue)
{
strValue.Replace(_T("&"), _T("&amp;"));
strValue.Replace(_T("'"), _T("&apos;"));
strValue.Replace(_T("<"), _T("&lt;"));
strValue.Replace(_T(">"), _T("&gt;"));
strValue.Replace(_T("\""), _T("&quot;"));
}
private: CString CorrectString2(CString& str)
{
CString strValue = str;
CorrectString(strValue);
return strValue;
}
const CString getAttr(XML::IXMLDOMElementPtr element, const CString& attrName)
{
XML::IXMLDOMNamedNodeMapPtr attrs = element->Getattributes();
while( XML::IXMLDOMAttributePtr attr = attrs->nextNode() )
if (attr->GetbaseName().GetBSTR() == attrName)
return attr->GetnodeValue().bstrVal;
return _T("");
}
public: int Load( CString sPackageFilename )
{
TCHAR tDrive[256];
TCHAR tDir[256];
_tsplitpath( sPackageFilename, tDrive, tDir, NULL, NULL );
m_sPackegePath = CString( tDrive );
m_sPackegePath.Append( tDir );
XmlUtils::CXmlReader oXmlReader;
if( TRUE == oXmlReader.OpenFromFile( sPackageFilename ) )
if( TRUE == oXmlReader.ReadRootNode( _T("package") ) )
{
XML::IXMLDOMNodePtr oNode;
oXmlReader.GetNode( oNode );
XmlUtils::CXmlReader oXmlSubReader;
// metadata
m_sMetadata = _T("");
try
{
if( TRUE == oXmlSubReader.OpenFromXmlNode( oNode ) )
if( TRUE == oXmlSubReader.ReadNode( _T("metadata") ) )
{
CString sTitle = oXmlSubReader.ReadNodeValue(_T("dc:title"));
CString sCreator = oXmlSubReader.ReadNodeValue(_T("dc:creator"));
CString sPublisher = oXmlSubReader.ReadNodeValue(_T("dc:publisher"));
CString sLanguage = oXmlSubReader.ReadNodeValue(_T("dc:language"));
CString sContributor = oXmlSubReader.ReadNodeValue(_T("dc:contributor"));
CString sDescription = oXmlSubReader.ReadNodeValue(_T("dc:description"));
CString sCoverage = oXmlSubReader.ReadNodeValue(_T("dc:coverage"));
oXmlSubReader.ReadNodeList(_T("meta"));
for(int i = 0; i < oXmlSubReader.GetLengthList(); i++)
{
XML::IXMLDOMNodePtr pMeta;
oXmlSubReader.GetNode(i, pMeta);
CString sName = getAttr(pMeta, _T("name"));
if(_T("cover") == sName)
sCoverage = "1";
}
if(_T("") != sTitle)
m_sMetadata += _T("<name>") + CorrectString2(sTitle) + _T("</name>");
if(_T("") != sCreator)
{
m_sMetadata += _T("<author>") + CorrectString2(sCreator) + _T("</author>");
m_sMetadata += _T("<creator>") + CorrectString2(sCreator) + _T("</creator>");
}
if(_T("") != sPublisher)
m_sMetadata += _T("<publisher>") + CorrectString2(sPublisher) + _T("</publisher>");
if(_T("") != sLanguage)
m_sMetadata += _T("<language>") + CorrectString2(sLanguage) + _T("</language>");
if(_T("") != sContributor)
m_sMetadata += _T("<creator>") + CorrectString2(sContributor) + _T("</creator>");
if(_T("") != sDescription)
m_sMetadata += _T("<annotation>") + CorrectString2(sDescription) + _T("</annotation>");
if(_T("") != sCoverage)
m_sMetadata += _T("<coverpage>1</coverpage>");
if(_T("") != m_sMetadata)
m_sMetadata = _T("<meta>") + m_sMetadata + _T("</meta>");
}
}
catch(...)
{
m_sMetadata = _T("");
}
CAtlArray<CString> aSequence;
if( TRUE == oXmlSubReader.OpenFromXmlNode( oNode ) )
if( TRUE == oXmlSubReader.ReadNode( _T("spine") ) )
if( TRUE == oXmlSubReader.ReadNodeList( _T("itemref") ) )
{
for( int i = 0; i < oXmlSubReader.GetLengthList(); i++ )
{
CString sId = oXmlSubReader.ReadNodeAttribute( i, _T("idref") );
if( _T("") != sId )
aSequence.Add( sId );
}
}
if( aSequence.GetCount() > 0 )
{
if( TRUE == oXmlSubReader.OpenFromXmlNode( oNode ) )
if( TRUE == oXmlSubReader.ReadNode( _T("manifest") ) )
if( TRUE == oXmlSubReader.ReadNodeList( _T("item") ) )
{
for( int i = 0; i < (int)aSequence.GetCount(); i++ )
{
CString sTargetId = aSequence[i];
for( int j = 0; j < oXmlSubReader.GetLengthList(); j++ )
{
CString sMime = oXmlSubReader.ReadNodeAttribute( j, _T("media-type") );
CString sHRef = oXmlSubReader.ReadNodeAttribute( j, _T("href") );
//Decode URL
sHRef.Replace(_T("%20"), _T(" "));
sHRef.Replace(_T("%3B"), _T(";"));
sHRef.Replace(_T("%2C"), _T(","));
sHRef.Replace(_T("%26"), _T("&"));
sHRef.Replace(_T("%3D"), _T("="));
sHRef.Replace(_T("%2B"), _T("+"));
sHRef.Replace(_T("%24"), _T("$"));
CString sId = oXmlSubReader.ReadNodeAttribute( j, _T("id") );
if( sTargetId == sId && _T("") != sMime && _T("") != sHRef )
m_aHtmls.Add( m_sPackegePath + sHRef );
}
}
}
}
if( m_aHtmls.GetCount() > 0 )
return 0;
}
return -1;
}
public: int GetCount()
{
return (int)m_aHtmls.GetCount();
}
public: CString GetItem( int nIndex )
{
if( nIndex >= 0 && nIndex < (int)m_aHtmls.GetCount() )
return m_aHtmls[nIndex];
return _T("");
}
public: int Create( CString sFolderPath, CString sFolderPathRelative )
{
m_sPackegePath = sFolderPath;
m_sPackegePathRel = sFolderPathRelative;
m_sUUID = CreateUUID();
return 0;
}
public: void AddHtml( CString sPath )
{
// 300Kb xml, Sony
// - 260Kb ( calibre)
CFile oHtmlFile;
oHtmlFile.OpenFile( sPath );
ULONG64 lFileSize = oHtmlFile.GetFileSize();
oHtmlFile.CloseFile();
long nCriticalSize = 260 * 1024;
long nPartSize = 150 * 1024; //
if( lFileSize > nCriticalSize )
{
//
int nPartsCount = (lFileSize / nPartSize) + 1;
// html
_SplitHtml( sPath, nPartsCount );
DeleteFile( sPath );
}
else
_AddHtml(sPath);
}
private: void _SplitHtml( CString sPath, long nPartsCount )
{
try
{
XML::IXMLDOMDocumentPtr pXmlDocument;
pXmlDocument.CreateInstance(CLSID_DOMDocument);
if( NULL != pXmlDocument )
{
if( VARIANT_TRUE == pXmlDocument->load( CComVariant(sPath) ) )
{
XML::IXMLDOMNodePtr piHtmlNode = NULL;
XML::IXMLDOMNodePtr piHeadNode = NULL;
XML::IXMLDOMNodePtr piBodyNode = NULL;
XML::IXMLDOMNodePtr piBodyDiv = NULL;
piHtmlNode = pXmlDocument->selectSingleNode( _T("html") );
piHeadNode = pXmlDocument->selectSingleNode( _T("html/head") );
piBodyNode = pXmlDocument->selectSingleNode( _T("html/body") );
piBodyDiv = pXmlDocument->selectSingleNode( _T("html/body/div") );
if( NULL != piHtmlNode && NULL != piHeadNode && NULL != piBodyNode && NULL != piBodyDiv )
{
XML::IXMLDOMNodeListPtr piHtmlAttr = NULL;
XML::IXMLDOMNodeListPtr piBodyAttr = NULL;
XML::IXMLDOMNodeListPtr piBodyDivAttr = NULL;
//
piHtmlAttr = piHtmlNode->selectNodes( L"@*" );
piBodyAttr = piBodyNode->selectNodes( L"@*" );
piBodyDivAttr = piBodyDiv->selectNodes( L"@*" );
XML::IXMLDOMNodeListPtr piBodyChilds = NULL;
piBodyChilds = piBodyDiv->GetchildNodes();
// ,
// html
if( NULL != piBodyChilds )
{
long nChildCount = piBodyChilds->Getlength();
long nPartSize = nChildCount / nPartsCount;
if( nChildCount > 1 )
{
CString sNameWithoutExt = sPath.Left( sPath.GetLength() - (CString(_T(".html"))).GetLength() );
for( int i = 0; i < nPartsCount ; i++ )
{
//
XML::IXMLDOMDocumentPtr pXmlDocumentPart;
pXmlDocumentPart.CreateInstance(CLSID_DOMDocument);
// html
XML::IXMLDOMElementPtr pHtmlPart = pXmlDocumentPart->createElement( L"html" );
if( NULL != piHtmlAttr )
{
for( int j = 0 ; j < piHtmlAttr->Getlength(); j++ )
{
XML::IXMLDOMNodePtr pCurAttr = piHtmlAttr->Getitem(j);
pHtmlPart->setAttribute( pCurAttr->GetnodeName(), pCurAttr->GetnodeValue() );
}
}
// body
XML::IXMLDOMElementPtr pBodyPart = pXmlDocumentPart->createElement( L"body" );
if( NULL != piBodyAttr )
{
for( int j = 0 ; j < piBodyAttr->Getlength(); j++ )
{
XML::IXMLDOMNodePtr pCurAttr = piBodyAttr->Getitem(j);
pBodyPart->setAttribute( pCurAttr->GetnodeName(), pCurAttr->GetnodeValue() );
}
}
// div
XML::IXMLDOMElementPtr pDivPart = pXmlDocumentPart->createElement( L"div" );
if( NULL != piBodyDivAttr )
{
for( int j = 0 ; j < piBodyDivAttr->Getlength(); j++ )
{
XML::IXMLDOMNodePtr pCurAttr = piBodyDivAttr->Getitem(j);
pDivPart->setAttribute( pCurAttr->GetnodeName(), pCurAttr->GetnodeValue() );
}
}
//
CString sNewPath = sNameWithoutExt;
sNewPath.AppendFormat( _T("%d.html"), i + 1 );
int nInterStart = 0;
int nInterEnd = 0;
if( 0 == i )
nInterStart = 0;
else
nInterStart = i * nPartSize;
if( nPartsCount - 1 == i )
nInterEnd = nChildCount;
else
nInterEnd = (i + 1) * nPartSize;
for( int k = nInterStart; k < nInterEnd; k++ )
pDivPart->appendChild( piBodyChilds->Getitem(k)->cloneNode(VARIANT_TRUE) );
//
pBodyPart->appendChild( pDivPart );
if( NULL != piHeadNode )
pHtmlPart->appendChild( piHeadNode );
pHtmlPart->appendChild( pBodyPart );
pXmlDocumentPart->appendChild( pHtmlPart );
//
if( SUCCEEDED(pXmlDocumentPart->save(CComVariant(sNewPath))) )
AddHtml( sNewPath );
}
}
}
}
}
}
}
catch(...)
{
}
}
private: int _AddHtml( CString sPath )
{
//
TCHAR tExt[256];
TCHAR tFilename[256];
TCHAR tFolder[256];
TCHAR tDrive[256];
_tsplitpath( sPath, tDrive, tFolder, tFilename, tExt );
CString sExt = CString(tExt);
CString sFilename = CString(tFilename);
CString sFolder = CString(tFolder);
CString sDrive = CString(tDrive);
CString sNewItem;
CString sId = m_oIdGenerator.GenerateId();
sNewItem.AppendFormat( _T("<item href=\"%s\" id=\"%s\" media-type=\"application/xhtml+xml\"/>"), sFilename + sExt, sId );
m_aHtmlsManifest.Add( sNewItem );
m_aHtmlsSpine.Add( _T("<itemref idref=\"") + sId + _T("\"/>") );
m_aHtmls.Add( sFilename + sExt );
// html
AddAdditional( sPath, tDrive + sFolder , sFilename );
ModifyHtml( sPath );
if( true == m_bEmbedFont )
AddFonts( sPath, tDrive + sFolder , sFilename );
return 0;
}
private: void ModifyHtml( CString sPath )
{
std::string sStdFullHtml;
ReadFileInString( sPath, sStdFullHtml );
//c margin
boost::regex xRegEx1( "margin-(top|left|right|bottom)([^/>]*?)(;|(\"))" );
sStdFullHtml = boost::regex_replace( sStdFullHtml, xRegEx1, "\\4" );
//div.basic -
boost::regex xRegEx2( "div\\.basic(.*?)\\}" );
sStdFullHtml = boost::regex_replace( sStdFullHtml, xRegEx2, "" );
CStringA sFullHtml = CStringA( sStdFullHtml.c_str() );
// html
HANDLE hFile = ::CreateFile( sPath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
DWORD dwBytesWritten;
::WriteFile(hFile, sFullHtml.GetBuffer() , sFullHtml.GetLength(), &dwBytesWritten, NULL);
sFullHtml.ReleaseBuffer();
CloseHandle( hFile );
}
private: void AddAdditional( CString sSourceHtml , CString sFolder, CString sFilename )
{// html ( , ... )
CString sTargetFolder = sFilename + _T("_files/");
CString sPath = sFolder + sFilename + _T("_files");
HANDLE Handle;
WIN32_FIND_DATA FindData;
DWORDLONG Result=0;
Handle = FindFirstFile( (sPath+"\\*.*"), &FindData );
if ( Handle == INVALID_HANDLE_VALUE )
return;
do
{
if(( CString( FindData.cFileName ) != _T(".") )&&( CString( FindData.cFileName ) != _T("..") ) )
if( 0 == ( FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{
CString sFullFilename = sPath + _T("\\") + FindData.cFileName;
AddToManifest( sTargetFolder, sFullFilename );
}
}
while(FindNextFile(Handle, &FindData) != 0);
FindClose(Handle);
}
private: void AddFonts( CString sSourceHtml , CString sFolder, CString sFilename )
{
CString sTargetFolder = sFilename + _T("_files/");
CString sPath = sFolder + sFilename + _T("_files");
//
CAtlArray<CString> aFonts;
// css
CString sTargetFontFolder = _T("fonts/");
CString sFontPath = sFolder + _T("fonts");
// html
std::wstring sStdFullHtml;
boost::regex xRegEx( "font-family\\:'(.*?)';" );
XmlUtils::CXmlReader oXmlReader;
if(TRUE == oXmlReader.OpenFromFile(sSourceHtml))
if(TRUE == oXmlReader.ReadRootNode(_T("html")))
{
XML::IXMLDOMNodePtr pFullXmlNode;
if( SUCCEEDED( oXmlReader.GetNode( pFullXmlNode ) ) )
{
sStdFullHtml = pFullXmlNode->Getxml();
FindFontInString( sStdFullHtml, xRegEx, aFonts );
//// css
//if(TRUE == oXmlReader.ReadNode(_T("head")))
// if(TRUE == oXmlReader.ReadNodeList(_T("link")))
// {
// for( int i = 0 ;i < oXmlReader.GetLengthList(); i++ )
// {
// CString sRel = oXmlReader.ReadNodeAttribute( i, _T("rel") );
// if( _T("stylesheet") == sRel )
// {
// CString sHref = oXmlReader.ReadNodeAttribute( i, _T("href") );
// TCHAR tFolder[256];
// TCHAR tDrive[256];
// _tsplitpath( sSourceHtml, tDrive, tFolder, NULL, NULL );
// CString sFolder = CString(tFolder);
// CString sDrive = CString(tDrive);
// FindFontInFile( sDrive + sFolder + sHref, aFonts );
// }
// }
// }
CStringA sFullHtml = Utils::UnicodeToCodepage( sStdFullHtml.c_str(), CP_UTF8 );
// html css
CString sCSSEmbedFont;
Painter::CFont oCurFont;
wchar_t wsDisplayName[1000];
wchar_t wsFontName[1000];
//
for( int i = 0; i < (int)aFonts.GetCount(); i++ )
{
CString sFontName = (CString)aFonts[i];
CAtlMap<CString, bool>::CPair *pPair = m_mapFonts.Lookup( sFontName );
if( NULL == pPair )
{
m_mapFonts.SetAt( sFontName, true );
AddFont( &oCurFont, sFontName, (LPTSTR)wsDisplayName, 1000, (LPTSTR)wsFontName, 1000, sFontPath, sTargetFontFolder, sCSSEmbedFont );
//AddFont( &oCurFont, sFontName + _T(" Bold"), (LPTSTR)wsDisplayName, 1000, (LPTSTR)wsFontName, 1000, sFontPath, sTargetFontFolder, sCSSEmbedFont );
//AddFont( &oCurFont, sFontName + _T(" Italic"), (LPTSTR)wsDisplayName, 1000, (LPTSTR)wsFontName, 1000, sFontPath, sTargetFontFolder, sCSSEmbedFont );
//AddFont( &oCurFont, sFontName + _T(" Bold Italic"), (LPTSTR)wsDisplayName, 1000, (LPTSTR)wsFontName, 1000, sFontPath, sTargetFontFolder, sCSSEmbedFont );
}
}
// css
if( -1 != sFullHtml.Find( "</style>" ) )
sFullHtml.Replace( "</style>", sCSSEmbedFont + "\n</style>" );
else
{
CStringA sAddStyle = "<style>";
sAddStyle.Append( sCSSEmbedFont + "\n</style>\n</head>" );
sFullHtml.Replace( "</head>", sAddStyle );
}
// html
HANDLE hFile = ::CreateFile( sSourceHtml, GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
DWORD dwBytesWritten;
::WriteFile(hFile, "" , 3, &dwBytesWritten, NULL);// utf-8
::WriteFile(hFile, sFullHtml.GetBuffer() , sFullHtml.GetLength(), &dwBytesWritten, NULL);
sFullHtml.ReleaseBuffer();
CloseHandle( hFile );
}
}
}
private: void ReadFileInString( CString sFilepath, std::string& sResult )
{
//
std::string sStdFullHtml;
CFile oXmlFile;
oXmlFile.OpenFile( sFilepath );
ULONG64 lBufSize = oXmlFile.GetFileSize();
BYTE* pTempBuf = new BYTE[ lBufSize + 1 ];
oXmlFile.ReadFile( pTempBuf, lBufSize );
pTempBuf [lBufSize] = '\0';
sResult = (char*)pTempBuf;
RELEASEARRAYOBJECTS( pTempBuf );
oXmlFile.CloseFile();
}
private: void FindFontInString( std::wstring sStdFullHtml, boost::regex xRegEx, CAtlArray<CString>& aResult )
{
boost::wsmatch oFonts;
std::wstring::const_iterator xItStart = sStdFullHtml.begin();
std::wstring::const_iterator xItEnd = sStdFullHtml.end();
while( boost::regex_search( xItStart, xItEnd, oFonts, xRegEx ) )
{
CString sNewFonts = ((std::wstring)oFonts[1]).c_str();
CString sCurFont;
int curPos= 0;
sCurFont= sNewFonts.Tokenize (_T(","), curPos);
while (sCurFont != "")
{
sCurFont.Trim();
bool bExist = false;
for( int j = 0; j < (int)aResult.GetCount(); j++ )
if( sCurFont == aResult[j] )
{
bExist = true;
break;
}
if( false == bExist )
aResult.Add( sCurFont );
sCurFont= sNewFonts.Tokenize (_T(","), curPos);
}
xItStart = oFonts[1].second;
}
}
private: void FindFontInFile( CString sFilepath, CAtlArray<CString>& aResult )
{
std::string sStdFullHtml;
boost::regex xRegEx( "font-family\\:(.*?);" );
ReadFileInString( sFilepath, sStdFullHtml );
//FindFontInString( sStdFullHtml, xRegEx, aResult );
}
private: void AddFont( Painter::CFont *pFont, CString sFontName, LPTSTR wsDisplayName, int nDisplayNameSize, LPTSTR wsFontName, int nFontFileSize, CString sFontPath, CString sTargetFontFolder, CString& sCSSEmbedFont )
{
BOOL bBold = FALSE;
BOOL bItalic = FALSE;
CString sFontFilePath;
//
if ( GetFontFile( pFont, sFontName, wsDisplayName, 1000, wsFontName, 1000, &bBold, &bItalic ) )
{
sFontFilePath = wsFontName;
//
if( ::GetFileAttributes( sFontFilePath ) == INVALID_FILE_ATTRIBUTES )
{//
// - , sFontFile
char *pValue;
size_t len;
errno_t err = _dupenv_s( &pValue, &len, "windir" );
sFontFilePath = CString(pValue);
sFontFilePath += "\\Fonts\\";
sFontFilePath += wsFontName;
if( ::GetFileAttributes( sFontFilePath ) == INVALID_FILE_ATTRIBUTES )
return;// ,
}
CString sFontFileName = wsFontName;
//CharLower( sFontFileName.GetBuffer() );
//sFontFileName.ReleaseBuffer();
CString sFontAddress = sFontPath + _T("\\") + sFontFileName;
CreateDirectory( sFontPath, NULL );
//
bool bFontEmbedResult = true;
if( FE_IDPF == m_nFontEncryption )
bFontEmbedResult = CryptFile( sFontFilePath, sFontAddress, (CStringA)m_sUUID, true, true );
else if( FE_ADOBE == m_nFontEncryption )
bFontEmbedResult = CryptFile( sFontFilePath, sFontAddress, (CStringA)m_sUUID, true, false );
else
{
// font
int nRes = Utils::CopyDirOrFile( sFontFilePath, sFontAddress );
if( NULL != nRes )
bFontEmbedResult = false;
}
if( true == bFontEmbedResult )
{
CString sStyle;
if( TRUE == bBold )
sStyle.Append( _T("font-weight:bold;") );
else
sStyle.Append( _T("font-weight:normal;") );
if( TRUE == bItalic )
sStyle.Append( _T("font-style:italic;") );
else
sStyle.Append( _T("font-style:normal;") );
// css
//sCSSEmbedFont.AppendFormat( _T("@font-face {font-family:'%s';%ssrc:url(%s);}"), sFontName, sStyle, sTargetFontFolder + sFontFileName );
sCSSEmbedFont.AppendFormat( _T("@font-face {font-family:'%s';font-weight:normal;font-style:normal;src:url('%s');}\n"), sFontName, sTargetFontFolder + sFontFileName );
sCSSEmbedFont.AppendFormat( _T("@font-face {font-family:'%s';font-weight:bold;font-style:normal;src:url('%s');}\n"), sFontName, sTargetFontFolder + sFontFileName );
sCSSEmbedFont.AppendFormat( _T("@font-face {font-family:'%s';font-weight:normal;font-style:italic;src:url('%s');}\n"), sFontName, sTargetFontFolder + sFontFileName );
sCSSEmbedFont.AppendFormat( _T("@font-face {font-family:'%s';font-weight:bold;font-style:italic;src:url('%s');}\n"), sFontName, sTargetFontFolder + sFontFileName );
// manifest
AddToManifest( sTargetFontFolder, sFontFileName, _T("application/octet-stream") );
if( FE_NONE != m_nFontEncryption )
{
AddToCrypt( sTargetFontFolder, sFontFileName );
}
}
}
}
private: void AddToCrypt( CString sTargetFolder, CString sFullFilename )
{
TCHAR tExt[256];
TCHAR tFilename[256];
TCHAR tFolder[256];
TCHAR tDrive[256];
_tsplitpath( sFullFilename, tDrive, tFolder, tFilename, tExt );
CString sExt = CString(tExt);
CString sFilename = CString(tFilename);
CString sFolder = CString(tFolder);
CString sDrive = CString(tDrive);
CString sNewItem;
sNewItem.AppendFormat( _T("<EncryptedData xmlns=\"http://www.w3.org/2001/04/xmlenc#\"><EncryptionMethod Algorithm=\"http://ns.adobe.com/pdf/enc#RC\"/><CipherData><CipherReference URI=\"%s\"/></CipherData></EncryptedData>"),m_sPackegePathRel + sTargetFolder + sFilename + sExt );
m_aCrypted.Add( sNewItem );
}
private: void AddToManifest( CString sTargetFolder, CString sFullFilename, CString sMime = _T("") )
{
if( _T("") == sMime )
{
TCHAR *pBuffer ;
FindMimeFromData( NULL, sFullFilename, NULL, NULL, NULL, FMFD_DEFAULT, &pBuffer, 0 );
sMime = CString( pBuffer );
RELEASEHEAP(pBuffer);
}
if( _T("") != sMime )
{
TCHAR tExt[256];
TCHAR tFilename[256];
TCHAR tFolder[256];
TCHAR tDrive[256];
_tsplitpath( sFullFilename, tDrive, tFolder, tFilename, tExt );
CString sExt = CString(tExt);
CString sFilename = CString(tFilename);
CString sFolder = CString(tFolder);
CString sDrive = CString(tDrive);
CString sNewItem;
sNewItem.AppendFormat( _T("<item href=\"%s\" id=\"%s\" media-type=\"%s\"/>"),sTargetFolder + sFilename + sExt, m_oIdGenerator.GenerateId(), sMime );
m_aHtmlsManifest.Add( sNewItem );
}
}
public: int Save()
{
if( _T("") != m_sCover )
SaveTitle();// titlepage.xhtml
// toc.ncx
SaveToc();
// content.opf
SaveContent();
return 0;
}
public: int SaveTitle()
{
HANDLE hFile = NULL;
DWORD dwBetysWritten = 0;
hFile = ::CreateFile( m_sPackegePath + _T("\\titlepage.xhtml"), GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
if( INVALID_HANDLE_VALUE == hFile )
return -1;
CString sTitle = _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sTitle.Append( _T("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">") );
sTitle.Append( _T("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>") );
sTitle.Append( _T("<title>Cover</title>") );
sTitle.Append( _T("<style type=\"text/css\" title=\"override_css\">") );
sTitle.Append( _T("@page {padding: 0pt; margin:0pt}") );
sTitle.Append( _T("body { text-align: center; padding:0pt; margin: 0pt; }") );
sTitle.Append( _T("</style></head>") );
sTitle.Append( _T("<body><div>") );
sTitle.AppendFormat( _T("<img src=\"%s\"/>"), m_sCover );
sTitle.Append( _T("</div></body></html>") );
CStringA sTitleUtf;
int nBufSize = WideCharToMultiByte(CP_UTF8, 0, sTitle, -1, NULL, NULL, NULL, NULL);
LPSTR p = sTitleUtf.GetBuffer(nBufSize);
WideCharToMultiByte(CP_UTF8, 0, sTitle, -1, p, nBufSize, NULL, NULL);
sTitleUtf.ReleaseBuffer();
::WriteFile( hFile, sTitleUtf, sTitleUtf.GetLength(), &dwBetysWritten, NULL );
RELEASEHANDLE( hFile );
return 0;
}
public: int SaveToc()
{
HANDLE hFile = NULL;
DWORD dwBetysWritten = 0;
hFile = ::CreateFile( m_sPackegePath + _T("\\toc.ncx"), GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
if( INVALID_HANDLE_VALUE == hFile )
return -1;
CString sToc = _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sToc.Append( _T("<ncx version=\"2005-1\" xmlns=\"http://www.daisy.org/z3986/2005/ncx/\">") );
sToc.AppendFormat( _T("<head><meta name=\"dtb:uid\" content=\"%s\"/><meta name=\"dtb:depth\" content=\"1\"/></head>"), m_sUUID );
sToc.AppendFormat( _T("<docTitle><text>%s</text></docTitle>"), m_sTitle );
sToc.AppendFormat( _T("<docAuthor><text>%s</text></docAuthor>"), m_sAuthor );
int nHtmlCount = (int)m_aHtmls.GetCount();
if( nHtmlCount > 0 )
{
sToc.Append( _T("<navMap>"));
for( int i = 0; i < nHtmlCount; i++ )
sToc.AppendFormat( _T("<navPoint id=\"part%d\" playOrder=\"%d\"><navLabel><text>Part %d</text></navLabel><content src=\"%s\"/></navPoint>"), (i+1), (i+1), (i+1), m_aHtmls[i] );
sToc.Append( _T("</navMap>"));
}
sToc.Append( _T("</ncx>") );
CStringA sTocUtf;
int nBufSize = WideCharToMultiByte(CP_UTF8, 0, sToc, -1, NULL, NULL, NULL, NULL);
LPSTR p = sTocUtf.GetBuffer(nBufSize);
WideCharToMultiByte(CP_UTF8, 0, sToc, -1, p, nBufSize, NULL, NULL);
sTocUtf.ReleaseBuffer();
::WriteFile( hFile, sTocUtf, sTocUtf.GetLength(), &dwBetysWritten, NULL );
RELEASEHANDLE( hFile );
return 0;
}
public: int SaveContent()
{
HANDLE hFile = NULL;
DWORD dwBetysWritten = 0;
//
hFile = ::CreateFile( m_sPackegePath + _T("\\content.opf"), GENERIC_WRITE, 0, 0, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, 0);
if( INVALID_HANDLE_VALUE == hFile )
return -1;
CString sContent = _T("<?xml version='1.0' encoding='utf-8'?>\n");
sContent.Append( _T("<package xmlns=\"http://www.idpf.org/2007/opf\" version=\"2.0\" unique-identifier=\"bookid\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:opf=\"http://www.idpf.org/2007/opf\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dcterms=\"http://purl.org/dc/terms/\">") );
sContent.Append( _T("<metadata>") );
if( false == m_sTitle.IsEmpty() )
sContent.AppendFormat( _T("<dc:title>%s</dc:title>"), m_sTitle );
if( false == m_sAuthor.IsEmpty() )
sContent.AppendFormat( _T("<dc:creator>%s</dc:creator>"), m_sAuthor );
if( false == m_sLanguage.IsEmpty() )
sContent.AppendFormat( _T("<dc:language>%s</dc:language>"), m_sLanguage );
sContent.AppendFormat( _T("<dc:identifier id=\"bookid\">%s</dc:identifier>"), m_sUUID );
sContent.Append( _T("</metadata>") );
//sContent.Append( _T("<package xmlns=\"http://www.idpf.org/2007/opf\" version=\"2.0\" >") );
sContent.Append( _T("<manifest>") );
if( _T("") != m_sCover )
{
sContent.AppendFormat( _T("<item href=\"%s\" id=\"cover\" media-type=\"image/jpeg\"/>"), m_sCover );
sContent.Append( _T("<item href=\"titlepage.xhtml\" id=\"titlepage\" media-type=\"application/xhtml+xml\"/>") );
}
sContent.Append( _T("<opf:item id=\"ncx\" href=\"toc.ncx\" media-type=\"application/x-dtbncx+xml\"/>") );
for( int i = 0; i < (int)m_aHtmlsManifest.GetCount(); i++ )
sContent.Append( m_aHtmlsManifest[i] );
sContent.Append( _T("</manifest>") );
sContent.Append( _T("<spine toc=\"ncx\">") );
if( _T("") != m_sCover )
sContent.Append( _T("<itemref idref=\"titlepage\"/>") );
for( int i = 0; i < (int)m_aHtmlsSpine.GetCount(); i++ )
sContent.Append( m_aHtmlsSpine[i] );
sContent.Append( _T("</spine>") );
sContent.Append( _T("</package>") );
CStringA sContentUtf;
int nBufSize = WideCharToMultiByte(CP_UTF8, 0, sContent, -1, NULL, NULL, NULL, NULL);
LPSTR p = sContentUtf.GetBuffer(nBufSize);
WideCharToMultiByte(CP_UTF8, 0, sContent, -1, p, nBufSize, NULL, NULL);
sContentUtf.ReleaseBuffer();
::WriteFile( hFile, sContentUtf, sContentUtf.GetLength(), &dwBetysWritten, NULL );
RELEASEHANDLE( hFile );
return 0;
}
public: CString CreateUUID()
{
CString sUUID = _T("urn:uuid:");
srand ( time(NULL) );
addRandomHexDigit(sUUID, 8, 0xF, 0);
sUUID.AppendChar('-');
addRandomHexDigit(sUUID, 4, 0xF, 0);
sUUID.AppendChar('-');
sUUID.AppendChar('4');
addRandomHexDigit(sUUID, 3, 0xF, 0);
sUUID.AppendChar('-');
addRandomHexDigit(sUUID, 1, 0x3, 0x8);
addRandomHexDigit(sUUID, 3, 0xF, 0);
sUUID.AppendChar('-');
addRandomHexDigit(sUUID, 12, 0xF, 0);
return sUUID;
}
private: void addRandomHexDigit( CString& sb, int count, int mask, int value )
{
for (int i = 0; i < count; i++)
{
int v = ( ( rand() % 16 ) & mask ) | value;
if (v < 10)
sb.AppendChar((char) ('0' + v));
else
sb.AppendChar((char) (('a' - 10) + v));
}
}
private: IdGenerator m_oIdGenerator;
private: CAtlArray<CString> m_aHtmls;
private: CAtlArray<CString> m_aHtmlsManifest;
private: CAtlArray<CString> m_aHtmlsSpine;
public: CAtlArray<CString> m_aCrypted;
private: CString m_sUUID;
private: CString m_sLanguage;
public: CString m_sTitle;
public: CString m_sAuthor;
public: CString m_sCover;
public: long m_nCoverWidth;
public: long m_nCoverHeight;
public: AVSGraphics::IAVSFontManager* m_piFontManager;
private: CAtlMap<CString, bool> m_mapFonts;
};
#pragma once
#include "..\AVSOfficeFile\OfficeEventsTemplate.h"
template <class T, class Reciever>
class COfficeHtmlEvent : public COfficeEventTemplate<T,Reciever>
{
public:
COfficeHtmlEvent(Reciever *pReciever):COfficeEventTemplate(pReciever)
{
m_cnt = 0;
m_dwAdvise = 0;
};
HRESULT OnProgress( LONG nID, LONG nPercent )
{
m_pReciever->OnProgressHtml( nID, nPercent );
return S_OK;
}
HRESULT OnProgressEx( LONG nID, LONG nPercent, SHORT* Cancel )
{
m_pReciever->OnProgressHtmlEx( nID, nPercent, Cancel );
return S_OK;
}
STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
//CTemporaryCS oCS(&m_csThread);
HRESULT hr;
VARIANTARG varg0;
VARIANTARG varg1;
VARIANTARG varg2;
switch(dispIdMember) {
case 1:
VariantInit(&varg0);
VariantInit(&varg1);
hr = DispGetParam(pDispParams,0,VT_I4,&varg0,puArgErr);
hr = DispGetParam(pDispParams,1,VT_I4,&varg1,puArgErr);
OnProgress( varg0.lVal, varg1.lVal );
return(S_OK);
break;
case 2:
VariantInit(&varg0);
VariantInit(&varg1);
VariantInit(&varg2);
hr = DispGetParam(pDispParams,0,VT_I4,&varg0,puArgErr);
hr = DispGetParam(pDispParams,1,VT_I4,&varg1,puArgErr);
hr = DispGetParam(pDispParams,2,VT_I2,&varg2,puArgErr);
OnProgressEx( varg0.lVal, varg1.lVal, &varg2.iVal );
if (pDispParams->rgvarg[0].vt & VT_BYREF) // implemented now for last VT_I2 arg only
{
SHORT* p = (SHORT*)pDispParams->rgvarg[0].byref;
if (p) *p = varg2.iVal;
}
return(S_OK);
break;
default:
return(E_NOTIMPL);
}
}
};
\ No newline at end of file
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AVSOfficeCAVSOfficeEpubFile.rc
//
#define IDS_PROJNAME 100
#define IDR_AVSOFFICEEPUBFILE 101
#define IDR_CRPT1 202
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 203
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif
/*
* sha1.cpp
*
* Copyright (C) 1998, 2009
* Paul E. Jones <paulej@packetizer.com>
* All Rights Reserved.
*
*****************************************************************************
* $Id: sha1.cpp 12 2009-06-22 19:34:25Z paulej $
*****************************************************************************
*
* Description:
* This class implements the Secure Hashing Standard as defined
* in FIPS PUB 180-1 published April 17, 1995.
*
* The Secure Hashing Standard, which uses the Secure Hashing
* Algorithm (SHA), produces a 160-bit message digest for a
* given data stream. In theory, it is highly improbable that
* two messages will produce the same message digest. Therefore,
* this algorithm can serve as a means of providing a "fingerprint"
* for a message.
*
* Portability Issues:
* SHA-1 is defined in terms of 32-bit "words". This code was
* written with the expectation that the processor has at least
* a 32-bit machine word size. If the machine word size is larger,
* the code should still function properly. One caveat to that
* is that the input functions taking characters and character arrays
* assume that only 8 bits of information are stored in each character.
*
* Caveats:
* SHA-1 is designed to work with messages less than 2^64 bits long.
* Although SHA-1 allows a message digest to be generated for
* messages of any number of bits less than 2^64, this implementation
* only works with messages with a length that is a multiple of 8
* bits.
*
*/
#include "stdafx.h"
#include "sha1.h"
/*
* SHA1
*
* Description:
* This is the constructor for the sha1 class.
*
* Parameters:
* None.
*
* Returns:
* Nothing.
*
* Comments:
*
*/
SHA1::SHA1()
{
Reset();
}
/*
* ~SHA1
*
* Description:
* This is the destructor for the sha1 class
*
* Parameters:
* None.
*
* Returns:
* Nothing.
*
* Comments:
*
*/
SHA1::~SHA1()
{
// The destructor does nothing
}
/*
* Reset
*
* Description:
* This function will initialize the sha1 class member variables
* in preparation for computing a new message digest.
*
* Parameters:
* None.
*
* Returns:
* Nothing.
*
* Comments:
*
*/
void SHA1::Reset()
{
Length_Low = 0;
Length_High = 0;
Message_Block_Index = 0;
H[0] = 0x67452301;
H[1] = 0xEFCDAB89;
H[2] = 0x98BADCFE;
H[3] = 0x10325476;
H[4] = 0xC3D2E1F0;
Computed = false;
Corrupted = false;
}
/*
* Result
*
* Description:
* This function will return the 160-bit message digest into the
* array provided.
*
* Parameters:
* message_digest_array: [out]
* This is an array of five unsigned integers which will be filled
* with the message digest that has been computed.
*
* Returns:
* True if successful, false if it failed.
*
* Comments:
*
*/
bool SHA1::Result(unsigned *message_digest_array)
{
int i; // Counter
if (Corrupted)
{
return false;
}
if (!Computed)
{
PadMessage();
Computed = true;
}
for(i = 0; i < 5; i++)
{
message_digest_array[i] = H[i];
}
return true;
}
/*
* Input
*
* Description:
* This function accepts an array of octets as the next portion of
* the message.
*
* Parameters:
* message_array: [in]
* An array of characters representing the next portion of the
* message.
*
* Returns:
* Nothing.
*
* Comments:
*
*/
void SHA1::Input( const unsigned char *message_array,
unsigned length)
{
if (!length)
{
return;
}
if (Computed || Corrupted)
{
Corrupted = true;
return;
}
while(length-- && !Corrupted)
{
Message_Block[Message_Block_Index++] = (*message_array & 0xFF);
Length_Low += 8;
Length_Low &= 0xFFFFFFFF; // Force it to 32 bits
if (Length_Low == 0)
{
Length_High++;
Length_High &= 0xFFFFFFFF; // Force it to 32 bits
if (Length_High == 0)
{
Corrupted = true; // Message is too long
}
}
if (Message_Block_Index == 64)
{
ProcessMessageBlock();
}
message_array++;
}
}
/*
* Input
*
* Description:
* This function accepts an array of octets as the next portion of
* the message.
*
* Parameters:
* message_array: [in]
* An array of characters representing the next portion of the
* message.
* length: [in]
* The length of the message_array
*
* Returns:
* Nothing.
*
* Comments:
*
*/
void SHA1::Input( const char *message_array,
unsigned length)
{
Input((unsigned char *) message_array, length);
}
/*
* Input
*
* Description:
* This function accepts a single octets as the next message element.
*
* Parameters:
* message_element: [in]
* The next octet in the message.
*
* Returns:
* Nothing.
*
* Comments:
*
*/
void SHA1::Input(unsigned char message_element)
{
Input(&message_element, 1);
}
/*
* Input
*
* Description:
* This function accepts a single octet as the next message element.
*
* Parameters:
* message_element: [in]
* The next octet in the message.
*
* Returns:
* Nothing.
*
* Comments:
*
*/
void SHA1::Input(char message_element)
{
Input((unsigned char *) &message_element, 1);
}
/*
* operator<<
*
* Description:
* This operator makes it convenient to provide character strings to
* the SHA1 object for processing.
*
* Parameters:
* message_array: [in]
* The character array to take as input.
*
* Returns:
* A reference to the SHA1 object.
*
* Comments:
* Each character is assumed to hold 8 bits of information.
*
*/
SHA1& SHA1::operator<<(const char *message_array)
{
const char *p = message_array;
while(*p)
{
Input(*p);
p++;
}
return *this;
}
/*
* operator<<
*
* Description:
* This operator makes it convenient to provide character strings to
* the SHA1 object for processing.
*
* Parameters:
* message_array: [in]
* The character array to take as input.
*
* Returns:
* A reference to the SHA1 object.
*
* Comments:
* Each character is assumed to hold 8 bits of information.
*
*/
SHA1& SHA1::operator<<(const unsigned char *message_array)
{
const unsigned char *p = message_array;
while(*p)
{
Input(*p);
p++;
}
return *this;
}
/*
* operator<<
*
* Description:
* This function provides the next octet in the message.
*
* Parameters:
* message_element: [in]
* The next octet in the message
*
* Returns:
* A reference to the SHA1 object.
*
* Comments:
* The character is assumed to hold 8 bits of information.
*
*/
SHA1& SHA1::operator<<(const char message_element)
{
Input((unsigned char *) &message_element, 1);
return *this;
}
/*
* operator<<
*
* Description:
* This function provides the next octet in the message.
*
* Parameters:
* message_element: [in]
* The next octet in the message
*
* Returns:
* A reference to the SHA1 object.
*
* Comments:
* The character is assumed to hold 8 bits of information.
*
*/
SHA1& SHA1::operator<<(const unsigned char message_element)
{
Input(&message_element, 1);
return *this;
}
/*
* ProcessMessageBlock
*
* Description:
* This function will process the next 512 bits of the message
* stored in the Message_Block array.
*
* Parameters:
* None.
*
* Returns:
* Nothing.
*
* Comments:
* Many of the variable names in this function, especially the single
* character names, were used because those were the names used
* in the publication.
*
*/
void SHA1::ProcessMessageBlock()
{
const unsigned K[] = { // Constants defined for SHA-1
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xCA62C1D6
};
int t; // Loop counter
unsigned temp; // Temporary word value
unsigned W[80]; // Word sequence
unsigned A, B, C, D, E; // Word buffers
/*
* Initialize the first 16 words in the array W
*/
for(t = 0; t < 16; t++)
{
W[t] = ((unsigned) Message_Block[t * 4]) << 24;
W[t] |= ((unsigned) Message_Block[t * 4 + 1]) << 16;
W[t] |= ((unsigned) Message_Block[t * 4 + 2]) << 8;
W[t] |= ((unsigned) Message_Block[t * 4 + 3]);
}
for(t = 16; t < 80; t++)
{
W[t] = CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
}
A = H[0];
B = H[1];
C = H[2];
D = H[3];
E = H[4];
for(t = 0; t < 20; t++)
{
temp = CircularShift(5,A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = CircularShift(30,B);
B = A;
A = temp;
}
for(t = 20; t < 40; t++)
{
temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = CircularShift(30,B);
B = A;
A = temp;
}
for(t = 40; t < 60; t++)
{
temp = CircularShift(5,A) +
((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = CircularShift(30,B);
B = A;
A = temp;
}
for(t = 60; t < 80; t++)
{
temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
temp &= 0xFFFFFFFF;
E = D;
D = C;
C = CircularShift(30,B);
B = A;
A = temp;
}
H[0] = (H[0] + A) & 0xFFFFFFFF;
H[1] = (H[1] + B) & 0xFFFFFFFF;
H[2] = (H[2] + C) & 0xFFFFFFFF;
H[3] = (H[3] + D) & 0xFFFFFFFF;
H[4] = (H[4] + E) & 0xFFFFFFFF;
Message_Block_Index = 0;
}
/*
* PadMessage
*
* Description:
* According to the standard, the message must be padded to an even
* 512 bits. The first padding bit must be a '1'. The last 64 bits
* represent the length of the original message. All bits in between
* should be 0. This function will pad the message according to those
* rules by filling the message_block array accordingly. It will also
* call ProcessMessageBlock() appropriately. When it returns, it
* can be assumed that the message digest has been computed.
*
* Parameters:
* None.
*
* Returns:
* Nothing.
*
* Comments:
*
*/
void SHA1::PadMessage()
{
/*
* Check to see if the current message block is too small to hold
* the initial padding bits and length. If so, we will pad the
* block, process it, and then continue padding into a second block.
*/
if (Message_Block_Index > 55)
{
Message_Block[Message_Block_Index++] = 0x80;
while(Message_Block_Index < 64)
{
Message_Block[Message_Block_Index++] = 0;
}
ProcessMessageBlock();
while(Message_Block_Index < 56)
{
Message_Block[Message_Block_Index++] = 0;
}
}
else
{
Message_Block[Message_Block_Index++] = 0x80;
while(Message_Block_Index < 56)
{
Message_Block[Message_Block_Index++] = 0;
}
}
/*
* Store the message length as the last 8 octets
*/
Message_Block[56] = (Length_High >> 24) & 0xFF;
Message_Block[57] = (Length_High >> 16) & 0xFF;
Message_Block[58] = (Length_High >> 8) & 0xFF;
Message_Block[59] = (Length_High) & 0xFF;
Message_Block[60] = (Length_Low >> 24) & 0xFF;
Message_Block[61] = (Length_Low >> 16) & 0xFF;
Message_Block[62] = (Length_Low >> 8) & 0xFF;
Message_Block[63] = (Length_Low) & 0xFF;
ProcessMessageBlock();
}
/*
* CircularShift
*
* Description:
* This member function will perform a circular shifting operation.
*
* Parameters:
* bits: [in]
* The number of bits to shift (1-31)
* word: [in]
* The value to shift (assumes a 32-bit integer)
*
* Returns:
* The shifted value.
*
* Comments:
*
*/
unsigned SHA1::CircularShift(int bits, unsigned word)
{
return ((word << bits) & 0xFFFFFFFF) | ((word & 0xFFFFFFFF) >> (32-bits));
}
/*
* sha1.h
*
* Copyright (C) 1998, 2009
* Paul E. Jones <paulej@packetizer.com>
* All Rights Reserved.
*
*****************************************************************************
* $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $
*****************************************************************************
*
* Description:
* This class implements the Secure Hashing Standard as defined
* in FIPS PUB 180-1 published April 17, 1995.
*
* Many of the variable names in this class, especially the single
* character names, were used because those were the names used
* in the publication.
*
* Please read the file sha1.cpp for more information.
*
*/
#ifndef _SHA1_H_
#define _SHA1_H_
class SHA1
{
public:
SHA1();
virtual ~SHA1();
/*
* Re-initialize the class
*/
void Reset();
/*
* Returns the message digest
*/
bool Result(unsigned *message_digest_array);
/*
* Provide input to SHA1
*/
void Input( const unsigned char *message_array,
unsigned length);
void Input( const char *message_array,
unsigned length);
void Input(unsigned char message_element);
void Input(char message_element);
SHA1& operator<<(const char *message_array);
SHA1& operator<<(const unsigned char *message_array);
SHA1& operator<<(const char message_element);
SHA1& operator<<(const unsigned char message_element);
private:
/*
* Process the next 512 bits of the message
*/
void ProcessMessageBlock();
/*
* Pads the current message block to 512 bits
*/
void PadMessage();
/*
* Performs a circular left shift operation
*/
inline unsigned CircularShift(int bits, unsigned word);
unsigned H[5]; // Message digest buffers
unsigned Length_Low; // Message length in bits
unsigned Length_High; // Message length in bits
unsigned char Message_Block[64]; // 512-bit message blocks
int Message_Block_Index; // Index into message block array
bool Computed; // Is the digest computed?
bool Corrupted; // Is the message digest corruped?
};
#endif
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: c_regex_traits.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Implements out of line c_regex_traits<char> members
*/
#define BOOST_REGEX_SOURCE
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
#include <boost/regex/v4/c_regex_traits.hpp>
#include <boost/regex/v4/primary_transform.hpp>
#include <boost/regex/v4/regex_traits_defaults.hpp>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{
using ::strxfrm; using ::isspace;
using ::ispunct; using ::isalpha;
using ::isalnum; using ::iscntrl;
using ::isprint; using ::isupper;
using ::islower; using ::isdigit;
using ::isxdigit; using ::strtol;
}
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
namespace boost{
c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform(const char* p1, const char* p2)
{
std::string result(10, ' ');
std::size_t s = result.size();
std::size_t r;
std::string src(p1, p2);
while(s < (r = std::strxfrm(&*result.begin(), src.c_str(), s)))
{
result.append(r - s + 3, ' ');
s = result.size();
}
result.erase(r);
return result;
}
c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform_primary(const char* p1, const char* p2)
{
static char s_delim;
static const int s_collate_type = ::boost::re_detail::find_sort_syntax(static_cast<c_regex_traits<char>*>(0), &s_delim);
std::string result;
//
// What we do here depends upon the format of the sort key returned by
// sort key returned by this->transform:
//
switch(s_collate_type)
{
case ::boost::re_detail::sort_C:
case ::boost::re_detail::sort_unknown:
// the best we can do is translate to lower case, then get a regular sort key:
{
result.assign(p1, p2);
for(std::string::size_type i = 0; i < result.size(); ++i)
result[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(result[i])));
result = transform(&*result.begin(), &*result.begin() + result.size());
break;
}
case ::boost::re_detail::sort_fixed:
{
// get a regular sort key, and then truncate it:
result = transform(p1, p2);
result.erase(s_delim);
break;
}
case ::boost::re_detail::sort_delim:
// get a regular sort key, and then truncate everything after the delim:
result = transform(p1, p2);
if(result.size() && (result[0] == s_delim))
break;
std::size_t i;
for(i = 0; i < result.size(); ++i)
{
if(result[i] == s_delim)
break;
}
result.erase(i);
break;
}
if(result.empty())
result = std::string(1, char(0));
return result;
}
enum
{
char_class_space=1<<0,
char_class_print=1<<1,
char_class_cntrl=1<<2,
char_class_upper=1<<3,
char_class_lower=1<<4,
char_class_alpha=1<<5,
char_class_digit=1<<6,
char_class_punct=1<<7,
char_class_xdigit=1<<8,
char_class_alnum=char_class_alpha|char_class_digit,
char_class_graph=char_class_alnum|char_class_punct,
char_class_blank=1<<9,
char_class_word=1<<10,
char_class_unicode=1<<11
};
c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_classname(const char* p1, const char* p2)
{
static const char_class_type masks[] =
{
0,
char_class_alnum,
char_class_alpha,
char_class_blank,
char_class_cntrl,
char_class_digit,
char_class_digit,
char_class_graph,
char_class_lower,
char_class_lower,
char_class_print,
char_class_punct,
char_class_space,
char_class_space,
char_class_upper,
char_class_unicode,
char_class_upper,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
int id = ::boost::re_detail::get_default_class_id(p1, p2);
if(id < 0)
{
std::string s(p1, p2);
for(std::string::size_type i = 0; i < s.size(); ++i)
s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i])));
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0]));
return masks[id+1];
}
bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask)
{
return
((mask & char_class_space) && (std::isspace)(static_cast<unsigned char>(c)))
|| ((mask & char_class_print) && (std::isprint)(static_cast<unsigned char>(c)))
|| ((mask & char_class_cntrl) && (std::iscntrl)(static_cast<unsigned char>(c)))
|| ((mask & char_class_upper) && (std::isupper)(static_cast<unsigned char>(c)))
|| ((mask & char_class_lower) && (std::islower)(static_cast<unsigned char>(c)))
|| ((mask & char_class_alpha) && (std::isalpha)(static_cast<unsigned char>(c)))
|| ((mask & char_class_digit) && (std::isdigit)(static_cast<unsigned char>(c)))
|| ((mask & char_class_punct) && (std::ispunct)(static_cast<unsigned char>(c)))
|| ((mask & char_class_xdigit) && (std::isxdigit)(static_cast<unsigned char>(c)))
|| ((mask & char_class_blank) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::re_detail::is_separator(c))
|| ((mask & char_class_word) && (c == '_'));
}
c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_collatename(const char* p1, const char* p2)
{
std::string s(p1, p2);
s = ::boost::re_detail::lookup_default_collate_name(s);
if(s.empty() && (p2-p1 == 1))
s.append(1, *p1);
return s;
}
int BOOST_REGEX_CALL c_regex_traits<char>::value(char c, int radix)
{
char b[2] = { c, '\0', };
char* ep;
int result = std::strtol(b, &ep, radix);
if(ep == b)
return -1;
return result;
}
}
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif
#endif
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE cpp_regex_traits.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Implements cpp_regex_traits<char> (and associated helper classes).
*/
#define BOOST_REGEX_SOURCE
#include <boost/config.hpp>
#ifndef BOOST_NO_STD_LOCALE
#include <boost/regex/regex_traits.hpp>
#include <boost/regex/pattern_except.hpp>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{
using ::memset;
}
#endif
namespace boost{ namespace re_detail{
void cpp_regex_traits_char_layer<char>::init()
{
// we need to start by initialising our syntax map so we know which
// character is used for which purpose:
std::memset(m_char_map, 0, sizeof(m_char_map));
#ifndef BOOST_NO_STD_MESSAGES
#ifndef __IBMCPP__
std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
#else
std::messages<char>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
#endif
std::string cat_name(cpp_regex_traits<char>::get_catalog_name());
if(cat_name.size())
{
cat = this->m_pmessages->open(
cat_name,
this->m_locale);
if((int)cat < 0)
{
std::string m("Unable to open message catalog: ");
std::runtime_error err(m + cat_name);
boost::re_detail::raise_runtime_error(err);
}
}
//
// if we have a valid catalog then load our messages:
//
if((int)cat >= 0)
{
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
{
string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i));
for(string_type::size_type j = 0; j < mss.size(); ++j)
{
m_char_map[static_cast<unsigned char>(mss[j])] = i;
}
}
this->m_pmessages->close(cat);
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
this->m_pmessages->close(cat);
throw;
}
#endif
}
else
{
#endif
for(regex_constants::syntax_type j = 1; j < regex_constants::syntax_max; ++j)
{
const char* ptr = get_default_syntax(j);
while(ptr && *ptr)
{
m_char_map[static_cast<unsigned char>(*ptr)] = j;
++ptr;
}
}
#ifndef BOOST_NO_STD_MESSAGES
}
#endif
//
// finish off by calculating our escape types:
//
unsigned char i = 'A';
do
{
if(m_char_map[i] == 0)
{
if(this->m_pctype->is(std::ctype_base::lower, i))
m_char_map[i] = regex_constants::escape_type_class;
else if(this->m_pctype->is(std::ctype_base::upper, i))
m_char_map[i] = regex_constants::escape_type_not_class;
}
}while(0xFF != i++);
}
} // re_detail
} // boost
#endif
/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: cregex.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Implements high level class boost::RexEx
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex.hpp>
#include <boost/cregex.hpp>
#if !defined(BOOST_NO_STD_STRING)
#include <map>
#include <list>
#include <boost/regex/v4/fileiter.hpp>
typedef boost::match_flag_type match_flag_type;
#include <cstdio>
#ifdef BOOST_MSVC
#pragma warning(disable:4309)
#endif
namespace boost{
#ifdef __BORLANDC__
#if __BORLANDC__ < 0x530
//
// we need to instantiate the vector classes we use
// since declaring a reference to type doesn't seem to
// do the job...
std::vector<std::size_t> inst1;
std::vector<std::string> inst2;
#endif
#endif
namespace{
template <class iterator>
std::string to_string(iterator i, iterator j)
{
std::string s;
while(i != j)
{
s.append(1, *i);
++i;
}
return s;
}
inline std::string to_string(const char* i, const char* j)
{
return std::string(i, j);
}
}
namespace re_detail{
class RegExData
{
public:
enum type
{
type_pc,
type_pf,
type_copy
};
regex e;
cmatch m;
#ifndef BOOST_REGEX_NO_FILEITER
match_results<mapfile::iterator> fm;
#endif
type t;
const char* pbase;
#ifndef BOOST_REGEX_NO_FILEITER
mapfile::iterator fbase;
#endif
std::map<int, std::string, std::less<int> > strings;
std::map<int, std::ptrdiff_t, std::less<int> > positions;
void update();
void clean();
RegExData() : e(), m(),
#ifndef BOOST_REGEX_NO_FILEITER
fm(),
#endif
t(type_copy), pbase(0),
#ifndef BOOST_REGEX_NO_FILEITER
fbase(),
#endif
strings(), positions() {}
};
void RegExData::update()
{
strings.erase(strings.begin(), strings.end());
positions.erase(positions.begin(), positions.end());
if(t == type_pc)
{
for(unsigned int i = 0; i < m.size(); ++i)
{
if(m[i].matched) strings[i] = std::string(m[i].first, m[i].second);
positions[i] = m[i].matched ? m[i].first - pbase : -1;
}
}
#ifndef BOOST_REGEX_NO_FILEITER
else
{
for(unsigned int i = 0; i < fm.size(); ++i)
{
if(fm[i].matched) strings[i] = to_string(fm[i].first, fm[i].second);
positions[i] = fm[i].matched ? fm[i].first - fbase : -1;
}
}
#endif
t = type_copy;
}
void RegExData::clean()
{
#ifndef BOOST_REGEX_NO_FILEITER
fbase = mapfile::iterator();
fm = match_results<mapfile::iterator>();
#endif
}
} // namespace
RegEx::RegEx()
{
pdata = new re_detail::RegExData();
}
RegEx::RegEx(const RegEx& o)
{
pdata = new re_detail::RegExData(*(o.pdata));
}
RegEx::~RegEx()
{
delete pdata;
}
RegEx::RegEx(const char* c, bool icase)
{
pdata = new re_detail::RegExData();
SetExpression(c, icase);
}
RegEx::RegEx(const std::string& s, bool icase)
{
pdata = new re_detail::RegExData();
SetExpression(s.c_str(), icase);
}
RegEx& RegEx::operator=(const RegEx& o)
{
*pdata = *(o.pdata);
return *this;
}
RegEx& RegEx::operator=(const char* p)
{
SetExpression(p, false);
return *this;
}
unsigned int RegEx::SetExpression(const char* p, bool icase)
{
boost::uint_fast32_t f = icase ? regex::normal | regex::icase : regex::normal;
return pdata->e.set_expression(p, f);
}
unsigned int RegEx::error_code()const
{
return pdata->e.error_code();
}
std::string RegEx::Expression()const
{
return pdata->e.expression();
}
//
// now matching operators:
//
bool RegEx::Match(const char* p, match_flag_type flags)
{
pdata->t = re_detail::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
if(regex_match(p, end, pdata->m, pdata->e, flags))
{
pdata->update();
return true;
}
return false;
}
bool RegEx::Search(const char* p, match_flag_type flags)
{
pdata->t = re_detail::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
if(regex_search(p, end, pdata->m, pdata->e, flags))
{
pdata->update();
return true;
}
return false;
}
namespace re_detail{
struct pred1
{
GrepCallback cb;
RegEx* pe;
pred1(GrepCallback c, RegEx* i) : cb(c), pe(i) {}
bool operator()(const cmatch& m)
{
pe->pdata->m = m;
return cb(*pe);
}
};
}
unsigned int RegEx::Grep(GrepCallback cb, const char* p, match_flag_type flags)
{
pdata->t = re_detail::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
unsigned int result = regex_grep(re_detail::pred1(cb, this), p, end, pdata->e, flags);
if(result)
pdata->update();
return result;
}
namespace re_detail{
struct pred2
{
std::vector<std::string>& v;
RegEx* pe;
pred2(std::vector<std::string>& o, RegEx* e) : v(o), pe(e) {}
bool operator()(const cmatch& m)
{
pe->pdata->m = m;
v.push_back(std::string(m[0].first, m[0].second));
return true;
}
private:
pred2& operator=(const pred2&);
};
}
unsigned int RegEx::Grep(std::vector<std::string>& v, const char* p, match_flag_type flags)
{
pdata->t = re_detail::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
unsigned int result = regex_grep(re_detail::pred2(v, this), p, end, pdata->e, flags);
if(result)
pdata->update();
return result;
}
namespace re_detail{
struct pred3
{
std::vector<std::size_t>& v;
const char* base;
RegEx* pe;
pred3(std::vector<std::size_t>& o, const char* pb, RegEx* p) : v(o), base(pb), pe(p) {}
bool operator()(const cmatch& m)
{
pe->pdata->m = m;
v.push_back(static_cast<std::size_t>(m[0].first - base));
return true;
}
private:
pred3& operator=(const pred3&);
};
}
unsigned int RegEx::Grep(std::vector<std::size_t>& v, const char* p, match_flag_type flags)
{
pdata->t = re_detail::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
unsigned int result = regex_grep(re_detail::pred3(v, p, this), p, end, pdata->e, flags);
if(result)
pdata->update();
return result;
}
#ifndef BOOST_REGEX_NO_FILEITER
namespace re_detail{
struct pred4
{
GrepFileCallback cb;
RegEx* pe;
const char* file;
bool ok;
pred4(GrepFileCallback c, RegEx* i, const char* f) : cb(c), pe(i), file(f), ok(true) {}
bool operator()(const match_results<mapfile::iterator>& m)
{
pe->pdata->t = RegExData::type_pf;
pe->pdata->fm = m;
pe->pdata->update();
ok = cb(file, *pe);
return ok;
}
};
}
namespace{
void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
{
file_iterator start(files);
file_iterator end;
if(recurse)
{
// go through sub directories:
char buf[MAX_PATH];
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(buf, MAX_PATH, start.root()));
if(*buf == 0)
{
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(buf, MAX_PATH, "."));
re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, directory_iterator::separator()));
re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, "*"));
}
else
{
re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, directory_iterator::separator()));
re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, "*"));
}
directory_iterator dstart(buf);
directory_iterator dend;
// now get the file mask bit of "files":
const char* ptr = files;
while(*ptr) ++ptr;
while((ptr != files) && (*ptr != *directory_iterator::separator()) && (*ptr != '/'))--ptr;
if(ptr != files) ++ptr;
while(dstart != dend)
{
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
(::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
#else
(std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
#endif
BuildFileList(pl, buf, recurse);
++dstart;
}
}
while(start != end)
{
pl->push_back(*start);
++start;
}
}
}
unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recurse, match_flag_type flags)
{
unsigned int result = 0;
std::list<std::string> file_list;
BuildFileList(&file_list, files, recurse);
std::list<std::string>::iterator start, end;
start = file_list.begin();
end = file_list.end();
while(start != end)
{
mapfile map((*start).c_str());
pdata->t = re_detail::RegExData::type_pf;
pdata->fbase = map.begin();
re_detail::pred4 pred(cb, this, (*start).c_str());
int r = regex_grep(pred, map.begin(), map.end(), pdata->e, flags);
result += r;
++start;
pdata->clean();
if(pred.ok == false)
return result;
}
return result;
}
unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recurse, match_flag_type flags)
{
unsigned int result = 0;
std::list<std::string> file_list;
BuildFileList(&file_list, files, recurse);
std::list<std::string>::iterator start, end;
start = file_list.begin();
end = file_list.end();
while(start != end)
{
mapfile map((*start).c_str());
pdata->t = re_detail::RegExData::type_pf;
pdata->fbase = map.begin();
if(regex_search(map.begin(), map.end(), pdata->fm, pdata->e, flags))
{
++result;
if(false == cb((*start).c_str()))
return result;
}
//pdata->update();
++start;
//pdata->clean();
}
return result;
}
#endif
#ifdef BOOST_REGEX_V3
#define regex_replace regex_merge
#endif
std::string RegEx::Merge(const std::string& in, const std::string& fmt,
bool copy, match_flag_type flags)
{
std::string result;
re_detail::string_out_iterator<std::string> i(result);
if(!copy) flags |= format_no_copy;
regex_replace(i, in.begin(), in.end(), pdata->e, fmt.c_str(), flags);
return result;
}
std::string RegEx::Merge(const char* in, const char* fmt,
bool copy, match_flag_type flags)
{
std::string result;
if(!copy) flags |= format_no_copy;
re_detail::string_out_iterator<std::string> i(result);
regex_replace(i, in, in + std::strlen(in), pdata->e, fmt, flags);
return result;
}
std::size_t RegEx::Split(std::vector<std::string>& v,
std::string& s,
match_flag_type flags,
unsigned max_count)
{
return regex_split(std::back_inserter(v), s, pdata->e, flags, max_count);
}
//
// now operators for returning what matched in more detail:
//
std::size_t RegEx::Position(int i)const
{
switch(pdata->t)
{
case re_detail::RegExData::type_pc:
return pdata->m[i].matched ? pdata->m[i].first - pdata->pbase : RegEx::npos;
#ifndef BOOST_REGEX_NO_FILEITER
case re_detail::RegExData::type_pf:
return pdata->fm[i].matched ? pdata->fm[i].first - pdata->fbase : RegEx::npos;
#endif
case re_detail::RegExData::type_copy:
{
std::map<int, std::ptrdiff_t, std::less<int> >::iterator pos = pdata->positions.find(i);
if(pos == pdata->positions.end())
return RegEx::npos;
return (*pos).second;
}
}
return RegEx::npos;
}
std::size_t RegEx::Marks()const
{
return pdata->e.mark_count();
}
std::size_t RegEx::Length(int i)const
{
switch(pdata->t)
{
case re_detail::RegExData::type_pc:
return pdata->m[i].matched ? pdata->m[i].second - pdata->m[i].first : RegEx::npos;
#ifndef BOOST_REGEX_NO_FILEITER
case re_detail::RegExData::type_pf:
return pdata->fm[i].matched ? pdata->fm[i].second - pdata->fm[i].first : RegEx::npos;
#endif
case re_detail::RegExData::type_copy:
{
std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i);
if(pos == pdata->strings.end())
return RegEx::npos;
return (*pos).second.size();
}
}
return RegEx::npos;
}
bool RegEx::Matched(int i)const
{
switch(pdata->t)
{
case re_detail::RegExData::type_pc:
return pdata->m[i].matched;
#ifndef BOOST_REGEX_NO_FILEITER
case re_detail::RegExData::type_pf:
return pdata->fm[i].matched;
#endif
case re_detail::RegExData::type_copy:
{
std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i);
if(pos == pdata->strings.end())
return false;
return true;
}
}
return false;
}
std::string RegEx::What(int i)const
{
std::string result;
switch(pdata->t)
{
case re_detail::RegExData::type_pc:
if(pdata->m[i].matched)
result.assign(pdata->m[i].first, pdata->m[i].second);
break;
case re_detail::RegExData::type_pf:
if(pdata->m[i].matched)
result.assign(to_string(pdata->m[i].first, pdata->m[i].second));
break;
case re_detail::RegExData::type_copy:
{
std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i);
if(pos != pdata->strings.end())
result = (*pos).second;
break;
}
}
return result;
}
#ifdef BOOST_HAS_LONG_LONG
const std::size_t RegEx::npos = static_cast<std::size_t>(~0ULL);
#else
const std::size_t RegEx::npos = static_cast<std::size_t>(~0UL);
#endif
} // namespace boost
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) && (__BORLANDC__ <= 0x551) && !defined(_RWSTD_COMPILE_INSTANTIATE)
//
// this is an ugly hack to work around an ugly problem:
// by default this file will produce unresolved externals during
// linking unless _RWSTD_COMPILE_INSTANTIATE is defined (Borland bug).
// However if _RWSTD_COMPILE_INSTANTIATE is defined then we get separate
// copies of basic_string's static data in the RTL and this DLL, this messes
// with basic_string's memory management and results in run-time crashes,
// Oh sweet joy of Catch 22....
//
namespace std{
template<> template<>
basic_string<char>& BOOST_REGEX_DECL
basic_string<char>::replace<const char*>(char* f1, char* f2, const char* i1, const char* i2)
{
unsigned insert_pos = f1 - begin();
unsigned remove_len = f2 - f1;
unsigned insert_len = i2 - i1;
unsigned org_size = size();
if(insert_len > remove_len)
{
append(insert_len-remove_len, ' ');
std::copy_backward(begin() + insert_pos + remove_len, begin() + org_size, end());
std::copy(i1, i2, begin() + insert_pos);
}
else
{
std::copy(begin() + insert_pos + remove_len, begin() + org_size, begin() + insert_pos + insert_len);
std::copy(i1, i2, begin() + insert_pos);
erase(size() + insert_len - remove_len);
}
return *this;
}
template<> template<>
basic_string<wchar_t>& BOOST_REGEX_DECL
basic_string<wchar_t>::replace<const wchar_t*>(wchar_t* f1, wchar_t* f2, const wchar_t* i1, const wchar_t* i2)
{
unsigned insert_pos = f1 - begin();
unsigned remove_len = f2 - f1;
unsigned insert_len = i2 - i1;
unsigned org_size = size();
if(insert_len > remove_len)
{
append(insert_len-remove_len, ' ');
std::copy_backward(begin() + insert_pos + remove_len, begin() + org_size, end());
std::copy(i1, i2, begin() + insert_pos);
}
else
{
std::copy(begin() + insert_pos + remove_len, begin() + org_size, begin() + insert_pos + insert_len);
std::copy(i1, i2, begin() + insert_pos);
erase(size() + insert_len - remove_len);
}
return *this;
}
} // namespace std
#endif
#endif
/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: fileiter.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Implements file io primitives + directory searching for class boost::RegEx.
*/
#define BOOST_REGEX_SOURCE
#include <climits>
#include <stdexcept>
#include <string>
#include <boost/throw_exception.hpp>
#include <boost/regex/v4/fileiter.hpp>
#include <boost/regex/v4/regex_workaround.hpp>
#include <boost/regex/pattern_except.hpp>
#include <cstdio>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::sprintf;
using ::fseek;
using ::fread;
using ::ftell;
using ::fopen;
using ::fclose;
using ::FILE;
using ::strcpy;
using ::strcpy;
using ::strcat;
using ::strcmp;
using ::strlen;
}
#endif
#ifndef BOOST_REGEX_NO_FILEITER
#if defined(__CYGWIN__) || defined(__CYGWIN32__)
#include <sys/cygwin.h>
#endif
#ifdef BOOST_MSVC
# pragma warning(disable: 4800)
#endif
namespace boost{
namespace re_detail{
// start with the operating system specific stuff:
#if (defined(__BORLANDC__) || defined(BOOST_REGEX_FI_WIN32_DIR) || defined(BOOST_MSVC)) && !defined(BOOST_RE_NO_WIN32)
// platform is DOS or Windows
// directories are separated with '\\'
// and names are insensitive of case
BOOST_REGEX_DECL const char* _fi_sep = "\\";
const char* _fi_sep_alt = "/";
#define BOOST_REGEX_FI_TRANSLATE(c) std::tolower(c)
#else
// platform is not DOS or Windows
// directories are separated with '/'
// and names are sensitive of case
BOOST_REGEX_DECL const char* _fi_sep = "/";
const char* _fi_sep_alt = _fi_sep;
#define BOOST_REGEX_FI_TRANSLATE(c) c
#endif
#ifdef BOOST_REGEX_FI_WIN32_MAP
void mapfile::open(const char* file)
{
#if defined(BOOST_NO_ANSI_APIS)
int filename_size = strlen(file);
LPWSTR wide_file = (LPWSTR)_alloca( (filename_size + 1) * sizeof(WCHAR) );
if(::MultiByteToWideChar(CP_ACP, 0, file, filename_size, wide_file, filename_size + 1) == 0)
hfile = INVALID_HANDLE_VALUE;
else
hfile = CreateFileW(wide_file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
#elif defined(__CYGWIN__)||defined(__CYGWIN32__)
char win32file[ MAX_PATH ];
cygwin_conv_to_win32_path( file, win32file );
hfile = CreateFileA(win32file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
#else
hfile = CreateFileA(file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
#endif
if(hfile != INVALID_HANDLE_VALUE)
{
hmap = CreateFileMapping(hfile, 0, PAGE_READONLY, 0, 0, 0);
if((hmap == INVALID_HANDLE_VALUE) || (hmap == NULL))
{
CloseHandle(hfile);
hmap = 0;
hfile = 0;
std::runtime_error err("Unable to create file mapping.");
boost::re_detail::raise_runtime_error(err);
}
_first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0));
if(_first == 0)
{
CloseHandle(hmap);
CloseHandle(hfile);
hmap = 0;
hfile = 0;
std::runtime_error err("Unable to create file mapping.");
}
_last = _first + GetFileSize(hfile, 0);
}
else
{
hfile = 0;
#ifndef BOOST_NO_EXCEPTIONS
throw std::runtime_error("Unable to open file.");
#else
BOOST_REGEX_NOEH_ASSERT(hfile != INVALID_HANDLE_VALUE);
#endif
}
}
void mapfile::close()
{
if(hfile != INVALID_HANDLE_VALUE)
{
UnmapViewOfFile((void*)_first);
CloseHandle(hmap);
CloseHandle(hfile);
hmap = hfile = 0;
_first = _last = 0;
}
}
#elif !defined(BOOST_RE_NO_STL)
mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i)
{
if(file && node)
file->unlock(node);
file = i.file;
node = i.node;
offset = i.offset;
if(file)
file->lock(node);
return *this;
}
mapfile_iterator& mapfile_iterator::operator++ ()
{
if((++offset == mapfile::buf_size) && file)
{
++node;
offset = 0;
file->lock(node);
file->unlock(node-1);
}
return *this;
}
mapfile_iterator mapfile_iterator::operator++ (int)
{
mapfile_iterator temp(*this);
if((++offset == mapfile::buf_size) && file)
{
++node;
offset = 0;
file->lock(node);
file->unlock(node-1);
}
return temp;
}
mapfile_iterator& mapfile_iterator::operator-- ()
{
if((offset == 0) && file)
{
--node;
offset = mapfile::buf_size - 1;
file->lock(node);
file->unlock(node + 1);
}
else
--offset;
return *this;
}
mapfile_iterator mapfile_iterator::operator-- (int)
{
mapfile_iterator temp(*this);
if((offset == 0) && file)
{
--node;
offset = mapfile::buf_size - 1;
file->lock(node);
file->unlock(node + 1);
}
else
--offset;
return temp;
}
mapfile_iterator operator + (const mapfile_iterator& i, long off)
{
mapfile_iterator temp(i);
temp += off;
return temp;
}
mapfile_iterator operator - (const mapfile_iterator& i, long off)
{
mapfile_iterator temp(i);
temp -= off;
return temp;
}
mapfile::iterator mapfile::begin()const
{
return mapfile_iterator(this, 0);
}
mapfile::iterator mapfile::end()const
{
return mapfile_iterator(this, _size);
}
void mapfile::lock(pointer* node)const
{
BOOST_ASSERT(node >= _first);
BOOST_ASSERT(node <= _last);
if(node < _last)
{
if(*node == 0)
{
if(condemed.empty())
{
*node = new char[sizeof(int) + buf_size];
*(reinterpret_cast<int*>(*node)) = 1;
}
else
{
pointer* p = condemed.front();
condemed.pop_front();
*node = *p;
*p = 0;
*(reinterpret_cast<int*>(*node)) = 1;
}
std::fseek(hfile, (node - _first) * buf_size, SEEK_SET);
if(node == _last - 1)
std::fread(*node + sizeof(int), _size % buf_size, 1, hfile);
else
std::fread(*node + sizeof(int), buf_size, 1, hfile);
}
else
{
if(*reinterpret_cast<int*>(*node) == 0)
{
*reinterpret_cast<int*>(*node) = 1;
condemed.remove(node);
}
else
++(*reinterpret_cast<int*>(*node));
}
}
}
void mapfile::unlock(pointer* node)const
{
BOOST_ASSERT(node >= _first);
BOOST_ASSERT(node <= _last);
if(node < _last)
{
if(--(*reinterpret_cast<int*>(*node)) == 0)
{
condemed.push_back(node);
}
}
}
long int get_file_length(std::FILE* hfile)
{
long int result;
std::fseek(hfile, 0, SEEK_END);
result = std::ftell(hfile);
std::fseek(hfile, 0, SEEK_SET);
return result;
}
void mapfile::open(const char* file)
{
hfile = std::fopen(file, "rb");
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
if(hfile != 0)
{
_size = get_file_length(hfile);
long cnodes = (_size + buf_size - 1) / buf_size;
// check that number of nodes is not too high:
if(cnodes > (long)((INT_MAX) / sizeof(pointer*)))
{
std::fclose(hfile);
hfile = 0;
_size = 0;
return;
}
_first = new pointer[(int)cnodes];
_last = _first + cnodes;
std::memset(_first, 0, cnodes*sizeof(pointer));
}
else
{
std::runtime_error err("Unable to open file.");
}
#ifndef BOOST_NO_EXCEPTIONS
}catch(...)
{ close(); throw; }
#endif
}
void mapfile::close()
{
if(hfile != 0)
{
pointer* p = _first;
while(p != _last)
{
if(*p)
delete[] *p;
++p;
}
delete[] _first;
_size = 0;
_first = _last = 0;
std::fclose(hfile);
hfile = 0;
condemed.erase(condemed.begin(), condemed.end());
}
}
#endif
inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data)
{
#ifdef BOOST_NO_ANSI_APIS
std::size_t wild_size = std::strlen(wild);
LPWSTR wide_wild = (LPWSTR)_alloca( (wild_size + 1) * sizeof(WCHAR) );
if (::MultiByteToWideChar(CP_ACP, 0, wild, wild_size, wide_wild, wild_size + 1) == 0)
return _fi_invalid_handle;
return FindFirstFileW(wide_wild, &data);
#else
return FindFirstFileA(wild, &data);
#endif
}
inline bool find_next_file(_fi_find_handle hf, _fi_find_data& data)
{
#ifdef BOOST_NO_ANSI_APIS
return FindNextFileW(hf, &data);
#else
return FindNextFileA(hf, &data);
#endif
}
inline void copy_find_file_result_with_overflow_check(const _fi_find_data& data, char* path, size_t max_size)
{
#ifdef BOOST_NO_ANSI_APIS
if (::WideCharToMultiByte(CP_ACP, 0, data.cFileName, -1, path, max_size, NULL, NULL) == 0)
re_detail::overflow_error_if_not_zero(1);
#else
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(path, max_size, data.cFileName));
#endif
}
inline bool is_not_current_or_parent_path_string(const _fi_find_data& data)
{
#ifdef BOOST_NO_ANSI_APIS
return (std::wcscmp(data.cFileName, L".") && std::wcscmp(data.cFileName, L".."));
#else
return (std::strcmp(data.cFileName, ".") && std::strcmp(data.cFileName, ".."));
#endif
}
file_iterator::file_iterator()
{
_root = _path = 0;
ref = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
_root = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_root)
_path = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_path)
ptr = _path;
*_path = 0;
*_root = 0;
ref = new file_iterator_ref();
BOOST_REGEX_NOEH_ASSERT(ref)
ref->hf = _fi_invalid_handle;
ref->count = 1;
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
delete[] _root;
delete[] _path;
delete ref;
throw;
}
#endif
}
file_iterator::file_iterator(const char* wild)
{
_root = _path = 0;
ref = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
_root = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_root)
_path = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_path)
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, wild));
ptr = _root;
while(*ptr)++ptr;
while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr;
if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) )
{
_root[1]='\0';
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root));
}
else
{
*ptr = 0;
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root));
if(*_path == 0)
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, "."));
re_detail::overflow_error_if_not_zero(re_detail::strcat_s(_path, MAX_PATH, _fi_sep));
}
ptr = _path + std::strlen(_path);
ref = new file_iterator_ref();
BOOST_REGEX_NOEH_ASSERT(ref)
ref->hf = find_first_file(wild, ref->_data);
ref->count = 1;
if(ref->hf == _fi_invalid_handle)
{
*_path = 0;
ptr = _path;
}
else
{
copy_find_file_result_with_overflow_check(ref->_data, ptr, (MAX_PATH - (ptr - _path)));
if(ref->_data.dwFileAttributes & _fi_dir)
next();
}
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
delete[] _root;
delete[] _path;
delete ref;
throw;
}
#endif
}
file_iterator::file_iterator(const file_iterator& other)
{
_root = _path = 0;
ref = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
_root = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_root)
_path = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_path)
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root));
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path));
ptr = _path + (other.ptr - other._path);
ref = other.ref;
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
delete[] _root;
delete[] _path;
throw;
}
#endif
++(ref->count);
}
file_iterator& file_iterator::operator=(const file_iterator& other)
{
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root));
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path));
ptr = _path + (other.ptr - other._path);
if(--(ref->count) == 0)
{
if(ref->hf != _fi_invalid_handle)
FindClose(ref->hf);
delete ref;
}
ref = other.ref;
++(ref->count);
return *this;
}
file_iterator::~file_iterator()
{
delete[] _root;
delete[] _path;
if(--(ref->count) == 0)
{
if(ref->hf != _fi_invalid_handle)
FindClose(ref->hf);
delete ref;
}
}
file_iterator file_iterator::operator++(int)
{
file_iterator temp(*this);
next();
return temp;
}
void file_iterator::next()
{
if(ref->hf != _fi_invalid_handle)
{
bool cont = true;
while(cont)
{
cont = find_next_file(ref->hf, ref->_data);
if(cont && ((ref->_data.dwFileAttributes & _fi_dir) == 0))
break;
}
if(!cont)
{
// end of sequence
FindClose(ref->hf);
ref->hf = _fi_invalid_handle;
*_path = 0;
ptr = _path;
}
else
copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
}
}
directory_iterator::directory_iterator()
{
_root = _path = 0;
ref = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
_root = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_root)
_path = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_path)
ptr = _path;
*_path = 0;
*_root = 0;
ref = new file_iterator_ref();
BOOST_REGEX_NOEH_ASSERT(ref)
ref->hf = _fi_invalid_handle;
ref->count = 1;
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
delete[] _root;
delete[] _path;
delete ref;
throw;
}
#endif
}
directory_iterator::directory_iterator(const char* wild)
{
_root = _path = 0;
ref = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
_root = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_root)
_path = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_path)
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, wild));
ptr = _root;
while(*ptr)++ptr;
while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr;
if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) )
{
_root[1]='\0';
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root));
}
else
{
*ptr = 0;
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root));
if(*_path == 0)
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, "."));
re_detail::overflow_error_if_not_zero(re_detail::strcat_s(_path, MAX_PATH, _fi_sep));
}
ptr = _path + std::strlen(_path);
ref = new file_iterator_ref();
BOOST_REGEX_NOEH_ASSERT(ref)
ref->count = 1;
ref->hf = find_first_file(wild, ref->_data);
if(ref->hf == _fi_invalid_handle)
{
*_path = 0;
ptr = _path;
}
else
{
copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
if(((ref->_data.dwFileAttributes & _fi_dir) == 0) || (std::strcmp(ptr, ".") == 0) || (std::strcmp(ptr, "..") == 0))
next();
}
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
delete[] _root;
delete[] _path;
delete ref;
throw;
}
#endif
}
directory_iterator::~directory_iterator()
{
delete[] _root;
delete[] _path;
if(--(ref->count) == 0)
{
if(ref->hf != _fi_invalid_handle)
FindClose(ref->hf);
delete ref;
}
}
directory_iterator::directory_iterator(const directory_iterator& other)
{
_root = _path = 0;
ref = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
_root = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_root)
_path = new char[MAX_PATH];
BOOST_REGEX_NOEH_ASSERT(_path)
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root));
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path));
ptr = _path + (other.ptr - other._path);
ref = other.ref;
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
delete[] _root;
delete[] _path;
throw;
}
#endif
++(ref->count);
}
directory_iterator& directory_iterator::operator=(const directory_iterator& other)
{
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root));
re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path));
ptr = _path + (other.ptr - other._path);
if(--(ref->count) == 0)
{
if(ref->hf != _fi_invalid_handle)
FindClose(ref->hf);
delete ref;
}
ref = other.ref;
++(ref->count);
return *this;
}
directory_iterator directory_iterator::operator++(int)
{
directory_iterator temp(*this);
next();
return temp;
}
void directory_iterator::next()
{
if(ref->hf != _fi_invalid_handle)
{
bool cont = true;
while(cont)
{
cont = find_next_file(ref->hf, ref->_data);
if(cont && (ref->_data.dwFileAttributes & _fi_dir))
{
if(is_not_current_or_parent_path_string(ref->_data))
break;
}
}
if(!cont)
{
// end of sequence
FindClose(ref->hf);
ref->hf = _fi_invalid_handle;
*_path = 0;
ptr = _path;
}
else
copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
}
}
#ifdef BOOST_REGEX_FI_POSIX_DIR
struct _fi_priv_data
{
char root[MAX_PATH];
char* mask;
DIR* d;
_fi_priv_data(const char* p);
};
_fi_priv_data::_fi_priv_data(const char* p)
{
std::strcpy(root, p);
mask = root;
while(*mask) ++mask;
while((mask > root) && (*mask != *_fi_sep) && (*mask != *_fi_sep_alt)) --mask;
if(mask == root && ((*mask== *_fi_sep) || (*mask == *_fi_sep_alt)) )
{
root[1] = '\0';
std::strcpy(root+2, p+1);
mask = root+2;
}
else if(mask == root)
{
root[0] = '.';
root[1] = '\0';
std::strcpy(root+2, p);
mask = root+2;
}
else
{
*mask = 0;
++mask;
}
}
bool iswild(const char* mask, const char* name)
{
while(*mask && *name)
{
switch(*mask)
{
case '?':
++name;
++mask;
continue;
case '*':
++mask;
if(*mask == 0)
return true;
while(*name)
{
if(iswild(mask, name))
return true;
++name;
}
return false;
case '.':
if(0 == *name)
{
++mask;
continue;
}
// fall through:
default:
if(BOOST_REGEX_FI_TRANSLATE(*mask) != BOOST_REGEX_FI_TRANSLATE(*name))
return false;
++mask;
++name;
continue;
}
}
if(*mask != *name)
return false;
return true;
}
unsigned _fi_attributes(const char* root, const char* name)
{
char buf[MAX_PATH];
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
(std::sprintf)(buf, "%s%s", root, name);
else
(std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
DIR* d = opendir(buf);
if(d)
{
closedir(d);
return _fi_dir;
}
return 0;
}
_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData)
{
_fi_find_handle dat = new _fi_priv_data(lpFileName);
DIR* h = opendir(dat->root);
dat->d = h;
if(h != 0)
{
if(_fi_FindNextFile(dat, lpFindFileData))
return dat;
}
delete dat;
return 0;
}
bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData)
{
dirent* d;
do
{
d = readdir(dat->d);
} while(d && !iswild(dat->mask, d->d_name));
if(d)
{
std::strcpy(lpFindFileData->cFileName, d->d_name);
lpFindFileData->dwFileAttributes = _fi_attributes(dat->root, d->d_name);
return true;
}
return false;
}
bool _fi_FindClose(_fi_find_handle dat)
{
closedir(dat->d);
delete dat;
return true;
}
#endif
} // namespace re_detail
} // namspace boost
#endif // BOOST_REGEX_NO_FILEITER
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE icu.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Unicode regular expressions on top of the ICU Library.
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex/config.hpp>
#ifdef BOOST_HAS_ICU
#define BOOST_REGEX_ICU_INSTANTIATE
#include <boost/regex/icu.hpp>
namespace boost{
namespace re_detail{
icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const
{
// TODO make thread safe!!!! :
typedef u32_to_u16_iterator<const char_type*, ::UChar> itt;
itt i(p1), j(p2);
#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
std::vector< ::UChar> t(i, j);
#else
std::vector< ::UChar> t;
while(i != j)
t.push_back(*i++);
#endif
::uint8_t result[100];
::int32_t len;
if(t.size())
len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result));
else
len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), result, sizeof(result));
if(std::size_t(len) > sizeof(result))
{
scoped_array< ::uint8_t> presult(new ::uint8_t[len+1]);
if(t.size())
len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len+1);
else
len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), presult.get(), len+1);
if((0 == presult[len-1]) && (len > 1))
--len;
#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
return string_type(presult.get(), presult.get()+len);
#else
string_type sresult;
::uint8_t const* ia = presult.get();
::uint8_t const* ib = presult.get()+len;
while(ia != ib)
sresult.push_back(*ia++);
return sresult;
#endif
}
if((0 == result[len-1]) && (len > 1))
--len;
#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
return string_type(result, result+len);
#else
string_type sresult;
::uint8_t const* ia = result;
::uint8_t const* ib = result+len;
while(ia != ib)
sresult.push_back(*ia++);
return sresult;
#endif
}
}
icu_regex_traits::size_type icu_regex_traits::length(const char_type* p)
{
size_type result = 0;
while(*p)
{
++p;
++result;
}
return result;
}
//
// define our bitmasks:
//
const icu_regex_traits::char_class_type icu_regex_traits::mask_blank = icu_regex_traits::char_class_type(1) << offset_blank;
const icu_regex_traits::char_class_type icu_regex_traits::mask_space = icu_regex_traits::char_class_type(1) << offset_space;
const icu_regex_traits::char_class_type icu_regex_traits::mask_xdigit = icu_regex_traits::char_class_type(1) << offset_xdigit;
const icu_regex_traits::char_class_type icu_regex_traits::mask_underscore = icu_regex_traits::char_class_type(1) << offset_underscore;
const icu_regex_traits::char_class_type icu_regex_traits::mask_unicode = icu_regex_traits::char_class_type(1) << offset_unicode;
const icu_regex_traits::char_class_type icu_regex_traits::mask_any = icu_regex_traits::char_class_type(1) << offset_any;
const icu_regex_traits::char_class_type icu_regex_traits::mask_ascii = icu_regex_traits::char_class_type(1) << offset_ascii;
icu_regex_traits::char_class_type icu_regex_traits::lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2)
{
static const ::UChar32 prop_name_table[] = {
/* any */ 'a', 'n', 'y',
/* ascii */ 'a', 's', 'c', 'i', 'i',
/* assigned */ 'a', 's', 's', 'i', 'g', 'n', 'e', 'd',
/* c* */ 'c', '*',
/* cc */ 'c', 'c',
/* cf */ 'c', 'f',
/* closepunctuation */ 'c', 'l', 'o', 's', 'e', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* cn */ 'c', 'n',
/* co */ 'c', 'o',
/* connectorpunctuation */ 'c', 'o', 'n', 'n', 'e', 'c', 't', 'o', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* control */ 'c', 'o', 'n', 't', 'r', 'o', 'l',
/* cs */ 'c', 's',
/* currencysymbol */ 'c', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 's', 'y', 'm', 'b', 'o', 'l',
/* dashpunctuation */ 'd', 'a', 's', 'h', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* decimaldigitnumber */ 'd', 'e', 'c', 'i', 'm', 'a', 'l', 'd', 'i', 'g', 'i', 't', 'n', 'u', 'm', 'b', 'e', 'r',
/* enclosingmark */ 'e', 'n', 'c', 'l', 'o', 's', 'i', 'n', 'g', 'm', 'a', 'r', 'k',
/* finalpunctuation */ 'f', 'i', 'n', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* format */ 'f', 'o', 'r', 'm', 'a', 't',
/* initialpunctuation */ 'i', 'n', 'i', 't', 'i', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* l* */ 'l', '*',
/* letter */ 'l', 'e', 't', 't', 'e', 'r',
/* letternumber */ 'l', 'e', 't', 't', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r',
/* lineseparator */ 'l', 'i', 'n', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
/* ll */ 'l', 'l',
/* lm */ 'l', 'm',
/* lo */ 'l', 'o',
/* lowercaseletter */ 'l', 'o', 'w', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r',
/* lt */ 'l', 't',
/* lu */ 'l', 'u',
/* m* */ 'm', '*',
/* mark */ 'm', 'a', 'r', 'k',
/* mathsymbol */ 'm', 'a', 't', 'h', 's', 'y', 'm', 'b', 'o', 'l',
/* mc */ 'm', 'c',
/* me */ 'm', 'e',
/* mn */ 'm', 'n',
/* modifierletter */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r',
/* modifiersymbol */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l',
/* n* */ 'n', '*',
/* nd */ 'n', 'd',
/* nl */ 'n', 'l',
/* no */ 'n', 'o',
/* nonspacingmark */ 'n', 'o', 'n', 's', 'p', 'a', 'c', 'i', 'n', 'g', 'm', 'a', 'r', 'k',
/* notassigned */ 'n', 'o', 't', 'a', 's', 's', 'i', 'g', 'n', 'e', 'd',
/* number */ 'n', 'u', 'm', 'b', 'e', 'r',
/* openpunctuation */ 'o', 'p', 'e', 'n', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* other */ 'o', 't', 'h', 'e', 'r',
/* otherletter */ 'o', 't', 'h', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r',
/* othernumber */ 'o', 't', 'h', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r',
/* otherpunctuation */ 'o', 't', 'h', 'e', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* othersymbol */ 'o', 't', 'h', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l',
/* p* */ 'p', '*',
/* paragraphseparator */ 'p', 'a', 'r', 'a', 'g', 'r', 'a', 'p', 'h', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
/* pc */ 'p', 'c',
/* pd */ 'p', 'd',
/* pe */ 'p', 'e',
/* pf */ 'p', 'f',
/* pi */ 'p', 'i',
/* po */ 'p', 'o',
/* privateuse */ 'p', 'r', 'i', 'v', 'a', 't', 'e', 'u', 's', 'e',
/* ps */ 'p', 's',
/* punctuation */ 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
/* s* */ 's', '*',
/* sc */ 's', 'c',
/* separator */ 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
/* sk */ 's', 'k',
/* sm */ 's', 'm',
/* so */ 's', 'o',
/* spaceseparator */ 's', 'p', 'a', 'c', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
/* spacingcombiningmark */ 's', 'p', 'a', 'c', 'i', 'n', 'g', 'c', 'o', 'm', 'b', 'i', 'n', 'i', 'n', 'g', 'm', 'a', 'r', 'k',
/* surrogate */ 's', 'u', 'r', 'r', 'o', 'g', 'a', 't', 'e',
/* symbol */ 's', 'y', 'm', 'b', 'o', 'l',
/* titlecase */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e',
/* titlecaseletter */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r',
/* uppercaseletter */ 'u', 'p', 'p', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r',
/* z* */ 'z', '*',
/* zl */ 'z', 'l',
/* zp */ 'z', 'p',
/* zs */ 'z', 's',
};
static const re_detail::character_pointer_range< ::UChar32> range_data[] = {
{ prop_name_table+0, prop_name_table+3, }, // any
{ prop_name_table+3, prop_name_table+8, }, // ascii
{ prop_name_table+8, prop_name_table+16, }, // assigned
{ prop_name_table+16, prop_name_table+18, }, // c*
{ prop_name_table+18, prop_name_table+20, }, // cc
{ prop_name_table+20, prop_name_table+22, }, // cf
{ prop_name_table+22, prop_name_table+38, }, // closepunctuation
{ prop_name_table+38, prop_name_table+40, }, // cn
{ prop_name_table+40, prop_name_table+42, }, // co
{ prop_name_table+42, prop_name_table+62, }, // connectorpunctuation
{ prop_name_table+62, prop_name_table+69, }, // control
{ prop_name_table+69, prop_name_table+71, }, // cs
{ prop_name_table+71, prop_name_table+85, }, // currencysymbol
{ prop_name_table+85, prop_name_table+100, }, // dashpunctuation
{ prop_name_table+100, prop_name_table+118, }, // decimaldigitnumber
{ prop_name_table+118, prop_name_table+131, }, // enclosingmark
{ prop_name_table+131, prop_name_table+147, }, // finalpunctuation
{ prop_name_table+147, prop_name_table+153, }, // format
{ prop_name_table+153, prop_name_table+171, }, // initialpunctuation
{ prop_name_table+171, prop_name_table+173, }, // l*
{ prop_name_table+173, prop_name_table+179, }, // letter
{ prop_name_table+179, prop_name_table+191, }, // letternumber
{ prop_name_table+191, prop_name_table+204, }, // lineseparator
{ prop_name_table+204, prop_name_table+206, }, // ll
{ prop_name_table+206, prop_name_table+208, }, // lm
{ prop_name_table+208, prop_name_table+210, }, // lo
{ prop_name_table+210, prop_name_table+225, }, // lowercaseletter
{ prop_name_table+225, prop_name_table+227, }, // lt
{ prop_name_table+227, prop_name_table+229, }, // lu
{ prop_name_table+229, prop_name_table+231, }, // m*
{ prop_name_table+231, prop_name_table+235, }, // mark
{ prop_name_table+235, prop_name_table+245, }, // mathsymbol
{ prop_name_table+245, prop_name_table+247, }, // mc
{ prop_name_table+247, prop_name_table+249, }, // me
{ prop_name_table+249, prop_name_table+251, }, // mn
{ prop_name_table+251, prop_name_table+265, }, // modifierletter
{ prop_name_table+265, prop_name_table+279, }, // modifiersymbol
{ prop_name_table+279, prop_name_table+281, }, // n*
{ prop_name_table+281, prop_name_table+283, }, // nd
{ prop_name_table+283, prop_name_table+285, }, // nl
{ prop_name_table+285, prop_name_table+287, }, // no
{ prop_name_table+287, prop_name_table+301, }, // nonspacingmark
{ prop_name_table+301, prop_name_table+312, }, // notassigned
{ prop_name_table+312, prop_name_table+318, }, // number
{ prop_name_table+318, prop_name_table+333, }, // openpunctuation
{ prop_name_table+333, prop_name_table+338, }, // other
{ prop_name_table+338, prop_name_table+349, }, // otherletter
{ prop_name_table+349, prop_name_table+360, }, // othernumber
{ prop_name_table+360, prop_name_table+376, }, // otherpunctuation
{ prop_name_table+376, prop_name_table+387, }, // othersymbol
{ prop_name_table+387, prop_name_table+389, }, // p*
{ prop_name_table+389, prop_name_table+407, }, // paragraphseparator
{ prop_name_table+407, prop_name_table+409, }, // pc
{ prop_name_table+409, prop_name_table+411, }, // pd
{ prop_name_table+411, prop_name_table+413, }, // pe
{ prop_name_table+413, prop_name_table+415, }, // pf
{ prop_name_table+415, prop_name_table+417, }, // pi
{ prop_name_table+417, prop_name_table+419, }, // po
{ prop_name_table+419, prop_name_table+429, }, // privateuse
{ prop_name_table+429, prop_name_table+431, }, // ps
{ prop_name_table+431, prop_name_table+442, }, // punctuation
{ prop_name_table+442, prop_name_table+444, }, // s*
{ prop_name_table+444, prop_name_table+446, }, // sc
{ prop_name_table+446, prop_name_table+455, }, // separator
{ prop_name_table+455, prop_name_table+457, }, // sk
{ prop_name_table+457, prop_name_table+459, }, // sm
{ prop_name_table+459, prop_name_table+461, }, // so
{ prop_name_table+461, prop_name_table+475, }, // spaceseparator
{ prop_name_table+475, prop_name_table+495, }, // spacingcombiningmark
{ prop_name_table+495, prop_name_table+504, }, // surrogate
{ prop_name_table+504, prop_name_table+510, }, // symbol
{ prop_name_table+510, prop_name_table+519, }, // titlecase
{ prop_name_table+519, prop_name_table+534, }, // titlecaseletter
{ prop_name_table+534, prop_name_table+549, }, // uppercaseletter
{ prop_name_table+549, prop_name_table+551, }, // z*
{ prop_name_table+551, prop_name_table+553, }, // zl
{ prop_name_table+553, prop_name_table+555, }, // zp
{ prop_name_table+555, prop_name_table+557, }, // zs
};
static const icu_regex_traits::char_class_type icu_class_map[] = {
icu_regex_traits::mask_any, // any
icu_regex_traits::mask_ascii, // ascii
(0x3FFFFFFFu) & ~(U_GC_CN_MASK), // assigned
U_GC_C_MASK, // c*
U_GC_CC_MASK, // cc
U_GC_CF_MASK, // cf
U_GC_PE_MASK, // closepunctuation
U_GC_CN_MASK, // cn
U_GC_CO_MASK, // co
U_GC_PC_MASK, // connectorpunctuation
U_GC_CC_MASK, // control
U_GC_CS_MASK, // cs
U_GC_SC_MASK, // currencysymbol
U_GC_PD_MASK, // dashpunctuation
U_GC_ND_MASK, // decimaldigitnumber
U_GC_ME_MASK, // enclosingmark
U_GC_PF_MASK, // finalpunctuation
U_GC_CF_MASK, // format
U_GC_PI_MASK, // initialpunctuation
U_GC_L_MASK, // l*
U_GC_L_MASK, // letter
U_GC_NL_MASK, // letternumber
U_GC_ZL_MASK, // lineseparator
U_GC_LL_MASK, // ll
U_GC_LM_MASK, // lm
U_GC_LO_MASK, // lo
U_GC_LL_MASK, // lowercaseletter
U_GC_LT_MASK, // lt
U_GC_LU_MASK, // lu
U_GC_M_MASK, // m*
U_GC_M_MASK, // mark
U_GC_SM_MASK, // mathsymbol
U_GC_MC_MASK, // mc
U_GC_ME_MASK, // me
U_GC_MN_MASK, // mn
U_GC_LM_MASK, // modifierletter
U_GC_SK_MASK, // modifiersymbol
U_GC_N_MASK, // n*
U_GC_ND_MASK, // nd
U_GC_NL_MASK, // nl
U_GC_NO_MASK, // no
U_GC_MN_MASK, // nonspacingmark
U_GC_CN_MASK, // notassigned
U_GC_N_MASK, // number
U_GC_PS_MASK, // openpunctuation
U_GC_C_MASK, // other
U_GC_LO_MASK, // otherletter
U_GC_NO_MASK, // othernumber
U_GC_PO_MASK, // otherpunctuation
U_GC_SO_MASK, // othersymbol
U_GC_P_MASK, // p*
U_GC_ZP_MASK, // paragraphseparator
U_GC_PC_MASK, // pc
U_GC_PD_MASK, // pd
U_GC_PE_MASK, // pe
U_GC_PF_MASK, // pf
U_GC_PI_MASK, // pi
U_GC_PO_MASK, // po
U_GC_CO_MASK, // privateuse
U_GC_PS_MASK, // ps
U_GC_P_MASK, // punctuation
U_GC_S_MASK, // s*
U_GC_SC_MASK, // sc
U_GC_Z_MASK, // separator
U_GC_SK_MASK, // sk
U_GC_SM_MASK, // sm
U_GC_SO_MASK, // so
U_GC_ZS_MASK, // spaceseparator
U_GC_MC_MASK, // spacingcombiningmark
U_GC_CS_MASK, // surrogate
U_GC_S_MASK, // symbol
U_GC_LT_MASK, // titlecase
U_GC_LT_MASK, // titlecaseletter
U_GC_LU_MASK, // uppercaseletter
U_GC_Z_MASK, // z*
U_GC_ZL_MASK, // zl
U_GC_ZP_MASK, // zp
U_GC_ZS_MASK, // zs
};
static const re_detail::character_pointer_range< ::UChar32>* ranges_begin = range_data;
static const re_detail::character_pointer_range< ::UChar32>* ranges_end = range_data + (sizeof(range_data)/sizeof(range_data[0]));
re_detail::character_pointer_range< ::UChar32> t = { p1, p2, };
const re_detail::character_pointer_range< ::UChar32>* p = std::lower_bound(ranges_begin, ranges_end, t);
if((p != ranges_end) && (t == *p))
return icu_class_map[p - ranges_begin];
return 0;
}
icu_regex_traits::char_class_type icu_regex_traits::lookup_classname(const char_type* p1, const char_type* p2) const
{
static const char_class_type masks[] =
{
0,
U_GC_L_MASK | U_GC_ND_MASK,
U_GC_L_MASK,
mask_blank,
U_GC_CC_MASK | U_GC_CF_MASK | U_GC_ZL_MASK | U_GC_ZP_MASK,
U_GC_ND_MASK,
U_GC_ND_MASK,
(0x3FFFFFFFu) & ~(U_GC_CC_MASK | U_GC_CF_MASK | U_GC_CS_MASK | U_GC_CN_MASK | U_GC_Z_MASK),
U_GC_LL_MASK,
U_GC_LL_MASK,
~(U_GC_C_MASK),
U_GC_P_MASK,
char_class_type(U_GC_Z_MASK) | mask_space,
char_class_type(U_GC_Z_MASK) | mask_space,
U_GC_LU_MASK,
mask_unicode,
U_GC_LU_MASK,
char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore,
char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore,
char_class_type(U_GC_ND_MASK) | mask_xdigit,
};
int id = ::boost::re_detail::get_default_class_id(p1, p2);
if(id >= 0)
return masks[id+1];
char_class_type result = lookup_icu_mask(p1, p2);
if(result != 0)
return result;
if(id < 0)
{
string_type s(p1, p2);
string_type::size_type i = 0;
while(i < s.size())
{
s[i] = static_cast<char>((::u_tolower)(s[i]));
if(::u_isspace(s[i]) || (s[i] == '-') || (s[i] == '_'))
s.erase(s.begin()+i, s.begin()+i+1);
else
{
s[i] = static_cast<char>((::u_tolower)(s[i]));
++i;
}
}
if(s.size())
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
if(id >= 0)
return masks[id+1];
if(s.size())
result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size());
if(result != 0)
return result;
}
BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0]));
return masks[id+1];
}
icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_type* p1, const char_type* p2) const
{
string_type result;
if(std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2)
{
#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
std::string s(p1, p2);
#else
std::string s;
const char_type* p3 = p1;
while(p3 != p2)
s.append(1, *p3++);
#endif
// Try Unicode name:
UErrorCode err = U_ZERO_ERROR;
UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, s.c_str(), &err);
if(U_SUCCESS(err))
{
result.push_back(c);
return result;
}
// Try Unicode-extended name:
err = U_ZERO_ERROR;
c = ::u_charFromName(U_EXTENDED_CHAR_NAME, s.c_str(), &err);
if(U_SUCCESS(err))
{
result.push_back(c);
return result;
}
// try POSIX name:
s = ::boost::re_detail::lookup_default_collate_name(s);
#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
result.assign(s.begin(), s.end());
#else
result.clear();
std::string::const_iterator si, sj;
si = s.begin();
sj = s.end();
while(si != sj)
result.push_back(*si++);
#endif
}
if(result.empty() && (p2-p1 == 1))
result.push_back(*p1);
return result;
}
bool icu_regex_traits::isctype(char_type c, char_class_type f) const
{
// check for standard catagories first:
char_class_type m = char_class_type(1u << u_charType(c));
if((m & f) != 0)
return true;
// now check for special cases:
if(((f & mask_blank) != 0) && u_isblank(c))
return true;
if(((f & mask_space) != 0) && u_isspace(c))
return true;
if(((f & mask_xdigit) != 0) && (u_digit(c, 16) >= 0))
return true;
if(((f & mask_unicode) != 0) && (c >= 0x100))
return true;
if(((f & mask_underscore) != 0) && (c == '_'))
return true;
if(((f & mask_any) != 0) && (c <= 0x10FFFF))
return true;
if(((f & mask_ascii) != 0) && (c <= 0x7F))
return true;
return false;
}
}
#endif // BOOST_HAS_ICU
/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: instances.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: regex narrow character template instances.
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex/config.hpp>
#if !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)
#define BOOST_REGEX_NARROW_INSTANTIATE
#ifdef __BORLANDC__
#pragma hrdstop
#endif
#include <boost/regex.hpp>
#endif
/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: posix_api.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Implements the Posix API wrappers.
*/
#define BOOST_REGEX_SOURCE
#include <cstdio>
#include <boost/regex.hpp>
#include <boost/cregex.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::sprintf;
using ::strcpy;
using ::strcmp;
}
#endif
namespace boost{
namespace{
unsigned int magic_value = 25631;
const char* names[] = {
"REG_NOERROR",
"REG_NOMATCH",
"REG_BADPAT",
"REG_ECOLLATE",
"REG_ECTYPE",
"REG_EESCAPE",
"REG_ESUBREG",
"REG_EBRACK",
"REG_EPAREN",
"REG_EBRACE",
"REG_BADBR",
"REG_ERANGE",
"REG_ESPACE",
"REG_BADRPT",
"REG_EEND",
"REG_ESIZE",
"REG_ERPAREN",
"REG_EMPTY",
"REG_ECOMPLEXITY",
"REG_ESTACK",
"REG_E_UNKNOWN",
};
} // namespace
typedef boost::basic_regex<char, c_regex_traits<char> > c_regex_type;
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
{
if(expression->re_magic != magic_value)
{
expression->guts = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
expression->guts = new c_regex_type();
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
return REG_ESPACE;
}
#else
if(0 == expression->guts)
return REG_E_MEMORY;
#endif
}
// set default flags:
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
// and translate those that are actually set:
if(f & REG_NOCOLLATE)
{
flags |= regex::nocollate;
#ifndef BOOST_REGEX_V3
flags &= ~regex::collate;
#endif
}
if(f & REG_NOSUB)
{
//expression->eflags |= match_any;
flags |= regex::nosubs;
}
if(f & REG_NOSPEC)
flags |= regex::literal;
if(f & REG_ICASE)
flags |= regex::icase;
if(f & REG_ESCAPE_IN_LISTS)
flags &= ~regex::no_escape_in_lists;
if(f & REG_NEWLINE_ALT)
flags |= regex::newline_alt;
const char* p2;
if(f & REG_PEND)
p2 = expression->re_endp;
else p2 = ptr + std::strlen(ptr);
int result;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
expression->re_magic = magic_value;
static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1;
result = static_cast<c_regex_type*>(expression->guts)->error_code();
#ifndef BOOST_NO_EXCEPTIONS
}
catch(const boost::regex_error& be)
{
result = be.code();
}
catch(...)
{
result = REG_E_UNKNOWN;
}
#endif
if(result)
regfreeA(expression);
return result;
}
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* e, char* buf, regsize_t buf_size)
{
std::size_t result = 0;
if(code & REG_ITOA)
{
code &= ~REG_ITOA;
if(code <= (int)REG_E_UNKNOWN)
{
result = std::strlen(names[code]) + 1;
if(buf_size >= result)
re_detail::strcpy_s(buf, buf_size, names[code]);
return result;
}
return result;
}
if(code == REG_ATOI)
{
char localbuf[5];
if(e == 0)
return 0;
for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i)
{
if(std::strcmp(e->re_endp, names[i]) == 0)
{
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
(::sprintf_s)(localbuf, 5, "%d", i);
#else
(std::sprintf)(localbuf, "%d", i);
#endif
if(std::strlen(localbuf) < buf_size)
re_detail::strcpy_s(buf, buf_size, localbuf);
return std::strlen(localbuf) + 1;
}
}
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
(::sprintf_s)(localbuf, 5, "%d", 0);
#else
(std::sprintf)(localbuf, "%d", 0);
#endif
if(std::strlen(localbuf) < buf_size)
re_detail::strcpy_s(buf, buf_size, localbuf);
return std::strlen(localbuf) + 1;
}
if(code <= (int)REG_E_UNKNOWN)
{
std::string p;
if((e) && (e->re_magic == magic_value))
p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
else
{
p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
}
std::size_t len = p.size();
if(len < buf_size)
{
re_detail::strcpy_s(buf, buf_size, p.c_str());
}
return len + 1;
}
if(buf_size)
*buf = 0;
return 0;
}
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, const char* buf, regsize_t n, regmatch_t* array, int eflags)
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4267)
#endif
bool result = false;
match_flag_type flags = match_default | expression->eflags;
const char* end;
const char* start;
cmatch m;
if(eflags & REG_NOTBOL)
flags |= match_not_bol;
if(eflags & REG_NOTEOL)
flags |= match_not_eol;
if(eflags & REG_STARTEND)
{
start = buf + array[0].rm_so;
end = buf + array[0].rm_eo;
}
else
{
start = buf;
end = buf + std::strlen(buf);
}
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
if(expression->re_magic == magic_value)
{
result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags);
}
else
return result;
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
return REG_E_UNKNOWN;
}
#endif
if(result)
{
// extract what matched:
std::size_t i;
for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i)
{
array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf);
array[i].rm_eo = (m[i].matched == false) ? -1 : (m[i].second - buf);
}
// and set anything else to -1:
for(i = expression->re_nsub + 1; i < n; ++i)
{
array[i].rm_so = -1;
array[i].rm_eo = -1;
}
return 0;
}
return REG_NOMATCH;
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
}
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA* expression)
{
if(expression->re_magic == magic_value)
{
delete static_cast<c_regex_type*>(expression->guts);
}
expression->re_magic = 0;
}
} // namespace boost
/*
*
* Copyright (c) 1998-2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: regex.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Misc boost::regbase member funnctions.
*/
#define BOOST_REGEX_SOURCE
#include <new>
#include <boost/regex.hpp>
#include <boost/throw_exception.hpp>
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
# include <malloc.h>
#endif
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
# define NOMINMAX
#endif
#define NOGDI
#define NOUSER
#include <windows.h>
#endif
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
#include <new>
#else
#include <boost/regex/v4/mem_block_cache.hpp>
#endif
#endif
namespace boost{
//
// fix: these are declared out of line here to ensure
// that dll builds contain the Virtual table for these
// types - this ensures that exceptions can be thrown
// from the dll and caught in an exe.
regex_error::regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos)
: std::runtime_error(s)
, m_error_code(err)
, m_position(pos)
{
}
regex_error::regex_error(regex_constants::error_type err)
: std::runtime_error(::boost::re_detail::get_default_error_string(err))
, m_error_code(err)
, m_position(0)
{
}
regex_error::~regex_error() throw()
{
}
void regex_error::raise()const
{
#ifndef BOOST_NO_EXCEPTIONS
::boost::throw_exception(*this);
#endif
}
namespace re_detail{
BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex)
{
::boost::throw_exception(ex);
}
//
// error checking API:
//
BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /*ef*/, match_flag_type mf)
{
#ifndef BOOST_REGEX_V3
//
// can't mix match_extra with POSIX matching rules:
//
if((mf & match_extra) && (mf & match_posix))
{
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
throw_exception(msg);
}
#endif
}
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
static void execute_eror()
{
// we only get here after a stack overflow,
// this has to be a separate proceedure because we
// can't mix __try{}__except block with local objects
// that have destructors:
reset_stack_guard_page();
std::runtime_error err("Out of stack space, while attempting to match a regular expression.");
raise_runtime_error(err);
}
bool BOOST_REGEX_CALL abstract_protected_call::execute()const
{
__try{
return this->call();
}__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode())
{
execute_eror();
}
// We never really get here at all:
return false;
}
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
{
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
_resetstkoflw();
#else
//
// We need to locate the current page being used by the stack,
// move to the page below it and then deallocate and protect
// that page. Note that ideally we would protect only the lowest
// stack page that has been allocated: in practice there
// seems to be no easy way to locate this page, in any case as
// long as the next page is protected, then Windows will figure
// the rest out for us...
//
SYSTEM_INFO si;
GetSystemInfo(&si);
MEMORY_BASIC_INFORMATION mi;
DWORD previous_protection_status;
//
// this is an address in our stack space:
//
LPBYTE page = (LPBYTE)&page;
//
// Get the current memory page in use:
//
VirtualQuery(page, &mi, sizeof(mi));
//
// Go to the page one below this:
//
page = (LPBYTE)(mi.BaseAddress)-si.dwPageSize;
//
// Free and protect everything from the start of the
// allocation range, to the end of the page below the
// one in use:
//
if (!VirtualFree(mi.AllocationBase, (LPBYTE)page - (LPBYTE)mi.AllocationBase, MEM_DECOMMIT)
|| !VirtualProtect(page, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &previous_protection_status))
{
throw std::bad_exception();
}
#endif
}
#endif
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block()
{
return ::operator new(BOOST_REGEX_BLOCKSIZE);
}
BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p)
{
::operator delete(p);
}
#else
#ifdef BOOST_HAS_THREADS
mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, };
#else
mem_block_cache block_cache = { 0, 0, };
#endif
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block()
{
return block_cache.get();
}
BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p)
{
block_cache.put(p);
}
#endif
#endif
} // namespace re_detail
} // namespace boost
#if defined(BOOST_RE_USE_VCL) && defined(BOOST_REGEX_DYN_LINK)
int WINAPI DllEntryPoint(HINSTANCE , unsigned long , void*)
{
return 1;
}
#endif
#if defined(__IBMCPP__) && defined(BOOST_REGEX_DYN_LINK)
//
// Is this correct - linker complains without it ?
//
int main()
{
return 0;
}
#endif
/*
*
* Copyright (c) 1998-2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: regex_debug.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Misc. debugging helpers.
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex/config.hpp>
//
// regex configuration information: this prints out the settings used
// when the library was built - include in debugging builds only:
//
#ifdef BOOST_REGEX_CONFIG_INFO
#define print_macro regex_lib_print_macro
#define print_expression regex_lib_print_expression
#define print_byte_order regex_lib_print_byte_order
#define print_sign regex_lib_print_sign
#define print_compiler_macros regex_lib_print_compiler_macros
#define print_stdlib_macros regex_lib_print_stdlib_macros
#define print_platform_macros regex_lib_print_platform_macros
#define print_boost_macros regex_lib_print_boost_macros
#define print_separator regex_lib_print_separator
#define OLD_MAIN regex_lib_main
#define NEW_MAIN regex_lib_main2
#define NO_RECURSE
#include <libs/regex/test/config_info/regex_config_info.cpp>
BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info()
{
std::cout << "\n\n";
print_separator();
std::cout << "Regex library build configuration:\n\n";
regex_lib_main2();
}
#endif
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE regex_raw_buffer.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Member functions for class raw_storage.
*/
#define BOOST_REGEX_SOURCE
#include <memory>
#include <cstring>
#include <boost/assert.hpp>
#include <boost/regex/v4/regex_raw_buffer.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
using ::memmove;
}
#endif
namespace boost{ namespace re_detail{
void BOOST_REGEX_CALL raw_storage::resize(size_type n)
{
register size_type newsize = start ? last - start : 1024;
while(newsize < n)
newsize *= 2;
register size_type datasize = end - start;
// extend newsize to WORD/DWORD boundary:
newsize = (newsize + padding_mask) & ~(padding_mask);
// allocate and copy data:
register pointer ptr = static_cast<pointer>(::operator new(newsize));
BOOST_REGEX_NOEH_ASSERT(ptr)
std::memcpy(ptr, start, datasize);
// get rid of old buffer:
::operator delete(start);
// and set up pointers:
start = ptr;
end = ptr + datasize;
last = ptr + newsize;
}
void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n)
{
BOOST_ASSERT(pos <= size_type(end - start));
if(size_type(last - end) < n)
resize(n + (end - start));
register void* result = start + pos;
std::memmove(start + pos + n, start + pos, (end - start) - pos);
end += n;
return result;
}
}} // namespaces
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE regex_traits_defaults.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares API's for access to regex_traits default properties.
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex/regex_traits.hpp>
#include <cctype>
#ifndef BOOST_NO_WREGEX
#include <cwctype>
#endif
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::tolower;
using ::toupper;
#ifndef BOOST_NO_WREGEX
using ::towlower;
using ::towupper;
#endif
}
#endif
namespace boost{ namespace re_detail{
BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n)
{
// if the user hasn't supplied a message catalog, then this supplies
// default "messages" for us to load in the range 1-100.
const char* messages[] = {
"",
"(",
")",
"$",
"^",
".",
"*",
"+",
"?",
"[",
"]",
"|",
"\\",
"#",
"-",
"{",
"}",
"0123456789",
"b",
"B",
"<",
">",
"",
"",
"A`",
"z'",
"\n",
",",
"a",
"f",
"n",
"r",
"t",
"v",
"x",
"c",
":",
"=",
"e",
"",
"",
"",
"",
"",
"",
"",
"",
"E",
"Q",
"X",
"C",
"Z",
"G",
"!",
"p",
"P",
"N",
};
return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]);
}
BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n)
{
static const char* const s_default_error_messages[] = {
"Success", /* REG_NOERROR */
"No match", /* REG_NOMATCH */
"Invalid regular expression", /* REG_BADPAT */
"Invalid collation character", /* REG_ECOLLATE */
"Invalid character class name", /* REG_ECTYPE */
"Invalid or trailing backslash", /* REG_EESCAPE */
"Invalid back reference", /* REG_ESUBREG */
"Unmatched [ or [^", /* REG_EBRACK */
"Unmatched ( or \\(", /* REG_EPAREN */
"Unmatched { or \\{", /* REG_EBRACE */
"Invalid content of repeat range", /* REG_BADBR */
"Invalid range end", /* REG_ERANGE */
"Memory exhausted", /* REG_ESPACE */
"Invalid preceding regular expression", /* REG_BADRPT */
"Premature end of regular expression", /* REG_EEND */
"Regular expression too big", /* REG_ESIZE */
"Unmatched ) or \\)", /* REG_ERPAREN */
"Empty expression", /* REG_EMPTY */
"Complexity requirements exceeded", /* REG_ECOMPLEXITY */
"Out of stack space", /* REG_ESTACK */
"Unknown error", /* REG_E_UNKNOWN */
"",
"",
"",
};
return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[ ::boost::regex_constants::error_unknown] : s_default_error_messages[n];
}
BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c)
{
const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
0x0483, 0x0486,
0x0903, 0x0903,
0x093E, 0x0940,
0x0949, 0x094C,
0x0982, 0x0983,
0x09BE, 0x09C0,
0x09C7, 0x09CC,
0x09D7, 0x09D7,
0x0A3E, 0x0A40,
0x0A83, 0x0A83,
0x0ABE, 0x0AC0,
0x0AC9, 0x0ACC,
0x0B02, 0x0B03,
0x0B3E, 0x0B3E,
0x0B40, 0x0B40,
0x0B47, 0x0B4C,
0x0B57, 0x0B57,
0x0B83, 0x0B83,
0x0BBE, 0x0BBF,
0x0BC1, 0x0BCC,
0x0BD7, 0x0BD7,
0x0C01, 0x0C03,
0x0C41, 0x0C44,
0x0C82, 0x0C83,
0x0CBE, 0x0CBE,
0x0CC0, 0x0CC4,
0x0CC7, 0x0CCB,
0x0CD5, 0x0CD6,
0x0D02, 0x0D03,
0x0D3E, 0x0D40,
0x0D46, 0x0D4C,
0x0D57, 0x0D57,
0x0F7F, 0x0F7F,
0x20D0, 0x20E1,
0x3099, 0x309A,
0xFE20, 0xFE23,
0xffff, 0xffff, };
const boost::uint_least16_t* p = combining_ranges + 1;
while(*p < c) p += 2;
--p;
if((c >= *p) && (c <= *(p+1)))
return true;
return false;
}
//
// these are the POSIX collating names:
//
BOOST_REGEX_DECL const char* def_coll_names[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline",
"vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK",
"SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark",
"quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe",
"left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen",
"period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign",
"question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash",
"right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket",
"vertical-line", "right-curly-bracket", "tilde", "DEL", "",
};
// these multi-character collating elements
// should keep most Western-European locales
// happy - we should really localise these a
// little more - but this will have to do for
// now:
BOOST_REGEX_DECL const char* def_multi_coll[] = {
"ae",
"Ae",
"AE",
"ch",
"Ch",
"CH",
"ll",
"Ll",
"LL",
"ss",
"Ss",
"SS",
"nj",
"Nj",
"NJ",
"dz",
"Dz",
"DZ",
"lj",
"Lj",
"LJ",
"",
};
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name)
{
unsigned int i = 0;
while(*def_coll_names[i])
{
if(def_coll_names[i] == name)
{
return std::string(1, char(i));
}
++i;
}
i = 0;
while(*def_multi_coll[i])
{
if(def_multi_coll[i] == name)
{
return def_multi_coll[i];
}
++i;
}
return std::string();
}
BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_lower(char c)
{
return static_cast<char>((std::tolower)((unsigned char)c));
}
BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_upper(char c)
{
return static_cast<char>((std::toupper)((unsigned char)c));
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c)
{
return (std::towlower)(c);
}
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c)
{
return (std::towupper)(c);
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_lower(unsigned short c)
{
return (std::towlower)(c);
}
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short c)
{
return (std::towupper)(c);
}
#endif
#endif
BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c)
{
//
// char_syntax determines how the compiler treats a given character
// in a regular expression.
//
static regex_constants::escape_syntax_type char_syntax[] = {
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /* */ // 32
regex_constants::escape_type_identity, /*!*/
regex_constants::escape_type_identity, /*"*/
regex_constants::escape_type_identity, /*#*/
regex_constants::escape_type_identity, /*$*/
regex_constants::escape_type_identity, /*%*/
regex_constants::escape_type_identity, /*&*/
regex_constants::escape_type_end_buffer, /*'*/
regex_constants::syntax_open_mark, /*(*/
regex_constants::syntax_close_mark, /*)*/
regex_constants::escape_type_identity, /***/
regex_constants::syntax_plus, /*+*/
regex_constants::escape_type_identity, /*,*/
regex_constants::escape_type_identity, /*-*/
regex_constants::escape_type_identity, /*.*/
regex_constants::escape_type_identity, /*/*/
regex_constants::escape_type_decimal, /*0*/
regex_constants::escape_type_backref, /*1*/
regex_constants::escape_type_backref, /*2*/
regex_constants::escape_type_backref, /*3*/
regex_constants::escape_type_backref, /*4*/
regex_constants::escape_type_backref, /*5*/
regex_constants::escape_type_backref, /*6*/
regex_constants::escape_type_backref, /*7*/
regex_constants::escape_type_backref, /*8*/
regex_constants::escape_type_backref, /*9*/
regex_constants::escape_type_identity, /*:*/
regex_constants::escape_type_identity, /*;*/
regex_constants::escape_type_left_word, /*<*/
regex_constants::escape_type_identity, /*=*/
regex_constants::escape_type_right_word, /*>*/
regex_constants::syntax_question, /*?*/
regex_constants::escape_type_identity, /*@*/
regex_constants::escape_type_start_buffer, /*A*/
regex_constants::escape_type_not_word_assert, /*B*/
regex_constants::escape_type_C, /*C*/
regex_constants::escape_type_not_class, /*D*/
regex_constants::escape_type_E, /*E*/
regex_constants::escape_type_not_class, /*F*/
regex_constants::escape_type_G, /*G*/
regex_constants::escape_type_not_class, /*H*/
regex_constants::escape_type_not_class, /*I*/
regex_constants::escape_type_not_class, /*J*/
regex_constants::escape_type_not_class, /*K*/
regex_constants::escape_type_not_class, /*L*/
regex_constants::escape_type_not_class, /*M*/
regex_constants::escape_type_named_char, /*N*/
regex_constants::escape_type_not_class, /*O*/
regex_constants::escape_type_not_property, /*P*/
regex_constants::escape_type_Q, /*Q*/
regex_constants::escape_type_not_class, /*R*/
regex_constants::escape_type_not_class, /*S*/
regex_constants::escape_type_not_class, /*T*/
regex_constants::escape_type_not_class, /*U*/
regex_constants::escape_type_not_class, /*V*/
regex_constants::escape_type_not_class, /*W*/
regex_constants::escape_type_X, /*X*/
regex_constants::escape_type_not_class, /*Y*/
regex_constants::escape_type_Z, /*Z*/
regex_constants::escape_type_identity, /*[*/
regex_constants::escape_type_identity, /*\*/
regex_constants::escape_type_identity, /*]*/
regex_constants::escape_type_identity, /*^*/
regex_constants::escape_type_identity, /*_*/
regex_constants::escape_type_start_buffer, /*`*/
regex_constants::escape_type_control_a, /*a*/
regex_constants::escape_type_word_assert, /*b*/
regex_constants::escape_type_ascii_control, /*c*/
regex_constants::escape_type_class, /*d*/
regex_constants::escape_type_e, /*e*/
regex_constants::escape_type_control_f, /*f*/
regex_constants::escape_type_class, /*g*/
regex_constants::escape_type_class, /*h*/
regex_constants::escape_type_class, /*i*/
regex_constants::escape_type_class, /*j*/
regex_constants::escape_type_class, /*k*/
regex_constants::escape_type_class, /*l*/
regex_constants::escape_type_class, /*m*/
regex_constants::escape_type_control_n, /*n*/
regex_constants::escape_type_class, /*o*/
regex_constants::escape_type_property, /*p*/
regex_constants::escape_type_class, /*q*/
regex_constants::escape_type_control_r, /*r*/
regex_constants::escape_type_class, /*s*/
regex_constants::escape_type_control_t, /*t*/
regex_constants::escape_type_class, /*u*/
regex_constants::escape_type_control_v, /*v*/
regex_constants::escape_type_class, /*w*/
regex_constants::escape_type_hex, /*x*/
regex_constants::escape_type_class, /*y*/
regex_constants::escape_type_end_buffer, /*z*/
regex_constants::syntax_open_brace, /*{*/
regex_constants::syntax_or, /*|*/
regex_constants::syntax_close_brace, /*}*/
regex_constants::escape_type_identity, /*~*/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
};
return char_syntax[(unsigned char)c];
}
BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c)
{
//
// char_syntax determines how the compiler treats a given character
// in a regular expression.
//
static regex_constants::syntax_type char_syntax[] = {
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_newline, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /* */ // 32
regex_constants::syntax_not, /*!*/
regex_constants::syntax_char, /*"*/
regex_constants::syntax_hash, /*#*/
regex_constants::syntax_dollar, /*$*/
regex_constants::syntax_char, /*%*/
regex_constants::syntax_char, /*&*/
regex_constants::syntax_char, /*'*/
regex_constants::syntax_open_mark, /*(*/
regex_constants::syntax_close_mark, /*)*/
regex_constants::syntax_star, /***/
regex_constants::syntax_plus, /*+*/
regex_constants::syntax_comma, /*,*/
regex_constants::syntax_dash, /*-*/
regex_constants::syntax_dot, /*.*/
regex_constants::syntax_char, /*/*/
regex_constants::syntax_digit, /*0*/
regex_constants::syntax_digit, /*1*/
regex_constants::syntax_digit, /*2*/
regex_constants::syntax_digit, /*3*/
regex_constants::syntax_digit, /*4*/
regex_constants::syntax_digit, /*5*/
regex_constants::syntax_digit, /*6*/
regex_constants::syntax_digit, /*7*/
regex_constants::syntax_digit, /*8*/
regex_constants::syntax_digit, /*9*/
regex_constants::syntax_colon, /*:*/
regex_constants::syntax_char, /*;*/
regex_constants::escape_type_left_word, /*<*/
regex_constants::syntax_equal, /*=*/
regex_constants::escape_type_right_word, /*>*/
regex_constants::syntax_question, /*?*/
regex_constants::syntax_char, /*@*/
regex_constants::syntax_char, /*A*/
regex_constants::syntax_char, /*B*/
regex_constants::syntax_char, /*C*/
regex_constants::syntax_char, /*D*/
regex_constants::syntax_char, /*E*/
regex_constants::syntax_char, /*F*/
regex_constants::syntax_char, /*G*/
regex_constants::syntax_char, /*H*/
regex_constants::syntax_char, /*I*/
regex_constants::syntax_char, /*J*/
regex_constants::syntax_char, /*K*/
regex_constants::syntax_char, /*L*/
regex_constants::syntax_char, /*M*/
regex_constants::syntax_char, /*N*/
regex_constants::syntax_char, /*O*/
regex_constants::syntax_char, /*P*/
regex_constants::syntax_char, /*Q*/
regex_constants::syntax_char, /*R*/
regex_constants::syntax_char, /*S*/
regex_constants::syntax_char, /*T*/
regex_constants::syntax_char, /*U*/
regex_constants::syntax_char, /*V*/
regex_constants::syntax_char, /*W*/
regex_constants::syntax_char, /*X*/
regex_constants::syntax_char, /*Y*/
regex_constants::syntax_char, /*Z*/
regex_constants::syntax_open_set, /*[*/
regex_constants::syntax_escape, /*\*/
regex_constants::syntax_close_set, /*]*/
regex_constants::syntax_caret, /*^*/
regex_constants::syntax_char, /*_*/
regex_constants::syntax_char, /*`*/
regex_constants::syntax_char, /*a*/
regex_constants::syntax_char, /*b*/
regex_constants::syntax_char, /*c*/
regex_constants::syntax_char, /*d*/
regex_constants::syntax_char, /*e*/
regex_constants::syntax_char, /*f*/
regex_constants::syntax_char, /*g*/
regex_constants::syntax_char, /*h*/
regex_constants::syntax_char, /*i*/
regex_constants::syntax_char, /*j*/
regex_constants::syntax_char, /*k*/
regex_constants::syntax_char, /*l*/
regex_constants::syntax_char, /*m*/
regex_constants::syntax_char, /*n*/
regex_constants::syntax_char, /*o*/
regex_constants::syntax_char, /*p*/
regex_constants::syntax_char, /*q*/
regex_constants::syntax_char, /*r*/
regex_constants::syntax_char, /*s*/
regex_constants::syntax_char, /*t*/
regex_constants::syntax_char, /*u*/
regex_constants::syntax_char, /*v*/
regex_constants::syntax_char, /*w*/
regex_constants::syntax_char, /*x*/
regex_constants::syntax_char, /*y*/
regex_constants::syntax_char, /*z*/
regex_constants::syntax_open_brace, /*{*/
regex_constants::syntax_or, /*|*/
regex_constants::syntax_close_brace, /*}*/
regex_constants::syntax_char, /*~*/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
};
return char_syntax[(unsigned char)c];
}
} // re_detail
} // boost
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE static_mutex.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares static_mutex lock type.
*/
#define BOOST_REGEX_SOURCE
#include <boost/config.hpp>
#ifdef BOOST_HAS_THREADS
#include <boost/regex/pending/static_mutex.hpp>
#if defined(BOOST_HAS_WINTHREADS)
#ifndef NOMINMAX
# define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <boost/static_assert.hpp>
#endif
namespace boost{
#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER)
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk)
: m_mutex(m), m_have_lock(false)
{
if(lk)
lock();
}
scoped_static_mutex_lock::~scoped_static_mutex_lock()
{
if(m_have_lock)
unlock();
}
void scoped_static_mutex_lock::lock()
{
if(0 == m_have_lock)
{
pthread_mutex_lock(&(m_mutex.m_mutex));
m_have_lock = true;
}
}
void scoped_static_mutex_lock::unlock()
{
if(m_have_lock)
{
pthread_mutex_unlock(&(m_mutex.m_mutex));
m_have_lock = false;
}
}
#elif defined(BOOST_HAS_WINTHREADS)
BOOST_STATIC_ASSERT(sizeof(LONG) == sizeof(boost::int32_t));
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk)
: m_mutex(m), m_have_lock(false)
{
if(lk)
lock();
}
scoped_static_mutex_lock::~scoped_static_mutex_lock()
{
if(m_have_lock)
unlock();
}
void scoped_static_mutex_lock::lock()
{
if(0 == m_have_lock)
{
#if !defined(InterlockedCompareExchangePointer)
while(0 != InterlockedCompareExchange(reinterpret_cast<void**>((boost::uint_least16_t*)&(m_mutex.m_mutex)), (void*)1, 0))
#else
while(0 != InterlockedCompareExchange(reinterpret_cast<LONG*>(&(m_mutex.m_mutex)), 1, 0))
#endif
{
Sleep(0);
}
m_have_lock = true;
}
}
void scoped_static_mutex_lock::unlock()
{
if(m_have_lock)
{
#if !defined(InterlockedCompareExchangePointer)
InterlockedExchange((LONG*)&(m_mutex.m_mutex), 0);
#else
InterlockedExchange(reinterpret_cast<LONG*>(&(m_mutex.m_mutex)), 0);
#endif
m_have_lock = false;
}
}
#else
//
// Portable version of a static mutex based on Boost.Thread library:
//
#include <stdlib.h>
#include <boost/assert.hpp>
boost::recursive_mutex* static_mutex::m_pmutex = 0;
boost::once_flag static_mutex::m_once = BOOST_ONCE_INIT;
extern "C" BOOST_REGEX_DECL void free_static_mutex()
{
delete static_mutex::m_pmutex;
static_mutex::m_pmutex = 0;
}
void static_mutex::init()
{
m_pmutex = new boost::recursive_mutex();
int r = atexit(free_static_mutex);
BOOST_ASSERT(0 == r);
}
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& , bool lk)
: m_plock(0), m_have_lock(false)
{
if(lk)
lock();
}
scoped_static_mutex_lock::~scoped_static_mutex_lock()
{
if(m_have_lock)
unlock();
delete m_plock;
}
void scoped_static_mutex_lock::lock()
{
if(0 == m_have_lock)
{
boost::call_once(static_mutex::m_once,&static_mutex::init);
if(0 == m_plock)
m_plock = new boost::recursive_mutex::scoped_lock(*static_mutex::m_pmutex, false);
m_plock->lock();
m_have_lock = true;
}
}
void scoped_static_mutex_lock::unlock()
{
if(m_have_lock)
{
m_plock->unlock();
m_have_lock = false;
}
}
#endif
}
#endif // BOOST_HAS_THREADS
/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: winstances.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: regex unsigned short template instances (MSVC only).
*/
#define BOOST_REGEX_SOURCE
#include <boost/detail/workaround.hpp>
#include <memory>
#include <string>
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \
&& !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER))
//
// This is a horrible workaround, but without declaring these symbols extern we get
// duplicate symbol errors when linking if the application is built without
// /Zc:wchar_t
//
#ifdef _CRTIMP2_PURE
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE
#else
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2
#endif
namespace std{
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
template class BOOST_REGEX_STDLIB_DECL allocator<unsigned short>;
template class BOOST_REGEX_STDLIB_DECL _String_val<unsigned short, allocator<unsigned short> >;
template class BOOST_REGEX_STDLIB_DECL basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >;
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*);
#endif
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
}
#endif
#include <boost/regex/config.hpp>
#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)
#define BOOST_REGEX_US_INSTANTIATE
#include <boost/regex.hpp>
#endif
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE w32_regex_traits.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Implements w32_regex_traits<char> (and associated helper classes).
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex/config.hpp>
#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
#include <boost/regex/regex_traits.hpp>
#include <boost/regex/pattern_except.hpp>
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
# define NOMINMAX
#endif
#define NOGDI
#include <windows.h>
#if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
#pragma comment(lib, "user32.lib")
#endif
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{
using ::memset;
}
#endif
namespace boost{ namespace re_detail{
#ifdef BOOST_NO_ANSI_APIS
UINT get_code_page_for_locale_id(lcid_type id)
{
WCHAR code_page_string[7];
if (::GetLocaleInfoW(id, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0)
return 0;
return static_cast<UINT>(_wtol(code_page_string));
}
#endif
void w32_regex_traits_char_layer<char>::init()
{
// we need to start by initialising our syntax map so we know which
// character is used for which purpose:
std::memset(m_char_map, 0, sizeof(m_char_map));
cat_type cat;
std::string cat_name(w32_regex_traits<char>::get_catalog_name());
if(cat_name.size())
{
cat = ::boost::re_detail::w32_cat_open(cat_name);
if(!cat)
{
std::string m("Unable to open message catalog: ");
std::runtime_error err(m + cat_name);
::boost::re_detail::raise_runtime_error(err);
}
}
//
// if we have a valid catalog then load our messages:
//
if(cat)
{
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
{
string_type mss = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i, get_default_syntax(i));
for(string_type::size_type j = 0; j < mss.size(); ++j)
{
m_char_map[static_cast<unsigned char>(mss[j])] = i;
}
}
}
else
{
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
{
const char* ptr = get_default_syntax(i);
while(ptr && *ptr)
{
m_char_map[static_cast<unsigned char>(*ptr)] = i;
++ptr;
}
}
}
//
// finish off by calculating our escape types:
//
unsigned char i = 'A';
do
{
if(m_char_map[i] == 0)
{
if(::boost::re_detail::w32_is(this->m_locale, 0x0002u, (char)i))
m_char_map[i] = regex_constants::escape_type_class;
else if(::boost::re_detail::w32_is(this->m_locale, 0x0001u, (char)i))
m_char_map[i] = regex_constants::escape_type_not_class;
}
}while(0xFF != i++);
//
// fill in lower case map:
//
char char_map[1 << CHAR_BIT];
for(int ii = 0; ii < (1 << CHAR_BIT); ++ii)
char_map[ii] = static_cast<char>(ii);
#ifndef BOOST_NO_ANSI_APIS
int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT);
BOOST_ASSERT(r != 0);
#else
UINT code_page = get_code_page_for_locale_id(this->m_locale);
BOOST_ASSERT(code_page != 0);
WCHAR wide_char_map[1 << CHAR_BIT];
int conv_r = ::MultiByteToWideChar(code_page, 0, char_map, 1 << CHAR_BIT, wide_char_map, 1 << CHAR_BIT);
BOOST_ASSERT(conv_r != 0);
WCHAR wide_lower_map[1 << CHAR_BIT];
int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT);
BOOST_ASSERT(r != 0);
conv_r = ::WideCharToMultiByte(code_page, 0, wide_lower_map, r, this->m_lower_map, 1 << CHAR_BIT, NULL, NULL);
BOOST_ASSERT(conv_r != 0);
#endif
if(r < (1 << CHAR_BIT))
{
// if we have multibyte characters then not all may have been given
// a lower case mapping:
for(int jj = r; jj < (1 << CHAR_BIT); ++jj)
this->m_lower_map[jj] = static_cast<char>(jj);
}
#ifndef BOOST_NO_ANSI_APIS
r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map);
#else
r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map);
#endif
BOOST_ASSERT(0 != r);
}
BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale()
{
return ::GetUserDefaultLCID();
}
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type id)
{
#ifndef BOOST_NO_ANSI_APIS
WORD mask;
if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
#else
UINT code_page = get_code_page_for_locale_id(id);
if (code_page == 0)
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
#endif
}
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type id)
{
WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type id)
{
WORD mask;
wchar_t c = ca;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
}
#endif
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type id)
{
#ifndef BOOST_NO_ANSI_APIS
WORD mask;
if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
#else
UINT code_page = get_code_page_for_locale_id(id);
if (code_page == 0)
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
#endif
}
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t c, lcid_type id)
{
WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type id)
{
WORD mask;
wchar_t c = ca;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
}
#endif
void free_module(void* mod)
{
::FreeLibrary(static_cast<HMODULE>(mod));
}
BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name)
{
#ifndef BOOST_NO_ANSI_APIS
cat_type result(::LoadLibraryA(name.c_str()), &free_module);
return result;
#else
LPWSTR wide_name = (LPWSTR)_alloca( (name.size() + 1) * sizeof(WCHAR) );
if (::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.size(), wide_name, name.size() + 1) == 0)
return cat_type();
cat_type result(::LoadLibraryW(wide_name), &free_module);
return result;
#endif
}
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def)
{
#ifndef BOOST_NO_ANSI_APIS
char buf[256];
if(0 == ::LoadStringA(
static_cast<HMODULE>(cat.get()),
i,
buf,
256
))
{
return def;
}
#else
WCHAR wbuf[256];
int r = ::LoadStringW(
static_cast<HMODULE>(cat.get()),
i,
wbuf,
256
);
if (r == 0)
return def;
LPSTR buf = (LPSTR)_alloca( (r + 1) * 2 );
if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, (r + 1) * 2, NULL, NULL) == 0)
return def;
#endif
return std::string(buf);
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def)
{
wchar_t buf[256];
if(0 == ::LoadStringW(
static_cast<HMODULE>(cat.get()),
i,
buf,
256
))
{
return def;
}
return std::wstring(buf);
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string<unsigned short>& def)
{
unsigned short buf[256];
if(0 == ::LoadStringW(
static_cast<HMODULE>(cat.get()),
i,
(LPWSTR)buf,
256
))
{
return def;
}
return std::basic_string<unsigned short>(buf);
}
#endif
#endif
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const char* p1, const char* p2)
{
#ifndef BOOST_NO_ANSI_APIS
int bytes = ::LCMapStringA(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
0, // destination buffer
0 // size of destination buffer
);
if(!bytes)
return std::string(p1, p2);
std::string result(++bytes, '\0');
bytes = ::LCMapStringA(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
&*result.begin(), // destination buffer
bytes // size of destination buffer
);
#else
UINT code_page = get_code_page_for_locale_id(id);
if(code_page == 0)
return std::string(p1, p2);
int src_len = static_cast<int>(p2 - p1);
LPWSTR wide_p1 = (LPWSTR)_alloca( (src_len + 1) * 2 );
if(::MultiByteToWideChar(code_page, 0, p1, src_len, wide_p1, src_len + 1) == 0)
return std::string(p1, p2);
int bytes = ::LCMapStringW(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
wide_p1, // source string
src_len, // number of characters in source string
0, // destination buffer
0 // size of destination buffer
);
if(!bytes)
return std::string(p1, p2);
std::string result(++bytes, '\0');
bytes = ::LCMapStringW(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
wide_p1, // source string
src_len, // number of characters in source string
(LPWSTR)&*result.begin(), // destination buffer
bytes // size of destination buffer
);
#endif
if(bytes > static_cast<int>(result.size()))
return std::string(p1, p2);
while(result.size() && result[result.size()-1] == '\0')
{
result.erase(result.size()-1);
}
return result;
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type id, const wchar_t* p1, const wchar_t* p2)
{
int bytes = ::LCMapStringW(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
0, // destination buffer
0 // size of destination buffer
);
if(!bytes)
return std::wstring(p1, p2);
std::string result(++bytes, '\0');
bytes = ::LCMapStringW(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
reinterpret_cast<wchar_t*>(&*result.begin()), // destination buffer *of bytes*
bytes // size of destination buffer
);
if(bytes > static_cast<int>(result.size()))
return std::wstring(p1, p2);
while(result.size() && result[result.size()-1] == L'\0')
{
result.erase(result.size()-1);
}
std::wstring r2;
for(std::string::size_type i = 0; i < result.size(); ++i)
r2.append(1, static_cast<wchar_t>(static_cast<unsigned char>(result[i])));
return r2;
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transform(lcid_type id, const unsigned short* p1, const unsigned short* p2)
{
int bytes = ::LCMapStringW(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
(LPCWSTR)p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
0, // destination buffer
0 // size of destination buffer
);
if(!bytes)
return std::basic_string<unsigned short>(p1, p2);
std::string result(++bytes, '\0');
bytes = ::LCMapStringW(
id, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
(LPCWSTR)p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
reinterpret_cast<wchar_t*>(&*result.begin()), // destination buffer *of bytes*
bytes // size of destination buffer
);
if(bytes > static_cast<int>(result.size()))
return std::basic_string<unsigned short>(p1, p2);
while(result.size() && result[result.size()-1] == L'\0')
{
result.erase(result.size()-1);
}
std::basic_string<unsigned short> r2;
for(std::string::size_type i = 0; i < result.size(); ++i)
r2.append(1, static_cast<unsigned short>(static_cast<unsigned char>(result[i])));
return r2;
}
#endif
#endif
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id)
{
char result[2];
#ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA(
id, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
#else
UINT code_page = get_code_page_for_locale_id(id);
if (code_page == 0)
return c;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return c;
WCHAR wide_result;
int b = ::LCMapStringW(
id, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
&wide_c, // source string
1, // number of characters in source string
&wide_result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0)
return c;
#endif
return result[0];
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type id)
{
wchar_t result[2];
int b = ::LCMapStringW(
id, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
return result[0];
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type id)
{
wchar_t result[2];
int b = ::LCMapStringW(
id, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
(wchar_t const*)&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
return result[0];
}
#endif
#endif
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id)
{
char result[2];
#ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA(
id, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
#else
UINT code_page = get_code_page_for_locale_id(id);
if(code_page == 0)
return c;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return c;
WCHAR wide_result;
int b = ::LCMapStringW(
id, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type
&wide_c, // source string
1, // number of characters in source string
&wide_result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0)
return c;
#endif
return result[0];
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type id)
{
wchar_t result[2];
int b = ::LCMapStringW(
id, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
return result[0];
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type id)
{
wchar_t result[2];
int b = ::LCMapStringW(
id, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type
(wchar_t const*)&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if(b == 0)
return c;
return result[0];
}
#endif
#endif
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, char c)
{
WORD mask;
#ifndef BOOST_NO_ANSI_APIS
if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
return true;
#else
UINT code_page = get_code_page_for_locale_id(id);
if(code_page == 0)
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
return true;
#endif
if((m & w32_regex_traits_implementation<char>::mask_word) && (c == '_'))
return true;
return false;
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, wchar_t c)
{
WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base))
return true;
if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_'))
return true;
if((m & w32_regex_traits_implementation<wchar_t>::mask_unicode) && (c > 0xff))
return true;
return false;
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, unsigned short c)
{
WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, (wchar_t const*)&c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base))
return true;
if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_'))
return true;
if((m & w32_regex_traits_implementation<wchar_t>::mask_unicode) && (c > 0xff))
return true;
return false;
}
#endif
#endif
} // re_detail
} // boost
#endif
/*
*
* Copyright (c) 2004
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: wc_regex_traits.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Implements out of line members for c_regex_traits<wchar_t>
*/
#define BOOST_REGEX_SOURCE
#include <boost/detail/workaround.hpp>
#include <memory>
#include <string>
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \
&& !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER))
//
// This is a horrible workaround, but without declaring these symbols extern we get
// duplicate symbol errors when linking if the application is built without
// /Zc:wchar_t
//
#ifdef _CRTIMP2_PURE
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE
#else
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2
#endif
namespace std{
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
template class BOOST_REGEX_STDLIB_DECL allocator<unsigned short>;
template class BOOST_REGEX_STDLIB_DECL _String_val<unsigned short, allocator<unsigned short> >;
template class BOOST_REGEX_STDLIB_DECL basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >;
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*);
#endif
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
}
#endif
#include <boost/regex/config.hpp>
#include <boost/detail/workaround.hpp>
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
#include <boost/regex/v4/c_regex_traits.hpp>
#ifndef BOOST_NO_WREGEX
#include <boost/regex/v4/primary_transform.hpp>
#include <boost/regex/v4/regex_traits_defaults.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::wcstol;
}
#endif
namespace boost{
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2)
{
std::size_t r;
std::size_t s = 10;
std::wstring src(p1, p2);
std::wstring result(s, L' ');
while(s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
{
result.append(r - s + 3, L' ');
s = result.size();
}
result.erase(r);
return result;
}
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2)
{
static wchar_t s_delim;
static const int s_collate_type = ::boost::re_detail::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim);
std::wstring result;
//
// What we do here depends upon the format of the sort key returned by
// sort key returned by this->transform:
//
switch(s_collate_type)
{
case ::boost::re_detail::sort_C:
case ::boost::re_detail::sort_unknown:
// the best we can do is translate to lower case, then get a regular sort key:
{
result.assign(p1, p2);
for(std::wstring::size_type i = 0; i < result.size(); ++i)
result[i] = (std::towlower)(result[i]);
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
break;
}
case ::boost::re_detail::sort_fixed:
{
// get a regular sort key, and then truncate it:
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
result.erase(s_delim);
break;
}
case ::boost::re_detail::sort_delim:
// get a regular sort key, and then truncate everything after the delim:
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
if(result.size() && (result[0] == s_delim))
break;
std::size_t i;
for(i = 0; i < result.size(); ++i)
{
if(result[i] == s_delim)
break;
}
result.erase(i);
break;
}
if(result.empty())
result = std::wstring(1, char(0));
return result;
}
enum
{
char_class_space=1<<0,
char_class_print=1<<1,
char_class_cntrl=1<<2,
char_class_upper=1<<3,
char_class_lower=1<<4,
char_class_alpha=1<<5,
char_class_digit=1<<6,
char_class_punct=1<<7,
char_class_xdigit=1<<8,
char_class_alnum=char_class_alpha|char_class_digit,
char_class_graph=char_class_alnum|char_class_punct,
char_class_blank=1<<9,
char_class_word=1<<10,
char_class_unicode=1<<11
};
c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
{
static const char_class_type masks[] =
{
0,
char_class_alnum,
char_class_alpha,
char_class_blank,
char_class_cntrl,
char_class_digit,
char_class_digit,
char_class_graph,
char_class_lower,
char_class_lower,
char_class_print,
char_class_punct,
char_class_space,
char_class_space,
char_class_upper,
char_class_unicode,
char_class_upper,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
int id = ::boost::re_detail::get_default_class_id(p1, p2);
if(id < 0)
{
std::wstring s(p1, p2);
for(std::wstring::size_type i = 0; i < s.size(); ++i)
s[i] = (std::towlower)(s[i]);
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_ASSERT(id+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
return masks[id+1];
}
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)
{
return
((mask & char_class_space) && (std::iswspace)(c))
|| ((mask & char_class_print) && (std::iswprint)(c))
|| ((mask & char_class_cntrl) && (std::iswcntrl)(c))
|| ((mask & char_class_upper) && (std::iswupper)(c))
|| ((mask & char_class_lower) && (std::iswlower)(c))
|| ((mask & char_class_alpha) && (std::iswalpha)(c))
|| ((mask & char_class_digit) && (std::iswdigit)(c))
|| ((mask & char_class_punct) && (std::iswpunct)(c))
|| ((mask & char_class_xdigit) && (std::iswxdigit)(c))
|| ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::re_detail::is_separator(c))
|| ((mask & char_class_word) && (c == '_'))
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)));
}
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)
{
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
&& !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\
&& !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)
std::string name(p1, p2);
#else
std::string name;
const wchar_t* p0 = p1;
while(p0 != p2)
name.append(1, char(*p0++));
#endif
name = ::boost::re_detail::lookup_default_collate_name(name);
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
&& !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\
&& !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)
if(name.size())
return string_type(name.begin(), name.end());
#else
if(name.size())
{
string_type result;
typedef std::string::const_iterator iter;
iter b = name.begin();
iter e = name.end();
while(b != e)
result.append(1, wchar_t(*b++));
return result;
}
#endif
if(p2 - p1 == 1)
return string_type(1, *p1);
return string_type();
}
int BOOST_REGEX_CALL c_regex_traits<wchar_t>::value(wchar_t c, int radix)
{
#ifdef __BORLANDC__
// workaround for broken wcstol:
if((std::iswxdigit)(c) == 0)
return -1;
#endif
wchar_t b[2] = { c, '\0', };
wchar_t* ep;
int result = std::wcstol(b, &ep, radix);
if(ep == b)
return -1;
return result;
}
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform(const unsigned short* p1, const unsigned short* p2)
{
std::wstring result = c_regex_traits<wchar_t>::transform((const wchar_t*)p1, (const wchar_t*)p2);
return string_type(result.begin(), result.end());
}
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform_primary(const unsigned short* p1, const unsigned short* p2)
{
std::wstring result = c_regex_traits<wchar_t>::transform_primary((const wchar_t*)p1, (const wchar_t*)p2);
return string_type(result.begin(), result.end());
}
c_regex_traits<unsigned short>::char_class_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_classname(const unsigned short* p1, const unsigned short* p2)
{
return c_regex_traits<wchar_t>::lookup_classname((const wchar_t*)p1, (const wchar_t*)p2);
}
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_collatename(const unsigned short* p1, const unsigned short* p2)
{
std::wstring result = c_regex_traits<wchar_t>::lookup_collatename((const wchar_t*)p1, (const wchar_t*)p2);
return string_type(result.begin(), result.end());
}
bool BOOST_REGEX_CALL c_regex_traits<unsigned short>::isctype(unsigned short c, char_class_type m)
{
return c_regex_traits<wchar_t>::isctype(c, m);
}
int BOOST_REGEX_CALL c_regex_traits<unsigned short>::value(unsigned short c, int radix)
{
return c_regex_traits<wchar_t>::value(c, radix);
}
#endif
}
#endif // BOOST_NO_WREGEX
#endif // __BORLANDC__
/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: wide_posix_api.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Implements the wide character POSIX API wrappers.
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex/config.hpp>
#ifndef BOOST_NO_WREGEX
#include <boost/regex.hpp>
#include <boost/cregex.hpp>
#include <cwchar>
#include <cstring>
#include <cstdio>
#if defined(BOOST_NO_STDC_NAMESPACE) || defined(__NetBSD__)
namespace std{
# ifndef BOOST_NO_SWPRINTF
using ::swprintf;
# endif
}
#endif
namespace boost{
namespace {
unsigned int wmagic_value = 28631;
const wchar_t* wnames[] = {
L"REG_NOERROR",
L"REG_NOMATCH",
L"REG_BADPAT",
L"REG_ECOLLATE",
L"REG_ECTYPE",
L"REG_EESCAPE",
L"REG_ESUBREG",
L"REG_EBRACK",
L"REG_EPAREN",
L"REG_EBRACE",
L"REG_BADBR",
L"REG_ERANGE",
L"REG_ESPACE",
L"REG_BADRPT",
L"REG_EEND",
L"REG_ESIZE",
L"REG_ERPAREN",
L"REG_EMPTY",
L"REG_ECOMPLEXITY",
L"REG_ESTACK",
L"REG_E_UNKNOWN",
};
}
typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > c_regex_type;
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
{
if(expression->re_magic != wmagic_value)
{
expression->guts = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
expression->guts = new c_regex_type();
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
return REG_ESPACE;
}
#else
if(0 == expression->guts)
return REG_E_MEMORY;
#endif
}
// set default flags:
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic);
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
// and translate those that are actually set:
if(f & REG_NOCOLLATE)
{
flags |= wregex::nocollate;
#ifndef BOOST_REGEX_V3
flags &= ~wregex::collate;
#endif
}
if(f & REG_NOSUB)
{
//expression->eflags |= match_any;
flags |= wregex::nosubs;
}
if(f & REG_NOSPEC)
flags |= wregex::literal;
if(f & REG_ICASE)
flags |= wregex::icase;
if(f & REG_ESCAPE_IN_LISTS)
flags &= ~wregex::no_escape_in_lists;
if(f & REG_NEWLINE_ALT)
flags |= wregex::newline_alt;
const wchar_t* p2;
if(f & REG_PEND)
p2 = expression->re_endp;
else p2 = ptr + std::wcslen(ptr);
int result;
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
expression->re_magic = wmagic_value;
static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1;
result = static_cast<c_regex_type*>(expression->guts)->error_code();
#ifndef BOOST_NO_EXCEPTIONS
}
catch(const boost::regex_error& be)
{
result = be.code();
}
catch(...)
{
result = REG_E_UNKNOWN;
}
#endif
if(result)
regfreeW(expression);
return result;
}
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* e, wchar_t* buf, regsize_t buf_size)
{
std::size_t result = 0;
if(code & REG_ITOA)
{
code &= ~REG_ITOA;
if((code <= (int)REG_E_UNKNOWN) && (code >= 0))
{
result = std::wcslen(wnames[code]) + 1;
if(buf_size >= result)
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
::wcscpy_s(buf, buf_size, wnames[code]);
#else
std::wcscpy(buf, wnames[code]);
#endif
return result;
}
return result;
}
#if !defined(BOOST_NO_SWPRINTF)
if(code == REG_ATOI)
{
wchar_t localbuf[5];
if(e == 0)
return 0;
for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i)
{
if(std::wcscmp(e->re_endp, wnames[i]) == 0)
{
#if defined(_WIN32_WCE) && !defined(UNDER_CE)
(std::swprintf)(localbuf, L"%d", i);
#else
(std::swprintf)(localbuf, 5, L"%d", i);
#endif
if(std::wcslen(localbuf) < buf_size)
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
::wcscpy_s(buf, buf_size, localbuf);
#else
std::wcscpy(buf, localbuf);
#endif
return std::wcslen(localbuf) + 1;
}
}
#if defined(_WIN32_WCE) && !defined(UNDER_CE)
(std::swprintf)(localbuf, L"%d", 0);
#else
(std::swprintf)(localbuf, 5, L"%d", 0);
#endif
if(std::wcslen(localbuf) < buf_size)
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
::wcscpy_s(buf, buf_size, localbuf);
#else
std::wcscpy(buf, localbuf);
#endif
return std::wcslen(localbuf) + 1;
}
#endif
if(code <= (int)REG_E_UNKNOWN)
{
std::string p;
if((e) && (e->re_magic == wmagic_value))
p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
else
{
p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
}
std::size_t len = p.size();
if(len < buf_size)
{
re_detail::copy(p.c_str(), p.c_str() + p.size() + 1, buf);
}
return len + 1;
}
if(buf_size)
*buf = 0;
return 0;
}
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, const wchar_t* buf, regsize_t n, regmatch_t* array, int eflags)
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4267)
#endif
bool result = false;
match_flag_type flags = match_default | expression->eflags;
const wchar_t* end;
const wchar_t* start;
wcmatch m;
if(eflags & REG_NOTBOL)
flags |= match_not_bol;
if(eflags & REG_NOTEOL)
flags |= match_not_eol;
if(eflags & REG_STARTEND)
{
start = buf + array[0].rm_so;
end = buf + array[0].rm_eo;
}
else
{
start = buf;
end = buf + std::wcslen(buf);
}
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
if(expression->re_magic == wmagic_value)
{
result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags);
}
else
return result;
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
return REG_E_UNKNOWN;
}
#endif
if(result)
{
// extract what matched:
std::size_t i;
for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i)
{
array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf);
array[i].rm_eo = (m[i].matched == false) ? -1 : (m[i].second - buf);
}
// and set anything else to -1:
for(i = expression->re_nsub + 1; i < n; ++i)
{
array[i].rm_so = -1;
array[i].rm_eo = -1;
}
return 0;
}
return REG_NOMATCH;
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
}
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression)
{
if(expression->re_magic == wmagic_value)
{
delete static_cast<c_regex_type*>(expression->guts);
}
expression->re_magic = 0;
}
} // namespace boost;
#endif
/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: winstances.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: regex wide character template instances.
*/
#define BOOST_REGEX_SOURCE
#include <boost/regex/config.hpp>
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)
#define BOOST_REGEX_WIDE_INSTANTIATE
#ifdef __BORLANDC__
#pragma hrdstop
#endif
#include <boost/regex.hpp>
#endif
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="boost_regexp"
ProjectGUID="{52B37168-F0D9-403D-ADD4-5C07B4602643}"
RootNamespace="boost_regexp"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\libboost_regex-vc80-mt-gd-1_38.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\libboost_regex-vc80-mt-1_38.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\Source\c_regex_traits.cpp"
>
</File>
<File
RelativePath=".\Source\cpp_regex_traits.cpp"
>
</File>
<File
RelativePath=".\Source\cregex.cpp"
>
</File>
<File
RelativePath=".\Source\fileiter.cpp"
>
</File>
<File
RelativePath=".\Source\icu.cpp"
>
</File>
<File
RelativePath=".\Source\instances.cpp"
>
</File>
<File
RelativePath=".\Source\posix_api.cpp"
>
</File>
<File
RelativePath=".\Source\regex.cpp"
>
</File>
<File
RelativePath=".\Source\regex_debug.cpp"
>
</File>
<File
RelativePath=".\Source\regex_raw_buffer.cpp"
>
</File>
<File
RelativePath=".\Source\regex_traits_defaults.cpp"
>
</File>
<File
RelativePath=".\Source\static_mutex.cpp"
>
</File>
<File
RelativePath=".\Source\usinstances.cpp"
>
</File>
<File
RelativePath=".\Source\w32_regex_traits.cpp"
>
</File>
<File
RelativePath=".\Source\wc_regex_traits.cpp"
>
</File>
<File
RelativePath=".\Source\wide_posix_api.cpp"
>
</File>
<File
RelativePath=".\Source\winstances.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
// stdafx.cpp : source file that includes just the standard includes
// AVSOfficeEpubFile.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define _CRT_SECURE_NO_DEPRECATE
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define USE_ATL_CSTRING
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
#import "../../../Redist/AVSOfficeStudio/AVSOfficeDocxRenderer.dll" raw_interfaces_only rename_namespace("DocxRenderer")
#import "../../../Redist/AVSOfficeStudio/AVSOfficeUtils.dll" raw_interfaces_only rename_namespace("OfficeUtils")
#import "../../../Redist/AVSOfficeStudio/AVSOfficeHtmlFile.dll" raw_interfaces_only rename_namespace("OfficeHtmlFile")
#import "../../../Redist/AVSGraphics.dll" raw_interfaces_only rename_namespace("AVSGraphics")
#import "../../../Redist/AVSImageFile3.dll" raw_interfaces_only rename_namespace("ImageFile")
#import "../../../Redist/AVSMediaCore3.dll" rename_namespace("AVSMediaCore3"), exclude("tagRECT")
#pragma once
//1
//0
//0
//18
#define INTVER 1,0,0,18
#define STRVER "1,0,0,18\0"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment