# HG changeset patch # User jjkang # Date 1277460694 -28800 # Node ID 6d08f4a05d939410b0a56c49ba640b59e48512ff # Parent fa7a3cc6effde7d2f40ed082e053c0cbbace44b6 add deprecated files diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/bin2coff/bin2coff.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/bin2coff.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,149 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Add a simple coff header to a binary file +// optionally strip off the first 256 bytes +// This is primarily for generating an image +// file that can be downloaded via the ether +// to cogent using the SmartFirmWare boot rom +// +// + +#include +#include +#include +#include +#include +#include + +// little error functionet +void error(const char* p) +{ + fprintf(stderr, "%s\n", p); + exit(1); +} + +// little usage functionet +void usage(const char* p) +{ + fprintf(stderr, "%s\n", p); + exit(EXIT_FAILURE); +} + + +int main(int argc, char* argv[]) +{ + // check for usage + if (argc < 3 || argc > 4) + { + usage("Usage: bin2coff infile outfile nostrip\nOption nostrip: don't strip off the first 256 bytes"); + } + + // make sure we are not operating on only one file + if (!strcmp(argv[1], argv[2])) + { + usage("Usage: bin2coff must specify different input and output files"); + } + + // try to open the input file + FILE *pInFile; + if((pInFile = fopen(argv[1], "rb" )) == NULL) + { + error("Cannot open input file"); + } + + // open output file + FILE *pOutFile; + if((pOutFile = fopen(argv[2], "wb") ) == NULL) + { + error("Cannot open output file"); + } + + // strip the 256 long header? + // ok, so it's simple, so what + bool stripheader = (argc == 3); + + // how big is the input file + struct stat filelength; + stat(argv[1], &filelength); + unsigned long fsize = filelength.st_size; + if (stripheader) + { + fsize -= 256; + } + + // write out the coff header to the new file + // somewhere to put a simple coff header + unsigned char coffhead[0x58] = {0}; // zero all the elements + + // fill in the constant bits + // this is supposed to be simple, remember + coffhead[1] = 0x0a; + coffhead[2] = 0x01; + coffhead[0x10] = 0x1c; + coffhead[0x12] = 0x0f; + coffhead[0x13] = 0xa1; + coffhead[0x14] = 0x0b; + coffhead[0x15] = 0x01; + coffhead[0x26] = 0x40; // entry point 0x00400000 + coffhead[0x2a] = 0x40; + coffhead[0x30] = 0x2e; + coffhead[0x31] = 0x74; + coffhead[0x32] = 0x65; + coffhead[0x33] = 0x78; + coffhead[0x34] = 0x74; + coffhead[0x3a] = 0x40; + coffhead[0x3e] = 0x40; + coffhead[0x44] = 0x58; + coffhead[0x54] = 0x20; + + // now fill in the text segment size + *(int *) (&coffhead[0x18]) = fsize; + *(int *) (&coffhead[0x40]) = fsize; + + // write out the new file + // first the header + int numwritten=0; + numwritten = fwrite(coffhead, sizeof(char), 0x58, pOutFile); + if (numwritten < 0x58) + { + error("The number of items written is less than 0x58"); + } + + // now the rest of the file + if (stripheader) + { + fpos_t filePositionIndicator = 0x100; + if (fsetpos(pInFile, &filePositionIndicator) !=0) + { + error("The file is not accessible "); + } + } + + static const int buffsize = 1024; + unsigned char fbuff[buffsize]; + while (!feof(pInFile)) + { + int nread = fread(fbuff,sizeof(unsigned char), sizeof(fbuff), pInFile); + int nwritten = fwrite(fbuff, sizeof(unsigned char), nread, pOutFile); + if (nwritten < nread) + { + error("The number of items written is less than number of items read"); + } + } + + fclose(pOutFile); + fclose(pInFile); + + return 0; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/bin2coff/group/bin2coff.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/group/bin2coff.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,25 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET bin2coff.exe +TARGETTYPE exe +SOURCEPATH ..\..\bin2coff +SOURCE bin2coff.cpp + +OPTION GCC -O2 + + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/bin2coff/group/bin2coff.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/group/bin2coff.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,10 @@ +component dev_build_bintools_bin2coff + +source \src\tools\build\bintools\bin2coff +binary \src\tools\build\bintools\bin2coff\group all +exports \src\tools\build\bintools\bin2coff\group + +notes_source \component_defs\release.src + +ipr T + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/bin2coff/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +bin2coff.mmp + +PRJ_TESTMMPFILES + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/evalid/evalid_test_notes.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/evalid/evalid_test_notes.txt Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,63 @@ +evalid_test_notes.txt + +testfiles.zip contains two matching trees, each divided into +three sub-trees: + +left\ok\... +left\missing\... +left\fail\... + +right\ok\... +right\missing\... +right\fail\... + +Running "evalid left\ok right\ok" should produce 100% OK. +The "ok" trees contain at least one example of each type of file, +and should grow to illustrate any new form of non-significant +difference. + +Running "evalid left\missing right\missing" should report +only failures in the shape of the tree. + +Running "evalid left\fail right\fail" should report differences +in all pairs of files. +The "fail" trees should grow whenever a new form of significant +difference is found, so that we can avoid making EVALID too +tolerant. + + +------------- +Significant Difference test cases + +Most examples are synthetic test cases obtained by copying one or more pairs from +the ok tree into the fail tree, then modifying the right\fail file to introduce +a specific type of difference. The files are usually renamed to indicate the +nature of the difference. Using the pair of files from the ok tree means that the +files have a collection of non-significant differences in addition to the extra +difference introduced. + +Other cases are copies of real examples which showed a signficant difference. + +unknown_format\data\BuildInfo.txt + +- simple example of a text file with different contents + +unknown_format\ksa\layout.bin + +- simple example of a binary file with different contents + +SIS_file\release\armi\urel\gdbstub.sis + +- stub SIS file, currently not correctly recognised? + +Intel_DLL\wins\udeb\C32.dll + +- ??? not recorded why this is different yet + +Intel_DLL\wins\urel\BAFL.dll + +- Compiler generated thunks are laid out in a different order. + This is a known problem with Developer Studio which is triggered + by building the source from a different location. + + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/evalid/left_right.reference.log --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/evalid/left_right.reference.log Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,98 @@ +PROBLEM: Directory right\missing\leftonlydir does not exist +OK: left\ok\ARM_library\arm4\udeb\EEXE.LIB and right\ok\ARM_library\arm4\udeb\EEXE.LIB (ARM library) +OK: left\ok\ARM_library\arm4\urel\ALARMSHARED.LIB and right\ok\ARM_library\arm4\urel\ALARMSHARED.LIB (ARM library) +OK: left\ok\ARM_library\arm4\urel\EEXE.LIB and right\ok\ARM_library\arm4\urel\EEXE.LIB (ARM library) +OK: left\ok\ARM_library\thumb\udeb\EEXE.LIB and right\ok\ARM_library\thumb\udeb\EEXE.LIB (ARM library) +OK: left\ok\ARM_library\thumb\urel\ALARMSHARED.LIB and right\ok\ARM_library\thumb\urel\ALARMSHARED.LIB (ARM library) +OK: left\ok\ARM_library\thumb\urel\EEXE.LIB and right\ok\ARM_library\thumb\urel\EEXE.LIB (ARM library) +OK: left\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE and right\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE and right\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE and right\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE and right\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL and right\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL and right\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL and right\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL and right\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE and right\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE and right\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE and right\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE and right\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\identical\console.ini and right\ok\identical\console.ini (identical) +OK: left\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL and right\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL and right\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL and right\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL and right\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_exe\wins\udeb\E32STRT.EXE and right\ok\Intel_exe\wins\udeb\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_exe\wins\urel\E32STRT.EXE and right\ok\Intel_exe\wins\urel\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_exe\winscw\udeb\E32STRT.EXE and right\ok\Intel_exe\winscw\udeb\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_exe\winscw\urel\E32STRT.EXE and right\ok\Intel_exe\winscw\urel\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_library\wins\udeb\ALARMSHARED.LIB and right\ok\Intel_library\wins\udeb\ALARMSHARED.LIB (Intel library) +OK: left\ok\Intel_library\wins\udeb\EEXE.LIB and right\ok\Intel_library\wins\udeb\EEXE.LIB (Intel library) +OK: left\ok\Intel_library\wins\urel\EEXE.LIB and right\ok\Intel_library\wins\urel\EEXE.LIB (Intel library) +OK: left\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB and right\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB (Intel library) +OK: left\ok\Intel_library\winscw\udeb\EEXE.LIB and right\ok\Intel_library\winscw\udeb\EEXE.LIB (Intel library) +OK: left\ok\Intel_library\winscw\urel\EEXE.LIB and right\ok\Intel_library\winscw\urel\EEXE.LIB (Intel library) +OK: left\ok\Intel_object\FNTTRAN.exp and right\ok\Intel_object\FNTTRAN.exp (Intel object) +OK: left\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map and right\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\arm4\udeb\E32STRT.EXE.map and right\ok\MAP_file\arm4\udeb\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map and right\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\arm4\urel\E32STRT.EXE.map and right\ok\MAP_file\arm4\urel\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map and right\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\thumb\udeb\E32STRT.EXE.map and right\ok\MAP_file\thumb\udeb\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map and right\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\thumb\urel\E32STRT.EXE.map and right\ok\MAP_file\thumb\urel\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map and right\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map (identical) +OK: left\ok\MAP_file\winscw\urel\E32STRT.EXE.map and right\ok\MAP_file\winscw\urel\E32STRT.EXE.map (identical) +OK: left\ok\Preprocessed_text\IRCOMM.rpp and right\ok\Preprocessed_text\IRCOMM.rpp (Preprocessed text) +OK: left\ok\SGML_file\allclasses-frame.html and right\ok\SGML_file\allclasses-frame.html (SGML file) +OK: left\ok\ZIP_file\aifapp_ResourceBundles.jar and right\ok\ZIP_file\aifapp_ResourceBundles.jar (ZIP file) + +Results of evalid left right + +1 missing files + +MISSING: right\missing\leftonlyfile.txt + +30 failed comparisons + +FAILED: left\fail\ARM_library\ARM4_symbol.lib and right\fail\ARM_library\ARM4_symbol.lib (ARM library) +FAILED: left\fail\ARM_library\Thumb_symbol.lib and right\fail\ARM_library\Thumb_symbol.lib (ARM library) +FAILED: left\fail\Intel_DLL\wins\udeb\C32.DLL and right\fail\Intel_DLL\wins\udeb\C32.DLL (Intel DLL) +FAILED: left\fail\Intel_DLL\wins\urel\BAFL.DLL and right\fail\Intel_DLL\wins\urel\BAFL.DLL (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_data.dll and right\fail\Intel_DLL\winscw_data.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_export.dll and right\fail\Intel_DLL\winscw_export.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_import.dll and right\fail\Intel_DLL\winscw_import.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_rdata.dll and right\fail\Intel_DLL\winscw_rdata.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_text.dll and right\fail\Intel_DLL\winscw_text.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_uid.dll and right\fail\Intel_DLL\winscw_uid.dll (Intel DLL) +FAILED: left\fail\Intel_EXE\winscw_data.exe and right\fail\Intel_EXE\winscw_data.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_import.exe and right\fail\Intel_EXE\winscw_import.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_rdata.exe and right\fail\Intel_EXE\winscw_rdata.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_text.exe and right\fail\Intel_EXE\winscw_text.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_uid.exe and right\fail\Intel_EXE\winscw_uid.exe (Intel EXE) +FAILED: left\fail\Intel_library\symbol.lib and right\fail\Intel_library\symbol.lib (Intel library) +FAILED: left\fail\Intel_object\symbol.obj and right\fail\Intel_object\symbol.obj (Intel object) +FAILED: left\fail\MAP_file\offset.map and right\fail\MAP_file\offset.map (MAP file) +FAILED: left\fail\MAP_file\size.map and right\fail\MAP_file\size.map (MAP file) +FAILED: left\fail\MAP_file\symbol.map and right\fail\MAP_file\symbol.map (MAP file) +FAILED: left\fail\MAP_file\winscw_offset.map and right\fail\MAP_file\winscw_offset.map (MAP file) +FAILED: left\fail\MAP_file\winscw_symbol.map and right\fail\MAP_file\winscw_symbol.map (MAP file) +FAILED: left\fail\Preprocessed_text\content.rpp and right\fail\Preprocessed_text\content.rpp (Preprocessed text) +FAILED: left\fail\SGML_file\content.html and right\fail\SGML_file\content.html (SGML file) +FAILED: left\fail\SIS_file\release\armi\urel\gdbstub.sis and right\fail\SIS_file\release\armi\urel\gdbstub.sis (SIS file) +FAILED: left\fail\unknown_format\data\BuildInfo.txt and right\fail\unknown_format\data\BuildInfo.txt (unknown format) +FAILED: left\fail\unknown_format\ksa\layout.bin and right\fail\unknown_format\ksa\layout.bin (unknown format) +FAILED: left\fail\ZIP_file\content.zip and right\fail\ZIP_file\content.zip (ZIP file) +FAILED: left\fail\ZIP_file\order.zip and right\fail\ZIP_file\order.zip (ZIP file) +FAILED: left\fail\ZIP_file\size.zip and right\fail\ZIP_file\size.zip (ZIP file) + +---------------- +16:03 06/10/2003 +evalid left right +Failed 32 of 83 comparisons +---------------- + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/evalid/right_left.reference.log --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/evalid/right_left.reference.log Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,98 @@ +PROBLEM: Directory left\missing\rightonlydir does not exist +OK: right\ok\ARM_library\arm4\udeb\EEXE.LIB and left\ok\ARM_library\arm4\udeb\EEXE.LIB (ARM library) +OK: right\ok\ARM_library\arm4\urel\ALARMSHARED.LIB and left\ok\ARM_library\arm4\urel\ALARMSHARED.LIB (ARM library) +OK: right\ok\ARM_library\arm4\urel\EEXE.LIB and left\ok\ARM_library\arm4\urel\EEXE.LIB (ARM library) +OK: right\ok\ARM_library\thumb\udeb\EEXE.LIB and left\ok\ARM_library\thumb\udeb\EEXE.LIB (ARM library) +OK: right\ok\ARM_library\thumb\urel\ALARMSHARED.LIB and left\ok\ARM_library\thumb\urel\ALARMSHARED.LIB (ARM library) +OK: right\ok\ARM_library\thumb\urel\EEXE.LIB and left\ok\ARM_library\thumb\urel\EEXE.LIB (ARM library) +OK: right\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE and left\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE and left\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE and left\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE and left\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL and left\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL and left\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL and left\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL and left\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE and left\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE and left\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE and left\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE and left\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\identical\console.ini and left\ok\identical\console.ini (identical) +OK: right\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL and left\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL and left\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL and left\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL and left\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_EXE\wins\udeb\E32STRT.EXE and left\ok\Intel_EXE\wins\udeb\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_EXE\wins\urel\E32STRT.EXE and left\ok\Intel_EXE\wins\urel\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_EXE\winscw\udeb\E32STRT.EXE and left\ok\Intel_EXE\winscw\udeb\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_EXE\winscw\urel\E32STRT.EXE and left\ok\Intel_EXE\winscw\urel\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_library\wins\udeb\ALARMSHARED.LIB and left\ok\Intel_library\wins\udeb\ALARMSHARED.LIB (Intel library) +OK: right\ok\Intel_library\wins\udeb\EEXE.LIB and left\ok\Intel_library\wins\udeb\EEXE.LIB (Intel library) +OK: right\ok\Intel_library\wins\urel\EEXE.LIB and left\ok\Intel_library\wins\urel\EEXE.LIB (Intel library) +OK: right\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB and left\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB (Intel library) +OK: right\ok\Intel_library\winscw\udeb\EEXE.LIB and left\ok\Intel_library\winscw\udeb\EEXE.LIB (Intel library) +OK: right\ok\Intel_library\winscw\urel\EEXE.LIB and left\ok\Intel_library\winscw\urel\EEXE.LIB (Intel library) +OK: right\ok\Intel_object\FNTTRAN.exp and left\ok\Intel_object\FNTTRAN.exp (Intel object) +OK: right\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map and left\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\arm4\udeb\E32STRT.EXE.map and left\ok\MAP_file\arm4\udeb\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map and left\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\arm4\urel\E32STRT.EXE.map and left\ok\MAP_file\arm4\urel\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map and left\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\thumb\udeb\E32STRT.EXE.map and left\ok\MAP_file\thumb\udeb\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map and left\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\thumb\urel\E32STRT.EXE.map and left\ok\MAP_file\thumb\urel\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map and left\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map (identical) +OK: right\ok\MAP_file\winscw\urel\E32STRT.EXE.map and left\ok\MAP_file\winscw\urel\E32STRT.EXE.map (identical) +OK: right\ok\Preprocessed_text\IRCOMM.rpp and left\ok\Preprocessed_text\IRCOMM.rpp (Preprocessed text) +OK: right\ok\SGML_file\allclasses-frame.html and left\ok\SGML_file\allclasses-frame.html (SGML file) +OK: right\ok\ZIP_file\aifapp_ResourceBundles.jar and left\ok\ZIP_file\aifapp_ResourceBundles.jar (ZIP file) + +Results of evalid right left + +1 missing files + +MISSING: left\missing\rightonlyfile.txt + +30 failed comparisons + +FAILED: right\fail\ARM_library\ARM4_symbol.lib and left\fail\ARM_library\ARM4_symbol.lib (ARM library) +FAILED: right\fail\ARM_library\Thumb_symbol.lib and left\fail\ARM_library\Thumb_symbol.lib (ARM library) +FAILED: right\fail\Intel_DLL\wins\udeb\C32.DLL and left\fail\Intel_DLL\wins\udeb\C32.DLL (Intel DLL) +FAILED: right\fail\Intel_DLL\wins\urel\BAFL.DLL and left\fail\Intel_DLL\wins\urel\BAFL.DLL (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_data.dll and left\fail\Intel_DLL\winscw_data.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_export.dll and left\fail\Intel_DLL\winscw_export.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_import.dll and left\fail\Intel_DLL\winscw_import.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_rdata.dll and left\fail\Intel_DLL\winscw_rdata.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_text.dll and left\fail\Intel_DLL\winscw_text.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_uid.dll and left\fail\Intel_DLL\winscw_uid.dll (Intel DLL) +FAILED: right\fail\Intel_EXE\winscw_data.exe and left\fail\Intel_EXE\winscw_data.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_import.exe and left\fail\Intel_EXE\winscw_import.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_rdata.exe and left\fail\Intel_EXE\winscw_rdata.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_text.exe and left\fail\Intel_EXE\winscw_text.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_uid.exe and left\fail\Intel_EXE\winscw_uid.exe (Intel EXE) +FAILED: right\fail\Intel_library\symbol.lib and left\fail\Intel_library\symbol.lib (Intel library) +FAILED: right\fail\Intel_object\symbol.obj and left\fail\Intel_object\symbol.obj (Intel object) +FAILED: right\fail\MAP_file\offset.map and left\fail\MAP_file\offset.map (MAP file) +FAILED: right\fail\MAP_file\size.map and left\fail\MAP_file\size.map (MAP file) +FAILED: right\fail\MAP_file\symbol.map and left\fail\MAP_file\symbol.map (MAP file) +FAILED: right\fail\MAP_file\winscw_offset.map and left\fail\MAP_file\winscw_offset.map (MAP file) +FAILED: right\fail\MAP_file\winscw_symbol.map and left\fail\MAP_file\winscw_symbol.map (MAP file) +FAILED: right\fail\Preprocessed_text\content.rpp and left\fail\Preprocessed_text\content.rpp (Preprocessed text) +FAILED: right\fail\SGML_file\content.html and left\fail\SGML_file\content.html (SGML file) +FAILED: right\fail\SIS_file\release\armi\urel\gdbstub.sis and left\fail\SIS_file\release\armi\urel\gdbstub.sis (SIS file) +FAILED: right\fail\unknown_format\data\BuildInfo.txt and left\fail\unknown_format\data\BuildInfo.txt (unknown format) +FAILED: right\fail\unknown_format\ksa\layout.bin and left\fail\unknown_format\ksa\layout.bin (unknown format) +FAILED: right\fail\ZIP_file\content.zip and left\fail\ZIP_file\content.zip (ZIP file) +FAILED: right\fail\ZIP_file\order.zip and left\fail\ZIP_file\order.zip (ZIP file) +FAILED: right\fail\ZIP_file\size.zip and left\fail\ZIP_file\size.zip (ZIP file) + +---------------- +16:03 06/10/2003 +evalid right left +Failed 32 of 83 comparisons +---------------- + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/evalid/testfiles.zip Binary file bintools/evalid/testfiles.zip has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,33 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +pe_dump.mmp +pediff.mmp +petran.mmp + +PRJ_TESTMMPFILES + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/group/pe_dump.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/pe_dump.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,25 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +TARGET pe_dump.exe +TARGETTYPE exe +SOURCEPATH ../pe_dump +SOURCE pe_dump.cpp + +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +OPTION MSVC /GX +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/group/pediff.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/pediff.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,38 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +target pediff.exe +targettype exe +sourcepath ../../../imgtools/imglib/e32uid +source e32uid.cpp +sourcepath ../../../imgtools/imglib/host +source h_mem.cpp h_utl.cpp +sourcepath ../pediff +source pediff.cpp +sourcepath ../../../imgtools/imglib/e32image +source e32image.cpp +sourcepath ../../../imgtools/imglib/e32image/deflate +source decode.cpp encode.cpp deflate.cpp inflate.cpp panic.cpp +source compress.cpp +sourcepath ../../../imgtools/imglib/compress +source pagedcompress.cpp byte_pair.cpp + +userinclude ../../../imgtools/imglib/compress +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/group/petools.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/petools.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_bintools_petools + +source /src/tools/build/bintools/petools +exports /src/tools/build/bintools/petools/group +binary /src/tools/build/bintools/petools/group all + +notes_source \component_defs\release.src + +ipr T diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/group/petran.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/petran.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,39 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +macro __SUPPORT_PE_FILES__ + +target petran.exe +targettype exe +sourcepath ../../../imgtools/imglib/e32uid +source e32uid.cpp +sourcepath ../../../imgtools/imglib/host +source h_file.cpp h_mem.cpp h_utl.cpp +sourcepath ../pefile +source pe_file.cpp pe_imp.cpp pe_reloc.cpp pe_tran.cpp pe_utl.cpp +sourcepath ../../../imgtools/imglib/e32image +source e32image.cpp tr_main.cpp imgdump.cpp +sourcepath ../../../imgtools/imglib/e32image/deflate +source decode.cpp encode.cpp deflate.cpp inflate.cpp panic.cpp compress.cpp +sourcepath ../../../imgtools/imglib/compress +source byte_pair.cpp pagedCompress.cpp + +userinclude ../../../imgtools/imglib/compress +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../compress + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/pe_dump/pe_dump.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pe_dump/pe_dump.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,460 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include + +#include "h_ver.h" +#include "pe_defs.h" +#include + +#if defined(__MSVCDOTNET__) || defined (__TOOLS2__) + #include + #include + #include + #include + using namespace std; +#else //__MSVCDOTNET__ + #include + #include + #include + #include +#endif //__MSVCDOTNET__ + +#include + +const int KDiffIdentical=0; +const int KDiffDifferent=2; + +class PeFile + { +public: + PeFile(); + ~PeFile(); + int Open(char *aFileName); + void Close(); + PIMAGE_DOS_HEADER DosHeader(); + PIMAGE_NT_HEADERS Headers(); + PIMAGE_SECTION_HEADER SectionHeaders(); + char *LoadSection(PIMAGE_SECTION_HEADER aSectionHeader); + int NumberOfSections(); + char *LoadExtraData(int aOffsetToExtraData, TUint aFileSize); + + int Errno(); // Should be invoked only if previous call of PeFile's + // member function returns incorrectly + int Errno(int aErrno); // Assign error number for special purpose. +public: + fstream iFile; + PIMAGE_DOS_HEADER iDosHeader; + PIMAGE_NT_HEADERS iHeaders; + PIMAGE_SECTION_HEADER iSectionHeaders; +private: + int errnumber; + }; + +PeFile::PeFile() + //: iDosHeader(NULL), iHeaders(NULL), iSectionHeaders(NULL), errno(KErrNone) + //commented out as SBSv2 reports error: anachronistic old-style base class initializer +{ + iDosHeader = NULL ; + iHeaders = NULL ; + iSectionHeaders = NULL ; + errnumber = KErrNone; + + return; +} + +PeFile::~PeFile() + { + delete iDosHeader; + delete iHeaders; + delete [] iSectionHeaders; + } + +int PeFile::Open(char *aFileName) +{ +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + iFile.open(aFileName, ios::in | ios::binary); +#else //!__MSVCDOTNET__ + iFile.open(aFileName, ios::in | ios::binary | ios::nocreate); +#endif //__MSVCDOTNET__ + if (!iFile.is_open()) + { + errnumber = KErrNotFound; + return KErrNotFound; + } + return KErrNone; +} + +void PeFile::Close() + { + iFile.close(); + } + + +PIMAGE_DOS_HEADER PeFile::DosHeader() + { + if (iDosHeader) + return iDosHeader; + + iDosHeader=new IMAGE_DOS_HEADER; + if (!iDosHeader) { + errnumber = KErrNoMemory; + return NULL; + } + + memset(iDosHeader, 0, sizeof(IMAGE_DOS_HEADER)); + + iFile.seekg(0); + iFile.read((char *)iDosHeader, sizeof(IMAGE_DOS_HEADER)); + if (iDosHeader->e_magic!=IMAGE_DOS_SIGNATURE) { + errnumber = KErrCorrupt; + return NULL; + } + return iDosHeader; + } + +PIMAGE_NT_HEADERS PeFile::Headers() + { + if (iHeaders) + return iHeaders; + PIMAGE_DOS_HEADER d=DosHeader(); + if (d==NULL) + return NULL; + + iHeaders=new IMAGE_NT_HEADERS; + if (!iHeaders) { + errnumber = KErrNoMemory; + return NULL; + } + + memset(iHeaders, 0, sizeof(IMAGE_NT_HEADERS)); + + iFile.seekg(d->e_lfanew); + if (iFile.eof()) { + errnumber = KErrCorrupt; // File size is too small. + return NULL; + } + + iFile.read((char *)iHeaders, sizeof(IMAGE_NT_HEADERS)); + return iHeaders; + } + +PIMAGE_SECTION_HEADER PeFile::SectionHeaders() + { + if (iSectionHeaders) + return iSectionHeaders; + PIMAGE_NT_HEADERS h=Headers(); + if (h==NULL) { + errnumber = KErrNoMemory; + return NULL; + } + + int numSec; + if ((numSec = NumberOfSections()) < 0) { + return NULL; + } + else { + iSectionHeaders=new IMAGE_SECTION_HEADER [numSec]; + if (!iSectionHeaders) { + errnumber = KErrNoMemory; + return NULL; + } + } + + iFile.seekg(DosHeader()->e_lfanew+sizeof(IMAGE_NT_HEADERS)); + int i=sizeof(IMAGE_SECTION_HEADER)*numSec; + iFile.read((char *)iSectionHeaders, i); + if (iFile.gcount() != i) { // The size of header is incorrect. + printf("Error: Cannot load section headers in offset: 0x%x \n", + (int) (DosHeader()->e_lfanew + sizeof(IMAGE_NT_HEADERS))); + errnumber = KErrCorrupt; + return NULL; + } + + return iSectionHeaders; + } + +int PeFile::NumberOfSections() + { + if (Headers()) + return iHeaders->FileHeader.NumberOfSections; + else + return -1; + } + +char *PeFile::LoadSection(PIMAGE_SECTION_HEADER h) + { + char *section=new char [h->SizeOfRawData]; + if (section==NULL){ + errnumber = KErrNoMemory; + return NULL; + } + + try + { + memset(section, 0, h->SizeOfRawData); + } + catch(...) + { + } + + iFile.seekg(h->PointerToRawData); + iFile.read(section, h->SizeOfRawData); + + // Guarantee we have loaded the section correctly. + unsigned int actNum = iFile.gcount(); + if (actNum != h->SizeOfRawData) { // The size of section is incorrect. + printf("Error: Cannot load section in offset: 0x%x \n", + (int)h->PointerToRawData); + errnumber = KErrCorrupt; + return NULL; + } + + return section; + } + +char* PeFile::LoadExtraData(int aOffset, TUint aFileSize) + { + TUint sizeOfExtraData = 0; + if(aFileSize >= (TUint)aOffset) + sizeOfExtraData=aFileSize-aOffset; + if(sizeOfExtraData>0){ + char* buffer=new char [sizeOfExtraData]; + if (!buffer) { + errnumber = KErrNoMemory; + return NULL; + } + + memset(buffer, 0, sizeOfExtraData); + iFile.seekg(aOffset); + iFile.read(buffer, sizeOfExtraData); // Should be OK if the file size is correct. + + // Guarantee we have loaded the data correctly. + unsigned int actNum = iFile.gcount(); + if (actNum != sizeOfExtraData){ // Shouldn't be here is the file size is correct. + printf("Error: Cannot load extra section in offset: 0x%x \n", aOffset); + errnumber = KErrCorrupt; + return NULL; + } + + return buffer; + } + else { + errnumber = KErrCorrupt; + return NULL; + } + +} + +int PeFile::Errno() { + return errnumber; +} + +int PeFile::Errno(int aErrno) { + return (errnumber = aErrno); +} + + +void dump(TUint *aData, TInt aLength) + { + TUint *p=aData; + TInt i=0; + char line[256]; + unsigned char *cp=(unsigned char*)aData; + TInt j=0; + memset(line,' ',sizeof(line)); + while (i127) + { + c = '.'; + } + *linep++ = c; + } + } + *linep='\0'; + printf("%s\n", line+(ccount*9)); + } + } + +int pecmp(char *aFileName) + { + + PeFile peFile; + if (peFile.Open(aFileName)!=KErrNone) + { + cout << "Cannot open file '"<FileHeader.TimeDateStamp=0; + headers->OptionalHeader.CheckSum = 0; // Fix for TOOLS2 + + printf("NT Headers:\n"); + dump((TUint*)headers, sizeof(IMAGE_NT_HEADERS)); + + int numberofsections=peFile.NumberOfSections(); + if (numberofsections==-1) + { + cout << "Not a valid PE file.\n"; + return KErrGeneral; + } + + PIMAGE_SECTION_HEADER sectionheaders=peFile.SectionHeaders(); + + printf("Section Headers:\n"); + dump((TUint*)sectionheaders, sizeof(IMAGE_SECTION_HEADER)*peFile.NumberOfSections()); + + TUint exportDirVa=headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + TUint debugDirVa=headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; + int SizeOfHeaders=headers->OptionalHeader.SizeOfHeaders; + int offsetToExtraData=0; + int i; + for (i=0; iSizeOfRawData == 0) + { + continue; + } + char *section=peFile.LoadSection(h); + if (section==NULL) + { + switch(peFile.Errno()){ + case KErrNoMemory: + cout << "Error: Out of memory\n"; + return KErrNoMemory; + default: + cout << "Not a valid PE file.\n"; + } + return KErrGeneral; + } + char name[9]; + for (int j=0; j<9; j++) + name[j]=h->Name[j]; + name[8]=0; + + if (debugDirVa>=h->VirtualAddress && debugDirVaVirtualAddress+h->SizeOfRawData) + { + // Debug data in this section + PIMAGE_DEBUG_DIRECTORY dd=(PIMAGE_DEBUG_DIRECTORY)(section+debugDirVa-h->VirtualAddress); + TInt debugDirSize=headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size; + while (debugDirSize>0) + { + dd->TimeDateStamp=0; + // size & location in file of debug data is not significant + // unless it's also mapped (AddressOfRawData != 0). If that's + // true, then the data will be visible in one of the sections + // anyway... + dd->SizeOfData=0; + dd->PointerToRawData=0; + dd++; + debugDirSize-=sizeof(IMAGE_DEBUG_DIRECTORY); + } + } + if (exportDirVa>=h->VirtualAddress && exportDirVaVirtualAddress+h->SizeOfRawData) + { + // Export directory in this section + PIMAGE_EXPORT_DIRECTORY ed=(PIMAGE_EXPORT_DIRECTORY)(section+exportDirVa-h->VirtualAddress); + ed->TimeDateStamp=0; + } + if (strcmp(".rsrc",name)==0) + { + int *t=(int *)(section+4); + *t=0; + } + + offsetToExtraData=offsetToExtraData+h->SizeOfRawData; + printf("Raw data:\n"); + dump((TUint*)section, h->SizeOfRawData); + + delete section; + } + struct stat buf; + stat (aFileName,&buf); + TUint fileSize=buf.st_size; + offsetToExtraData=offsetToExtraData+SizeOfHeaders; + TUint sizeOfExtraData = 0; + if(buf.st_size >= offsetToExtraData) + sizeOfExtraData=buf.st_size-offsetToExtraData; + char* extraData=peFile.LoadExtraData(offsetToExtraData, fileSize); + if(sizeOfExtraData>0){ + char* nsisSign; + nsisSign=extraData+8; + if(strncmp (nsisSign,"NullsoftInst",12) == 0){ + printf("\n\n Extra Data:\n"); + dump((TUint*)extraData, sizeOfExtraData); + } + } + peFile.Close(); + return KErrNone; + } + +int main(int argc, char *argv[]) + { + int r=KErrArgument; + if (argc==2) + { + r=pecmp(argv[1]); + } + if (r==KErrArgument) + { + cout << "\nPE_DUMP - PE file dumper V"; + cout << MajorVersion << '.' << setfill('0') << setw(2) << MinorVersion; + cout << '(' << setw(3) << Build << ")\n"; + cout << Copyright; + cout << "Syntax: "< + #include + #include + using namespace std; +#else //!__MSVCDOTNET__ + #include + #include + #include +#endif //__MSVCDOTNET__ + +const int KDiffIdentical=0; +const int KDiffDifferent=2; + +class PeFile + { +public: + PeFile(); + ~PeFile(); + int Open(char *aFileName); + void Close(); + PIMAGE_DOS_HEADER DosHeader(); + PIMAGE_NT_HEADERS Headers(); + PIMAGE_SECTION_HEADER SectionHeaders(); + char *LoadSection(PIMAGE_SECTION_HEADER aSectionHeader); + int NumberOfSections(); +public: + fstream iFile; + PIMAGE_DOS_HEADER iDosHeader; + PIMAGE_NT_HEADERS iHeaders; + PIMAGE_SECTION_HEADER iSectionHeaders; + }; + +PeFile::PeFile() + : iDosHeader(NULL), iHeaders(NULL), iSectionHeaders(NULL) + {} + +PeFile::~PeFile() + { + + delete iDosHeader; + delete iHeaders; + delete [] iSectionHeaders; + } + +int PeFile::Open(char *aFileName) + { + iFile.open(aFileName, ios::in | ios::binary); + if (!iFile.is_open()) + return KErrNotFound; + return KErrNone; + } + +void PeFile::Close() + { + + iFile.close(); + } + + +PIMAGE_DOS_HEADER PeFile::DosHeader() + { + if (iDosHeader) + return iDosHeader; + iDosHeader=new IMAGE_DOS_HEADER; + iFile.seekg(0); + iFile.read((char *)iDosHeader, sizeof(IMAGE_DOS_HEADER)); + if (iDosHeader->e_magic!=IMAGE_DOS_SIGNATURE) + return NULL; + return iDosHeader; + } + +PIMAGE_NT_HEADERS PeFile::Headers() + { + if (iHeaders) + return iHeaders; + PIMAGE_DOS_HEADER d=DosHeader(); + if (d==NULL) + return NULL; + iHeaders=new IMAGE_NT_HEADERS; + iFile.seekg(d->e_lfanew); + if (iFile.eof()) + return NULL; + iFile.read((char *)iHeaders, sizeof(IMAGE_NT_HEADERS)); + return iHeaders; + } + +PIMAGE_SECTION_HEADER PeFile::SectionHeaders() + { + if (iSectionHeaders) + return iSectionHeaders; + PIMAGE_NT_HEADERS h=Headers(); + if (h==NULL) + return NULL; + iSectionHeaders=new IMAGE_SECTION_HEADER [NumberOfSections()]; + iFile.seekg(DosHeader()->e_lfanew+sizeof(IMAGE_NT_HEADERS)); + int i=sizeof(IMAGE_SECTION_HEADER)*NumberOfSections(); + iFile.read((char *)iSectionHeaders, i); + return iSectionHeaders; + } + +int PeFile::NumberOfSections() + { + if (Headers()) + return iHeaders->FileHeader.NumberOfSections; + else + return -1; + } + +char *PeFile::LoadSection(PIMAGE_SECTION_HEADER h) + { + char *section=new char [h->SizeOfRawData]; + memset(section, 0, h->SizeOfRawData); + if (section==NULL) + return NULL; + iFile.seekg(h->PointerToRawData); + iFile.read(section, h->SizeOfRawData); + return section; + } + +int pecmp(char *aFileName1, char *aFileName2) + { + + PeFile file1, file2; + if (file1.Open(aFileName1)!=KErrNone) + { + cout << "Cannot open file '"<FileHeader.TimeDateStamp==headers2->FileHeader.TimeDateStamp); + headers1->FileHeader.TimeDateStamp=0; + headers2->FileHeader.TimeDateStamp=0; + + int r=memcmp(headers1, headers2, sizeof(IMAGE_NT_HEADERS)); + if (r) + { + cout << "PE file headers are different.\n"; + return KDiffDifferent; + } + + PIMAGE_SECTION_HEADER sectionheaders1=file1.SectionHeaders(); + PIMAGE_SECTION_HEADER sectionheaders2=file2.SectionHeaders(); + // file one and two have the same number of sections + int numberofsections=file1.NumberOfSections(); + if (numberofsections==-1) + { + cout << "Not a valid PE file.\n"; + return KErrGeneral; + } + r=memcmp(sectionheaders1, sectionheaders2, sizeof(IMAGE_SECTION_HEADER)*file1.NumberOfSections()); + if (r) + { + cout << "The files are different: PE section headers are different.\n"; + return KDiffDifferent; + } + + TUint exportDirVa=headers1->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + TUint debugDirVa=headers1->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; + + int i; + for (i=0; iName[j]; + name[8]=0; + + if (debugDirVa>=h->VirtualAddress && debugDirVaVirtualAddress+h->SizeOfRawData) + { + // Debug data in this section + PIMAGE_DEBUG_DIRECTORY dd1=(PIMAGE_DEBUG_DIRECTORY)(section1+debugDirVa-h->VirtualAddress); + PIMAGE_DEBUG_DIRECTORY dd2=(PIMAGE_DEBUG_DIRECTORY)(section2+debugDirVa-h->VirtualAddress); + TInt debugDirSize=headers1->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size; + while (debugDirSize>0) + { + if (sameTime) + sameTime=(dd1->TimeDateStamp==dd2->TimeDateStamp); + dd1->TimeDateStamp=0; + dd2->TimeDateStamp=0; + // size & location in file of debug data is not significant + // unless it's also mapped (AddressOfRawData != 0). If that's + // true, then the data will be visible in one of the sections + // anyway... + dd1->SizeOfData=0; + dd2->SizeOfData=0; + dd1->PointerToRawData=0; + dd2->PointerToRawData=0; + dd1++; + dd2++; + debugDirSize-=sizeof(IMAGE_DEBUG_DIRECTORY); + } + } + if (exportDirVa>=h->VirtualAddress && exportDirVaVirtualAddress+h->SizeOfRawData) + { + // Export directory in this section + PIMAGE_EXPORT_DIRECTORY ed1=(PIMAGE_EXPORT_DIRECTORY)(section1+exportDirVa-h->VirtualAddress); + PIMAGE_EXPORT_DIRECTORY ed2=(PIMAGE_EXPORT_DIRECTORY)(section2+exportDirVa-h->VirtualAddress); + if (sameTime) + sameTime=(ed1->TimeDateStamp==ed2->TimeDateStamp); + ed1->TimeDateStamp=0; + ed2->TimeDateStamp=0; + } + if (strcmp(".rsrc",name)==0) + { + int *t1=(int *)(section1+4); + int *t2=(int *)(section2+4); + if (sameTime) + sameTime=(*t1==*t2); + *t1=0; + *t2=0; + } + + r=memcmp(section1, section2, h->SizeOfRawData); + if (r) + { + cout << name << " sections are different.\n"; + return KDiffDifferent; + } + delete section1; + delete section2; + } + + if (sameTime) + cout << "PE files are identical (time/data stamps also identical).\n"; + else + cout << "PE files are identical except for time/date stamps.\n"; + file1.Close(); + file2.Close(); + return KDiffIdentical; + } + +int e32cmp(char *aFileName1, char *aFileName2) + { + char* f1 = NormaliseFileName(aFileName1); + char* f2 = NormaliseFileName(aFileName2); + + E32ImageFile e32image1; + E32ImageFile e32image2; + TInt r = e32image1.Open(f1); + if (r != KErrNone) + { + if (r<0) + fprintf(stderr, "%s is not a valid E32Image file (error %d)\n", f1, r); + else + r = -1; + return r; + } + r = e32image2.Open(f2); + if (r != KErrNone) + { + if (r<0) + fprintf(stderr, "%s is not a valid E32Image file (error %d)\n", f2, r); + else + r = -1; + return r; + } + + + + int sametime=(e32image1.iHdr->iTimeLo==e32image2.iHdr->iTimeLo) + &&(e32image1.iHdr->iTimeHi==e32image2.iHdr->iTimeHi); + e32image1.iHdr->iTimeLo=0; + e32image1.iHdr->iTimeHi=0; + e32image1.iOrigHdr->iTimeLo=0; + e32image1.iOrigHdr->iTimeHi=0; + e32image2.iHdr->iTimeLo=0; + e32image2.iHdr->iTimeHi=0; + e32image2.iOrigHdr->iTimeLo=0; + e32image2.iOrigHdr->iTimeHi=0; + e32image1.iHdr->iToolsVersion=e32image2.iHdr->iToolsVersion; + e32image1.iOrigHdr->iToolsVersion=e32image2.iOrigHdr->iToolsVersion; + e32image1.iHdr->iHeaderCrc=0; + e32image2.iHdr->iHeaderCrc=0; + + int ohs1 = e32image1.iOrigHdr->TotalSize(); + int ohs2 = e32image2.iOrigHdr->TotalSize(); + int orighdrcmp = (ohs1==ohs2) ? memcmp(e32image1.iOrigHdr, e32image2.iOrigHdr, ohs1) : 1; + + int hs1 = e32image1.iHdr->TotalSize(); + int hs2 = e32image2.iHdr->TotalSize(); + int hdrcmp = (hs1==hs2) ? memcmp(e32image1.iHdr, e32image2.iHdr, hs1) : 1; + + int rs1 = e32image1.iSize - ohs1; + int rs2 = e32image2.iSize - ohs2; + int rcmp = (rs1==rs2) ? memcmp(e32image1.iData + ohs1, e32image2.iData + ohs2, rs1) : 1; + + if (orighdrcmp==0 && rcmp==0) + { + if (sametime) + printf("E32 image files are identical\n"); + else + printf("E32 image files are identical apart from timestamps and Header CRC \n"); + return KDiffIdentical; + } + if (hdrcmp==0 && rcmp==0) + { + printf("E32 image files are functionally equivalent but have different headers\n"); + return KDiffDifferent; + } + printf("E32 image files are different\n"); + return KDiffDifferent; + } + + +int main(int argc, char *argv[]) + { + cout << "\nPEDIFF - PE file compare V"; + cout << MajorVersion << '.' << setfill('0') << setw(2) << MinorVersion; + cout << '(' << setw(3) << Build << ")\n"; + cout << Copyright; + + int r=KErrArgument; + if ((argc==3) || (argc==4)) + { + if (argc==3) + r=pecmp(argv[1], argv[2]); + else if (strcmp("-e32", argv[1])==0) + r=e32cmp(argv[2], argv[3]); + } + if (r==KErrArgument) + { + cout << "Syntax: "< +#include +#include +#include +#include "e32image.h" +#include "pe_defs.h" +#include "pe_file.h" +#include "h_utl.h" + +TBool hadText, hadReloc = EFalse; +TUint32 PEFile::iRomMemBase=0; +TUint32 PEFile::iRomLinearBase=0; + +extern char* gX86imp; +extern int gX86num_imp_dlls; + +PEFile::PEFile() + :iMemBase(0),iEntryPoint(0),iImageSize(0),iCodeSize(0),iDataSize(0), + iHeapReservedSize(0),iHeapCommittedSize(0),iStackReservedSize(0),iStackCommittedSize(0), + iBssSize(0),iBssOffset(0),iSectionAlign(0),iExpDirectoryOffset(0),iDataOffset(0), + iImageIsDll(EFalse), + iHeader(0),iExpDirectory(0),iImpDescriptor(0),iFileName(0),iFileHandle(0), + iLinkedBase(0),iStartOfHeaders(0),iSizeOfHeaders(0),iNumSections(0), + iRomRunAddr(0),iRamRunAddr(0),iRomDelta(0),iRamDelta(0),iHadDataSection(EFalse), + iBssSectionLinkedAddr(0),iBssSectionAddr(0),iBssSectionSize(0), + iDataSectionLinkedAddr(0),iDataSectionAddr(0),iDataSectionSize(0), + iCodeSectionAddr(0),iCodeSectionSize(0), + iRDataSectionAddr(0),iRDataSectionSize(0), + iCRTSectionAddr(0),iCRTSectionSize(0), + iExportDataDir(0) +// +// Constructor +// + { + + for (TInt i=0; ie_lfanew; + else + iStartOfHeaders = 0; + + if (!HFile::Seek(iFileHandle, iStartOfHeaders)) + { + Print(EPeError,"File %s is not large enough to contain valid headers.\n",iFileName); + HFile::Close(iFileHandle); + return EFalse; + } + + if (!HFile::Read(iFileHandle,iHeader,sizeof(IMAGE_NT_HEADERS))) + { + Print(EPeError,"Unable to read NT headers.\n"); + HFile::Close(iFileHandle); + return EFalse; + } + + if (!IsValidNTHeader(iHeader)) + { + Print(EPeError,"Invalid NT header.\n"); + HFile::Close(iFileHandle); + return EFalse; + } + + if (!(IsValidFileHeader((PIMAGE_FILE_HEADER)&iHeader->FileHeader))) + { + Print(EPeError,"Invalid file header.\n"); + HFile::Close(iFileHandle); + return EFalse; + } + +// PIMAGE_NT_HEADERS pNTHeader = iHeader; + PIMAGE_FILE_HEADER pFileHeader = (PIMAGE_FILE_HEADER)&iHeader->FileHeader; + PIMAGE_OPTIONAL_HEADER pOptionalHeader = (PIMAGE_OPTIONAL_HEADER)&iHeader->OptionalHeader; +// PIMAGE_SECTION_HEADER pSectionHeader = (PIMAGE_SECTION_HEADER)(iHeader+1); + + iImageSize = pOptionalHeader->SizeOfImage; + iCodeSize = pOptionalHeader->SizeOfCode; + iDataSize = pOptionalHeader->SizeOfInitializedData; + iEntryPoint = pOptionalHeader->AddressOfEntryPoint; + iHeapReservedSize = pOptionalHeader->SizeOfHeapReserve; + iHeapCommittedSize = pOptionalHeader->SizeOfHeapCommit; + iStackReservedSize = 0x2000; + iStackCommittedSize = 0x2000; + iBssSize = pOptionalHeader->SizeOfUninitializedData; + iSectionAlign = pOptionalHeader->SectionAlignment; + if (pFileHeader->Characteristics & IMAGE_FILE_DLL) + iImageIsDll = ETrue; + else + iImageIsDll = EFalse; + iLinkedBase=pOptionalHeader->ImageBase; + iNumSections = pFileHeader->NumberOfSections; + iSizeOfHeaders = pOptionalHeader->SizeOfHeaders; + iExportDataDir=pOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + iExportDirSize=pOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size; +// + iCpu=pFileHeader->Machine; + HMem::Free(iHeader); + iHeader=0; + return ETrue; + } + +void PEFile::Close() +// +// close the pe file +// + { + HFile::Close(iFileHandle); + } + +TInt PEFile::ReadExportDirectory() +// +// Read in just the export directory +// + { + + if (iExportDataDir==0) + return KErrNotFound; + TInt r=ReadSectionHeaders(); + if (r!=KErrNone) + return r; + iSectionData[KConstSection]=ReadSectionData(iSectionHeader[KConstSection]); + iExpDirectoryOffset=iSectionHeader[KConstSection]->VirtualAddress; + iExpDirectory=(PIMAGE_EXPORT_DIRECTORY)(iSectionData[KConstSection]+iExportDataDir-iExpDirectoryOffset); + return KErrNone; + } + +TInt PEFile::ReadSectionHeaders() +// +// Read in the section headers +// + { + + TInt i; + for (i=0; iName); + delete header; + } + } + return KErrNone; + } + +char *PEFile::ReadSectionData(PIMAGE_SECTION_HEADER aPeHeader) +// +// Read in the data for this section +// + { + char *section=NULL; + if (aPeHeader) + { + section=(char *)HMem::Alloc(NULL, aPeHeader->SizeOfRawData); + if (section==NULL) + return NULL; + HFile::Seek(iFileHandle, aPeHeader->PointerToRawData); + HFile::Read(iFileHandle, section, aPeHeader->SizeOfRawData); + } + return section; + } + +TInt PEFile::ReadData() +// +// +// + { + + TInt i; + for (i=0; iName); + } + else + iSectionData[i]=NULL; + } + return KErrNone; + } + +TInt PEFile::NumberOfImports() const +// +// Count the total number of imports for this image +// + { + +// if (gX86imp) +// return gX86num_imp_dlls; + char *importData=iSectionData[KImportSection]; + PIMAGE_SECTION_HEADER importHeader=iSectionHeader[KImportSection]; + if (importData==NULL) + return 0; + TInt n=0; + TUint *src=(TUint *)importData; + while (*src) + { + TUint vaoffset=src[4]; + if (!gLittleEndian) ByteSwap(vaoffset); + TUint offset=vaoffset-importHeader->VirtualAddress; // find the offset into the section of import addr table + TUint *p=(TUint *)(importData+offset); + while (*p++) + n++; + src+=5; // sizeof pe import block/4 + } + return n; + } + +TInt PEFile::NumberOfImportDlls() const +// +// Count the number of referenced Dlls +// + { + + char *importData=iSectionData[KImportSection]; +// PIMAGE_SECTION_HEADER importHeader=iSectionHeader[KImportSection]; + if (importData==NULL) + return 0; + TInt n=0; + while (*(TUint *)importData) + { + n++; + importData+=5*4; // size of pe import block + } + return n; + } + +TInt PEFile::NumberOfExports() const +// +// Count the number of exported symbols +// + { + + if (iExportDataDir==0) + return 0; + return ((PIMAGE_EXPORT_DIRECTORY)iSectionData[KExportSection])->NumberOfFunctions; + } + +TInt PEFile::NumberOfRelocs() +// +// Count the number of reloctions +// + { + + if (iSectionData[KRelocSection]==NULL) + return 0; + char *relocs=iSectionData[KRelocSection]; + TInt n=0; + TInt dudrelocs=0; + TInt blocksize; + TUint page; + TInt size=iSectionHeader[KRelocSection]->Misc.VirtualSize; + + TUint *rrelocs=(TUint *)relocs; + TUint ssize=size; + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + + while (size>0) + { + page=*(TUint *)relocs; + blocksize=*(TInt *)(relocs+4); + if (blocksize==0) + break; + size-=blocksize; + TUint16 *p=(TUint16 *)(relocs+8); + relocs+=blocksize; + blocksize-=8; + while (blocksize>0) + { + TInt rtype=(*p&0xf000)>>12; + if (rtype==IMAGE_REL_BASED_HIGHLOW) + { + TUint va=page+(*p&0xfff); + + // va is the address requiring relocation, so it must be in a section and can't have been offset + TInt section=FindSectionByVa(va+iLinkedBase); + if (section==KTextSection || section==KConstSection || section==KDataSection || section==KCrtSection) + n++; + else + dudrelocs++; + } + else if (rtype!=IMAGE_REL_BASED_ABSOLUTE) // used for padding + Print(EWarning, "Relocation type other than IMAGE_REL_BASED_HIGHLOW has been ignored.\n"); + *p++; + blocksize-=2; + } + } +#if defined(_DEBUG) + if (dudrelocs>0) + Print(EWarning, "Image '%s' has %d relocations pointing at uninitialised data.\n", iFileName, dudrelocs); +#endif + + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + return n; + } + +void PEFile::GetRelocs(TUint *aReloc, TUint *aRelocSection, TInt /*aNumberOfRelocs*/) +// +// load the relocs from the reloc section into relocation and relocsection arrays +// + { + + TUint *relocation=aReloc; + TUint *relocsection=aRelocSection; + char *aRelocData=iSectionData[KRelocSection]; + + TUint16 *relocs=(TUint16 *)aRelocData; + TInt relocsize=iSectionHeader[KRelocSection]->Misc.VirtualSize; + TUint offset; + TUint page; + TInt i=0; + + TUint *rrelocs=(TUint *)aRelocData; + TUint ssize=relocsize; + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + + while (relocsize>0) + { + page=*(TUint *)relocs; + relocs+=2; + TInt size=*(TUint *)relocs; + if (size==0) + break; + relocsize-=size; + relocs+=2; + size-=8; + while (size>0) + { + offset=*relocs++; + TInt type=offset&0xf000; + if (type==0x3000) + { + TUint va=page+(offset&0xfff); + + // va is the address requiring relocation, so it must be in a section and can't have been offset + TInt section=FindSectionByVa(va+iLinkedBase); + if (section==KTextSection || section==KConstSection || section==KDataSection || section==KCrtSection) + { + relocsection[i]=section; + relocation[i++]=va; + } + } + size-=2; + } + } + + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + } + +TInt PEFile::Normalise() +// +// Remove the MSVC anomalies +// + { + + // MSVC puts export data in with .rdata + if (iExportDataDir && iSectionHeader[KExportSection]==NULL) + { + if (!PEFile::VirtualAddressInSection(iExportDataDir+iLinkedBase, iSectionHeader[KConstSection])) + return Print(EError, "Can't find exports in this PE file.\n"); + else + { + iSectionHeader[KExportSection]=new IMAGE_SECTION_HEADER; + iSectionHeader[KExportSection]->VirtualAddress=iExportDataDir; + iSectionHeader[KExportSection]->Misc.VirtualSize=iExportDirSize; + iSectionHeader[KExportSection]->SizeOfRawData=iExportDirSize; + iSectionData[KExportSection]=new char [iExportDirSize]; + if (iSectionData[KExportSection]==NULL) + return Print(EError, "Out of memory.\n"); + memcpy(iSectionData[KExportSection], iSectionData[KConstSection]+iExportDataDir-iSectionHeader[KConstSection]->VirtualAddress, iExportDirSize); + // adjust .rdata so it does not include .edata + iSectionHeader[KConstSection]->Misc.VirtualSize-=iExportDirSize; + iSectionHeader[KConstSection]->SizeOfRawData-=iExportDirSize; + char *c=new char [iSectionHeader[KConstSection]->SizeOfRawData]; + if (c==NULL) + return Print(EError, "Out of memory.\n"); + memcpy(c, iSectionData[KConstSection], iSectionHeader[KConstSection]->SizeOfRawData); + delete iSectionData[KConstSection]; + iSectionData[KConstSection]=c; + } + } + // Stupid compilers generate .idata sections even when there are no imports + if (iSectionHeader[KImportSection]) + { + if (NumberOfImports()==0) + { + delete iSectionHeader[KImportSection]; + delete iSectionData[KImportSection]; + iSectionHeader[KImportSection]=NULL; + iSectionData[KImportSection]=NULL; + } + } + return KErrNone; + } + + +TInt PEFile::HasInitialisedData(PIMAGE_SECTION_HEADER aHeader) +// +// Returns true if the pe file section contains any initialised data +// + { + + if (aHeader==NULL) + return FALSE; + if (aHeader->SizeOfRawData==0) + return FALSE; + return TRUE; + } + +void PEFile::CopySectionData(TAny *source, TAny *dest, TUint32 fileLength, TUint32 memLength) + { + + if (fileLength <= memLength) + { + Print(EScreen," Copying %08x bytes from file at %08x to memory at %08x\n", fileLength, source, dest); + HMem::Copy(dest,source,fileLength); + dest = (TAny *)((TUint32)dest + fileLength); + TUint32 remainingSize = memLength - fileLength; + Print(EScreen," Zeroing remaining %08x bytes at %08x\n", remainingSize, dest); + HMem::Set(dest, 0, remainingSize); + } + else + { + Print(EScreen," Copying %08x bytes from file at %08x to memory at %08x\n", memLength, source, dest); + HMem::Copy(dest,source,memLength); + } + } + + +TBool PEFile::ProcessRelocData(TAny *relocData,TInt dataSize) + { + + TBool hadBadRelocs=EFalse; + PIMAGE_BASE_RELOCATION pRelocData = (PIMAGE_BASE_RELOCATION)((TUint32)relocData); + Print(ELog," Info on .reloc section...\n"); + + while (pRelocData->SizeOfBlock != 0) + { + TUint16 relocType; + TUint32 relocOffset; + TUint32 *relocAddr; + + Print(ELog," Virtual address: %08x size: %08x\n",pRelocData->VirtualAddress, pRelocData->SizeOfBlock); + + TUint numEntries = (pRelocData->SizeOfBlock-sizeof(*pRelocData))/sizeof(TUint16); + TUint16 *pEntry = (TUint16 *)((TUint32)pRelocData+sizeof(*pRelocData)); + + for (TUint i=0; i>12); + // The rest of the field is the offset + relocOffset = (*pEntry & 0x0FFF); + switch (relocType) + { + case 0: // Just padding + pEntry++; + break; + + case 1: + case 2: + case 4: + case 5: + Print(EPeError,".reloc section, relocation type not handled.\n"); + return EFalse; + break; + + case 3: + { + if (pRelocData->VirtualAddress==0) // Defect in .reloc section of arm ekern.exe + { + pEntry++; + break; + } + TUint thisReloc=0; + relocAddr = (TUint32 *)((TUint32)iMemBase + (TUint32)pRelocData->VirtualAddress + relocOffset); + TUint32 reloc = *relocAddr; + + if (IsInCode((TUint32)relocAddr) || IsInData((TUint32)relocAddr)) + { + if (IsInDataReloc(reloc)) + { + if (iImageIsDll) + { + Print(EPeError,"Dlls should have no RAM (data) relocations.\n"); + return(EFalse); + } + thisReloc=reloc+iRamDelta; + } + else + thisReloc=reloc+iRomDelta; + *relocAddr = thisReloc; // this line here to enable breaking on values of thisReloc + } + else + hadBadRelocs=ETrue; + pEntry++; + } + break; + default: + Print(EPeError,".reloc section, invalid relocation type.\n"); + return(EFalse); + } + } + dataSize-=pRelocData->SizeOfBlock; + if(dataSize<=0) + break; + pRelocData = (PIMAGE_BASE_RELOCATION)((TUint32)pRelocData+pRelocData->SizeOfBlock); + } + + if (hadBadRelocs) + Print(EPeError,"File %s has relocation in invalid section\n",iFileName); + return(ETrue); + } + +TBool PEFile::IsInCode(TUint32 anAddr) + { + if ((anAddr>=iCodeSectionAddr) && (anAddr<(iCodeSectionAddr+iCodeSectionSize))) + return(ETrue); + if ((anAddr>=iRDataSectionAddr) && (anAddr<(iRDataSectionAddr+iRDataSectionSize))) + return(ETrue); + if ((anAddr>=iCRTSectionAddr) && (anAddr<(iCRTSectionAddr+iCRTSectionSize))) + return(ETrue); + return(EFalse); + } + +TBool PEFile::IsInData(TUint32 anAddr) + { + if ((anAddr>=iDataSectionAddr) && (anAddr<(iDataSectionAddr+iDataSectionSize))) + return(ETrue); + if ((anAddr>=iBssSectionAddr) && (anAddr<(iBssSectionAddr+iBssSectionSize))) + return(ETrue); + return(EFalse); + } + +TBool PEFile::IsInDataReloc(TUint32 anAddr) + { + if ((anAddr>=iDataSectionLinkedAddr) && (anAddr<(iDataSectionLinkedAddr+iDataSectionSize))) + return(ETrue); + if ((anAddr>=iBssSectionLinkedAddr) && (anAddr<(iBssSectionLinkedAddr+iBssSectionSize))) + return(ETrue); + return(EFalse); + } + + +TBool PEFile::IsValidDOSHeader(PIMAGE_DOS_HEADER aDOSHeader) + { + if (aDOSHeader->e_magic!=IMAGE_DOS_SIGNATURE) + { + Print(EPeError,"File does not have valid DOS MZ signature.\n"); + return EFalse; + } + else + return ETrue; + } + + + +TBool PEFile::IsValidNTHeader(PIMAGE_NT_HEADERS aNTHeader) + { + if (aNTHeader->Signature != IMAGE_NT_SIGNATURE ) + { + Print(EPeError,"File does not have valid NT PE signature.\n"); + return EFalse; + } + else + return ETrue; + } + + +TBool PEFile::IsValidFileHeader(PIMAGE_FILE_HEADER aFileHeader) + { + if ((aFileHeader->Machine != IMAGE_FILE_MACHINE_I386) + && (aFileHeader->Machine != 0xa00) + && (aFileHeader->Machine != 0xb00) + && (aFileHeader->Machine !=IMAGE_FILE_MACHINE_ALPHA)) + { + Print(EPeError,"File is not a valid i386, ARM, M*Core or ALPHA executable.\n"); + return EFalse; + } + + if (aFileHeader->SizeOfOptionalHeader == 0) + { + Print(EPeError,"Optional header is 0 bytes in length - this is probably an object, not an executable\n"); + return EFalse; + } + + if (!(aFileHeader->Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE)) + { + Print(EPeError,"File is not a valid executable - probably linker error\n"); + return EFalse; + } + + return ETrue; + } + + +// Get details of the next import to fix-up in the current file. Fill in the name of the dll +//it is imported from, the ordinal number and the address to write back to. +#define ORDINAL_DONE 0x40000000 + +TImportStat PEFile::GetNextImport(char * &aDllName, TUint16 &aOrdinal, TUint32 * &aThunk) + { + PIMAGE_THUNK_DATA pLookupTable = 0; + TUint32 *pThunk = 0; + TUint32 rawOrdinal = ORDINAL_DONE; + TImportStat res = EImpDone; + PIMAGE_IMPORT_DESCRIPTOR impDesc = iImpDescriptor; + char *expDllName = 0; + + if (impDesc == 0) + return EImpDone; // This file imports nothing + + while ((rawOrdinal & ORDINAL_DONE) && ((impDesc->TimeDateStamp!=0 ) || (impDesc->Name!=0))) + { + expDllName = (char *)(iMemBase + impDesc->Name); + pLookupTable = (PIMAGE_THUNK_DATA)(iMemBase + impDesc->Characteristics); + pThunk = (TUint32 *)(iMemBase + (TUint32)impDesc->FirstThunk); + while ((rawOrdinal & ORDINAL_DONE) && (pLookupTable->u1.AddressOfData != 0)) + { + if (pLookupTable->u1.Ordinal & IMAGE_ORDINAL_FLAG ) + rawOrdinal = pLookupTable->u1.Ordinal; + else + { + Print(EPeError,"in file %s\n",iFileName); + Print(EPeError,"It is importing a symbol by name from %s\n",expDllName); + return EImpError; + } + pThunk++; + pLookupTable++; + } + impDesc++; + } + + if (!(rawOrdinal & ORDINAL_DONE)) + { + pThunk--; + pLookupTable--; + res = EImpSuccess; + aDllName = expDllName; + aThunk = pThunk; + aOrdinal = (TUint16)(rawOrdinal & 0xFFFF); + pLookupTable->u1.Ordinal |= ORDINAL_DONE; + } + + return res; + } + +TUint32 PEFile::GetFixUp(const TUint16 aOrdinal) +// +// Look through export directory to find fix-up for given ordinal +// + { + + TUint32 ordBase = iExpDirectory->Base; + TUint32 *functions = (TUint32 *)((TUint32)iExpDirectory->AddressOfFunctions + iMemBase); + TUint32 fixupAddr = functions[aOrdinal-ordBase] + iRomRunAddr; + return fixupAddr; + } + +TUint PEFile::GetNumberOfExportedFunctions() + { + + return iExpDirectory->NumberOfFunctions; + } + + +TUint PEFile::GetOrdinalBase() + { + + return iExpDirectory->Base; + } + + +TBool PEFile::ExportSectionExists() + { + + if (iExpDirectory) + return ETrue; + else + return EFalse; + } + + +TBool PEFile::ImportSectionExists() + { + + if (iImpDescriptor) + return ETrue; + else + return EFalse; + } + + +TUint PEFile::RoundToSectionSize(TUint aSize) +// +// Round to the nearest size in sections +// + { + TUint sAlign = iSectionAlign; + return ((aSize+sAlign-1)/sAlign)*sAlign ; + } + + +void PEFile::DumpPeHeaders() +// +// Print out loads of stuff from the PE header +// + { + TInt err = HFile::Open(iFileName, &iFileHandle); + if (err!=0) + return; + + iHeader = (PIMAGE_NT_HEADERS)(HMem::Alloc(0,iSizeOfHeaders-iStartOfHeaders)); + if (!iHeader) + return; + + if (!HFile::Seek(iFileHandle, iStartOfHeaders)) + return; + + if (!HFile::Read(iFileHandle, iHeader, iSizeOfHeaders-iStartOfHeaders)) + return; + + PIMAGE_FILE_HEADER pFileHeader = (PIMAGE_FILE_HEADER)&iHeader->FileHeader; + PIMAGE_OPTIONAL_HEADER pOptionalHeader = (PIMAGE_OPTIONAL_HEADER)&iHeader->OptionalHeader; + PIMAGE_SECTION_HEADER pSectionHeader = (PIMAGE_SECTION_HEADER)(iHeader+1); + + printf("File header\n"); + printf("-----------\n\n"); + char *szMachine=0; + switch( pFileHeader->Machine ) + { + case 0xa00: + szMachine = (char *)"ARM"; break; + case 0xb00: + szMachine = (char *)"M*Core"; break; + case IMAGE_FILE_MACHINE_I386: + szMachine = (char *)"i386"; break; + case IMAGE_FILE_MACHINE_I860: + szMachine = (char *)"i860"; break; + case IMAGE_FILE_MACHINE_R3000: + szMachine = (char *)"R3000"; break; + case IMAGE_FILE_MACHINE_R4000: + szMachine = (char *)"R4000"; break; + case IMAGE_FILE_MACHINE_ALPHA: + szMachine = (char *)"Alpha"; break; + case IMAGE_FILE_MACHINE_POWERPC: + szMachine = (char *)"IBM PowerPC"; break; + default: + printf ("ERROR - machine not specified.\n"); + szMachine = (char *)"unknown"; + break; + } + + printf("\n Machine: %s (Id=%04x)",szMachine, pFileHeader->Machine); + if ((pFileHeader->Machine != 0xa00) // ARM + && (pFileHeader->Machine != 0xb00)) // M*Core + printf("..........ERROR!!"); + printf("\n Number of sections : %04x",pFileHeader->NumberOfSections); + printf("\n Time date stamp : %08lx",pFileHeader->TimeDateStamp); + if (pFileHeader->TimeDateStamp == 0) + printf("..........ERROR!!"); + printf("\n Pointer to symbol table : %08lx",pFileHeader->PointerToSymbolTable); + printf("\n Number of symbols : %08lx",pFileHeader->NumberOfSymbols); + printf("\n Size of optional header : %08x",pFileHeader->SizeOfOptionalHeader); + if (pFileHeader->SizeOfOptionalHeader == 0) + printf("..........ERROR!!"); + printf("\n Characteristics : %08x\n",pFileHeader->Characteristics); + if (pFileHeader->Characteristics & IMAGE_FILE_RELOCS_STRIPPED) + printf("\n Relocations stripped..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE) + printf("\n Executable image."); + else + printf("\n Not executable image..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_CHAR_REVERSED_LO) + printf("\n Bytes reversed lo..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_32BIT_MACHINE) + printf("\n 32bit image."); + else + printf("\n Not 32bit image..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_SYSTEM) + printf("\n System file."); + if (pFileHeader->Characteristics & IMAGE_FILE_DLL) + printf("\n Dll file."); + if (pFileHeader->Characteristics & IMAGE_FILE_CHAR_REVERSED_HI) + printf("\n Bytes reversed hi..........ERROR!!"); + + + printf ("\n\n\nOptional Header\n"); + printf ("------------------"); + + printf("\n Magic = %04x", pOptionalHeader->Magic); + printf("\n Major Linker Version = %02x", pOptionalHeader->MajorLinkerVersion); + printf("\n Minor Linker Version = %02x", pOptionalHeader->MinorLinkerVersion); + printf("\n Size of code (bytes) = %08lx", pOptionalHeader->SizeOfCode); + printf("\n Size of initialized data (bytes) = %08lx", pOptionalHeader->SizeOfInitializedData); + printf("\n Size of uninitialized data (bytes) = %08lx", pOptionalHeader->SizeOfUninitializedData); + printf("\n Entrypoint RVA = %08lx", pOptionalHeader->AddressOfEntryPoint); + if (pOptionalHeader->AddressOfEntryPoint & 0x80000000) + printf("..........ERROR!!"); + printf("\n Base of code = %08lx", pOptionalHeader->BaseOfCode); + if (pOptionalHeader->BaseOfCode & 0x80000000) + printf("..........ERROR!!"); + printf("\n Base of data = %08lx", pOptionalHeader->BaseOfData); + if (pOptionalHeader->BaseOfData & 0x80000000) + printf("..........ERROR!!"); + printf("\n Image base = %08lx", pOptionalHeader->ImageBase); + if (pOptionalHeader->ImageBase & 0x80000000) + printf("..........ERROR!!"); + printf("\n Section alignment (bytes) = %08lx",pOptionalHeader->SectionAlignment); + if (pOptionalHeader->SectionAlignment & 0x80000000) + printf("..........ERROR!!\n"); + printf("\n File alignment (bytes) = %08lx", pOptionalHeader->FileAlignment); + if (pOptionalHeader->FileAlignment & 0x80000000) + printf("..........ERROR!!"); + printf("\n Major Operating System Version = %04x", pOptionalHeader->MajorOperatingSystemVersion); + printf("\n Minor Operating System Version = %04x", pOptionalHeader->MinorOperatingSystemVersion); + printf("\n Major Image Version = %04x", pOptionalHeader->MajorImageVersion); + printf("\n Minor Image Version = %04x", pOptionalHeader->MinorImageVersion); + printf("\n Major Subsystem Version = %04x", pOptionalHeader->MajorSubsystemVersion); + printf("\n Minor Subsystem Version = %04x", pOptionalHeader->MinorSubsystemVersion); + + printf("\n Size of image (bytes) = %08lx", pOptionalHeader->SizeOfImage); + if (pOptionalHeader->SizeOfImage & 0x80000000) + printf("..........ERROR!!"); + printf("\n Size of headers (bytes) = %08lx",pOptionalHeader->SizeOfHeaders); + if (pOptionalHeader->SizeOfHeaders & 0x80000000) + printf("..........ERROR!!"); + printf("\n CheckSum = %04lx", pOptionalHeader->CheckSum); + printf("\n Subsystem = %04x", pOptionalHeader->Subsystem); + printf("\n Dll Characteristics = %04x", pOptionalHeader->DllCharacteristics); + printf("\n Size Of Stack Reserve = %04lx", pOptionalHeader->SizeOfStackReserve); + printf("\n Size Of Stack Commit = %04lx", pOptionalHeader->SizeOfStackCommit); + printf("\n Size Of Heap Reserve = %04lx", pOptionalHeader->SizeOfHeapReserve); + printf("\n Size Of Heap Commit = %04lx", pOptionalHeader->SizeOfHeapCommit); + printf("\n Loader Flags = %04lx", pOptionalHeader->LoaderFlags); + printf("\n Number Of Rva and Sizes = %04lx", pOptionalHeader->NumberOfRvaAndSizes); + + printf("\n\n\nSection Headers\n"); + printf("---------------\n\n"); + + for (TUint i=0;iName); + printf("\n Virtual size : %08lx", pSectionHeader->Misc.VirtualSize); + printf("\n RVA of section data : %08lx", pSectionHeader->VirtualAddress); + if (pSectionHeader->VirtualAddress & 0x80000000) + printf("..........ERROR!!"); + printf("\n Size of raw data : %08lx", pSectionHeader->SizeOfRawData); + printf("\n Pointer to raw data : %08lx", pSectionHeader->PointerToRawData); + printf("\n Characteristics: %08lx\n", pSectionHeader->Characteristics); + if (pSectionHeader->Characteristics & IMAGE_SCN_LNK_REMOVE) + printf("\nERROR - Section should have been removed by linker.\n"); + + // read the section in + TUint32 filePos = pSectionHeader->PointerToRawData; + TUint32 fileLength = pSectionHeader->SizeOfRawData; +// TUint32 memLength = pSectionHeader->Misc.VirtualSize; + TAny *sectionFile = HMem::Alloc((TAny *)0, fileLength); // get a buffer + HFile::Seek(iFileHandle, filePos); + HFile::Read(iFileHandle, sectionFile, fileLength); // and read the file into the buffer +// TAny *sectionMem = (TAny *)((TUint32)iMemBase + pSectionHeader->VirtualAddress); + + if (strnicmp((const char *)pSectionHeader->Name, ".text", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + hadText = ETrue; + if (!(pSectionHeader->Characteristics & IMAGE_SCN_CNT_CODE)) + printf("\nERROR - Code section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_EXECUTE)) + printf("\nERROR - Code section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_READ)) + printf("\nERROR - Code section has incorrect characteristics.\n"); + } + else if (strnicmp((const char *)pSectionHeader->Name, ".data", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + if (iImageIsDll) + { + printf ("\nERROR - DLL has data section.\n"); + } + else + { + if (!(pSectionHeader->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA)) + printf("\nERROR - data section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_WRITE)) + printf("\nERROR - data section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_READ)) + printf("\nERROR - data section has incorrect characteristics.\n"); + } + } + else if (strnicmp((const char *)pSectionHeader->Name, ".rdata", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + } + else if (strnicmp((const char *)pSectionHeader->Name, ".bss", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + if (iImageIsDll) + { + printf ("\nERROR - DLL has bss section.\n"); + } + else + { + if (!(pSectionHeader->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)) + printf("\nERROR - BSS section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_WRITE)) + printf("\nERROR - BSS section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_READ)) + printf("\nERROR - BSS section has incorrect characteristics.\n"); + } + } + else if (strnicmp((const char *)pSectionHeader->Name, ".reloc", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + hadReloc = ETrue; + } + else if (strnicmp((const char *)pSectionHeader->Name, ".idata", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + } + else if (strnicmp((const char *)pSectionHeader->Name, ".edata", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + iExpDirectory = (PIMAGE_EXPORT_DIRECTORY)(sectionFile); + if (iImageIsDll) + { + printf("\n Ordinal base = %08lx", iExpDirectory->Base); + printf("\n Number of functions = %08lx", iExpDirectory->NumberOfFunctions); + printf("\n Number of names = %08lx", iExpDirectory->NumberOfNames); + printf("\n Export address table RVA = %08lx", (TUint32)iExpDirectory->AddressOfFunctions); + printf("\n Name pointer RVA = %08lx", (TUint32)iExpDirectory->AddressOfNames); + printf("\n Ordinal table RVA = %08lx", (TUint32)iExpDirectory->AddressOfNameOrdinals); + } + else + { + printf("\nERROR - non-DLL with export section."); + } + } + else + { + printf("\nERROR - unexpected section."); + } + + HMem::Free(sectionFile); + return; + } + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/pefile/pe_imp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_imp.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,235 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include +#include +#include "h_utl.h" +#include "pe_file.h" + +TInt E32ImageFile_PE::CopyImportAddrTable(char *aPtr, PEFile &aPeFile) +// +// Copy the import address table entries +// + { + + TUint *ptr=(TUint *)aPtr; + char *importsection=aPeFile.iSectionData[KImportSection]; + TUint *src=(TUint *)importsection; + while (*src) + { + TUint vaoffset=src[4]; + if (!gLittleEndian) ByteSwap(vaoffset); + TUint offset=vaoffset-aPeFile.iSectionHeader[KImportSection]->VirtualAddress; // find the offset into the section of import addr table + vaoffset=src[3]; + if (!gLittleEndian) ByteSwap(vaoffset); + TUint exportername=vaoffset-aPeFile.iSectionHeader[KImportSection]->VirtualAddress; + TUint *p=(TUint *)(importsection+offset); + while (*p) + { + if ((*p&0x80000000)==0) + { + Print(EError, "%s exporting symbol by name\n", importsection+exportername); + return KErrGeneral; + } + *ptr++=(*p++)&0x7fffffff; // mask out the high bit (- indicates export by ordinal) + } + src+=5; + } + *ptr++=0; + return KErrNone; + } + +extern char* gX86imp; +extern int gX86num_imports; +extern int gX86num_imp_dlls; +extern int gX86imp_size; +int* gX86imp_relocs=NULL; + +TInt CrunchImportSection(TAny* aSection, TInt aNumImpDlls, TInt aNumImports) + { + // Remove lists of ordinals from import section + TInt* d = (TInt*)aSection; + TInt orig_size = *d; + TInt offset_correction = aNumImports*sizeof(TUint); + *d -= offset_correction; // reduce total section size + TInt *dd = d+1; + TInt *ss = d+1; + + TInt i; + for (i=0; i>2; + *s=rdata[rdata_int_offset]&0x7fffffffu; // rdata offset to ordinal + gX86imp_relocs[rdata_int_offset]=j<<2; + ++j; + ++s; + } + } + *(TInt*)section = bytecount; + aSize = CrunchImportSection(section, gX86num_imp_dlls, total_imports); + return section; + } + PIMAGE_SECTION_HEADER aHeader=aPeFile.iSectionHeader[KImportSection]; + TUint *aSrc=(TUint *)aPeFile.iSectionData[KImportSection]; + + TInt nimportdlls=aPeFile.NumberOfImportDlls(); + if (nimportdlls==0) + { + aSize=0; + return NULL; + } + E32ImportBlock *block=new E32ImportBlock [nimportdlls]; + char **name=new char* [nimportdlls]; + TUint **import=new TUint* [nimportdlls]; + + TInt bytecount=sizeof(E32ImportSection)+sizeof(E32ImportBlock)*nimportdlls; + TUint *src=aSrc; + TInt i; + for (i=0; iVirtualAddress; // find the offset into the section of import addr table + TUint *p=aSrc+offset/4; + block[i].iNumberOfImports=0; + while (*p++) + block[i].iNumberOfImports++; + total_imports += block[i].iNumberOfImports; + import[i]=new TUint [block[i].iNumberOfImports]; + TInt j; + p=aSrc+offset/4; + for (j=0; jVirtualAddress; + name[i]=((char *)aSrc)+offset; + bytecount+=strlen(name[i])+1; + src+=5; + } + + bytecount=ALIGN4(bytecount); + char *section=new char [bytecount]; + char *s=section+sizeof(E32ImportSection); + for (i=0; iiOffsetOfDllName=s-section; + strcpy(s, name[i]); + s+=strlen(name[i])+1; + t += ((E32ImportBlock *)t)->iNumberOfImports * sizeof(TUint) + sizeof(E32ImportBlock); + } + while ((s-section)VirtualAddress; + + while (iatVirtualAddress; + } + else + { + n++; + iat+=4; + } + } + + // Flag errors brought about by a corrupt input binary + if (iat>va) + { + Print(EError, "%s is corrupt - problem processing import address table.\n", this->iFileName); + return (TUint)KErrGeneral; + } + + return iHdr->iTextSize+n*sizeof(TUint); + } + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/pefile/pe_reloc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_reloc.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,374 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include +#include +#include "pe_file.h" +#include "h_utl.h" +#include + +extern char* gX86imp; +extern int gX86num_imp_dlls; +extern int gX86imp_size; +extern int gX86num_imports; +extern int* gX86imp_relocs; + +TInt sizeOfCodeRelocs(TUint *relocs, TUint *relocsection, TInt nrelocs) + { + + TInt bytecount=0; + TInt page=-1; + TInt i; + for (i=0; iiNumberOfRelocs=ncoderelocs; + ((E32RelocSection *)section)->iSize=bytecount; + return section; + } + +char *E32ImageFile_PE::CreateDataRelocs(TUint *relocs, TUint *relocsection, TInt nrelocs, TInt &aSize) + { + + TInt bytecount=sizeOfDataRelocs(relocs, relocsection, nrelocs); + aSize=0; + if (bytecount==0) + return NULL; + aSize=bytecount+sizeof(E32RelocSection); + + char *section=new char [bytecount+sizeof(E32RelocSection)]; + char *data=section+sizeof(E32RelocSection); + char *startofblock=data; + + TInt ndatarelocs=0; + TInt page=-1; + TInt pagesize=8; + TInt i; + for (i=0; iiNumberOfRelocs=ndatarelocs; + ((E32RelocSection *)section)->iSize=bytecount; + return section; + } + +void checkreloc(PEFile &aPeFile, TUint va, TUint reloc) + { + + // Allow the section find routine to use heuristics to resolve addresses + // which have been offset by the compiler + TInt s = aPeFile.FindSectionByVa(va, 1); + switch(s) + { + case KTextSection: + case KConstSection: + case KDataSection: + case KCrtSection: + case KBssSection: + case KImportSection: + return; + default: + break; + } + Print(EAlways, "bad relocation: [%08x] = %08x\n", reloc, va); + } + +void E32ImageFile_PE::FixRelocs(PEFile &aPeFile, TUint *relocation, TUint *relocsection, TInt aNumberOfRelocs) + { + + TUint *data; + TInt i; +#if 0 + Print(EAlways, "Linked base %08x\n", aPeFile.iLinkedBase); + for (i=0; iVirtualAddress; + TUint finish = start + aPeFile.iSectionHeader[i]->Misc.VirtualSize; + Print(EAlways, "Section %d %08x-%08x\n", i, start, finish); + } +#endif + for (i=0; iVirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KTextSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KTextSection]->VirtualAddress); + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + case KConstSection: + relocation[i]-=aPeFile.iSectionHeader[KConstSection]->VirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KConstSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KConstSection]->VirtualAddress); + relocation[i]+=ConstOffset(); + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + case KCrtSection: + relocation[i]-=aPeFile.iSectionHeader[KCrtSection]->VirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KCrtSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KCrtSection]->VirtualAddress); + relocation[i]+=iCrtOffset; + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + case KDataSection: + relocation[i]-=aPeFile.iSectionHeader[KDataSection]->VirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KDataSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KDataSection]->VirtualAddress); + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + default: + Print(EWarning, "Relocation in invalid section.\n"); + break; + } + } + reorderRelocs(relocation, relocsection, aNumberOfRelocs); + } + +TUint E32ImageFile_PE::FixAddress(PEFile &aPeFile, TUint va) +// +// Fix the given virtual address for the new headers +// + { + + // Allow the section find routine to use heuristics to resolve addresses + // which have been offset by the compiler + TInt section=aPeFile.FindSectionByVa(va, 1); + switch(section) + { + case KTextSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KTextSection]->VirtualAddress; + va+=iHdr->iCodeBase; + break; + case KConstSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KConstSection]->VirtualAddress; + if (gX86imp) + { + TUint old_iat_size=(gX86num_imports+gX86num_imp_dlls)<<2; + if (vaiTextSize; +// fprintf(stderr,"IAT OFF %x ",va); + va=gX86imp_relocs[va>>2]+iHdr->iCodeBase+offset; +// fprintf(stderr,"-> %x\n",va); + break; + } + } + va+=iHdr->iCodeBase+ConstOffset(); +// fprintf(stderr,"const reloc -> %x\n",va); + break; + case KDataSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KDataSection]->VirtualAddress; + va+=iHdr->iDataBase; //DataOffset(); + break; + case KCrtSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KCrtSection]->VirtualAddress; + va+=iHdr->iCodeBase+iCrtOffset; + break; + case KBssSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KBssSection]->VirtualAddress; + va+=iHdr->iDataBase+iHdr->iDataSize; + break; + case KImportSection: + va-=aPeFile.iLinkedBase; + va=FixImportThunk(aPeFile, va-aPeFile.iSectionHeader[KImportSection]->VirtualAddress); + va+=iHdr->iCodeBase; + break; + default: + if (va < 0x10000u) + { + // assume it's a relocation relative to an omitted section + break; + } + Print(EWarning, "Address to relocate cannot be resolved to .text, .rdata, .idata or data sections\n"); + Print(EWarning, "Problem address = %08x (section %d)\n", va, section); + break; + } + // va is now an offset from the start of the text + return va; + } + + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/pefile/pe_tran.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_tran.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,453 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include +#include "e32image.h" +#include +#include +#include "pe_defs.h" +#include "pe_file.h" +#include "h_ver.h" +#include "h_utl.h" + +int gAlignConstSection=FALSE; +TUint gConstSectionAddressMask=0; +static TUint gRequiredConstPadding; + +extern char* gX86imp; +extern int gX86num_imp_dlls; +extern int gX86imp_size; +extern int gX86num_imports; + +E32ImageFile* E32ImageFile::New() + { + return new E32ImageFile_PE; + } + +E32ImageFile_PE::E32ImageFile_PE() + { + } + +E32ImageFile_PE::~E32ImageFile_PE() + { + } + +TUint E32ImageFile_PE::ImportAddressTableOffset() +// +// Return the offset of the iat +// + { + return iHdr->iTextSize; + } + +TUint E32ImageFile_PE::ConstOffset() +// +// return the offset of the const data +// + { + return iConstOffset; + } + +void E32ImageFile_PE::CreateExportDirectory(char *aPtr, PEFile &aPeFile) +// +// create a new format export directory +// + { + + if (iHdr->iExportDirCount==0) + return; + TUint *src=(TUint *)aPeFile.iSectionData[KExportSection]; + TUint *dst=(TUint *)aPtr; + PIMAGE_EXPORT_DIRECTORY dir=(PIMAGE_EXPORT_DIRECTORY)src; + src+=(((TInt)dir->AddressOfFunctions)-((TInt)aPeFile.iSectionHeader[KExportSection]->VirtualAddress))/4; + TUint i; + for (i=0; iNumberOfFunctions; i++) + { + TUint va=*src++; + dst[i]=va; + } + FixExportDirectory(dst, aPeFile); + } + +void E32ImageFile_PE::FixExportDirectory(TUint *aExportDir, PEFile &aPeFile) +// +// Fix the export directory +// + { + + TUint lb = aPeFile.iLinkedBase; + TUint *exportdir=aExportDir; + TInt n; + for (n=0; n<(TInt)iHdr->iExportDirCount; n++) + { + TUint va=*exportdir; + if (!gLittleEndian) ByteSwap(va); + + // va is the address of an exported item, so assume it can't have been offset + TInt i=aPeFile.FindSectionByVa(va+lb); + if (i==KTextSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress; + else if (i==KConstSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress+ConstOffset(); + else if (i==KDataSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress+DataOffset(); + else if (i==KBssSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress+BssOffset(); + else + { + if (va == 0) + Print(EWarning, "No export specified for ordinal %d\n", n+1, va); + else + Print(EError, "Export %d (address %08x) is not from .text, .rdata, or data sections\n", n+1, va); + } + if (!gLittleEndian) ByteSwap(va); + *exportdir++=va; + } + } + +TInt E32ImageFile_PE::DoCodeHeader(PEFile &aPeFile) +// +// Calculate the code parts of the pefile +// + { + + // .text + TInt size=ALIGN4(aPeFile.iSectionHeader[KTextSection]->Misc.VirtualSize); + + // .rdata + iConstOffset=0; + if (gAlignConstSection) + { + // Compute the amount of padding to put before the + // const section to align it correctly + TUint oldAddressBits = aPeFile.iSectionHeader[KConstSection]->VirtualAddress & gConstSectionAddressMask; + TUint oldConstAddress = size; + TUint newConstAddress = oldConstAddress; + // slow but sure + while ((newConstAddress & gConstSectionAddressMask) != oldAddressBits) + { + newConstAddress++; + } + gRequiredConstPadding = newConstAddress - oldConstAddress; + size += gRequiredConstPadding; + } + if (aPeFile.iSectionHeader[KConstSection]) + { + iConstOffset = size; + size += ALIGN4(aPeFile.iSectionHeader[KConstSection]->Misc.VirtualSize); + } + + // .crt + iCrtOffset=0; + if (aPeFile.iSectionHeader[KCrtSection]) + { + iCrtOffset = size; + size += ALIGN4(aPeFile.iSectionHeader[KCrtSection]->Misc.VirtualSize); + } + + iHdr->iTextSize=size; // The "text" part of the E32 code section combines PE's .text + .rdata + .crt. + // The remainder of the E32 code section is the IAT + export directory. + + // Import Address Table (IAT) + TInt nimports=gX86imp?gX86num_imports:aPeFile.NumberOfImports(); + if (nimports!=0) + size+=nimports*4+4; // null terminated + + // Export Dir + if (iHdr->iExportDirCount) + { + iHdr->iExportDirOffset = iHdr->iCodeOffset + size; + size += ALIGN4(iHdr->iExportDirCount*4); + } + iHdr->iCodeSize=size; + return size; + } + +TInt E32ImageFile_PE::DoDataHeader(PEFile &aPeFile, TUint aDataBase) +// +// +// + { + + if (aDataBase == (TUint)0) + aDataBase=iHdr->iCodeBase+iHdr->iCodeSize; + TInt size=0; + if (PEFile::HasInitialisedData(aPeFile.iSectionHeader[KDataSection])) + { + size=ALIGN4(aPeFile.iSectionHeader[KDataSection]->Misc.VirtualSize); + iHdr->iDataBase=aDataBase; + iHdr->iDataOffset = iHdr->iCodeOffset + iHdr->iCodeSize; + TInt bsssize=aPeFile.iSectionHeader[KDataSection]->Misc.VirtualSize-aPeFile.iSectionHeader[KDataSection]->SizeOfRawData; + // drop any uninitialised data + if (bsssize>0) + { + iHdr->iBssSize+=bsssize; + size=ALIGN4(aPeFile.iSectionHeader[KDataSection]->SizeOfRawData); + } + iHdr->iDataSize=size; + } + else if (aPeFile.iSectionHeader[KDataSection]) + { // just .bss + iHdr->iDataBase=aDataBase; + TInt bsssize=aPeFile.iSectionHeader[KDataSection]->Misc.VirtualSize; + iHdr->iBssSize+=bsssize; + } + if (aPeFile.iSectionHeader[KBssSection]) + { + iHdr->iBssSize+=ALIGN4(aPeFile.iSectionHeader[KBssSection]->Misc.VirtualSize); + if (iHdr->iDataBase==0) // .bss but no .data + iHdr->iDataBase=aDataBase; + } + return size; + } + +TInt E32ImageFile_PE::CopyCode(char *p, PEFile &aPeFile) +// +// Copies the files code sections to p +// returns the number of bytes copied or KErrGeneral +// + { + + // text + TInt size=aPeFile.iSectionHeader[KTextSection]->Misc.VirtualSize; + memcpy(p, aPeFile.iSectionData[KTextSection], size); + TInt text_offset=ALIGN4(size); + p+=text_offset; + + // rdata + if (aPeFile.iSectionData[KConstSection]) + { + if (gAlignConstSection) + { + // add padding ahead of const section + p += gRequiredConstPadding; + } + TInt size=ALIGN4(aPeFile.iSectionHeader[KConstSection]->Misc.VirtualSize); + memcpy(p, aPeFile.iSectionData[KConstSection], size); + p+=size; + } + if (aPeFile.iSectionData[KCrtSection]) + { + TInt size=ALIGN4(aPeFile.iSectionHeader[KCrtSection]->Misc.VirtualSize); + memcpy(p, aPeFile.iSectionData[KCrtSection], size); + p+=size; + } + + // iat + TInt nimports=gX86imp?gX86num_imports:aPeFile.NumberOfImports(); +// TInt nimports=aPeFile.NumberOfImports(); + if (nimports) + { + if (gX86imp) + { + TUint *rdata=(TUint*)aPeFile.iSectionData[KConstSection]; + int i; + int* s=(int*)gX86imp; + s++; + for (i=0; i>2]&0x7fffffffu; // rdata offset to ordinal + ++s; + p+=4; + } + } + *(int*)p=0; + p+=4; + } + else + { + TInt r=CopyImportAddrTable(p, aPeFile); + p+=ALIGN4(nimports*4+4); + if (r!=KErrNone) + return Print(EError, "%s is importing symbols by name.\n", iFileName); + } + } + // export dir + CreateExportDirectory(p, aPeFile); + p+=iHdr->iExportDirCount*4; + return iHdr->iCodeSize; + } + +TInt E32ImageFile_PE::CopyData(char *p, PEFile &aPeFile) + { + + if (iHdr->iDataSize) + memcpy(p, aPeFile.iSectionData[KDataSection], iHdr->iDataSize); + return iHdr->iDataSize; + } + +TInt E32ImageFile_PE::Translate(const char* aFileName, TUint aDataBase, TBool aAllowDllData, TBool /*aSymLkupEnabled*/) +// +// Translate a PE format file to a E32Image file +// + { + iSource = EPeFile; + PEFile pefile; + if (!pefile.Init((const char * const)aFileName)) + return KErrGeneral; + TInt r=pefile.ReadSectionHeaders(); + if (r!=KErrNone) return r; + r=pefile.ReadData(); + if (r!=KErrNone) return r; + pefile.Close(); + r=pefile.Normalise(); + if (r!=KErrNone) return r; + iFileName = strdup(aFileName); + + Adjust(ALIGN4(sizeof(E32ImageHeaderV))); // fixed for now because holes not supported + SetDefaultHeader(); + if (gX86imp) + iHdr->iDllRefTableCount=gX86num_imp_dlls; + else + iHdr->iDllRefTableCount=pefile.NumberOfImportDlls(); + iHdr->iExportDirCount=pefile.NumberOfExports(); + iHdr->iCodeBase=pefile.iLinkedBase; + TInt nimports=gX86imp?gX86num_imports:pefile.NumberOfImports(); + + TInt importSectionSize; + char *newImportSection=CreateImportSection(pefile, importSectionSize); + + TInt size = ALIGN4(sizeof(E32ImageHeaderV)); // fixed for now because holes not supported + iHdr->iCodeOffset = size; + TInt pos = size; + size+=DoCodeHeader(pefile); + TInt t=DoDataHeader(pefile, aDataBase); + if (t>0) + { + iHdr->iDataOffset = size; + size += t; + } + if (importSectionSize!=0) + { + iHdr->iImportOffset = size; + size += importSectionSize; + } + + char *newCodeRelocs=NULL; + char *newDataRelocs=NULL; + TInt codeRelocSize=0, dataRelocSize=0; + TInt nrelocs=pefile.NumberOfRelocs(); + if (nrelocs) + { + TUint *relocs=new TUint [nrelocs]; + TUint *relocsection=new TUint [nrelocs]; + pefile.GetRelocs(relocs, relocsection, nrelocs); + FixRelocs(pefile, relocs, relocsection, nrelocs); + newCodeRelocs=CreateCodeRelocs(relocs, relocsection, nrelocs, codeRelocSize); + newDataRelocs=CreateDataRelocs(relocs, relocsection, nrelocs, dataRelocSize); + if (codeRelocSize) + { + iHdr->iCodeRelocOffset = size; + size += codeRelocSize; + } + if (dataRelocSize) + { + iHdr->iDataRelocOffset = size; + size += dataRelocSize; + } + delete [] relocs; + delete [] relocsection; + } + + Adjust(size); + t=CopyCode(iData + pos, pefile); + if (t<0) + return KErrGeneral; + pos += t; + pos += CopyData(iData + pos, pefile); + if (nimports) + { + memcpy(iData + pos, newImportSection, importSectionSize); + pos += importSectionSize; + } + if (codeRelocSize) + { + memcpy(iData + pos, newCodeRelocs, codeRelocSize); + pos += codeRelocSize; + } + if (dataRelocSize) + { + memcpy(iData + pos, newDataRelocs, dataRelocSize); + pos += dataRelocSize; + } + + // locate the entry point + // entry point must be in the text section + TInt entryPointSectionIndex=pefile.FindSectionByVa(pefile.iEntryPoint+pefile.iLinkedBase); + TUint entryPointOffset=pefile.iEntryPoint-pefile.iSectionHeader[entryPointSectionIndex]->VirtualAddress; + if (entryPointSectionIndex!=KTextSection) + return Print(EError, "Entry Point not in code section\n"); + + // Arrange a header for this E32 Image + switch (pefile.iCpu) + { + case IMAGE_FILE_MACHINE_I386: + iHdr->iCpuIdentifier = (TUint16)ECpuX86; + break; + case 0x0a00: + iHdr->iCpuIdentifier = (TUint16)ECpuArmV4; + break; + case 0x0b00: + iHdr->iCpuIdentifier = (TUint16)ECpuMCore; + break; + default: + iHdr->iCpuIdentifier = (TUint16)ECpuUnknown; + break; + } + + // Import format is PE-derived without redundant ordinal lists + // ABI is GCC98r2 ABI (on ARM) + iHdr->iFlags |= KImageImpFmt_PE2; + + if (pefile.iImageIsDll) + { + iHdr->iFlags|=KImageDll; + if (iHdr->iDataSize && !aAllowDllData) + return Print(EError, "Dll '%s' has initialised data.\n", iFileName); + if (iHdr->iBssSize && !aAllowDllData) + return Print(EError, "Dll '%s' has uninitialised data.\n", iFileName); + } + iHdr->iHeapSizeMin=pefile.iHeapCommittedSize; + iHdr->iHeapSizeMax=pefile.iHeapReservedSize; + iHdr->iStackSize=pefile.iStackCommittedSize; + iHdr->iEntryPoint=entryPointOffset; + r = DetermineEntryPointType(); + if (r == KErrCorrupt) + return Print(EError, "File '%s': Bad Entry Point.\n", iFileName); + else if (r == KErrNotSupported) + return Print(EError, "File '%s': Bad Entry Point Type.\n", iFileName); + + delete [] newImportSection; + delete [] newCodeRelocs; + delete [] newDataRelocs; + + return KErrNone; + } + +TBool E32ImageFile_PE::Translate(PEFile &aPeFile) +// +// +// + { + + return Translate((const char*)aPeFile.iFileName, (TUint)0, EFalse, EFalse); + } + diff -r fa7a3cc6effd -r 6d08f4a05d93 bintools/petools/pefile/pe_utl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_utl.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,94 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include "pe_file.h" +#include +#include "e32image.h" +#include "h_utl.h" + +TInt PEFile::CmpSectionName(PIMAGE_SECTION_HEADER apSectionHeader, char *aName) +// +// Returns true if the name of the pe section is the same as aName +// + { + + return (strnicmp((const char *)apSectionHeader->Name, aName, IMAGE_SIZEOF_SHORT_NAME)==0); + } + +TInt PEFile::VirtualAddressInSection(TUint aVA, PIMAGE_SECTION_HEADER aHeader) +// +// Returns true if the virtual address is in the section +// + { + + TUint start = iLinkedBase + aHeader->VirtualAddress; + TUint finish = start + aHeader->Misc.VirtualSize; + return (aVA>=start) && (aVAVirtualAddress; + TUint finish = start + aHeader->Misc.VirtualSize; + if (aVA>=start) + { + if (aVA= 0x1000u) + s = -1; // too far for comfort + } + return s; + } diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/eruntest/eruntest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/eruntest.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,327 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include + +#ifdef __MSVCDOTNET__ + #include + #include + using namespace std; +#else //!__MSVCDOTNET__ + #include + #include +#endif //__MSVCDOTNET__ + +#include +#include + +#if defined(__VC32__) && !defined(__MSVCDOTNET__) +#pragma warning( disable : 4710 ) // 'fn': function not inlined +#endif // old MSVC + +const unsigned int KMaxLineLen=256; +const unsigned int KTimeout=600000; // 10 minutes + + +void NumFileLines(ifstream& inStream, unsigned int &aNumLines) + { + // finds out how many lines are in the file specified + + aNumLines=0; + inStream.clear(); + inStream.seekg(0); + + char str[KMaxLineLen]; + while (!inStream.eof()) + { + inStream.getline(str, KMaxLineLen); + aNumLines++; + } + } + +void GetTestData(ifstream& inStream, char (*aDataArray)[KMaxLineLen], unsigned int &aNumTests) + { + // fill the test data structure from the file stream + + aNumTests=0; + inStream.clear(); + inStream.seekg(0); + + char str[KMaxLineLen]=""; + while (!inStream.eof()) + { + bool charsPresent=0; + inStream.getline(str, KMaxLineLen); + if (strlen(str)) + { + unsigned int len=strlen(str); + for (unsigned int i=0; iKMaxLineLen) + r=1; + + if (!r) + if (KMaxLineLen > (strlen(KTestOutFileName)+strlen(tmpDir))) + { + strcpy(aOutFile, tmpDir); + strcat(aOutFile, KTestOutFileName); + } + else + r=1; + return(r); + } + +void RemoveLeadingSpaces(char* aStr) + { + // removes leading whitespace from a string + + int spaces=0; + while (isspace(aStr[spaces])) + spaces++; + int newLen=strlen(aStr)-spaces; + for (int j=0;j<=newLen;j++) + aStr[j]=aStr[j+spaces]; + } + +int TestSucceeded(char* aLastLineBut1) + { + // checks whether an EPOC RTest has succeeded by comparing the + // last line but 1 in the EPOCWIND.OUT file with a template success + // string + + int r=0; + const char KSuccessResult[20]="RTEST: SUCCESS :"; + + char testStr[KMaxLineLen]; + strcpy(testStr,aLastLineBut1); + RemoveLeadingSpaces(testStr); + testStr[strlen(KSuccessResult)]='\0'; + if (strcmp(testStr, KSuccessResult)==0) + r=1; + return(r); + } + +int GetPenultimateLines(char* aFile, char* aLastLineBut1, char* aLastLineBut2) + { + // Gets the two penultimate lines in a file. + // Returns 0 if successful, 1 otherwise. + + int r=0; + + aLastLineBut1[0]='\0'; + aLastLineBut2[0]='\0'; + + ifstream fileStream(aFile); + if (!fileStream) + r=1; + + if (!r) + { + char lastLine[KMaxLineLen]=""; + while (!fileStream.eof()) + { + strcpy(aLastLineBut2, aLastLineBut1); + strcpy(aLastLineBut1, lastLine); + fileStream.getline(lastLine, KMaxLineLen); + } + } + return(r); + } + +int main(int argc, char *argv[]) + { + FILE *stream = NULL; + if (argc != 2) + { + cerr << "Syntax: eruntest " << endl; + return(1); + } + // Check if input file exists + if( (stream = fopen(argv[1], "r" )) == NULL) + { + cerr << "ERROR: Cannot open input file " << argv[1] << endl; + return(1); + } + else + fclose(stream); +// stream the input file + ifstream inFile(argv[1]); + + // get the number of lines in the input file + unsigned int numLines=0; + NumFileLines(inFile, numLines); + + // allocate space for the tests names + char (*pTests)[KMaxLineLen]; + pTests = new char[numLines][KMaxLineLen]; + if (!pTests) + { + cerr << "ERROR: Out of memory" << endl; + return(1); + } + + // populate the data structure for the tests + unsigned int numTests=0; + GetTestData(inFile, pTests, numTests); + + // Get the test output file name + char testOutFile[KMaxLineLen]; + if (GetTestOutFileName(testOutFile)!=0) + { + cerr << "Error getting temporary path" << endl; + return(1); + } + + // Get the current directory + char currentDir[KMaxLineLen]=""; + GetCurrentDirectory(KMaxLineLen, currentDir); + strcat(currentDir, "\\"); + + // Retrieve the STARTUPINFO structure for the current process + STARTUPINFO startUpInfo; + PROCESS_INFORMATION procInfo; + GetStartupInfo(&startUpInfo); + + unsigned failCount=0; + unsigned timeoutCount=0; + unsigned cantStartCount=0; + unsigned unknownCount=0; + + // run each test in turn + for (unsigned int i=0; i" << endl; + unknownCount++; + } + else + { + // make the comparison + if (TestSucceeded(lastLineBut1)) + cout << "PASSED: " << currentDir << pTests[i] << endl; + else + { + cout << "FAILED(RTest): " << currentDir << pTests[i] << endl; + cout << " " << lastLineBut2 << endl; + cout << " " << lastLineBut1 << endl; + cout << endl; + failCount++; + } + } + break; + case WAIT_FAILED: + cout << "FAILED: " << currentDir << pTests[i] << endl; + if (GetPenultimateLines(testOutFile, lastLineBut1, lastLineBut2)!=0) + { + cout << " " << endl; + } + else + { + cout << " " << lastLineBut2 << endl; + cout << " " << lastLineBut1 << endl; + cout << endl; + } + failCount++; + break; + case WAIT_TIMEOUT: + cout << "TIMED OUT: " << currentDir << pTests[i] << endl; + if (GetPenultimateLines(testOutFile, lastLineBut1, lastLineBut2)!=0) + { + cout << " " << endl; + } + else + { + cout << " " << lastLineBut2 << endl; + cout << " " << lastLineBut1 << endl; + cout << endl; + } + timeoutCount++; + if (!TerminateProcess(procInfo.hProcess, 1)) + { + cout << "FROZEN: " << currentDir << endl; + cout << " Cannot terminate - kill via Task Manager" << endl; + cout << endl; + } + break; + } + } + + delete [] pTests; + + cout << endl; + cout << "TotalErrors " << dec << (failCount+timeoutCount+unknownCount+cantStartCount) << endl; + cout << " Failures " << dec << failCount << endl; + cout << " Timeouts " << dec << timeoutCount << endl; + cout << " Unknown " << dec << unknownCount << endl; + cout << " Can't start " << dec << cantStartCount << endl; + cout << endl; + + return(0); + } diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/eruntest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +eruntest.mmp + +PRJ_TESTMMPFILES + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/eruntest/group/eruntest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/group/eruntest.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,24 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET eruntest.exe +TARGETTYPE exe +SOURCEPATH ../../eruntest +SOURCE eruntest.cpp + + + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/eruntest/group/eruntest.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/group/eruntest.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_eruntest + +source /src/tools/build/deprecated/eruntest +exports /src/tools/build/deprecated/eruntest/group +binary /src/tools/build/deprecated/eruntest/group all + +notes_source \component_defs\release.src + +ipr T diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/etouch/etouch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/etouch.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,46 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#if defined(__MSVCDOTNET__) || defined (__TOOLS2__) + #include + using namespace std; +#else //!__MSVCDOTNET__ + #include +#endif //__MSVCDOTNET__ + +#if defined(__VC32__) || defined(__TOOLS2__) + #include +#else + #include +#endif + +#if defined(__VC32__) && !defined(__MSVCDOTNET__) +#pragma warning( disable : 4710 ) // 'fn': function not inlined +#endif // old MSVC + +int main(int argc,char *argv[]) +// +// Collect the filename from the command line +// and change its date/time stamp to the current date/time +// + { + + if (argc!=2) + { + cout << "Syntax: etouch filename" << endl; + return(1); + } + return(utime(argv[1],NULL)==(-1) ? 1 : 0); + } diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/etouch/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +etouch.mmp + +PRJ_TESTMMPFILES + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/etouch/group/etouch.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/group/etouch.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,23 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET etouch.exe +TARGETTYPE exe +SOURCEPATH ../../etouch +SOURCE etouch.cpp + + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/etouch/group/etouch.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/group/etouch.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_etouch + +source /src/tools/build/deprecated/etouch +exports /src/tools/build/deprecated/etouch/group +binary /src/tools/build/deprecated/etouch/group all + +notes_source \component_defs\release.src + +ipr T diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/fix_eabi_think_offsets/fix_eabi_thunk_offsets.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/fix_eabi_think_offsets/fix_eabi_thunk_offsets.bat Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,427 @@ +:: Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +:: All rights reserved. +:: This component and the accompanying materials are made available +:: under the terms of "Eclipse Public License v1.0" +:: which accompanies this distribution, and is available +:: at the URL "http://www.eclipse.org/legal/epl-v10.html". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: + +@rem = '--*-Perl-*-- +@echo off +if "%OS%" == "Windows_NT" goto WinNT +perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 +goto endofperl +:WinNT +perl -x -S "%0" %* +if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl +if %errorlevel% == 9009 echo You do not have Perl in your PATH. +goto endofperl +@rem '; +#!perl +#line 28 + +use strict; +use Getopt::Long; + +my $toolVersion = "1.0"; + +my $update = 0; +my $use_perforce = 0; +my $verbose = 0; +my $defFile; + +# 1. Check arguments, output help etc. + +GetOptions ( + 'update' => \$update, # modify the files + 'perforce' => \$use_perforce, # apply "p4 edit" to changed files + 'v+' => \$verbose, # print extra diagnostic info + 'match=s' => \$defFile # only process DEF files matching a pattern + ); + +if (@ARGV == 0) + { + print STDERR "\nfix_eabi_thunk_offsets.bat - Version $toolVersion\n"; + + print STDERR << 'END_OF_HELP'; + +Usage: fix_eabi_think_offsets [-update] [-perforce] [-match exp] build_log ... + +Parse the output from one or more build logs, extracting MAKEDEF errors and +warnings which relate to EABI virtual function override thunks. Using this +information, prepare modified DEF files in which each "missing" export is +replaced by a corresponding "unfrozen" export. + +-update Overwrite the existing .def files with the modified versions +-perforce Apply "p4 edit" to each of the modified .def files +-match exp Process only .def files with names that contain "\exp" + +NOTE: The tool assumes that the original build source layout is replicated on +the drive where it is being executed. + +Build logs will sometimes contain corrupted warning messages, in which case +the tool will probably report that there is nothing to replace some missing +symbol. It may help to edit the log file and try again: it is always safe to +run this tool more than once on the same log file. + +END_OF_HELP + + exit(1); + } + +my $parseWarnings = 1; +my $parseErrors = 1; + + +# 2. Parse the build logs, extracting the Makedef warnings & errors + +my $line; +my $header; +my $parseWarning = 0; +my $parseError = 0; +my $variant; +my $component; +my $sourceDefFile; +my @errorOutput; +my @warningOutput; + +my %DefFiles; +my %TempDefFiles; + +sub newDefFile($) + { + my ($defFile) = @_; + if (!defined $DefFiles{$defFile}) + { + @{$DefFiles{$defFile}} = \(); + } + } + +while ($line = <>) + { + if ($line =~ /^Chdir /) + { + $component = $line; + $component =~ s/^Chdir //; + $component =~ s/\s//g; + next; + } + + if (($line =~ /^ make/) && ($line =~ / CFG\=/)) + { + $variant = $line; + $variant =~ s/^.*CFG\=//; + $variant =~ s/ .*$//; + $variant =~ s/\s//g; + next; + } + + if ($parseWarnings && ($line =~ /MAKEDEF WARNING:/)) + { + $parseWarning = 1; + $parseError = 0; + $header = $line; + next; + } + + if ($parseErrors && ($line =~ /MAKEDEF ERROR:/)) + { + $parseWarning = 0; + $parseError = 1; + $header = $line; + next; + } + + if ($line !~ /^ /) + { + $parseWarning = 0; + $parseError = 0; + next; + } + + if ($parseWarning) + { + if ($header) + { + if ($defFile && ($header !~ /\\$defFile/i)) + { + $parseWarning = 0; + $parseError = 0; + next; + } + + $sourceDefFile = $header; + $sourceDefFile =~ s/^.*not yet Frozen in//; + $sourceDefFile =~ s/://; + $sourceDefFile =~ s/\s//g; + + push @warningOutput, "--\n$sourceDefFile ($variant)\n$component\n$header"; + newDefFile($sourceDefFile); + $header = ""; + } + + next if ($line =~ /\*\*\*/); + if ($line =~ /^ (\S.*}\.def)(\(\d+\) : \S+.*)$/) + { + push @{$DefFiles{$sourceDefFile}}, "W$2"; + $TempDefFiles{$1} = $sourceDefFile; + } + push @warningOutput, $line; + + next; + } + + if ($parseError) + { + if ($defFile && ($line !~ /\\$defFile/i)) + { + $parseWarning = 0; + $parseError = 0; + next; + } + + if ($header) + { + $sourceDefFile = $line; + $sourceDefFile =~ s/\(.*$//; + $sourceDefFile =~ s/\s//g; + + push @errorOutput, "--\n$sourceDefFile ($variant)\n$component\n$header"; + newDefFile($sourceDefFile); + $header = ""; + } + + next if ($line =~ /\*\*\*/); + if ($line =~ /(\(\d+\) : \S+.*)$/) + { + push @{$DefFiles{$sourceDefFile}}, "E$1"; + } + push @errorOutput, $line; + + next; + } + + # Catch a orphaned warning line... + + if ($line =~ /^ (\S.*}\.def)(\(\d+\) : \S+.*)$/) + { + my $tempDefFile = $1; + my $newline = $2; + + next if ($defFile && ($tempDefFile !~ /\\$defFile/i)); + + my $sourceDefFile = $TempDefFiles{$tempDefFile}; + push @{$DefFiles{$sourceDefFile}}, "W$newline"; + push @warningOutput, $line; + } + + } + +close BUILD_LOG; + +# 3. Process the information for each DEF file + +my %Classes; +my @DefFileList; + +foreach my $def (sort keys %DefFiles) + { + my @replacements; + my @errors; + my @warnings; + my $problems = 0; + + print "\n----\n$def\n"; + if ($verbose > 1) + { + print "Information extracted from Makedef warnings and errors:\n"; + # printed inside the following loop... + } + + # Process into lists of errors and warnings which can be sorted + + my $previousline = ""; + foreach $line (sort @{$DefFiles{$def}}) + { + next if ($line eq $previousline); # skip duplicates + $previousline = $line; + print "\t$line\n" if ($verbose > 1); + + if ($line =~ /^(.)\((\d+)\) : (((_ZTh|_ZTv)([n0-9_]+)_(NK?(\d+)(\S+)))\s.*)$/) + { + my $msgtype = $1; + my $lineno = $2; + my $defline = $3; + my $symbol = $4; + my $thunkprefix = $5; + my $thunkoffset = $6; + my $unthunked = $7; + my $topnamelen = $8; + my $restofsymbol = $9; + + if ($msgtype eq "E") + { + push @errors, "$unthunked\@$thunkprefix $thunkoffset $lineno $symbol"; + } + else + { + push @warnings, "$unthunked\@$thunkprefix $thunkoffset $symbol"; + } + + my $class = substr $restofsymbol, 0, $topnamelen; + $Classes{$class} = 1; + } + else + { + print "WARNING: Ignored - not a thunk: $line\n"; + } + } + + # Match up the errors and warnings for related symbols + + @errors = sort @errors; + @warnings = sort @warnings; + my $error; + my $warning; + while (scalar @errors && scalar @warnings) + { + # Unpack the first entry in each of the lists + + $error = shift @errors; + my ($ekey, $eoffset, $eline, $esymbol) = split / /, $error; + $warning = shift @warnings; + my ($wkey, $woffset, $wsymbol) = split / /, $warning; + + # Are they for the same thunk? + + if ($ekey lt $wkey) + { + # no - unmatched error, so put back the warning + unshift @warnings, $warning; + print "Nothing to replace missing symbol on $eline : $esymbol\n"; + $problems += 1; + next; + } + + if ($ekey gt $wkey) + { + # no - unmatched warning, so put back the error + unshift @errors, $error; + print "Nothing missing for replacement symbol : $wsymbol\n"; + $problems += 1; + next; + } + + # Yes - create replacement instruction + + push @replacements, "$eline $esymbol => $wsymbol"; + } + + # drain remaining problems, if any + + foreach my $error (@errors) + { + my ($ekey, $eoffset, $eline, $esymbol) = split / /, $error; + print "Nothing to replace missing symbol on $eline : $esymbol\n"; + $problems += 1; + } + foreach my $warning (@warnings) + { + my ($wkey, $woffset, $wsymbol) = split / /, $warning; + print "Nothing missing for replacement symbol : $wsymbol\n"; + $problems += 1; + } + + if ($verbose) + { + print "\nSubstitions identified:\n\t"; + print join("\n\t", sort @replacements); + print "\n"; + } + + open DEFFILE, "<$def" or print "Can't open $def: $!\n" and next; + my @deflines = ; + close DEFFILE; + my $changedlines = 0; + + foreach my $fix (@replacements) + { + my ($lineno, $before, $to, $after) = split ' ', $fix; + + my $line = @deflines[$lineno-1]; + if ($line =~ /\s($after)\s/) + { + print "$lineno - already fixed\n"; + next; + } + if ($line =~ /\s($before)\s/) + { + $line =~ s/(\s)$before(\s)/$1$after$2/; + @deflines[$lineno-1] = $line; + print "Changed $lineno to $line" if ($verbose > 1); + $changedlines += 1; + next; + } + print "$lineno doesn't contain $before\n"; + $problems += 1; + } + print "\n"; + + if ($problems != 0) + { + print "WARNING: $problems thunks could not be repaired\n"; + } + + if ($changedlines == 0) + { + print "Nothing to change\n"; + next; + } + print "Will change $changedlines lines\n\n"; + + # Now update the file (and edit in Perforce if required) + + if ($update) + { + chmod 0666, $def; # make it writeable + + open DEFFILE, ">$def" or print "Can't open $def for writing: $!\n" and next; + print DEFFILE @deflines; + close DEFFILE; + + print "Updated $def\n"; + push @DefFileList, $def; + + if ($use_perforce) + { + print "* p4 edit $def\n"; + system "p4 edit $def"; + print "\n"; + } + } + } + +# 5. More diagnostic information + +if (scalar @DefFileList) + { + print "\nList of updated def files\n"; + print join("\n", @DefFileList); + print "\n"; + } + +if ($verbose && scalar keys %Classes != 0) + { + print "\nList of affected classes:\n"; + print join("\n", sort keys %Classes), "\n"; + } + +__END__ +:endofperl diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/fix_eabi_think_offsets/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/fix_eabi_think_offsets/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS +TOOLS2 + +PRJ_EXPORTS diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/fix_eabi_think_offsets/group/fix_eabi_thunk_offsets.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/fix_eabi_think_offsets/group/fix_eabi_thunk_offsets.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,10 @@ +component dev_build_sbsv1_fix_eabi_thunk_offsets + +source \src\tools\build\sbsv1\fix_eabi_thunk_offsets +binary \src\tools\build\sbsv1\fix_eabi_thunk_offsets\group all +exports \src\tools\build\sbsv1\fix_eabi_thunk_offsets\group + +notes_source \component_defs\release.src + +ipr T + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/rommask/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +rommask.mmp + +PRJ_TESTMMPFILES + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/rommask/group/rommask.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/group/rommask.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,24 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET rommask.exe +TARGETTYPE exe +SOURCEPATH ../../rommask +SOURCE rommask.cpp +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/rommask/group/rommask.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/group/rommask.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_rommask + +source /src/tools/build/deprecated/rommask +exports /src/tools/build/deprecated/rommask/group +binary /src/tools/build/deprecated/rommask/group all + +notes_source \component_defs\release.src + +ipr T diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/rommask/rommask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/rommask.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,395 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) +#include +#else //!__MSVCDOTNET__ +#include +#endif //__MSVCDOTNET__ + +#include "h_utl.h" +#include "h_ver.h" + +// ROMMASK.EXE cl parameters +char *gRomImage=NULL; +char *gOutputRom=NULL; +int gRomSize=0; +char gFormat='P'; +const int KMaxSections=8; +int gNumberOfSections=0; +int gSectionSize[KMaxSections]; +int gHeader=ETrue; +int gVerbose=EFalse; + + +TInt MaskPlain(TInt aRomSize,ifstream& aPsionImageFile,ofstream& aMaskRomImageFile) +// +// Create a plain mask rom image file +// + { + + const char KMaskRomFillCharacter='\377'; + const TInt KBufferSize=1024; + char empty[KBufferSize]; + for (TInt y=0;y=argc) + error=KErrArgument; + if (error==KErrNone) + { + int val; +// if (!isNumber(argv[param])) +// return KErrArgument; + +#ifdef __TOOLS2__ +istringstream s(argv[param]); +#else +istrstream s(argv[param], strlen(argv[param])); +#endif + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + s >> setbase(0); +#endif //__MSVCDOTNET__ + + s>>val; + if (!s.fail()) + return val; + } + cerr << "Error: Integer argument required for "; + cerr << argv[param-1]; + cerr << "\r\n"; + return -1; + } + +char *getStringArg(int argc, char *argv[], int param) + { + + if (param>=argc) + { + cerr << "Error: String argument required for "; + cerr << argv[param-1]; + cerr << "\r\n"; + return NULL; + } + return argv[param]; + } + +char getCharArg(int argc, char *argv[], int param) + { + + char *p=getStringArg(argc,argv,param); + if (p!=NULL) + return p[0]; + return '\000'; + } + +TInt processCommandLine(int argc, char *argv[]) + { + + if (argc==1) + return KErrArgument; + int param=1; + while (param=KMaxSections) + { + cerr << "Error: Too many sections\r\n"; + return KErrGeneral; + } + param++; + gSectionSize[gNumberOfSections]=getIntegerArg(argc, argv, param); + if (gSectionSize[gNumberOfSections]==-1) + return KErrGeneral; + if (gSectionSize[gNumberOfSections]==0) + { + cerr << "Error: Section is zero bytes long\r\n"; + return KErrGeneral; + } + if (gSectionSize[gNumberOfSections]>64) + { + cerr << "Error: Section too big\r\n"; + return KErrGeneral; + } + gNumberOfSections++; + } + break; + case 'f': + case 'F': + param++; + gRomSize=getCharArg(argc, argv, param); + break; + case 'l': + case 'L': + cerr << "Error: Use -verbose instead of -log"; + break; + case 'v': + case 'V': + gVerbose=ETrue; + break; + case 'o': + case 'O': + param++; + gOutputRom=getStringArg(argc, argv, param); + break; + case 'n': + case 'N': + // -no-header + gHeader=EFalse; + break; + default: + cout << "Error: Unrecognised switch '"<64) + { + cerr << "Error: Rom too big\r\n"; + return KErrGeneral; + } + if (gRomSize==0) + { + cerr << "Error: No rom size specified\r\n"; + return KErrArgument; + } + if (gFormat!='P' && gFormat!='M') + { + cerr << "Error: Invalid mask rom format specified\r\n"; + return KErrArgument; + } + + return KErrNone; + } + +TInt Align1M(TInt aVal) + { + return (aVal+0xfffff) & 0x7ff00000; + } + +TInt main(int argc, char *argv[]) + { + + const TInt KPsionImageFileHeaderSize=0x100; + + cout << "\r\nROMMASK - Rom masker V" << MajorVersion << "." << MinorVersion << "(Build " << Build << ")\r\n"; + cout << Copyright; + + char HelpText[] = + "Syntax: ROMMASK -romimage -output \r\n" + " [-verbose] [-size ]\r\n" + " [-no-header] [-format ] [-section ]*\r\n" + "Format: MOTOROLA (ascii s-record format)\r\n" + " PLAIN (plain binary format) default\r\n"; + int r=processCommandLine(argc, argv); + if (r==KErrArgument) + { + cout << HelpText; + return(KErrArgument); + } + +// Open the psion image file + + ifstream PsionImageFile; + char*& PsionImageFileName=gRomImage; + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + PsionImageFile.open(PsionImageFileName, ios::in | ios::binary); +#else //!__MSVCDOTNET__ + PsionImageFile.open(PsionImageFileName, ios::nocreate | ios::binary); +#endif //__MSVCDOTNET__ + + if (!PsionImageFile) + { + cerr << "Error: Cannot open psion image file (" << PsionImageFileName << ")\r\n"; + return(KErrArgument); + } + + gRomSize*=1024*1024; // in Mb + // resolve sections to cover whole rom + int size=0; + int i; + for (i=0; igRomSize) + { + cerr << "Error: Sections too big for rom"; + return KErrGeneral; + } + +// Create the mask rom image file + + ofstream MaskRomImageFile; + char*& MaskRomImageFileName=gOutputRom; + + MaskRomImageFile.open(MaskRomImageFileName); + if (!MaskRomImageFile) + { + cerr << "Error: Cannot create mask rom image file (" << MaskRomImageFileName << ")\r\n"; + PsionImageFile.close(); + return(KErrArgument); + } + + if (gHeader) + { + PsionImageFile.ignore(KPsionImageFileHeaderSize); + int count=PsionImageFile.gcount(); + if (count!=KPsionImageFileHeaderSize) + { + cerr << "Error: Corrupt Psion image file\r\n"; + return(KErrGeneral); + } + } + + r=KErrNone; + for (i=0; i +#include + +#include +#include +#include +#include "h_utl.h" +#include "h_ver.h" + +// need to pretend we've done e32image.h, to avoid clashes with winnt.h +#define __E32IMAGE_H__ +struct E32ImageFile + { + }; +class CBytePair; +#include "r_rom.h" + +#define READ_BUFFER_SIZE 0x1000 // allows for exuberant T_REPRO without delays in it +#define WRITE_BUFFER_SIZE 0x1000 + +TRomLoad TheRomHeader; +TUint ImageDataSize=0; +TUint FileSize=0; +TText PortNumber='1'; +TUint BaudRate=115200; +TBool Kick=EFalse; +TBool UseHex=EFalse; +TBool Verbose=EFalse; +TBool RawImage=EFalse; +TText* BootstrapName=NULL; + +const TUint KReproWrapperSize = 0x100; // REPRO protocol assumes a wrapper size of 256 bytes + +HANDLE comPort; +TUint32 BytesWritten; + +TText *processCommandLine(int argc, char *argv[]) +// +// Process the command line arguments, printing a helpful message if none are supplied +// + { + + char HelpText[] = + "* Syntax: W32REPRO [options] filename[.bin]\n" + "* \n" + "* Option: -P port number, defaults to COM1,\n" + "* Option: -K kick the other end, to force another repro attempt\n" + "* Option: -B baud rate, minimum 9600, defaults to 115200\n" + "* Option: -RAW raw image with no header\n" + "* Option: -BOOT bootstrap with transmitted at 9600 baud\n" + "* Option: -HEX use base 16 (for use with ReproC)\n" + "* Option: -V display raw protocol messages\n" + "* \n" + "* All messages from W32REPRO begin with '*', every thing else comes from the\n" + "* machine being reprogrammed.\n"; + + TText *filename=NULL; + if (argc == 1) + { + cout << HelpText; + return NULL; + } + for (int i=1; i=9600) + { + BaudRate=rate; + } + else + { + cout << "**** Invalid baud rate: " << argv[i] << "\n*\n"; + cout << HelpText; + return NULL; + } + } + else if (argv[i][1] == '?') + { + cout << HelpText; + return NULL; + } + else + { + cout << "**** Unrecognised argument " << argv[i] << "\n*\n"; + cout << HelpText; + return NULL; + } + } + else // Must be the image filename + filename=(TText *)argv[i]; + } + if (filename==NULL) + { + cout << "**** Missing image filename\n*\n"; + cout << HelpText; + } + return filename; + } + +TInt openComPort() +// +// Open the com port and configure it +// + { + char port[5]="COM1"; + port[3]=PortNumber; + comPort=CreateFile(port,GENERIC_READ+GENERIC_WRITE,0,0,OPEN_EXISTING,0,NULL); + if (comPort==INVALID_HANDLE_VALUE) + return Print(EError,"* Cannot open %s\n",port); + + DCB settings; + if (!GetCommState(comPort,&settings)) + return Print(EError,"* Cannot read settings for %s\n",port); + + if (!SetupComm(comPort,READ_BUFFER_SIZE,WRITE_BUFFER_SIZE)) + return Print(EError,"* Cannot set buffer sizes for %s\n",port); + + settings.fBinary=TRUE; + settings.fParity=FALSE; + settings.fAbortOnError=TRUE; // overrides EV_ERR + settings.BaudRate=BaudRate; + settings.ByteSize=8; + settings.Parity=NOPARITY; + settings.StopBits=ONESTOPBIT; + settings.fRtsControl=RTS_CONTROL_ENABLE; + settings.fDtrControl=DTR_CONTROL_ENABLE; + settings.fOutxCtsFlow=FALSE; + settings.fOutxDsrFlow=FALSE; + settings.fDsrSensitivity=FALSE; + settings.fOutX=FALSE; // no XON/XOFF for transmission + settings.fInX=FALSE; // no XON/XOFF for reception + settings.fNull=FALSE; // don't discard null bytes + + settings.EvtChar='\001'; // REPRO command separator + + if (!SetCommState(comPort,&settings)) + return Print(EError,"* Cannot configure %s\n",port); + + if (!SetCommMask(comPort,EV_RXFLAG+EV_ERR)) + return Print(EError,"* Cannot set CommMask for %s\n",port); + + COMMTIMEOUTS timeouts = { + //20,0,0, // allow up to 20 milliseconds between characters, i.e. buffer them properly + MAXDWORD,0,0, // return immediately + 0,0 // no write timeouts + }; + if (!SetCommTimeouts(comPort,&timeouts)) + return Print(EError,"* Cannot set timeouts for %s\n",port); + + if (!SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_HIGHEST)) + Print(EError,"* Failed to raise priority of this thread err=%d\n",GetLastError()); + if (!SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS)) + Print(EError,"* Failed to raise priority of this process err=%d\n",GetLastError()); + + Print(EScreen,"* Using %s at %d baud\n\n",port,BaudRate); + return KErrNone; + } + +BOOL WriteToComPort(char* data, DWORD length, char* comment) + { + if (Verbose) + { + if (comment==NULL) + Print(EScreen, "* TX=%*s\n", length, data); + else + Print(EScreen, "* TX <%d bytes of %s>\n", length, comment); + } + return WriteFile(comPort, data, length, &BytesWritten, NULL); + } + +TInt Bootstrap9600() + { + DCB settings; + if (!GetCommState(comPort,&settings)) + return Print(EError,"* Cannot read COM settings\n"); + + settings.BaudRate=9600; + if (!SetCommState(comPort,&settings)) + return Print(EError,"* Cannot reconfigure to 9600 baud\n"); + + FILE* bootstrapFile=fopen((const char*)BootstrapName,"rb"); + if (bootstrapFile==NULL) + return Print(EError,"* Cannot open bootstrap file %s for input (errno=%d)\n",BootstrapName,errno); + + Print(EScreen,"* Sending bootstrap %s at 9600 baud\n",BootstrapName,BaudRate); + + char bootdata[WRITE_BUFFER_SIZE]; + TUint32 imageBytes=0; + + while (!feof(bootstrapFile)) + { + imageBytes=fread(bootdata,1,WRITE_BUFFER_SIZE,bootstrapFile); + if (imageBytes==0 && feof(bootstrapFile)) + break; + if (imageBytes!=WRITE_BUFFER_SIZE && ferror(bootstrapFile)) + { + return Print(ESevereError,"* Read only %d bytes of bootstrap err=%d\n",imageBytes,ferror(bootstrapFile)); + } + if (!WriteToComPort(bootdata,imageBytes,"bootstrap data")) + return Print(ESevereError,"* Wrote only %d of %d bytes of bootstrap err=%d\n", + BytesWritten,imageBytes,GetLastError()); + } + fclose(bootstrapFile); + + settings.BaudRate=BaudRate; + if (!SetCommState(comPort,&settings)) + return Print(EError,"* Cannot reconfigure to %d baud\n",BaudRate); + + Print(EScreen,"* Bootstrap downloaded\n\n"); + + return KErrNone; + } + +TInt main(int argc, char *argv[]) + { + TInt err=KErrNone; + + Print(EScreen,"\n* W32REPRO - Win32 version of PREPRO"); + Print(EScreen," V%02d.%02d (Build %03d)\n",MajorVersion,MinorVersion,Build); + Print(EScreen,"* %s",Copyright); + + TText *imageFileName = processCommandLine(argc, argv); + if (imageFileName==NULL) + return KErrGeneral; + + FILE* romFile=fopen((const char*)imageFileName,"rb"); + if (romFile==NULL) + return Print(EError,"* Cannot open ROM Image file %s for input (errno=%d)\n",imageFileName,errno); + + if (RawImage) + TheRomHeader.wrapSize=0; + else + { + if (fread(&TheRomHeader,sizeof(TheRomHeader),1,romFile)!=1) + return Print(EError,"* Cannot read ROM Image header\n"); + if (TheRomHeader.wrapSize!=KRomWrapperSize) + return Print(EError,"* Incorrect ROM header - wrong wrapper size\n"); + } + if (fseek(romFile,0,SEEK_END)!=0) + return Print(EError,"* Cannot seek in ROM Image file\n"); + FileSize=ftell(romFile); + ImageDataSize=FileSize-TheRomHeader.wrapSize; + + Print(EAlways,"\n* ROM Image %s - 0x%06x bytes\n",imageFileName,ImageDataSize); + + err=openComPort(); + if (err!=KErrNone) + return err; + + if (BootstrapName != NULL) + { + err=Bootstrap9600(); + if (err!=KErrNone) + return err; + } + + char romdata[WRITE_BUFFER_SIZE]; + if (Kick) + { + memset(romdata,'!',64); // string of non-numeric characters, won't harm old REPRO + WriteToComPort(romdata,64,NULL); + } + // + // Wait around for REPRO on the other end to send us commands + // + char command[READ_BUFFER_SIZE+1]; + char* cp=command; + TInt length=READ_BUFFER_SIZE; + TUint expectedOffset=0; + TInt done=0; + while (!done) + { + TUint32 bytesRead=0,imageBytes=0,offset=0; + + TUint32 event; + if (!WaitCommEvent(comPort,&event,NULL)) + { + if (GetLastError()!=ERROR_OPERATION_ABORTED) + Print(EAlways,"\n* Unexpected WaitCommEvent failure %d event %x\n",GetLastError(),event); + TUint32 commError; + if (!ClearCommError(comPort,&commError,NULL)) + { + Print(ESevereError,"\n* Failed to clear CommError - give up now!\n"); + return KErrGeneral; + } + if (commError!=CE_OVERRUN) + Print(EAlways,"\n* Unexpected comms error %x\n",commError); + } + if (!ReadFile(comPort,cp,length,&bytesRead,NULL)) + { + if (GetLastError()!=ERROR_OPERATION_ABORTED) + Print(EAlways,"\n* Unexpected ReadFile failure %d bytes %d\n",GetLastError(),bytesRead); + } + if (bytesRead==0) + continue; + + char* next; + char* end = cp+bytesRead; + *end='\0'; // stick a terminator on the end, just in case + + for (cp=(char*)command; (next=(char*)memchr(cp,'\001',end-cp))!=NULL ;cp=next+1) + { + *next='\0'; // drop the terminator + if (Verbose) + Print(EScreen, " * RX=%s\n", cp); + switch (cp[0]) + { + case 'D': // disconnect after successful REPRO + Print(EScreen,"* Disconnect\n"); + done=1; + break; + case 'M': // print message + Print(EScreen,"%s",cp+1); + break; + case 'P': // panic + Print(ESevereError,"%s",cp+1); + break; + case 'R': // request for data from the image at specified address + if (end-next>1) + break; // must be the last command in the buffer + offset=strtoul(cp+1,NULL,UseHex?16:10)-KReproWrapperSize; // REPRO assumes wrapSize=256 + if ((offset&4095)!=0) + { + Print(ESevereError,"* Image offset %x not a multiple of 4k (%s)\n", offset,cp); + break; + } + if (offset>expectedOffset) + { + Print(ESevereError,"* Image offset %x should have been %x\n", offset,expectedOffset); + break; + } + Print(EScreen,"%x \r",offset); // in case we lost the message + expectedOffset=offset+WRITE_BUFFER_SIZE; // what we expect next time + offset+=TheRomHeader.wrapSize; // offset into the file + if (fseek(romFile,offset,SEEK_SET)!=0) + { + Print(ESevereError,"* Can't seek to file offset %x", offset); + break; + } + + memset(romdata,0xff,WRITE_BUFFER_SIZE); + imageBytes=fread(romdata,1,WRITE_BUFFER_SIZE,romFile); + if (imageBytes!=WRITE_BUFFER_SIZE && offset+imageBytes!=FileSize) + { + Print(ESevereError,"* Read only %d bytes of image data err=%d\n",imageBytes,ferror(romFile)); + break; + } + if (!WriteToComPort(romdata,WRITE_BUFFER_SIZE,"image data")) + Print(ESevereError,"* Wrote only %d bytes of image data err=%x\n",BytesWritten,GetLastError()); + break; + case 'S': // request for the size of the image + if (end-next>1) + break; // must be the last command in the buffer + if (next-cp==1) + { + sprintf((char*)romdata,"%010d\n",ImageDataSize+KReproWrapperSize); + if (!WriteToComPort(romdata,strlen(romdata),NULL) + || BytesWritten!=strlen(romdata)) + Print(ESevereError,"* Failed to write file size\n"); + expectedOffset=0; // because we are starting again + break; + } + // otherwise fall through + default: + Print(EAlways,"\n* Unrecognised command >%s<\n", cp); + } + } + if (cp + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/winc/tools_redistribution_cedar.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/winc/tools_redistribution_cedar.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,15 @@ +component tools_redistribution_cedar + +source \sf\os\buildtools\dist_os\redistributionwinceka2\winc + +source \sf\os\buildtools\dist_os\redistributionwinceka2\bld.inf +source \sf\os\buildtools\dist_os\redistributionwinceka2\tools_redistribution_cedar.mrp + +binary \sf\os\buildtools\dist_os\redistributionwinceka2 all +#binary \sf\os\buildtools\dist_os\redistributionwinceka2 cwtools +#exports \sf\os\buildtools\dist_os\redistributionwinceka2 + +notes_source \component_defs\release.src + +ipr T + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/winc/tools_redistribution_winc.history.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/winc/tools_redistribution_winc.history.xml Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,5 @@ + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/winc/tools_redistribution_winc.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/winc/tools_redistribution_winc.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,389 @@ +component tools_redistribution_winc + +# IainW: Workaround - the following are all exported from winc.zip, but we can't yet have more than one exported file from the same place +# They are all IPR category E + +source \sf\os\buildtools\dist_os\redistributionwinceka2\tools_redistribution_winc.mrp + +binary \epoc32\release\winc\udeb\accesspointmonitor.exe +binary \epoc32\release\winc\udeb\agnmodel.dll +binary \epoc32\release\winc\udeb\agnversit.dll +binary \epoc32\release\winc\udeb\aiftool.exe +binary \epoc32\release\winc\udeb\alarmclient.dll +binary \epoc32\release\winc\udeb\alarmserver.dll +binary \epoc32\release\winc\udeb\alarmshared.dll +binary \epoc32\release\winc\udeb\apgrfx.dll +binary \epoc32\release\winc\udeb\apmime.dll +binary \epoc32\release\winc\udeb\apparc.dll +binary \epoc32\release\winc\udeb\bafl.dll +binary \epoc32\release\winc\udeb\bifu.dll +binary \epoc32\release\winc\udeb\big5.cpl +binary \epoc32\release\winc\udeb\big5_shared.dll +binary \epoc32\release\winc\udeb\bitgdi.dll +binary \epoc32\release\winc\udeb\bmtran.dll +binary \epoc32\release\winc\udeb\charconv.dll +binary \epoc32\release\winc\udeb\cnftool.exe +binary \epoc32\release\winc\udeb\conarc.dll +binary \epoc32\release\winc\udeb\connmngmntbox.exe +binary \epoc32\release\winc\udeb\connmngmntbox.tlb +binary \epoc32\release\winc\udeb\connmngmnthelpbox.dll +binary \epoc32\release\winc\udeb\connmngmnthelpbox.lib +binary \epoc32\release\winc\udeb\connmngmnthelpbox.tlb +binary \epoc32\release\winc\udeb\connmngmntres.dll +binary \epoc32\release\winc\udeb\contprosap.dll +binary \epoc32\release\winc\udeb\contprosap.lib +binary \epoc32\release\winc\udeb\contprosap.tlb +binary \epoc32\release\winc\udeb\contprosapres.dll +binary \epoc32\release\winc\udeb\contprosapres.lib +binary \epoc32\release\winc\udeb\contprotest.exe +binary \epoc32\release\winc\udeb\convnames.dll +binary \epoc32\release\winc\udeb\convutils.dll +binary \epoc32\release\winc\udeb\csbmsto.dll +binary \epoc32\release\winc\udeb\csdbcust.dll +binary \epoc32\release\winc\udeb\csdbi.dll +binary \epoc32\release\winc\udeb\csdbw.dll +binary \epoc32\release\winc\udeb\cshlpwtr.exe +binary \epoc32\release\winc\udeb\cssup.dll +binary \epoc32\release\winc\udeb\dbwriter.dll +binary \epoc32\release\winc\udeb\dlog.dll +binary \epoc32\release\winc\udeb\dlogfl.dll +binary \epoc32\release\winc\udeb\dlogsr.dll +binary \epoc32\release\winc\udeb\dlogwn.dll +binary \epoc32\release\winc\udeb\ealm.dll +binary \epoc32\release\winc\udeb\ealwl.dll +binary \epoc32\release\winc\udeb\ecdrv.pdd +binary \epoc32\release\winc\udeb\ecomm.ldd +binary \epoc32\release\winc\udeb\econs.dll +binary \epoc32\release\winc\udeb\edbms.dll +binary \epoc32\release\winc\udeb\edev.lib +binary \epoc32\release\winc\udeb\edll.lib +binary \epoc32\release\winc\udeb\eexe.lib +binary \epoc32\release\winc\udeb\efile.dll +binary \epoc32\release\winc\udeb\efsrv.dll +binary \epoc32\release\winc\udeb\ehwa.ldd +binary \epoc32\release\winc\udeb\ehwac.pdd +binary \epoc32\release\winc\udeb\ekdata.dll +binary \epoc32\release\winc\udeb\ekern.dll +binary \epoc32\release\winc\udeb\ektran.dll +binary \epoc32\release\winc\udeb\elocal.fsy +binary \epoc32\release\winc\udeb\elocl.01 +binary \epoc32\release\winc\udeb\elocl.02 +binary \epoc32\release\winc\udeb\elocl.03 +binary \epoc32\release\winc\udeb\elocl.04 +binary \epoc32\release\winc\udeb\elocl.05 +binary \epoc32\release\winc\udeb\elocl.10 +binary \epoc32\release\winc\udeb\elocl.18 +binary \epoc32\release\winc\udeb\elocl.19 +binary \epoc32\release\winc\udeb\elocl.29 +binary \epoc32\release\winc\udeb\elocl.31 +binary \epoc32\release\winc\udeb\elocl.32 +binary \epoc32\release\winc\udeb\elocl.dll +binary \epoc32\release\winc\udeb\elocl.loc +binary \epoc32\release\winc\udeb\elocl.sc +binary \epoc32\release\winc\udeb\esock.dll +binary \epoc32\release\winc\udeb\estor.dll +binary \epoc32\release\winc\udeb\etext.dll +binary \epoc32\release\winc\udeb\eucjp_packed.cpl +binary \epoc32\release\winc\udeb\euniw.dll +binary \epoc32\release\winc\udeb\euser.dll +binary \epoc32\release\winc\udeb\exdll.lib +binary \epoc32\release\winc\udeb\fbscli.dll +binary \epoc32\release\winc\udeb\fbserv.dll +binary \epoc32\release\winc\udeb\field.dll +binary \epoc32\release\winc\udeb\fntstr.dll +binary \epoc32\release\winc\udeb\form.dll +binary \epoc32\release\winc\udeb\form_and_etext_editor.dll +binary \epoc32\release\winc\udeb\gb12345.cpl +binary \epoc32\release\winc\udeb\gb2312.cpl +binary \epoc32\release\winc\udeb\gb2312_shared.dll +binary \epoc32\release\winc\udeb\gbk.cpl +binary \epoc32\release\winc\udeb\gbk_shared.dll +binary \epoc32\release\winc\udeb\gdi.dll +binary \epoc32\release\winc\udeb\general.pdl +binary \epoc32\release\winc\udeb\hal.dll +binary \epoc32\release\winc\udeb\hz.cpl +binary \epoc32\release\winc\udeb\iso2022jp.cpl +binary \epoc32\release\winc\udeb\iso2022jp1.cpl +binary \epoc32\release\winc\udeb\iso885910.cpl +binary \epoc32\release\winc\udeb\iso885913.cpl +binary \epoc32\release\winc\udeb\iso885914.cpl +binary \epoc32\release\winc\udeb\iso885915.cpl +binary \epoc32\release\winc\udeb\iso88592.cpl +binary \epoc32\release\winc\udeb\iso88593.cpl +binary \epoc32\release\winc\udeb\iso88594.cpl +binary \epoc32\release\winc\udeb\iso88595.cpl +binary \epoc32\release\winc\udeb\iso88596.cpl +binary \epoc32\release\winc\udeb\iso88597.cpl +binary \epoc32\release\winc\udeb\iso88598.cpl +binary \epoc32\release\winc\udeb\iso88599.cpl +binary \epoc32\release\winc\udeb\iwzlib.dll +binary \epoc32\release\winc\udeb\iwzlib.lib +binary \epoc32\release\winc\udeb\jis.cpl +binary \epoc32\release\winc\udeb\jisbase_shared.dll +binary \epoc32\release\winc\udeb\jisx0201.dll +binary \epoc32\release\winc\udeb\jisx0208.dll +binary \epoc32\release\winc\udeb\jisx0212.dll +binary \epoc32\release\winc\udeb\linebreak.dll +binary \epoc32\release\winc\udeb\listcomportsbox.dll +binary \epoc32\release\winc\udeb\listcomportsbox.lib +binary \epoc32\release\winc\udeb\listcomportsbox.tlb +binary \epoc32\release\winc\udeb\mednand.pdd +binary \epoc32\release\winc\udeb\mrouterdeveloper.exe +binary \epoc32\release\winc\udeb\mroutersocket.dll +binary \epoc32\release\winc\udeb\mroutersocket.lib +binary \epoc32\release\winc\udeb\mroutersocket.tlb +binary \epoc32\release\winc\udeb\palette.dll +binary \epoc32\release\winc\udeb\pccustomservertest2.exe +binary \epoc32\release\winc\udeb\pdrstr.dll +binary \epoc32\release\winc\udeb\plp.prt +binary \epoc32\release\winc\udeb\plpcli.dll +binary \epoc32\release\winc\udeb\plpconfig.dll +binary \epoc32\release\winc\udeb\plpexe.dll +binary \epoc32\release\winc\udeb\plplog.dll +binary \epoc32\release\winc\udeb\plpremlink.dll +binary \epoc32\release\winc\udeb\plprfs.rsy +binary \epoc32\release\winc\udeb\plpsvr.dll +binary \epoc32\release\winc\udeb\plpvariant.dll +binary \epoc32\release\winc\udeb\powermgrcli.dll +binary \epoc32\release\winc\udeb\print.dll +binary \epoc32\release\winc\udeb\rpcs.rsy +binary \epoc32\release\winc\udeb\rtsock.dll +binary \epoc32\release\winc\udeb\rtsock.lib +binary \epoc32\release\winc\udeb\rtsock.tlb +binary \epoc32\release\winc\udeb\scdv.dll +binary \epoc32\release\winc\udeb\scrfs.exe +binary \epoc32\release\winc\udeb\scrfs.tlb +binary \epoc32\release\winc\udeb\scrfsproxy.dll +binary \epoc32\release\winc\udeb\scrfsproxy.lib +binary \epoc32\release\winc\udeb\shiftjis.cpl +binary \epoc32\release\winc\udeb\shiftjis_shared.dll +binary \epoc32\release\winc\udeb\socktest.exe +binary \epoc32\release\winc\udeb\tagma.dll +binary \epoc32\release\winc\udeb\testaccesspointlists.exe +binary \epoc32\release\winc\udeb\undo.dll +binary \epoc32\release\winc\udeb\vcal.dll +binary \epoc32\release\winc\udeb\vcard.dll +binary \epoc32\release\winc\udeb\versit.dll +binary \epoc32\release\winc\udeb\wldcomp.exe +binary \epoc32\release\winc\udeb\worldclient.dll +binary \epoc32\release\winc\udeb\worldserver.dll +binary \epoc32\release\winc\udeb\wpeng.dll +binary \epoc32\release\winc\udeb\ws32.dll +binary \epoc32\release\winc\udeb\xmllx.dll +binary \epoc32\release\winc\udeb\z\system\charconv\big5.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\builtin.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\eucjp_packed.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\gb12345.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\gb2312.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\gbk.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\hz.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso2022jp.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso2022jp1.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885910.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885913.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885914.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885915.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88592.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88593.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88594.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88595.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88596.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88597.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88598.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88599.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\jis.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\shiftjis.rsc +binary \epoc32\release\winc\udeb\z\system\printers\general.pdr +binary \epoc32\release\winc\udeb\z\system\printers\general.r01 +binary \epoc32\release\winc\udeb\z\system\printers\general.r10 +binary \epoc32\release\winc\urel\agnmodel.dll +binary \epoc32\release\winc\urel\agnversit.dll +binary \epoc32\release\winc\urel\aiftool.exe +binary \epoc32\release\winc\urel\alarmclient.dll +binary \epoc32\release\winc\urel\alarmserver.dll +binary \epoc32\release\winc\urel\alarmshared.dll +binary \epoc32\release\winc\urel\apgrfx.dll +binary \epoc32\release\winc\urel\apmime.dll +binary \epoc32\release\winc\urel\apparc.dll +binary \epoc32\release\winc\urel\bafl.dll +binary \epoc32\release\winc\urel\bifu.dll +binary \epoc32\release\winc\urel\big5.cpl +binary \epoc32\release\winc\urel\big5_shared.dll +binary \epoc32\release\winc\urel\bitgdi.dll +binary \epoc32\release\winc\urel\bmtran.dll +binary \epoc32\release\winc\urel\charconv.dll +binary \epoc32\release\winc\urel\cnftool.exe +binary \epoc32\release\winc\urel\conarc.dll +binary \epoc32\release\winc\urel\connmngmntbox.exe +binary \epoc32\release\winc\urel\connmngmntbox.tlb +binary \epoc32\release\winc\urel\connmngmnthelpbox.dll +binary \epoc32\release\winc\urel\connmngmnthelpbox.lib +binary \epoc32\release\winc\urel\connmngmnthelpbox.tlb +binary \epoc32\release\winc\urel\connmngmntres.dll +binary \epoc32\release\winc\urel\contprosap.dll +binary \epoc32\release\winc\urel\contprosap.lib +binary \epoc32\release\winc\urel\contprosap.tlb +binary \epoc32\release\winc\urel\contprosapres.dll +binary \epoc32\release\winc\urel\contprosapres.lib +binary \epoc32\release\winc\urel\convnames.dll +binary \epoc32\release\winc\urel\convutils.dll +binary \epoc32\release\winc\urel\csbmsto.dll +binary \epoc32\release\winc\urel\csdbcust.dll +binary \epoc32\release\winc\urel\csdbi.dll +binary \epoc32\release\winc\urel\csdbw.dll +binary \epoc32\release\winc\urel\cshlpwtr.exe +binary \epoc32\release\winc\urel\cssup.dll +binary \epoc32\release\winc\urel\dbwriter.dll +binary \epoc32\release\winc\urel\dlog.dll +binary \epoc32\release\winc\urel\dlogfl.dll +binary \epoc32\release\winc\urel\dlogsr.dll +binary \epoc32\release\winc\urel\dlogwn.dll +binary \epoc32\release\winc\urel\ealm.dll +binary \epoc32\release\winc\urel\ealwl.dll +binary \epoc32\release\winc\urel\ecdrv.pdd +binary \epoc32\release\winc\urel\ecomm.ldd +binary \epoc32\release\winc\urel\econs.dll +binary \epoc32\release\winc\urel\edbms.dll +binary \epoc32\release\winc\urel\edev.lib +binary \epoc32\release\winc\urel\edll.lib +binary \epoc32\release\winc\urel\eexe.lib +binary \epoc32\release\winc\urel\efile.dll +binary \epoc32\release\winc\urel\efsrv.dll +binary \epoc32\release\winc\urel\ehwa.ldd +binary \epoc32\release\winc\urel\ehwac.pdd +binary \epoc32\release\winc\urel\ekdata.dll +binary \epoc32\release\winc\urel\ekern.dll +binary \epoc32\release\winc\urel\ektran.dll +binary \epoc32\release\winc\urel\elocal.fsy +binary \epoc32\release\winc\urel\elocl.01 +binary \epoc32\release\winc\urel\elocl.02 +binary \epoc32\release\winc\urel\elocl.03 +binary \epoc32\release\winc\urel\elocl.04 +binary \epoc32\release\winc\urel\elocl.05 +binary \epoc32\release\winc\urel\elocl.10 +binary \epoc32\release\winc\urel\elocl.18 +binary \epoc32\release\winc\urel\elocl.19 +binary \epoc32\release\winc\urel\elocl.29 +binary \epoc32\release\winc\urel\elocl.31 +binary \epoc32\release\winc\urel\elocl.32 +binary \epoc32\release\winc\urel\elocl.dll +binary \epoc32\release\winc\urel\elocl.loc +binary \epoc32\release\winc\urel\elocl.sc +binary \epoc32\release\winc\urel\esock.dll +binary \epoc32\release\winc\urel\estor.dll +binary \epoc32\release\winc\urel\etext.dll +binary \epoc32\release\winc\urel\eucjp_packed.cpl +binary \epoc32\release\winc\urel\euniw.dll +binary \epoc32\release\winc\urel\euser.dll +binary \epoc32\release\winc\urel\exdll.lib +binary \epoc32\release\winc\urel\fbscli.dll +binary \epoc32\release\winc\urel\fbserv.dll +binary \epoc32\release\winc\urel\field.dll +binary \epoc32\release\winc\urel\fntstr.dll +binary \epoc32\release\winc\urel\form.dll +binary \epoc32\release\winc\urel\form_and_etext_editor.dll +binary \epoc32\release\winc\urel\gb12345.cpl +binary \epoc32\release\winc\urel\gb2312.cpl +binary \epoc32\release\winc\urel\gb2312_shared.dll +binary \epoc32\release\winc\urel\gbk.cpl +binary \epoc32\release\winc\urel\gbk_shared.dll +binary \epoc32\release\winc\urel\gdi.dll +binary \epoc32\release\winc\urel\general.pdl +binary \epoc32\release\winc\urel\hal.dll +binary \epoc32\release\winc\urel\hz.cpl +binary \epoc32\release\winc\urel\iso2022jp.cpl +binary \epoc32\release\winc\urel\iso2022jp1.cpl +binary \epoc32\release\winc\urel\iso885910.cpl +binary \epoc32\release\winc\urel\iso885913.cpl +binary \epoc32\release\winc\urel\iso885914.cpl +binary \epoc32\release\winc\urel\iso885915.cpl +binary \epoc32\release\winc\urel\iso88592.cpl +binary \epoc32\release\winc\urel\iso88593.cpl +binary \epoc32\release\winc\urel\iso88594.cpl +binary \epoc32\release\winc\urel\iso88595.cpl +binary \epoc32\release\winc\urel\iso88596.cpl +binary \epoc32\release\winc\urel\iso88597.cpl +binary \epoc32\release\winc\urel\iso88598.cpl +binary \epoc32\release\winc\urel\iso88599.cpl +binary \epoc32\release\winc\urel\iwzlib.dll +binary \epoc32\release\winc\urel\iwzlib.lib +binary \epoc32\release\winc\urel\jis.cpl +binary \epoc32\release\winc\urel\jisbase_shared.dll +binary \epoc32\release\winc\urel\jisx0201.dll +binary \epoc32\release\winc\urel\jisx0208.dll +binary \epoc32\release\winc\urel\jisx0212.dll +binary \epoc32\release\winc\urel\linebreak.dll +binary \epoc32\release\winc\urel\listcomportsbox.dll +binary \epoc32\release\winc\urel\listcomportsbox.lib +binary \epoc32\release\winc\urel\listcomportsbox.tlb +binary \epoc32\release\winc\urel\mednand.pdd +binary \epoc32\release\winc\urel\mroutersocket.dll +binary \epoc32\release\winc\urel\mroutersocket.lib +binary \epoc32\release\winc\urel\mroutersocket.tlb +binary \epoc32\release\winc\urel\palette.dll +binary \epoc32\release\winc\urel\pdrstr.dll +binary \epoc32\release\winc\urel\plp.prt +binary \epoc32\release\winc\urel\plpcli.dll +binary \epoc32\release\winc\urel\plpconfig.dll +binary \epoc32\release\winc\urel\plpexe.dll +binary \epoc32\release\winc\urel\plplog.dll +binary \epoc32\release\winc\urel\plpremlink.dll +binary \epoc32\release\winc\urel\plprfs.rsy +binary \epoc32\release\winc\urel\plpsvr.dll +binary \epoc32\release\winc\urel\plpvariant.dll +binary \epoc32\release\winc\urel\powermgrcli.dll +binary \epoc32\release\winc\urel\print.dll +binary \epoc32\release\winc\urel\rpcs.rsy +binary \epoc32\release\winc\urel\rtsock.dll +binary \epoc32\release\winc\urel\rtsock.lib +binary \epoc32\release\winc\urel\rtsock.tlb +binary \epoc32\release\winc\urel\scdv.dll +binary \epoc32\release\winc\urel\scrfs.exe +binary \epoc32\release\winc\urel\scrfs.tlb +binary \epoc32\release\winc\urel\scrfsproxy.dll +binary \epoc32\release\winc\urel\scrfsproxy.lib +binary \epoc32\release\winc\urel\shiftjis.cpl +binary \epoc32\release\winc\urel\shiftjis_shared.dll +binary \epoc32\release\winc\urel\tagma.dll +binary \epoc32\release\winc\urel\undo.dll +binary \epoc32\release\winc\urel\vcal.dll +binary \epoc32\release\winc\urel\vcard.dll +binary \epoc32\release\winc\urel\versit.dll +binary \epoc32\release\winc\urel\wldcomp.exe +binary \epoc32\release\winc\urel\worldclient.dll +binary \epoc32\release\winc\urel\worldserver.dll +binary \epoc32\release\winc\urel\wpeng.dll +binary \epoc32\release\winc\urel\ws32.dll +binary \epoc32\release\winc\urel\xmllx.dll +binary \epoc32\release\winc\urel\z\system\charconv\big5.rsc +binary \epoc32\release\winc\urel\z\system\charconv\builtin.rsc +binary \epoc32\release\winc\urel\z\system\charconv\eucjp_packed.rsc +binary \epoc32\release\winc\urel\z\system\charconv\gb12345.rsc +binary \epoc32\release\winc\urel\z\system\charconv\gb2312.rsc +binary \epoc32\release\winc\urel\z\system\charconv\gbk.rsc +binary \epoc32\release\winc\urel\z\system\charconv\hz.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso2022jp.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso2022jp1.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885910.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885913.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885914.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885915.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88592.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88593.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88594.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88595.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88596.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88597.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88598.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88599.rsc +binary \epoc32\release\winc\urel\z\system\charconv\jis.rsc +binary \epoc32\release\winc\urel\z\system\charconv\shiftjis.rsc +binary \epoc32\release\winc\urel\z\system\printers\general.pdr +binary \epoc32\release\winc\urel\z\system\printers\general.r01 +binary \epoc32\release\winc\urel\z\system\printers\general.r10 +notes_source \component_defs\release.src + + + +ipr T + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/winc/winc/winc.zip Binary file deprecated/winc/winc/winc.zip has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/wveconv/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +wveconv.mmp + +PRJ_TESTMMPFILES + diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/wveconv/group/wveconv.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/group/wveconv.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,25 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET wveconv.exe +TARGETTYPE exe +SOURCEPATH ../../wveconv +SOURCE wveconv.cpp + + + + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/wveconv/group/wveconv.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/group/wveconv.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_wveconv + +source /src/tools/build/deprecated/wveconv +exports /src/tools/build/deprecated/wveconv/group +binary /src/tools/build/deprecated/wveconv/group all + +notes_source \component_defs\release.src + +ipr T diff -r fa7a3cc6effd -r 6d08f4a05d93 deprecated/wveconv/wveconv.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/wveconv.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,250 @@ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Psion3a WVE to Series5 sound file convertor +// +// + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) +#include +#include +using namespace std; +#else //!__MSVCDOTNET__ +#include +#include +#ifdef __CW32__ +using std::streampos; +#endif //__CW32__ +#endif //__MSVCDOTNET__ + +#include + +#if defined(__VC32__) && !defined(__MSVCDOTNET__) +#pragma warning( disable : 4710 ) // 'fn': function not inlined +#endif // old MSVC + +#define KUidRecordApp 0x1000007e + +#define KUid1 0x10000037 +#define KUid2 0x1000006d +#define KUid3 KUidRecordApp +#define KUidCheckSum 0x5508accf + +#define KUidAppStream 0x10000089 +#define KUidSampleStream 0x10000052 + + +int ErrorNotWveFile() + { + cout << "The specified input file is not a Series 3a WVE file" << endl ; + return(0); + } + +int ErrorNotFound() + { + cout << "Unable to open input file" << endl ; + return(0); + } + +int ReadInt32(ifstream& inStream) + { + char ch[4]; + inStream.read(&ch[0],4); + return *(int*)&ch[0]; + } + +int ReadInt16(ifstream& inStream) + { + char ch[4]; + inStream.read(&ch[0],2); + ch[2]=0; + ch[3]=0; + return *(int*)&ch[0]; + } + +int WriteWord(ofstream& outStream,unsigned int aWord) + { + outStream.write((char*)&aWord,4); + return 0; + } + +int WriteByte(ofstream& outStream,const char aByte) + { + outStream.write((char*)&aByte,1); + return 0; + } + +int WriteText(ofstream& outStream,const char* aText) + { + char ch; + while((ch=*aText++)!=0) + outStream << ch; + return 0; + } + +void ShowHelp() + { + cout << "WveConv 0.04"; + cout << endl ; + cout << "Converts a Psion 3a WVE file to an EPOC sound file" << endl ; + cout << endl ; + cout << "Usage: WVECONV S3AFILE.WVE [EPOCFILE]" << endl ; + cout << endl ; + cout << "If [EPOCFILE] is omitted, the input filename" << endl ; + cout << "without the extension will be used" << endl ; + } + +int ConvertFile(const char* inputFile,const char* outputFile) + { + ifstream inStream(inputFile,ios::in|ios::binary); + ofstream outStream(outputFile,ios::out|ios::binary); + + if(!inStream.is_open()) + return(ErrorNotFound()); + + const char* appName="Record.app"; + char header[16]; + + inStream.read(&header[0],16); + + if(strcmp(header,"ALawSoundFile**")!=0) + return(ErrorNotWveFile()); + + int compressedLength=0; + int trailingSilence=0; + int compressorUid=0; + int sampleLength=0; + int repeatCount=0; + int versionNumber=0; +// +// extract the sample length, repeat count and trailing silence... +// + versionNumber=ReadInt16(inStream); + sampleLength=ReadInt32(inStream); + trailingSilence=ReadInt16(inStream); + repeatCount=ReadInt16(inStream); + if(repeatCount==0) // 0 and 1 are the same on Series 3 + repeatCount=1; + + trailingSilence*=31250; + + compressedLength=sampleLength; + + cout << "Converting " << inputFile << " to " << outputFile << endl << endl; + cout << "Version number :" << versionNumber << endl ; + cout << "Sample length :" << sampleLength << " bytes" << endl ; + cout << "Repeat count :" << repeatCount << endl ; + cout << "Trailing silence:" << trailingSilence << " uS" << endl ; + + inStream.seekg((streampos)0x20); +// +// Write out the header... +// + unsigned int rootstreamid=0x14; + unsigned int appstreamid=0x25; + unsigned int samplestreamid=0x34; + +// checked uid header + + WriteWord(outStream,KUid1); + WriteWord(outStream,KUid2); + WriteWord(outStream,KUidRecordApp); + WriteWord(outStream,KUidCheckSum); + +// root stream id + + WriteWord(outStream,rootstreamid); + +//stream dictionary @ 0x14 root stream + + WriteByte(outStream,4); // two entries in dictionary + WriteWord(outStream,KUidSampleStream); // sample stream + WriteWord(outStream,samplestreamid); + WriteWord(outStream,KUidAppStream); // appid stream + WriteWord(outStream,appstreamid); + +// record app identifier stream @ 0x25 + + WriteWord(outStream,KUidRecordApp); + WriteByte(outStream,42); + WriteText(outStream,appName); + +// sample header @ 0x34 + + WriteWord(outStream,sampleLength); + WriteWord(outStream,compressorUid); + WriteWord(outStream,repeatCount-1); // repeats are zero based on Series 5 + WriteWord(outStream,trailingSilence); + WriteWord(outStream,compressedLength); +// +// Copy the sample data... +// + streampos newPos=0x20; // start of sample data in 3a file... + inStream.seekg(newPos); + + char buffer[256]; + int count; + int actualLength=0; + do + { + inStream.read(&buffer[0],256); + if((count=inStream.gcount())!=0) + { + outStream.write(&buffer[0],count); + actualLength+=count; + } + } while(count); +// +// should check actualLength==sampleLength...but what the heck +// + outStream.close(); + inStream.close(); + return 0; + } + +int main(int aNumArgs,char* aArgs[]) + { + if(aNumArgs<=1 || aArgs[1][0]=='?' || aArgs[1][0]=='/') + { + ShowHelp(); + return 0; + } + char inputFile[255]; + char outputFile[255]; + + strcpy(inputFile,aArgs[1]); + + if(aNumArgs==3) + strcpy(outputFile,aArgs[2]); + + if(aNumArgs==2 || outputFile[0]==0) + { + strcpy(outputFile,inputFile); +// +// remove the extension +// + int len=strlen(outputFile); + for(;;) + { + if(--len<0) + break; + if(outputFile[len]=='.') + { + outputFile[len]=0; + break; + } + } + } + return(ConvertFile(inputFile,outputFile)); + } + diff -r fa7a3cc6effd -r 6d08f4a05d93 e32tools/e32lib/seclib/seclib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/e32lib/seclib/seclib.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,41 @@ +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32tools/inc/seclib.h +// Get the capabilities of an emulator / e32image. +// Image security information structure. +// +// + +/** + @internalTechnology + @prototype +*/ +struct SBinarySecurityInfo + { + TUint32 iSecureId; + TUint32 iVendorId; + TUint8 iCapabilities[KCapabilitySetMaxSize]; + TBool iE32Image; + }; + +/** + * Extracts security information from an image. + * + * @internalTechnology + * @prototype + */ +TInt GetSecurityInfo(const char* aFileName, SBinarySecurityInfo& aInfo); +#ifndef __LINUX__ +TInt GetSecurityInfo(const wchar_t* aFileName, SBinarySecurityInfo& aInfo); +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 e32tools/uidcrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Base tools (e.g. petran) +* +*/ + + +/** + @file +*/ + +PRJ_PLATFORMS +TOOLS2 + +PRJ_MMPFILES +uidcrc diff -r fa7a3cc6effd -r 6d08f4a05d93 e32tools/uidcrc/group/uidcrc.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/group/uidcrc.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +TARGET uidcrc.exe +TARGETTYPE exe +SOURCEPATH ../src +SOURCE uidcrc.cpp e32uid.cpp +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +VENDORID 0x70000001 + +option GCC -O2 -Wno-uninitialized diff -r fa7a3cc6effd -r 6d08f4a05d93 e32tools/uidcrc/group/uidcrc.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/group/uidcrc.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,5 @@ +component dev_build_e32tools_uidcrc + +source /src/tools/build/e32tools/uidcrc +binary /src/tools/build/e32tools/uidcrc/group all + diff -r fa7a3cc6effd -r 6d08f4a05d93 e32tools/uidcrc/src/e32uid.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/src/e32uid.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,253 @@ +/* +* Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + #include + using namespace std; +#endif + +typedef unsigned char BYTE; // TUint8 +typedef unsigned short WORD; // TUint16 +typedef unsigned int UINT; // TUint + +#include +#include +#include +#include "e32uid.h" + +const UINT crcTab[256] = + { + 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,0x8108,0x9129,0xa14a, + 0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294, + 0x72f7,0x62d6,0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,0x2462, + 0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,0xa56a,0xb54b,0x8528,0x9509, + 0xe5ee,0xf5cf,0xc5ac,0xd58d,0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695, + 0x46b4,0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,0x48c4,0x58e5, + 0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948, + 0x9969,0xa90a,0xb92b,0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12, + 0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,0x6ca6,0x7c87,0x4ce4, + 0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b, + 0x8d68,0x9d49,0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,0xff9f, + 0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,0x9188,0x81a9,0xb1ca,0xa1eb, + 0xd10c,0xc12d,0xf14e,0xe16f,0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046, + 0x6067,0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,0x02b1,0x1290, + 0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e, + 0xe54f,0xd52c,0xc50d,0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405, + 0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,0x26d3,0x36f2,0x0691, + 0x16b0,0x6657,0x7676,0x4615,0x5634,0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9, + 0xb98a,0xa9ab,0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,0xcb7d, + 0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,0x4a75,0x5a54,0x6a37,0x7a16, + 0x0af1,0x1ad0,0x2ab3,0x3a92,0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8, + 0x8dc9,0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,0xef1f,0xff3e, + 0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,0x6e17,0x7e36,0x4e55,0x5e74,0x2e93, + 0x3eb2,0x0ed1,0x1ef0 + }; + +void Crc(WORD& aCrc,const void* aPtr,int aLength) +// +// Perform a CCITT CRC checksum. +// + { + + const BYTE* pB=(const BYTE*)aPtr; + const BYTE* pE=pB+aLength; + UINT crc=aCrc; + while (pB>8)^*pB++)&0xff]; + aCrc=(WORD)crc; + } + +UINT checkSum(const void* aPtr) +// +// Checksum every other byte +// + { + + const BYTE* pB=(const BYTE*)aPtr; + const BYTE* pE=pB+(KMaxCheckedUid*sizeof(TUid)); + BYTE buf[(KMaxCheckedUid*sizeof(TUid))>>1]; + BYTE* pT=(&buf[0]); + while (pB>1); + return(crc); + } + +int TUid::operator==(const TUid& aUid) const +// +// Compare UID's for equality +// + { + + return(iUid==aUid.iUid); + } + +int TUid::operator!=(const TUid& aUid) const +// +// Compare UID's for equality +// + { + + return(iUid!=aUid.iUid); + } + +TUidType::TUidType() +// +// Constructor +// + { + + memset(this,0,sizeof(TUidType)); + } + +TUidType::TUidType(TUid aUid1) +// +// Constructor +// + { + + + memset(this,0,sizeof(TUidType)); + iUid[0]=aUid1; + } + +TUidType::TUidType(TUid aUid1,TUid aUid2) +// +// Constructor +// + { + + iUid[0]=aUid1; + iUid[1]=aUid2; + iUid[2]=KNullUid; + } + +TUidType::TUidType(TUid aUid1,TUid aUid2,TUid aUid3) +// +// Constructor +// + { + + + iUid[0]=aUid1; + iUid[1]=aUid2; + iUid[2]=aUid3; + } + +int TUidType::operator==(const TUidType& aUidType) const +// +// TRUE if equal. +// + { + + return(iUid[0]==aUidType.iUid[0] && + iUid[1]==aUidType.iUid[1] && + iUid[2]==aUidType.iUid[2]); + } + +int TUidType::operator!=(const TUidType& aUidType) const +// +// TRUE if not equal. +// + { + + + return(!(*this==aUidType)); + } + +const TUid& TUidType::operator[](int anIndex) const +// +// Array operator. +// + { + + return(iUid[anIndex]); + } + +TUid TUidType::MostDerived() const +// +// Return the most derived type +// + { + + if (iUid[2]!=KNullUid) + return(iUid[2]); + if (iUid[1]!=KNullUid) + return(iUid[1]); + return(iUid[0]); + } + +int TUidType::IsPresent(TUid aUid) const +// +// TRUE if aUid is present as any type. +// + { + + return(iUid[0]==aUid || iUid[1]==aUid || iUid[2]==aUid); + } + +int TUidType::IsValid() const +// +// TRUE if one of the type is not NULL. +// + { + + return(MostDerived()!=KNullUid); + } + +TCheckedUid::TCheckedUid() +// +// Constructor +// + { + + memset(this,0,sizeof(TCheckedUid)); + } + +TCheckedUid::TCheckedUid(const TUidType& aUidType) +// +// Constructor +// + { + + Set(aUidType); + } + +void TCheckedUid::Set(const TUidType& aUidType) +// +// Set from a aUidType +// + { + + iType=aUidType; + iCheck=Check(); + } + +UINT TCheckedUid::Check() const +// +// Return the checksum of the UIDs +// + { + + return((checkSum(((BYTE*)this)+1)<<16)|checkSum((BYTE*)this)); + } + diff -r fa7a3cc6effd -r 6d08f4a05d93 e32tools/uidcrc/src/uidcrc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/src/uidcrc.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include +using namespace std; + +#include +#include +#include +#include +#include + +// Get round the privateness of the checksum etc. +// See also PE_TRAN.CPP TE32ImageUids + +class TCheckedUidX : public TCheckedUid + { +public: + inline TCheckedUidX(TUint uids[3]) + : TCheckedUid(TUidType(TUid::Uid(uids[1]),TUid::Uid(uids[2]),TUid::Uid(uids[3]))) + {} + inline TUint CRC() + { return Check(); } + }; + +int usage() + { + fprintf(stderr, "uidcrc [ ]\n"); + return -1; + } + +int main(int argc, char* argv[]) + { + if (argc<4 || argc>5) + return usage(); + + TUint uids[5]; + int i=0; + + for (i=1; i<4; i++) + { + char* endptr = "failed"; + uids[i] = strtoul(argv[i],&endptr,0); + if (*endptr!='\0') + { + fprintf(stderr, "invalid uid%d >%s<\n",i,argv[i]); + return -1; + } + } + + TCheckedUidX checked(uids); + uids[4] = checked.CRC(); + + if (argc==5) + { + FILE* fp=fopen(argv[4], "wb"); + if (fp==0) + { + fprintf(stderr, "cannot open %s for writing\n", argv[4]); + return -1; + } + for (i=1; i<5; i++) + { + TUint word=uids[i]; + unsigned char bytes[4]; + bytes[0] = (unsigned char)( word &0xFF); + bytes[1] = (unsigned char)((word>> 8)&0xFF); + bytes[2] = (unsigned char)((word>>16)&0xFF); + bytes[3] = (unsigned char)((word>>24)&0xFF); + fwrite(bytes, 4, 1, fp); + } + fclose(fp); + return 0; + } + + printf("0x%08x 0x%08x 0x%08x 0x%08x\n", uids[1], uids[2], uids[3], uids[4]); + return 0; + } diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/unzip-5.40/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/unzip-5.40/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,22 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS + +PRJ_EXPORTS + +../unzip.exe /tools/unzip-5.40/unzip.exe + +PRJ_MMPFILES diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/unzip-5.40/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/unzip-5.40/group/release.txt Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,5 @@ +NOTESRC_RELEASER +Symbian Software Ltd. + +NOTESRC_RELEASE_REASON +Unzip tools. diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/unzip-5.40/group/unzip-5.40.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/unzip-5.40/group/unzip-5.40.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,23 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component dev_build_hostenv_unzip-5.40 + +source \src\tools\build\hostenv\unzip-5.40 +exports \src\tools\build\hostenv\unzip-5.40\group + +notes_source \src\tools\build\hostenv\unzip-5.40\group\release.txt + +ipr T \ No newline at end of file diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/unzip-5.40/unzip.exe Binary file hostenv/unzip-5.40/unzip.exe has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/zip-2.2/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/zip-2.2/group/bld.inf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,22 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS + +PRJ_EXPORTS + +../zip.exe /tools/zip-2.2/zip.exe + +PRJ_MMPFILES diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/zip-2.2/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/zip-2.2/group/release.txt Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,5 @@ +NOTESRC_RELEASER +Symbian Software Ltd. + +NOTESRC_RELEASE_REASON +Zip tools. diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/zip-2.2/group/zip-2.2.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/zip-2.2/group/zip-2.2.mrp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,23 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component dev_build_hostenv_zip-2.2 + +source \src\tools\build\hostenv\zip-2.2 +exports \src\tools\build\hostenv\zip-2.2\group + +notes_source \src\tools\build\hostenv\zip-2.2\group\release.txt + +ipr T \ No newline at end of file diff -r fa7a3cc6effd -r 6d08f4a05d93 hostenv/zip-2.2/zip.exe Binary file hostenv/zip-2.2/zip.exe has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/group/configpaging.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/group/configpaging.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET configpaging.exe +TARGETTYPE exe +SOURCEPATH ../src +SOURCE configpaging.cpp +SYSTEMINCLUDE /epoc32/include +SYSTEMINCLUDE /epoc32/include/tools/stlport +SYSTEMINCLUDE ../../imglib/boostlibrary + +STATICLIBRARY boost_regex-1.39 +STATICLIBRARY stlport.5.1 +#ifdef TOOLS2_LINUX +OPTION GCC -pthread -O2 -Wno-uninitialized +#else +OPTION GCC -mthreads -O2 -Wno-uninitialized +#endif + + +VENDORID 0x70000001 diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/src/configpaging.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/src/configpaging.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,478 @@ +/* +* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* @internalComponent * @released +* configpaging mainfile to do configpaging in buildrom. +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace boost ; + +typedef const char* const_str ; + +static const string NULL_STRING(""); +static const char CONSTANT_UNPAGED[] = "unpaged"; +static const char CONSTANT_PAGED[] = "paged"; +static const char CONSTANT_UNPAGEDCODE[] = "unpagedcode"; +static const char CONSTANT_PAGEDCODE[] = "pagedcode"; +static const char CONSTANT_UNPAGEDDATA[] = "unpageddata"; +static const char CONSTANT_PAGEDDATA[] = "pageddata"; +#ifdef WIN32 +static const char CONSTANT_CONFIG_PATH[] = "epoc32\\rom\\configpaging\\"; +static string epocroot("\\"); +static const char SLASH_CHAR = '\\'; +#else +#include +#define strnicmp strncasecmp +#define _alloca alloca +static const char CONSTANT_CONFIG_PATH[] = "epoc32/rom/configpaging/"; +static string epocroot("/"); +static const char SLASH_CHAR = '/'; +#endif +static const char CONSTANT_CONFIG_FILE[] = "configpaging.cfg" ; +#define is_undef(s) (0 == s.length()) +static const int MAJOR_VERSION = 1; +static const int MINOR_VERSION = 2; +static const int BUILD_NUMBER = 0; +static const char COPYRIGHT[]="Copyright (c) 2010 Nokia Corporation."; +struct ListElement{ + const_str code ; + const_str data ; +}; + + +static string configlist ; +static regex e0("^(file|data|dll|secondary)(=|\\s+)",regex::perl|regex::icase); +static regex e1("^(code|data)?pagingoverride=(.*)\\s*",regex::perl); +static regex e2("^(un)?paged(code|data)?(\\s+(un)?paged(code|data)?)?:",regex::perl); +static regex e3("^include\\s*\"(.*)\"",regex::perl); +static regex e4("(\\S+)(\\s+(un)?paged(code|data)?(\\s+(un)?paged(code|data)?)?)?",regex::perl); +static regex e5("\\b(un)?paged(data)?\\b\\s*$",regex::perl|regex::icase); +static regex e6("\\b(un)?paged(code)?\\b\\s*$",regex::perl|regex::icase); +static regex e7("\\b(un)?paged(code|data)?\\b",regex::perl|regex::icase); +//static regex e8("tool=|\\s+)",regex::perl|regex::icase); + + + +static bool is_obystatement(const char* aLine) { + if(!strnicmp(aLine,"file",4)|| !strnicmp(aLine,"data",4)) + aLine += 4 ; + else if(!strnicmp(aLine,"dll",3)) + aLine += 3; + else if(!strnicmp(aLine,"secondary",9)) + aLine += 9 ; + else + return false ; + + return (*aLine =='=' || *aLine == ' '|| *aLine == '\t'); + +} +static void trim(string& aStr){ + + char* data = const_cast(aStr.data()); + int length = aStr.length(); + int firstIndex = 0 ; + int lastIndex = length - 1; + // remove ending blanks + while(lastIndex >= 0 && (data[lastIndex] == ' ' || data[lastIndex] == '\t')){ + lastIndex -- ; + } + + // remove heading blanks + while((firstIndex < lastIndex ) && (data[firstIndex] == ' ' || data[firstIndex] == '\t')){ + firstIndex ++ ; + } + lastIndex++ ; + if(lastIndex < length){ + aStr.erase(lastIndex,length - lastIndex); + } + if(firstIndex > 0){ + aStr.erase(0,firstIndex); + } +} +static void make_lower(char* aStr,size_t aLength){ + + for(size_t i = 0 ; i < aLength ; i++){ + if(aStr[i] >= 'A' && aStr[i] <= 'Z') + aStr[i] |= 0x20 ; + } +} +static bool readConfigFile(const_str& aCodePagingRef, const_str& aDataPagingRef, + map& aListRef, const_str aFileName ) { + ifstream is(aFileName, ios_base::binary | ios_base::in); + if(!is.is_open()){ + cerr<< "Can not open \""<< aFileName << "\" for reading.\n"; + return false ; + } + const_str filecodepaging = ""; + const_str filedatapaging = ""; + match_results what; + + is.seekg(0,ios::end); + size_t size = is.tellg(); + is.seekg(0,ios::beg); + + char *buf = new char[size + 1]; + is.read(buf,size); + buf[size] = '\n' ; + + char* end = buf + size ; + char* lineStart = buf ; + int lfcr ; + string line ; + + while(lineStart < end ){ + // trim left ; + while(*lineStart == ' ' || *lineStart == '\t' ){ + lineStart++ ; + } + char* lineEnd = lineStart; + while(*lineEnd != '\r' && *lineEnd != '\n'){ + lineEnd++ ; + } + if(*lineEnd == '\r' && lineEnd[1] == '\n') + lfcr = 2 ; + else + lfcr = 1 ; + + *lineEnd = 0 ; + // empty line or comment + if(lineEnd == lineStart || *lineStart == '#' ){ + lineStart = lineEnd + lfcr ; + continue ; + } + size_t lenOfLine = lineEnd - lineStart; + make_lower(lineStart,lenOfLine); + line.assign(lineStart,lenOfLine); + + if(regex_search(line, what, e1)){ + string r1 = what[1].str(); + string r2 = what[2].str(); + if(is_undef(r1)){ //if ($1 eq undef) + if(r2 == "defaultpaged"){ + aCodePagingRef = CONSTANT_PAGED ; + } else if(r2 == "defaultunpaged"){ + aCodePagingRef = CONSTANT_UNPAGED ; + aDataPagingRef = CONSTANT_UNPAGED; + }else{ + cerr << "Configpaging Warning: invalid pagingoverride setting: "<< r2 <<"\n" ; + } + }else if(r1 == "code"){ + if(r2 == "defaultpaged"){ + aCodePagingRef = CONSTANT_PAGED ; + } else if(r2 == "defaultunpaged"){ + aCodePagingRef = CONSTANT_UNPAGED ; + }else{ + cerr << "Configpaging Warning: invalid codepagingoverride setting: "<< r2 <<"\n" ; + } + } + else if(r1 == "data" ){ + if(r2 == "defaultpaged"){ + aDataPagingRef = CONSTANT_PAGED ; + } else if(r2 == "defaultunpaged"){ + aDataPagingRef = CONSTANT_UNPAGED ; + }else{ + cerr << "Configpaging Warning: invalid datapagingoverride setting: "<< r2 <<"\n" ; + } + } + }// check e1 + else if(regex_search(line, what, e2)){ + string r1 = what[1].str(); + string r2 = what[2].str(); + string r3 = what[3].str(); + string r4 = what[4].str(); + string r5 = what[5].str(); + filecodepaging = ""; + filedatapaging = ""; + if (is_undef(r1)) { + if (is_undef(r2)) { + filecodepaging = CONSTANT_PAGED; + }else if (r2 == "code") { + filecodepaging = CONSTANT_PAGED; + } else if(r2 == "data") { + filedatapaging = CONSTANT_PAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else if (r1 == "un"){ + if (is_undef(r2)) { //$2 eq undef + filecodepaging = CONSTANT_UNPAGED; + filedatapaging = CONSTANT_UNPAGED; + }else if (r2 == "code") { + filecodepaging = CONSTANT_UNPAGED; + } else if(r2 == "data") { + filedatapaging = CONSTANT_UNPAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + if (r3.length() > 0){ //$3 ne undef + if (is_undef(r4)) { + if (is_undef(r5)) { + filecodepaging = CONSTANT_PAGED; + }else if (r5 == "code") { + filecodepaging = CONSTANT_PAGED; + } else if(r5 == "data") { + filedatapaging = CONSTANT_PAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else if (r4 == "un") { + if (is_undef(r5)) { + filecodepaging = CONSTANT_UNPAGED; + filedatapaging = CONSTANT_UNPAGED; + }else if (r5 == "code") { + filecodepaging = CONSTANT_UNPAGED; + } else if(r5 == "data") { + filedatapaging = CONSTANT_UNPAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } + } + else if(regex_search(line, what, e3)){ + string filename = epocroot + CONSTANT_CONFIG_PATH; + filename += what[1].str(); + readConfigFile(aCodePagingRef, aDataPagingRef, aListRef, filename.c_str()); + } + else if(regex_search(line, what, e4)){ + string r1 = what[1].str(); + string r2 = what[2].str(); + string r3 = what[3].str(); + string r4 = what[4].str(); + string r5 = what[5].str(); + string r6 = what[6].str(); + string r7 = what[7].str(); + ListElement element = {aCodePagingRef, aDataPagingRef}; + if (is_undef(r2)){ //($2 eq undef){ + if (0 != *filecodepaging){//filecodepaging ne "") + element.code = filecodepaging; //$element{code} = $filecodepaging; + } + if ( 0 != *filedatapaging){//$filedatapaging ne "") + element.data = filedatapaging ;//element.data = $filedatapaging; + } + } else { + if (is_undef(r4)){//$4 eq undef + if (is_undef(r3)) {//$3 eq undef + element.code = CONSTANT_PAGED; + } else if (r3 == "un") { + element.code = CONSTANT_UNPAGED; + element.data = CONSTANT_UNPAGED; + } + } else if (r4 == "code") { + if (is_undef(r3)) { + element.code = CONSTANT_PAGED; + } else if (r3 == "un") { + element.code = CONSTANT_UNPAGED; + } + } else if (r4 == "data") { + if (is_undef(r3)) { + element.data = CONSTANT_PAGED; + } else if (r3 == "un") { + element.data = CONSTANT_UNPAGED; + } + } else { + cerr << "Configpaging Warning: unrecognized attribute in line: "<< lineStart << "\n"; + } + if (r5.length() > 0){//$5 ne undef + if (is_undef(r7)){ //$7 eq undef + if (is_undef(r6)) { //$6 eq undef + element.code = CONSTANT_PAGED; + } else if (r6 == "un") { + element.code = CONSTANT_UNPAGED; + element.data = CONSTANT_UNPAGED; + } + } else if (r7 == "code") { + if (is_undef(r6)) { + element.code = CONSTANT_PAGED; + } else if (r6 == "un") { + element.code = CONSTANT_UNPAGED; + } + } else if (r7 == "data") { + if (is_undef(r6)) { + element.data = CONSTANT_PAGED; + } else if (r6 == "un") { + element.data = CONSTANT_UNPAGED; + } + } else { + cerr << "Configpaging Warning: unrecognized attribute in line: "<< lineStart << "\n"; + } + } + } + //$$listref{$1} = \%element; + aListRef.insert(pair(r1,element)); + } + lineStart = lineEnd + lfcr ; + } + + delete []buf ; + is.close(); + + return true ; +} + +static bool match_icase(const string& a, const string& b){ + int la = a.length(); + int lb = b.length(); + char *copyOfA = (char*)_alloca(la+2); + *copyOfA = ' '; + copyOfA++ ; + memcpy(copyOfA ,a.c_str(),la); + copyOfA[la] = 0; + char* end = ©OfA[la]; + make_lower(copyOfA,la); + while(copyOfA < end){ + char *found = strstr(copyOfA,b.c_str()); + if(0 == found) + return false ; + if((found[-1] == ' ' || found[-1] == '\\'|| found[-1] == '/'|| found[-1] == '\t' || found[-1] == '"'|| found[-1] == '=') && + ( found[lb] == ' '|| found[lb] == '\t' || found[lb] == '"'|| found[lb] == '\0')) + return true ; + copyOfA = found + lb ; + } + + return false ; +} + +static void configpaging_single(){ + + const_str codepaging=""; + const_str datapaging=""; + map list ; + vector keys ;//my @keys; + string line ; + + cerr << "configpaging.exe: Modifying demand paging configuration using "<< configlist <<"\n"; + readConfigFile(codepaging, datapaging, list, configlist.c_str()); + match_results what; + string codepagingadd ,datapagingadd ; + while(true){ + getline(cin,line); + if(cin.eof()) break ; + if(line == ":q") break ; + trim(line); + const char* lineData = line.data(); + if(*lineData == '#' ){ + cout << lineData << "\n" ; + continue ; + } + int length = line.length(); + if( length > 2){ + //check rem + if((lineData[0] == 'R' || lineData[0] == 'r' ) && (lineData[1] == 'E' || lineData[1] == 'e' ) && (lineData[2] == 'M' || lineData[2] == 'm' )){ + cout << lineData << "\n" ; + continue ; + } + } + codepagingadd = ""; + datapagingadd = ""; + + if(is_obystatement(lineData)){ + for( map::iterator it = list.begin() ; it != list.end() ; it++){ + if(match_icase(line,it->first) ){ + if (it->second.code == CONSTANT_PAGED ){ + codepagingadd += " " ; + codepagingadd += CONSTANT_PAGEDCODE; + } else if (it->second.code == CONSTANT_UNPAGED) { + codepagingadd += " " ; + codepagingadd += CONSTANT_UNPAGEDCODE; + } + if (it->second.data == CONSTANT_PAGED) { + datapagingadd += " " ; + datapagingadd += CONSTANT_PAGEDDATA; + } else if (it->second.data == CONSTANT_UNPAGED) { + datapagingadd += " " ; + datapagingadd += CONSTANT_UNPAGEDDATA; + } + break ; + } + }//for + if (codepagingadd.length() == 0 && 0 != *codepaging) {//!$codepagingadd and $codepaging + codepagingadd = " " ; + codepagingadd += codepaging ; + codepagingadd += "code"; + } + if (datapagingadd.length() == 0 && 0 != *datapaging) { //!$datapagingadd and $datapaging + datapagingadd = " " ; + datapagingadd += datapaging ; + datapagingadd += "data"; + } + if (codepagingadd.length() > 0 && datapagingadd.length() == 0){ //$codepagingadd and !$datapagingadd + if (regex_search(line,what,e5)){ //$line =~ /\b(un)?paged(data)?\b\s*$/) { //$line =~ /\b(un)?paged(data)?\b\s*$/ + datapagingadd = " " ; + if(what[1].length() > 0) + { + datapagingadd += what[1].str(); + datapagingadd += "pageddata"; + } + } + } else if (datapagingadd.length() > 0 && codepagingadd.length() == 0) {//$datapagingadd and !$codepagingadd + if (regex_search(line,what,e6)){ + codepagingadd = " " ; + codepagingadd += what[1].str(); + codepagingadd += "pagedcode"; + } + } + if (datapagingadd.length() > 0 || datapagingadd.length() > 0) { // $datapagingadd or $datapagingadd + line = regex_replace(line,e7,NULL_STRING); + } + } + cout << line << codepagingadd << datapagingadd << "\n"; + + } +} +// +int main(int argc , char* argv[]) { + + char* tmp = getenv("EPOCROOT"); + if(tmp && *tmp) + epocroot = string(tmp); + char ch = epocroot.at(epocroot.length() - 1); + if(ch != '\\' && ch != '/') + epocroot += SLASH_CHAR; + + if(argc > 1 ){ + char* arg = argv[1]; + if('-' == *arg && (arg[1] | 0x20) == 'v'){ + cout << "configpaging - The paging configuration plugin for BUILDROM V" ; + cout << MAJOR_VERSION << "."<< MINOR_VERSION << "." << BUILD_NUMBER<< endl; + cout << COPYRIGHT << endl << endl; + return 0; + } + configlist = epocroot + CONSTANT_CONFIG_PATH; + configlist += string(arg); + } + else{ + configlist = epocroot + CONSTANT_CONFIG_PATH; + configlist += CONSTANT_CONFIG_FILE; + } + configpaging_single(); + + return 0; +} + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/tools/buildrom --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/buildrom Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,2 @@ +#!/bin/sh +perl -S buildrom.pl $@ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/tools/checkepocroot.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/checkepocroot.pl Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,118 @@ +#!/usr/bin/perl + +use Getopt::Long; + +use constant TOOL_VERSION=>"0.1"; + +my $help; +my $dir; +my $convert; +my $logfile; +&processcmdline(); + +open (LOG, ">$logfile") or die "cannot open log file $logfile\n"; +&checkdir($dir); +close LOG; + +sub processcmdline +{ + GetOptions("h" => \$help, "l=s" => \$logfile, "c" => \$convert); + + if ($help) + { + print_usage(); + exit 0; + } + $logfile = "checkepocroot.log" if (!defined $logfile); + + $dir = shift @ARGV; + if (!defined $dir || !-d $dir) + { + print_usage(); + die "\nERROR: directory missing!!\n" if (!defined $dir); + die "\nERROR: directory $dir does not exist!!\n" if (!-d $dir); + } +} + +sub checkdir +{ + my $path = shift; + return if (!-d $path); + opendir(DIR,$path); + my @entries = readdir(DIR); + closedir(DIR); + my $entry; + foreach $entry (@entries) { + next if (($entry eq ".") || ($entry eq "..")); + my $item = "$path/$entry"; + if (-d $item) { + &checkdir($item); + }else { + next if ($entry !~ /.*\.[a-z]by$/i); + + &convobyfile($item, "$item.bak"); + } + } +} + +sub convobyfile +{ + my $src = shift; + my $dst = shift; + open (SRC, "<$src"); + open (DST, ">$dst") if($convert); + + my $line; + while($line = ) + { + if ($line =~ /[\\\/]epoc32/) + { + print "Found content in file $src\n"; + print LOG "Found content in file $src\n"; + print "current line is $line"; + print LOG "current line is $line"; + if ($line =~ /EPOCROOT##[\\\/]?epoc32/) + { + print "Error: this line already contain EPOCROOT\n"; + next; + } + if($convert) + { + $line =~ s-[\\\/]epoc32-EPOCROOT##epoc32-g; + print "converted line is $line"; + print LOG "converted line is $line"; + } + print "\n"; + print LOG "\n"; + } + print DST $line if($convert); + } + close SRC; + if($convert) + { + close DST; + + unlink "$src"; + rename ("$dst", "$src"); + } +} + +sub print_usage +{ + print "\nCheckepocroot - Check epocroot tool V".TOOL_VERSION."\n"; + print "Copyright (c) 2010 Nokia Corporation.\n\n"; + print <] + +Check oby/iby files cursively in the . +When it find epoc32 without EPOCROOT## in the files, it will report the line in log file. If with -c option it will add EPOCROOT## to the epoc32. +The is the directory contain all the oby/iby files. Usually it should be /epoc32/rom/ and it will be checked cursively. + +Options: + -l - the log file to record the log, + if not specfied it is \"checkepocroot.log\" + -h - displays this help + -c - convert the back slash to forward slash. +USAGE_EOF +} \ No newline at end of file diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/tools/checkincludeslash.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/checkincludeslash.pl Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,120 @@ +#!/usr/bin/perl + +use Getopt::Long; + +use constant TOOL_VERSION=>"0.1"; + +my $help; +my $dir; +my $convert; +my $logfile; +&processcmdline(); + +open (LOG, ">$logfile") or die "cannot open log file $logfile\n"; +&checkdir($dir); +close LOG; + +sub processcmdline +{ + GetOptions("h" => \$help, "l=s" => \$logfile, "c" => \$convert); + + if ($help) + { + print_usage(); + exit 0; + } + $logfile = "checkincludeslash.log" if (!defined $logfile); + + $dir = shift @ARGV; + if (!defined $dir || !-d $dir) + { + print_usage(); + die "\nERROR: directory missing!!\n" if (!defined $dir); + die "\nERROR: directory $dir does not exist!!\n" if (!-d $dir); + } +} + +sub checkdir +{ + my $path = shift; + return if (!-d $path); + opendir(DIR,$path); + my @entries = readdir(DIR); + closedir(DIR); + my $entry; + foreach $entry (@entries) { + next if (($entry eq ".") || ($entry eq "..")); + my $item = "$path/$entry"; + if (-d $item) { + &checkdir($item); + }else { + next if ($entry !~ /.*\.[a-z]by$/i); + + &convobyfile($item, "$item.bak"); + } + } +} + +sub convobyfile +{ + my $src = shift; + my $dst = shift; + open (SRC, "<$src"); + open (DST, ">$dst") if($convert); + + my $line; + while($line = ) + { + if ($line =~ /#\s*include\s*(<|\")(.*\\.*)(>|\")/) + { + print "Found content in file $src\n"; + print LOG "Found content in file $src\n"; + print "current line is $line"; + print LOG "current line is $line"; + if($convert) + { + my $path = $2; + my $pathorg = $path; + $pathorg =~ s-\\-\\\\-g; + $path =~ s-\\-\/-g; + $line =~ s-$pathorg-$path-g; + print "converted line is $line"; + print LOG "converted line is $line"; + } + print "\n"; + print LOG "\n"; + } + print DST $line if($convert); + } + close SRC; + if($convert) + { + close DST; + + unlink "$src"; + rename ("$dst", "$src"); + } +} + +sub print_usage +{ + print "\nCheckincludeslash - Check back slash tool V".TOOL_VERSION."\n"; + print "Copyright (c) 2010 Nokia Corporation.\n\n"; + print <] + +Check oby/iby files cursively in the . +When it find back slash in include line in the files like \"\#include \", +it will report the line in log file. If with -c option it will convert the back slash +to forward slash like \"\#include \". +The is the directory contain all the oby/iby files. +Usually it should be /epoc32/rom/ and it will be checked cursively. + +Options: + -l - the log file to record the log, + if not specfied it is \"checkincludeslash.log\" + -h - displays this help + -c - convert the back slash to forward slash. +USAGE_EOF +} \ No newline at end of file diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/tools/directory.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/directory.bat Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,4 @@ +@echo off + +cd %1 +echo %cd% \ No newline at end of file diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/tools/experimental/metarombuild.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/experimental/metarombuild.pl Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,298 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +#! perl + +# This script builds ROMs which are specified in a supplied XML file +# To use this script \epoc32\tools\buildrom must be installed on the drive +# with \epoc32\tools in the path + +# Note: The TargetBoard attribute is no longer used but is still needed because of the structure of this script! + +use strict; +use XML::Simple; +use Getopt::Long; +use Cwd; +use Cwd 'abs_path'; +use File::Copy; +use File::Path; + +# Get command line arguments +my ($romspec, $boards, $roms, $logdir, $buildnum, $publish, $help, $version) = ProcessCommandLine(); + +Usage() if ($help); +Version() if ($version); + +die "Romspec xml file must be specified using the -romspec option\n" if (!$romspec); + +# Construct arrays of boards and roms if they were specified +my @boards = split /,/, $boards if ($boards); +my @roms = split /,/, $roms if ($roms); + +# Use the XML::Simple module to parse the romspec and pass the result +# into the $Roms hash reference +my $xml = new XML::Simple; +my $Roms = $xml->XMLin($romspec); + +my $RomList = %$Roms->{'Rom'}; + +my $RomBuildStage = 1; + +foreach my $rom (sort keys %$RomList) +{ + my $board = $RomList->{$rom}->{'TargetBoard'}; + if( (@boards == 0 and @roms == 0) or grep $rom, @roms or grep $board, @boards) + { + BuildRom($RomBuildStage, $RomList, $rom, $logdir, $buildnum ,$publish); + $RomBuildStage++; + } +} + +##################################################### +#### Run buildrom on the specified ROM using ######## +#### info from the romspec.xml ######## +##################################################### +sub BuildRom +{ + my $Stage = shift; # BuildRom stage + my $RomList = shift; # Hash of the romspec.xml + my $rom = shift; # Rom to be built + my $logdir = shift; # logs directory + my $buildnum = shift; # build number + my $publish = shift; # Publish Location + my $type = $ENV{Type}; # type of Build Master or Release + my $builddir = $ENV{BuildDir}; # Build Directory + my $Epocroot = $ENV{EPOCROOT}; # EpocRoot; + my $InFileList=""; # i.e. Platsec, Techview, obyfiles + my $XmlFileList=""; + my $MacroList=""; # for the buildrom -D option + my $TargetBoard = $RomList->{$rom}->{'TargetBoard'}; + my $ImageFile = " -o".$RomList->{$rom}->{'ImageFile'}->{'name'}; # for the buildrom -o option + + # Construct the list of InFiles to pass to buildrom + my $InFiles = %$RomList->{$rom}->{'InFile'}; + foreach my $infile (sort keys %$InFiles) + { + if ($infile eq "name") + { + $InFileList = " ".$InFiles->{'name'} unless (lc($InFiles->{'name'}) eq lc($TargetBoard)); + } + else + { + $InFileList .= " ".$infile unless(lc($infile) eq lc($TargetBoard)); + } + } + my $RomXmlFlag='-f'; + my $XmlFiles = %$RomList->{$rom}->{'XMLFile'}; + foreach my $XmlFlags (keys %$XmlFiles) + { + if ($XmlFlags eq "flag") + { + $RomXmlFlag= $XmlFiles->{'flag'}; + } + } + foreach my $XmlFile (keys %$XmlFiles) + { + if ($XmlFile eq "name") + { + $XmlFileList = "$RomXmlFlag"."$Epocroot"."epoc32\\rom\\include\\".$XmlFiles->{'name'}; + } + else + { + $XmlFileList .= "$RomXmlFlag"."$Epocroot"."epoc32\\rom\\include\\".$XmlFile unless(lc($XmlFile) eq lc($TargetBoard)); + } + } + + # Get the ROM macro if one is defined + if ( defined $RomList->{$rom}->{'Macro'} ) + { + if (defined $RomList->{$rom}->{'Macro'}->{'name'} ) + { + if ( $RomList->{$rom}->{'Macro'}->{'value'} ne "" ) + { + $MacroList = " -D".$RomList->{$rom}->{'Macro'}->{'name'}."=".$RomList->{$rom}->{'Macro'}->{'value'}; + } + else + { + $MacroList = " -D".$RomList->{$rom}->{'Macro'}->{'name'}; + } + } + else + { + my $Macros = %$RomList->{$rom}->{'Macro'}; + foreach my $macro (keys %$Macros) + { + if ( $Macros->{$macro}->{'value'} ne "" ) + { + $MacroList .= " -D".$macro."=".$Macros->{$macro}->{'value'}; + } + else + { + $MacroList .= " -D".$macro; + } + } + } + } + + # Call buildrom + my $buildrom_command = "buildrom $InFileList $MacroList $XmlFileList $ImageFile 2>&1"; + my $gHiResTimer = 0; + if (eval "require Time::HiRes;") + { + $gHiResTimer = 1; + } + else + { + print "Cannot load HiResTimer Module\n"; + } + open TVROMLOG, ">> $logdir\\techviewroms$buildnum.log"; + print TVROMLOG "===------------------------------------------------\n"; + print TVROMLOG "-- Stage=$Stage\n"; + print TVROMLOG "===----------------------------------------------\n"; + print TVROMLOG "-- Stage=$Stage started ".localtime()."\n"; + print TVROMLOG "=== Stage=$Stage == Build $rom\n"; + print TVROMLOG "-- Stage=$Stage == $TargetBoard $InFileList\n"; + print TVROMLOG "-- $buildrom_command\n"; + print TVROMLOG "-- MetaromBuild Executed ID $Stage $buildrom_command \n"; + print TVROMLOG "++ Started at ".localtime()."\n"; + if ($gHiResTimer == 1) + { + print TVROMLOG "+++ HiRes Start ".Time::HiRes::time()."\n"; + } + else + { + # Add the HiRes timer unavailable statement + print TVROMLOG "+++ HiRes Time Unavailable\n"; + } + my $command_output = `$buildrom_command`; + print TVROMLOG $command_output; + if ($?) + { + print TVROMLOG "ERROR: $buildrom_command returned an error code $?\n"; + } + if (($command_output =~m/\d\sFile/g) and ($command_output!~/Failed/ig) and ($command_output!~/Unsucessful/ig)) + { + print TVROMLOG "Rom Built Sucessfully\n"; + } + else + { + print TVROMLOG "ERROR: $buildrom_command failed .Please check log techviewroms$buildnum.log for details\n"; + } + if ($gHiResTimer == 1) + { + print TVROMLOG "+++ HiRes End ".Time::HiRes::time()."\n"; + } + else + { + # Add the HiRes timer unavailable statement + print TVROMLOG "+++ HiRes Time Unavailable\n"; + } + print TVROMLOG "++ Finished at ".localtime()."\n"; + print TVROMLOG "=== Stage=$Stage finished ".localtime()."\n"; + close TVROMLOG; + + # Publishing of Logs and Roms##################### + my $ImageFileXML = $ImageFile ; + $ImageFileXML =~s/^\s-o//i; + $ImageFileXML =~/(.*\d.techview)/; + my $ImageFileXMLresult = $1; + my $cwdir = abs_path ( $ENV { 'PWD' } ); + $cwdir =~s/\//\\/g; + $rom =~ /(\w+).*/; + my $data = $1; + if(($publish ne "")) + { + if($rom =~ /(\w+).*/) + { + my $data = $1; + if(not -d "$publish\\$1") + { + mkpath "$publish\\$1" || die "ERROR: Cannot create $publish\\$1"; # If folder doesnt exist create it + } + opendir(DIR, $cwdir) || die "can't opendir $cwdir: $!"; + my @file_array =readdir(DIR); + foreach ($ImageFileXMLresult) + { + foreach my $ImageFileConcat (@file_array) + { + $ImageFileConcat =~/(.*\d.techview)/; + my $Image = $1; + + if ($ImageFileXMLresult eq $Image) + { + copy ("$cwdir\\$ImageFileConcat" , "$publish\\$data\\");# or die "Cannot copy file:$!"; + } + } + closedir DIR; + } + } + } + else + { + print"Publish Option not used \n"; + } +} + +######################################## +##### Process the command line ######### +######################################## +sub ProcessCommandLine +{ + my ($romspec, $boards, $roms, $publish, $help, $version); + + GetOptions('romspec=s' => \$romspec, + 'roms=s' => \$roms, + 'boards=s' => \$boards, + 'logdir=s' => \$logdir, + 'buildnum=s' => \$buildnum, + 'publish=s' => \$publish, + 'help' => \$help, + 'version' => \$version)|| die Usage(); + + return ($romspec, $boards, $roms, $logdir, $buildnum, $publish, $help, $version); +} + + +sub Usage +{ + print < [options] + + When no options are specified, all ROMs specified in the romspec wil be built. + + Options: + -logdir + -buildnum + -publish + -help + -version + +USAGE_EOF +exit 0; +} + +sub Version +{ + print <import; + } +} + +1; diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/tools/romosvariant.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/romosvariant.pm Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,74 @@ +# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Collection of utilitiy functions which is copied from Symbian OS perl modules. +# It provides platform related information to ROM Tools including buildrom, +# features.pl, etc. +# + +package romosvariant; + +require Exporter; +@ISA=qw(Exporter); +@EXPORT=qw( + os_name + is_windows + is_linux + env_delimiter + path_delimiter +); + +use strict; + +sub os_name +{ + return $^O; +} + +sub is_windows +{ + if ($^O =~ /^MSWin32$/i){ + return 1; + }else{ + return 0; + } +} + +sub is_linux +{ + if ($^O =~ /^MSWin32$/i){ + return 0; + }else{ + return 1; + } +} + +sub env_delimiter +{ + if ($^O =~ /^MSWin32$/i){ + return ";"; + }else{ + return ":"; + } +} + +sub path_delimiter +{ + if ($^O =~ /^MSWin32$/i){ + return "\\"; + }else{ + return "\/"; + } +} + +1; diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/buildrom/tools/romutl.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/romutl.pm Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,1697 @@ +# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Collection of utilitiy functions which is copied from Symbian OS perl modules. +# It provides platform related information to ROM Tools including buildrom, +# features.pl, etc. +# + +package romutl; + +require Exporter; +@ISA=qw(Exporter); +@EXPORT=qw( + init_plat + init_bsfs + init_platwithbpabi + + get_epocroot + get_drive + get_epocdrive + get_versionedname + get_bpabiplatlist + get_platlist + get_platcustomizes + get_platroot + get_makeeabspath + get_variantmacrolist + get_variantmacroHRHfile + get_abiv2mode + get_variantfullpath + get_BVbinname + get_variant + + is_existinpath + + set_verbose + + check_varfile + split_path + append_driveandquote + write_32bit +); + + +# EPOCROOT with proper format +my $epocroot; +my $epocdrive = ""; +my $drive = ""; + +BEGIN { + require 5.005_03; # check user has a version of perl that will cope + + $epocroot = $ENV{EPOCROOT}; + $epocroot = "\/" if (!$epocroot); # use "\" if EPOCROOT is not specified + $epocroot =~ s/\\/\//g; + $epocroot .= "\/" unless $epocroot =~ /\/$/; +} + +use strict; +use Cwd; +use File::Spec; +use romosvariant; + +my $verbose=0; + +######################## +#Init +# + +#die "ERROR: EPOCROOT must specify an existing directory." if (!-d $epocroot); +#die "ERROR: EPOCROOT must not be a UNC path\n" if ($epocroot =~ /^\\\\/); + +$drive=$1 if (cwd =~ /^(.:)/); + +if ($epocroot =~ /^(.:)/) +{ + $epocdrive=$1; +} +else +{ +# current working directory is different to SDK's + $epocdrive=$drive +} + +##################################### +# General functions +# + +sub get_epocroot +{ + return $epocroot; +} + +sub get_epocdrive +{ + return $epocdrive; +} + +sub get_drive +{ + return $drive; +} + +sub set_verbose +{ + $verbose = shift; +} + +use constant QUIET_NOT_FOUND => 0; # return 0 if file not found in the PATH +use constant DIE_NOT_FOUND => 1; # issue error and die if file not found in the PATH +use constant ERROR_NOT_FOUND => 2; # issue error and return 0 if file not found in the PATH + +# Simulate shell to locate executable file in the PATH +# +# WARNING: don't use this func in a deep loop because of the +# less efficient implementation +# +# usage: is_existinpath [] +# +# flag == DIE_NOT_FOUND die and display error when not found +# flag == ERROR_NOT_FOUND display error and return 0 when not found +# else return 0 when not found +# return 1 when found + +sub is_existinpath +{ + my ($filename, $flag)=@_; + return 0 unless defined $filename; + return 0 if ($filename =~ /\\/); + return 0 if ($filename =~ /\//); + + my @paths; + my $delimiter = &env_delimiter; + @paths = split(/$delimiter/, $ENV{PATH}); + unshift @paths, "\."; + + foreach my $path (@paths) + { + next if ($path =~ /^\s*$/); + chomp $path; + $path =~ s/\\/\//g; + $path .= "\/" unless ($path =~ /\/$/); + $path = $path.$filename; + foreach my $ext ("", ".bat", ".cmd", ".exe", ".com", ".pl", ".py") + { + return 1 if (-e $path.$ext); + } + } + die "Error: Cannot found \"$filename\" in the PATH.\n" if ($flag == DIE_NOT_FOUND); + print "Error: Cannot found \"$filename\" in the PATH.\n" if ($flag == ERROR_NOT_FOUND); + return 0; +} + +######################################### +# Symbian variant functions and variables +# +# copy from e32variant.pm +# + +my $toolspath = $epocroot . "epoc32\/tools\/"; +# SPPR begin +# enable includation of spp_variant.cfg if it exist +my $spp_cfgFile = $toolspath . "variant\/spp_variant.cfg"; +my $cfgFile = $toolspath . "variant\/variant.cfg"; # default location +$cfgFile = $spp_cfgFile if -e $spp_cfgFile; # use spp_variant.cfg +# SPPR End + +my $variantABIV2Keyword = &get_abiv2mode; # if variant ABIv2 mode enabled + +my $hrhdrive = $epocdrive; # variant hrh drive +my $hrhfile; # variant hrh file +my @macros; # variant macros + +if ($cfgFile =~ /^(.:)/i) +{ + $hrhdrive = lc($1); +} + +# returns the variant specific macro definitions as a list +sub get_variantmacrolist{ + + return @macros if (@macros); + + my $vfile = get_variantmacroHRHfile(); + + if($vfile) + { + my $VariantFilePath = split_path('Path',$vfile); + chop( $VariantFilePath ); + $VariantFilePath = &append_driveandquote($VariantFilePath); + $vfile = &append_driveandquote($vfile); + my $e32Path = &append_driveandquote($epocroot."epoc32\/include"); + + open CPPPIPE,"cpp -I $e32Path -I $VariantFilePath -undef -dM $vfile |" or die "ERROR: Can't invoke CPP.EXE\n"; + while(){ + if($_ =~ /(\#define)(\s+)(.+)/){ + push @macros, $3; + } + } + close CPPPIPE; + } + return @macros; +} + +# return hrh filename defined in variant cfg file +# notice: abort if hrh file located in different drive to cfg file +sub get_variantmacroHRHfile{ + + return $hrhfile if ($hrhfile); + if(-e $cfgFile){ + open(FILE, $cfgFile) || die "\nCould not open: " . $cfgFile ."\n"; + while () { + # strip comments + s/^([^#]*)#.*$/$1/o; + # skip blank lines + if (/^\s*$/o) { + next; + } + # get the hrh file + if($_ =~ /\.hrh/xi){ + $hrhfile = $_; + last; + } + } + close FILE; + die "\nERROR: No variant file specified in $cfgFile!\n" unless $hrhfile; + $hrhfile =~ s/\s+//g; + $hrhfile=~s/^(.:)//io; # remove drive letter + my $paths_drive = lc($1); + + chomp $hrhfile; + $hrhfile = get_makeeabspath($epocroot."epoc32\/", $epocroot, $hrhfile); # assume relative to EPOCROOT + + + if($paths_drive){ + die "\nERROR: Variant file specified in $cfgFile is not on the same drive as \/epoc32\/\n" + unless ($paths_drive eq $hrhdrive); + } + die "\nERROR: $cfgFile specifies $hrhfile which doesn't exist!\n" unless (-e $hrhfile); + + # make sure it is in unix syntax + $hrhfile=~ s/\\/\//g; + } + return $hrhfile; +} + +# get status of EANBLE_ABIV2_MODE +# 1=enabled 0=disabled +sub get_abiv2mode{ + + return $variantABIV2Keyword if (defined $variantABIV2Keyword); + + $variantABIV2Keyword=0; + if(-e $cfgFile){ + open(FILE, $cfgFile) || die "\nCould not open: " . $cfgFile ."\n"; + while () { + # strip comments + s/^([^#]*)#.*$/$1/o; + # skip blank lines + if (/^\s*$/o) { + next; + } + # get the hrh file + if($_ =~ /^ENABLE_ABIV2_MODE$/xi){ + $variantABIV2Keyword=1; + last; + } + } + close FILE; + } + + return $variantABIV2Keyword; +} + +############################# +# Path utilities +# +# copy from pathutl.pm +# + +#args: $_[0] Start EPOCPath Abs FilePath/Path $_[1]... list of (Abs/Rel FilePath/Path) +# Variant of MakAbs which also maps "+\\" to "${EPOCPath}" +sub get_makeeabspath ($@) { + return undef unless $_[0]=~m-^(.:)?[\\\/]-o; + my ($EPOCPath,$Path,@List)=@_; + my $BasePath=&split_path("Path",$Path); + undef $Path; + my $p; + foreach $p (@List) { + $p =~ s-\\-\/-g; + if ($p=~m-^\/?epoc32\/(.*)$-io) { # change - special case for existing \\epoc32 references + $p=$EPOCPath.$1; + next; + } + if ($p=~m-^\s*\+\/(.*)$-o) { + $p=$EPOCPath.$1; + next; + } + if ($p=~m-^\.{2}-o) { + $p=&strip_path($BasePath.$p); + next; + } + if ($p=~m-^[^\.\/]-o) { + $p=$BasePath.$p unless ($p =~ m-^.:-o); + next; + } + if ($p=~m-^(.:)?\/-o) { + next; + } + if ($p=~m-^\.\/(.*)$-o) { + $p=&strip_path($BasePath.$1); + next; + } + return undef; + } + return wantarray ? @List : $List[0]; +} + +#args: $_[0] Abs FilePath/Path +# Remove excess occurrences of '..' and '.' from a path +sub strip_path ($) { + return undef unless $_[0]=~m-^(.:)?[\/\\]-o; + my $P=$_[0]; + while ($P=~s-([\/\\])\.[\/\\]-$1-go) { } + while ($P=~s-[\\](?!\.{2}\\)[^\\]*\\\.{2}(?=\\)--go) { } + $P; +} + +#args: $_[0] 'Path' or 'Base' or 'Ext' $_[1] Abs/Rel FilePath/Path +# return the section of a file path required - Path, Base, Ext or File +sub split_path ($$) { + my ($Sect,$P)=@_; + + return '' if !$P; + $Sect= ucfirst lc $Sect; + if ($Sect eq 'Path') { + if ($P=~/^(.*[\\\/])/o) { + return $1; + } + return ''; + } + undef; +} + +sub append_driveandquote ($) { +# Take a path, or list of paths, and prefix with drive based on 1. epocroot, 2.CWD. +# Relative paths are just quoted. + my @List=@_; + my $Path; + + + foreach $Path (@List) { + next if ($Path !~ /^[\/\\]/); # skip prefix with drive letter or relative path + $Path=$epocdrive.$Path; + } + + foreach $Path (@List) { + chomp $Path; + $Path="\"".$Path."\""; + } + + return wantarray ? @List : $List[0]; +} + + +############################### +# General Utilities +# +# copy from genutl.pm +# + +# return name with well formated version id in hex +sub get_versionedname($) { + my ($name) = @_; + if ($name =~ /(.*)\{\s*(\d+)\s*\.\s*(\d+)\s*\}(.*?)$/i) { + my $a = $1; + my $b = $4; + my $major = $2; + my $minor = $3; + return $a.sprintf("{%04x%04x}",$major,$minor).$b if ($major<32768 and $minor<32768); + } + return $name; +} + + +############################### +# BPABI Platform Utilities +# +# copy from bpabiutl.pm +# + +my @BPABIPlats; + + +# Identify the BPABI platforms to be supported based on the compiler configuration files +# present in the location specified by the environment variable "SYMBIAN_COMPILATION_CONFIG_DIR" +# and in the directory $EPOCROOT\epoc32\tools\compilation_config +sub get_bpabiplatlist +{ + return @BPABIPlats if (scalar(@BPABIPlats)); + + my @CompilerConfigPath; + + if (exists($ENV{'SYMBIAN_COMPILATION_CONFIG_DIR'})) + { + my $Path = $ENV{SYMBIAN_COMPILATION_CONFIG_DIR}; + @CompilerConfigPath = split(/;/, $Path); + } + + push @CompilerConfigPath, "${epocroot}epoc32\/tools\/compilation_config"; + + my $ConfigDir; + + foreach $ConfigDir (@CompilerConfigPath) + { + opendir DIR, "$ConfigDir"; + my @Plats=grep /\.mk$/i, readdir DIR; + my $Plat; + foreach $Plat (@Plats) + { +# The platform name will be same as the name of the configuration file +# with the suffix '.mk' removed + $Plat =~ s/\.mk//; + if ($variantABIV2Keyword) { + if ($Plat =~ /^armv5_abiv2$/i) { + $Plat = "ARMV5"; + } + } + else { + if ($Plat =~ /^armv5$/i) { + $Plat = "ARMV5_ABIV2"; + } + } + unless (grep /$Plat$/i, @BPABIPlats) { + $Plat = uc $Plat; + push @BPABIPlats, $Plat; + } + } + } + closedir DIR; + return @BPABIPlats; +} + +############################# +# Platform Utilities +# +# copy from e32plat.pm +# +my %Plat=( + ARM4=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + }, + ARM4SMP=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + SMP=>1, + StatLink=>'ARM4SMP', + }, + ARM4T=>{ + ABI=>'ARM4T', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + }, + ARMI=>{ + ASSP=>'MARM', + Generic=>1, + ASSPABI=>'', + }, + SARM4=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + Single=>1, + }, + SARMI=>{ + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + Single=>1, + }, + STHUMB=>{ + ABI=>'THUMB', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + Single=>1, + }, + THUMB=>{ + ABI=>'THUMB', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + }, + TOOLS=>{ + ABI=>'TOOLS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'TOOLS', + OS=>'TOOLS', + MakeMod=>'Cl_win', + MakeCmd=>'nmake', + }, + TOOLS2=>{ + ABI=>'TOOLS2', + ASSPABI=>'', + Compiler=>'GCC32', + CPU=>'TOOLS2', + OS=>'TOOLS2', + MakeMod=>'Cl_mingw', + MakeCmd=>'make', + }, + CWTOOLS=>{ + ABI=>'TOOLS', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'TOOLS', + OS=>'TOOLS', + MakeMod=>'Cl_tools', + MakeCmd=>'make', + }, + VC6TOOLS=>{ + ABI=>'TOOLS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'TOOLS', + Ext=>'.DSP', + MakeMod=>'Ide_vc6', + MakeCmd=>'nmake', + OS=>'TOOLS', + Real=>'TOOLS', + UsrHdrsOnly=>1, + }, + WINS=>{ + ABI=>'WINS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'WINS', + MakeMod=>'Cl_win', + MakeCmd=>'nmake', + OS=>'WINS', + }, + VC6=>{ + ABI=>'WINS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'WINS', + Ext=>'.DSP', + MakeMod=>'Ide_vc6', + MakeCmd=>'nmake', + OS=>'WINS', + Real=>'WINS', + UsrHdrsOnly=>1, + }, + WINSCW=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + MakeMod=>'Cl_codewarrior', + OS=>'WINS', + DefFile=>'WINS', # use the MSVC def files + }, + CW_IDE=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + Ext=>'.xml', + MakeMod=>'Ide_cw', + MakeCmd=>'make', + OS=>'WINS', + Real=>'WINSCW', + DefFile=>'WINS', # use the MSVC def files + UsrHdrsOnly=>1, + SupportsMultiplePlatforms=>1, # supports more than one real platform + }, + X86=>{ + ABI=>'X86', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'X86', + MakeMod=>'Cl_x86', + MakeCmd=>'nmake', + OS=>'EPOC32', + DefFile=>'X86', + Generic=>1, + }, + X86SMP=>{ + ABI=>'X86', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'X86', + MakeMod=>'Cl_x86', + MakeCmd=>'nmake', + OS=>'EPOC32', + DefFile=>'X86', + Generic=>1, + SMP=>1, + StatLink=>'X86SMP', + }, + X86GCC=>{ + ABI=>'X86gcc', + ASSPABI=>'', + Compiler=>'X86GCC', + CPU=>'X86', + MakeMod=>'Cl_x86gcc', + OS=>'EPOC32', + DefFile=>'x86gcc', + Generic=>1, + }, + X86GMP=>{ + ABI=>'X86gcc', + ASSPABI=>'', + Compiler=>'X86GCC', + CPU=>'X86', + MakeMod=>'Cl_x86gcc', + OS=>'EPOC32', + DefFile=>'x86gcc', + Generic=>1, + SMP=>1, + StatLink=>'X86GMP', + }, + ARMV4=>{ + ABI=>'ARMV4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_arm', + Compiler=>'ARMCC', + DefFile=>'EABI', + EABI=>1, + }, + ARMV4SMP=>{ + ABI=>'ARMV4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_arm', + Compiler=>'ARMCC', + DefFile=>'EABI', + EABI=>1, + SMP=>1, + StatLink=>'ARMV4SMP', + }, + ARMV5_ABIV1=>{ + ABI=>'ARMV5', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_arm', + Compiler=>'ARMCC', + DefFile=>'EABI', + EABI=>1, + SupportsFeatureVariants=>1, + }, + ABIV2=>{ + ABI=>'ARMV5', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_bpabi', + DefFile=>'EABI', + EABI=>1, + SupportsFeatureVariants=>1, + }, + GCCXML=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'cl_gccxml', + }, + VS6=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + MakeMod=>'Cl_vscw', + OS=>'WINS', + Real=>'WINSCW', + DefFile=>'WINS', # use the MSVC def files + Ext=>'.mak' + }, + VS2003=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + MakeMod=>'Cl_vscw', + OS=>'WINS', + Real=>'WINSCW', + DefFile=>'WINS', # use the MSVC def files + Ext=>'.mak' + }, + EDG=>{ + ABI=>'ARMV5', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'cl_edg', + }, + + # ASSP platforms should be described using .ASSP files + # Do not add additional ASSP platforms to this file. +); + +my $init_bsfs_done = 0; +my $init_plat_done = 0; +my @PlatList; # Platlist returned by list_plat() + +# initialize BSF platforms into %Plat +sub init_bsfs($) { + return $init_bsfs_done if ($init_bsfs_done); + + my ($Path)=@_; +# get a list of modules + opendir DIR, $Path; + my @BSFs=grep s/^([^\.].*)\.BSF$/$1/, map { uc $_ } sort readdir DIR; + closedir DIR; + + my $BSF; + foreach $BSF (@BSFs) { + my $File=$Path.lc($BSF).'.bsf'; +# check whether the assp is already defined + if (defined %{$Plat{$BSF}}) { + warn( + "$File : warning: Platform \"$BSF\" already defined\n", + " ... skipping this spec\n" + ); + delete $Plat{$BSF}; + next; + } +# open the module + unless (open FILE, $File) { + delete $Plat{$BSF}; + warn "warning: Can't open BSF specification \"$File\"\n"; + next; + } + my $line1 = ; + $line1 = uc($line1); + unless ($line1 =~ /^\#\\#/) { + warn "warning: \"$File\" Invalid BSF specification - missing ##\n"; + delete $Plat{$BSF}; + close FILE; + next; + } + my $custom; + while ($custom = ) { + #skip blank lines and comments + delete $Plat{$BSF}; + last unless ($custom =~ /^$|^\#/); + } + $custom = uc $custom; + unless ($custom =~ /^\s*CUSTOMIZES\s+(\S+)/) { + warn "warning: \"$File\" Invalid BSF specification - 'customizes' missing\n"; + delete $Plat{$BSF}; + close FILE; + next; + } + my $root = $1; + my $platname = ''; + my $CustomizedPlatName = ''; + + # In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist + my $Armv5Flag = 0; + if (!$variantABIV2Keyword && $root =~ /^ARMV5$/i) { + $Armv5Flag = 1; + } + + # Support for Hierarchy of Customizations (BSF file customization of another BSF file) + # 1. Check whether the BSF file customizes another BSF file. + # 2. If so, check whether the root BSF file has already been read. + # 3. If not read, then defer the current BSF file reading until the root file is read. + my $rootPlatFound = 0; + if (defined %{$Plat{$root}} || $Armv5Flag) + { + # BSF platform customizes another valid BSF platform + if (defined $Plat{$root}{'CUSTOMIZES'}) + { + $rootPlatFound = 1; + $platname = $root; + $CustomizedPlatName = $root; + + # Set the root platform name which is same as of customizes platform + $Plat{$BSF}{'ROOTPLATNAME'} = $Plat{$root}{'ROOTPLATNAME'}; + } + # BSF platform customizes to one of the existing ABI platforms + else + { + # All BPABI platforms inherits from ABIV2 platform listed in the platlist + if (grep /^$root$/i, @BPABIPlats) { + $platname = "ABIV2"; + } + elsif ($Armv5Flag) { + # In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist + $platname = "ARMV5_ABIV1"; + } + else { + $platname = $root; + } + + $CustomizedPlatName=$root; + + # BSF File check Begins + # The following check is included to handle the existing BSF files which has to behave in different manner + # in default v1 mode and v2 mode. The following code changes the BSF name and the custmoized platform name + # to the implied names. This is done to support switching between v1 and v2 modes by enabling the keyword in + # the variant configuration file. + # In v1 mode, the ARMV6_ABIV1 => ARMV6 platform and ARMV6 => ARMV6_ABIV2 platform. + if (!$variantABIV2Keyword) { + if ($BSF =~ /^ARMV6_ABIV1$/i) { + $BSF = "ARMV6"; + $CustomizedPlatName = "ARMV5"; + } + elsif ($BSF =~ /^ARMV6$/i) { + $BSF = "ARMV6_ABIV2"; + $CustomizedPlatName = "ARMV5_ABIV2"; + $platname = "ABIV2"; + } + } + # BSF File check Ends + + # Set the root platform name + $Plat{$BSF}{'ROOTPLATNAME'} = $CustomizedPlatName; + } + } + else + { + my $rootbsf = $Path.$root.".bsf"; + if ( -e $rootbsf ) { + # BSF file customizes another BSF file which has not been read yet. + # So defer current BSF file reading until the root BSF file is read. + delete $Plat{$BSF}; + push(@BSFs, $BSF); + next; + } + } + # If the customizes platform is not a valid BSF platform or BPABI platorm or ARMV5 or ARMV5_ABIV1, + # then throw warning. + unless ($rootPlatFound || $root =~ /^ARMV5(_ABIV1)?$/ || (grep /^$root$/i, @BPABIPlats)) { + warn "warning: \"$File\" Invalid BSF specification - customization restricted to ARMV5, ABIv2 and valid BSF platforms\n"; + close FILE; + delete $Plat{$BSF}; + next; + } + + my ( $key, $value); + while (($key, $value) = each %{$Plat{$platname}}) { + $Plat{$BSF}{$key}=$value; + } + + push @{$Plat{$CustomizedPlatName}{'CUSTOMIZATIONS'}}, $BSF; + $Plat{$BSF}{'CUSTOMIZES'} = $CustomizedPlatName; + while () { + next if (/^$|^\#/); + if (/^\s*SMP\s*$/i) { + $Plat{$BSF}{'SMP'} = 1; + $Plat{$BSF}{'StatLink'} = lc $BSF; + next; + } + $Plat{$BSF}{'CUSTOMIZATION_DATA'} .= $_; + } + # BSF file statements will have newline character("\n") at the end, except for the last statement. + # So append "\n" for the last BSF file statement. + # "\n" will be used to split BSF statements to support hierarchy of customizations. + $Plat{$BSF}{'CUSTOMIZATION_DATA'} .= "\n"; + close FILE; + } + $init_bsfs_done = 1; +} + +# setup Plat with bpabi platforms +sub init_platwithbpabi() +{ + foreach my $Candidate (&get_bpabiplatlist) + { +# All BPABI platforms inherit from ABIV2 properties as listed in the platlist +# and Platlist is updated to include the BPABI platforms. + my ( $key, $value); + while (($key, $value) = each %{$Plat{ABIV2}}) { + $Plat{$Candidate}{$key}=$value; + } + } +} + +# initialize %Plat with BSF/Bpabi/ASSP +sub init_plat ($) { # takes path to ASSP modules + + return $init_plat_done if ($init_plat_done); + + my ($Path)=@_; + + my %PlatHashKeys=( + ABI=>1, + ASSPABI=>1, + SINGLE=>1, + Compiler=>1, + CPU=>1, + MakeMod=>1, + MakeCmd=>1, + OS=>1, + DefFile=>1, + ASSP=>1, + ); + +# Include the list of BPABI platforms + &init_platwithbpabi; + + init_bsfs($Path); + +# get a list of modules + opendir DIR, $Path; + my @_ASSPs=grep s/^([^\.].*)\.ASSP$/$1/, map { uc $_ } readdir DIR; + closedir DIR; + + my @ASSPs; + foreach (@_ASSPs) { + next if (!$ENV{USEARMCC} and /EDG$/i); + push @ASSPs, $_; + } + +# open each module in turn, and add it to the array + my $ASSP; + foreach $ASSP (@ASSPs) { + my $File=$Path.$ASSP.'.assp'; +# check whether the assp is already defined + if (defined %{$Plat{$ASSP}}) { + warn( + "$File : warning: ASSP \"$ASSP\" already defined\n", + " ... skipping this module\n" + ); + + next; + } +# open the module + unless (open FILE, $File) { + warn "warning: Can't open assp module \"$File\"\n"; + next; + } + my %Data=(); + my %SingleData=(); + my $MatchingSingle=""; + my @Errors=(); + while () { +# strip comments + s/^([^#]*)#.*$/$1/o; +# skip blank lines + if (/^\s*$/o) { + next; + } +# get the key-value pair + unless (/^\s*(\w+)\s+(\w+)\s*$/o) { + push @Errors, "$File($.) : warning: syntax error - only key-value pairs allowed\n"; + next; + } + my ($Key, $Val)=($1, $2); + if ($PlatHashKeys{$Key}!=1) { + push @Errors, "$File($.) : warning: unrecognized keyword - $Key\n"; + next; + } + if ($Key eq "SINGLE") { + $SingleData{Single} = 1; + $SingleData{ASSP} = $ASSP; + $MatchingSingle = uc $2; + } else { + $Data{$Key}=$Val; + $SingleData{$Key}=$Val; + } + } + close FILE; + if (@Errors) { + warn( + @Errors, + " ... skipping this module\n" + ); + next; + } +# change - Allow ASSPs to pick up all the options of the ABI they specify, +# in particular the compiler they need. + $Data{'ASSP'} = $ASSP unless $Data{'ASSP'}; + if ($Plat{$Data{'ABI'}}) { + foreach (keys %{$Plat{$Data{'ABI'}}}) { + $Data{$_} = $Plat{$Data{'ABI'}}{$_} unless ($_ =~ /^GENERIC$/i) or $Data{$_}; + } + } + + %{$Plat{$ASSP}}=%Data; + if ($MatchingSingle ne "") { + foreach (keys %Data) { + $SingleData{$_} = $Data{$_} unless ($_ =~ /^GENERIC$/i) or $SingleData{$_}; + } + %{$Plat{$MatchingSingle}}=%SingleData; + } + } + $init_plat_done=1; +} + +# return list of supported platforms +# should be invoked atfer init_plat +sub get_platlist () { + + return @PlatList if (scalar(@PlatList)); + + &init_plat; + + my $Key; + foreach $Key (keys %Plat) { + if (!$variantABIV2Keyword && $Key =~ /^armv5_abiv1$/i) { + $Key = 'ARMV5'; + } + unless (grep /^$Key$/i, @PlatList) { + push @PlatList, $Key; + } + } + return @PlatList +} + +# return customizes BSF plat if any +sub get_platcustomizes($) { + my ($plat) = @_; + return $Plat{$plat}{'CUSTOMIZES'} ? $Plat{$plat}{'CUSTOMIZES'} : ""; +} + +# return root of a specific plat +sub get_platroot($) { + my ($plat) = @_; + + my $RootName = $Plat{$plat}{'ROOTPLATNAME'}; + + if ($RootName) { + return $RootName; + } + else { + # A non-BSF platform is its own root. + return $plat; + } +} + +################################# +# featurevariant map functions +# +# copy from featurevariantmap.pm + +my $featureListDir = "${epocroot}epoc32\/include\/variant\/featurelists"; + +# Usage: get_BVbinname("my.dll", "myvar") +# +# Look for a binary using its "final" name. We will use the feature +# variant map and the feature variant name to deduce the "variant" +# binary name and test for its existence. +# +# "my.dll" - the final target (full path) +# "myvar" - the feature variant name +# +# returns the file name if found, or "" otherwise. + +sub get_BVbinname +{ + my $binName = shift; + my $varName = shift; + + # look for the vmap file + my $vmapFile = "$binName.$varName.vmap"; + + if (! -e $vmapFile) + { + # compatible to old BV + $vmapFile = "$binName.vmap"; + } + + if (-e $vmapFile) + { + my $key = get_vmapkey($varName, $vmapFile); + + if ($key) + { + $binName =~ /^(.*)\.([^\.]*)$/; + $binName = "$1.$key.$2"; + } + else + { + print "ERROR: No \'$varName\' variant for $binName in $vmapFile\n"; + return ""; # file not found + } + } + + # check that the actual binary exists + if (-e $binName) + { + return $binName; + } + return ""; # file not found +} + +# internal functions +sub get_vmapkey +{ + my @res = get_vmapdata(@_); + return $res[0]; +} + +# Usage: featurevariantmap->GetDataFromVMAP("myvar", "mydll.vmap") +# +# Opens the vmap file indicated and returns the data for the requested variant +# +# "myvar" - the feature variant name +# "my.vmap" - the final target vmap file (full path) +# +# Returns a list ( hash, features ) for the variant in the vmap or undef if not found + +sub get_vmapdata +{ + my $varName = shift; + my $fileName = shift; + + if (!open(VMAP, $fileName)) + { + print "ERROR: Could not read VMAP from $fileName\n"; + return ""; + } + while () + { + chomp; + if (/(\w{32})\s+$varName\s+(.*)$/i or /(\w{32})\s+$varName$/i) + { + my ( $hash, $features ) = ( $1, $2 ? $2 : '' ); + close(VMAP); + return ( $hash, $features ); + } + } + close(VMAP); + return; +} + +###################################### +# Feature variant parser +# +# copy from featurevariantparser.pm +# + + +# Parses .VAR files and returns key variables. +# The following hashes can be used with this module: +# NAME -> Returns the name of the variant file (without the extension) +# FULLPATH -> Returns the full path of the variant file (including the extension) +# VALID -> Set to 1 if the variant file is valid, otherwise set to 0 +# VIRTUAL -> Set to 1 if the variant is a grouping node, otherwise set to 0 +# ROM_INCLUDES -> Returns a pointer to the list of ROM_INCLUDES (including Parent nodes). +# VARIANT_HRH -> Returns the full VARIANT_HRH file path used by the VAR file. + + +my $defaultDir = "${epocroot}epoc32\/tools\/variant"; +my $pathregex = '.+[^\s]' ; # Regex to match all characters (including \ or /), excluding whitespaces. + +my @rominclude; +my @parents; +my @childNodes; +my $virtual; +my $childNodeStatus; +my $varianthrh; + +my $dir; #var directory +my $fullpath; #full path of var file +my $fulldir; # + +# Wrapper function to return all the correct variables +# Arguments : (Variant Name, Variant Directory(optional)) +# Returns a Hash. +sub get_variant +{ + @rominclude = (); + @parents = (); + @childNodes = (); + $dir = ""; + $fullpath = ""; + $varianthrh = ""; + $virtual = 0; + $childNodeStatus = 0; + + + my %data; + my $romincs = ""; + + $data{'VALID'} = 0; + + my ( $varname, $dirname ) = @_; + + my $fullvarpath = get_variantfullpath( $varname, $dirname ); + + if ( $dirname ) + { + $fulldir = $dirname; + } + else + { + $fulldir = $defaultDir; + } + + $data{'FULLPATH'} = "$fullvarpath"; + $data{'NAME'} = "$varname"; + + # If the variant file exists, check the syntax and setup variables. + if ( -e $fullvarpath ) + { + if ( check_varfile( $fullvarpath, $varname ) ) + { + $data{'VALID'} = 1; + } + } + else + { + print "ERROR: $fullvarpath" . " does not exist\n"; + } + + my $count = 0; + + # If VAR file is valid, setup all other variables. + if ( $data{'VALID'} ) + { + + $romincs = find_varrominc($fullvarpath); + + # Remove empty elements from the ROM_INCLUDE list + @$romincs = grep /\S/, @$romincs; + + # Fix paths for all ROM_INCLUDES + for ( my $i = 0 ; $i < scalar(@$romincs) ; $i++ ) + { + @$romincs[$i] = get_fixpath( @$romincs[$i] ); + } + + $data{'ROM_INCLUDES'} = clone_list($romincs); + $data{'VARIANT_HRH'} = $varianthrh; + $data{'VIRTUAL'} = $virtual; + } + + # If variant file is not valid, return reference to a blank array + else + { + $data{'ROM_INCLUDES'} = []; + $data{'VARIANT_HRH'} = ""; + } + + return %data; +} + +# Method to construct a full variant path from the variant file and directory +sub get_variantfullpath +{ + + my $vardirectory = $_[1]; + my $varname = $_[0]; + + my $dir; + + # Check if a directory is supplied + if ($vardirectory) + { + $dir = "$vardirectory"; + } + + else + { + $dir = $defaultDir; + } + my $filename = "$varname" . "\.var"; + $fullpath = File::Spec->catfile( File::Spec->rel2abs($dir), $filename ); + + if ( !File::Spec->file_name_is_absolute($fullpath) ) + { + $fullpath = File::Spec->rel2abs($fullpath); + } + + return $fullpath; +} + +# Checks the variant file for the correct syntax and reports any errors +# Also sets up some variables(VIRTUAL ,VARIANT_HRH and VARIANT) whilst file is being parsed. + +# Usage: check_varfile(,) . Note: without .var +sub check_varfile +{ + + my $fullpath = $_[0]; + my $varname = $_[1]; + my $varianthrhpresent = 0; + + open( READVAR, "<$fullpath" ); + my $exp = "#"; + my $line = ""; + + while () + { + s/\r\n/\n/g; + + $line = $.; + + # Checks for a valid argument supplied to EXTENDS keyword. Checks for one and only one argument supplied. + if (/^EXTENDS/) + { + if ( !m/^EXTENDS\s+./ ) + { + print "\nERROR: Invalid format supplied to argument EXTENDS on line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + my $str = get_extends($_); + if ( $str =~ /\s+/ ) + { + print "\nERROR: Cannot extend from two nodes. Error in line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + + $childNodeStatus = 1; + } + + # Checks for the grammar of BUILD_INCLUDE, i.e. KEYWORD MODIFIER VALUE + elsif (/^BUILD_INCLUDE/) + { + # skip build inc checking + } + + # Checks for the grammar of ROM_INCLUDE, i.e. KEYWORD MODIFIER VALUE + elsif (/^ROM_INCLUDE/) + { + + if (!m/^ROM_INCLUDE\s+(append|prepend|set)\s+$pathregex/) + { + print "\nERROR: Invalid syntax supplied to keyword ROM_INCLUDE on line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + + if (m/^ROM_INCLUDE\s+(append|prepend|set)\s+$pathregex\s+$pathregex/) + { + print "\nERROR: Too many arguments supplied to keyword ROM_INCLUDE on line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + } + + # Checks for a valid VARIANT name + elsif (/^VARIANT[^_HRH]/) + { + if ( !m/^VARIANT\s+\w+/ ) + { + print "\nERROR: VARIANT name not specified on line " . "$." + . " in file " + . "$fullpath"; + return 0; + } + if ( uc("$varname") ne uc( get_variantname($_) ) ) + { + print "\nERROR: VARIANT filename does not match variant name specified on line " + . "$line" + . " in file " + . "$fullpath" + . "\nVariant value extracted from the VAR file is " . "$_"; + } + + } + + # Checks that keyword VIRTUAL is declared correctly + elsif (/^VIRTUAL/) + { + if (m/^VIRTUAL\s+\w+/) + { + print "\nERROR: Invalid declaration of VIRTUAL on line " . "$." + . " in file " + . "$fullpath"; + return 0; + } + + $virtual = 1; + } + + # Checks if VARIANT_HRH is declared correctly. + elsif (/^VARIANT_HRH/) + { + $varianthrhpresent = 1; + my $lineno = $.; + if ( !m/^VARIANT_HRH\s+./ ) + { + print "\nERROR: Invalid format supplied to argument VARIANT_HRH on line " + . "$lineno" + . " in file " + . "$fullpath"; + return 0; + } + + my $str = get_hrhname($_); + if ( $str =~ /\s+/ ) + { + print "\nERROR: Cannot have 2 or more hrh files. Error in line " + . "$lineno" + . " in file " + . "$fullpath"; + return 0; + } + + unless( -e get_fixpath($str) ) + { + print "\nERROR: VARIANT HRH file : " + . get_fixpath($str) + . " specified on line " + . "$lineno" + . " does not exist"; + return 0; + } + + $varianthrh = get_fixpath( get_hrhname($_) ); + + } + + # If none of the valid keywords are found + else + { + + # Do nothing if a comment or blank line is found + if ( (m/$exp\s+\S/) || (m/$exp\S/) || ( !m/./ ) || (m/^\n/) ) + { + } + + # Unsupported keyword + else + { + + print "\nERROR: Invalid keyword " . '"' . "$_" . '"' + . " found on line " . "$." + . " in file " + . "$fullpath"; + return 0; + } + } + } + + close(READVAR); + + # If no HRH file defined, check if the default one exists + if ( !$varianthrhpresent ) + { + print "\nINFO: No VARIANT_HRH defined in VAR file, using ${epocroot}epoc32\/include\/variant\/$varname\.hrh" if ($verbose); + my $str = + get_hrhname( + "VARIANT_HRH ${epocroot}epoc32\/include\/variant\/$varname\.hrh" + ); + + if ( ! -e $str ) + { + print "\nERROR: VARIANT HRH file : " . "$str " . "does not exist\n"; + return 0; + } + else + { + $varianthrh = $str; + } + } + return 1; +} + +# Extract the value of the VARIANT keyword +sub get_variantname +{ + + $_[0] =~ m/^VARIANT\s+(\w+)/i; + return $1; +} + +# Extracts the value of the HRH file from the VARIANT_HRH line supplied +sub get_hrhname +{ + + $_[0] =~ m/^VARIANT_HRH\s+($pathregex)/; + return $1; + +} + +# Method to find the immediate parent node of a child node +sub get_extends +{ + + $_[0] =~ m/^EXTENDS\s+(\w+)/; + return $1; +} + + +# Method to correct all the slashes, and also append EPOCROOT if the path begins with a \ or / +# If path doesn't start with \ or /, returns an abosulte canonical path +sub get_fixpath +{ + + my $arr = $_[0]; + + if ( $arr =~ m/^\// ) + { + $arr =~ s/^\/?//; + return File::Spec->canonpath( "$epocroot" . "$arr" ); + } + + elsif ( $arr =~ m/^\\/ ) + { + $arr =~ s/^\\?//; + return File::Spec->canonpath( "$epocroot" . "$arr" ); + } + + else + { + return File::Spec->rel2abs( File::Spec->canonpath("$arr") ); + } + +} + +# Method to find the ROMINCLUDE values of the VAR file. +sub find_varrominc +{ + + my $filename = $_[0]; + + my $parentNodes; + + # Construct a list of parent nodes if node is a child + if ($childNodeStatus) + { + $parentNodes = find_varparentnode("$filename"); + } + + if ($parentNodes) + { + + # Go through and build the list of all parent ROM_INCLUDES + for ( my $i = scalar(@$parentNodes) - 1 ; $i >= 0 ; $i-- ) + { + my $t = get_variantfullpath( @$parentNodes[$i], $fulldir ); + open( NEWHANDLE, "<$t" ); + + while () + { + if (/ROM_INCLUDE/) + { + get_varrominc($_); + } + } + close(NEWHANDLE); + } + } + + # Append the ROM_INCLUDES of the VAR file in the end + open( NEWHANDLE, "<$filename" ); + + while () + { + if (/ROM_INCLUDE/) + { + get_varrominc($_); + } + } + + undef(@parents); # Flush out parent array; + return \@rominclude; + +} + +# Constructs a list of Parent nodes for a given Child node. +sub find_varparentnode +{ + + my $filename = $_[0]; + my $hasparents = 0; + + open( READHANDLE, "<$filename" ); + while () + { + if (/EXTENDS/) + { + $hasparents = 1; + push( @parents, get_extends($_) ); + + } + } + + close(READHANDLE); + + if ( $hasparents == 1 ) + { + find_varparentnode( + get_variantfullpath( @parents[ scalar(@parents) - 1 ], $fulldir ) + ); + } + else + { + return \@parents; + } + +} + +# Method to extract the ROM_INCLUDE value of a node. +sub get_varrominc +{ + +# If modifier append is found, push the rominclude to the end of the array list. + if (/^ROM_INCLUDE\s+append\s+($pathregex)/) + { + push( @rominclude, ($1) ); + } + +# If modifier prepend is found, push the rominclude to the beginning of the array list. + if (/^ROM_INCLUDE\s+prepend\s+($pathregex)/) + { + unshift( @rominclude, ($1) ); + } + +# If keyword set is found, then empty the rominclude variable and push the new value + if (/^ROM_INCLUDE\s+set\s+($pathregex)/) + { + undef(@rominclude); + push( @rominclude, ($1) ); + } + +} + +# Helper method that clones a reference to a simple list +sub clone_list + { + my $ref = shift; + + # Check the reference is a list + die "Not a list ref" if ref($ref) ne 'ARRAY'; + + # Create a new list object + my @list; + foreach my $entry ( @$ref ) + { + # Only clone lists of scalars + die "Not a scalar" if ref($entry); + + # Add the entry to the new list + push @list, $entry; + } + + # return a reference to the copy + return \@list; + } + +############################## +# write helper +# +# copy from writer.pm +sub write_32bit # little-endian +{ + my $fileHandle=shift; + my $integer=shift; + &write_8bit($fileHandle, $integer&0x000000ff); + &write_8bit($fileHandle, ($integer>>8)&0x000000ff); + &write_8bit($fileHandle, ($integer>>16)&0x000000ff); + &write_8bit($fileHandle, ($integer>>24)&0x000000ff); +} + +sub write_8bit +{ + my $fileHandle=shift; + my $integer=shift; + if ($integer&0xffffff00) + { + die("Error: the integer ".sprintf("0x%08x", $integer)." is too large to write into 8 bits\n"); + } + printf $fileHandle "%c", $integer; +} + + +1; + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/linux/libboost_filesystem-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_filesystem-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/linux/libboost_regex-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_regex-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/linux/libboost_regex-mgw34-mt-p-1_39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_regex-mgw34-mt-p-1_39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/linux/libboost_system-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_system-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/linux/libboost_thread-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_thread-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/windows/libboost_filesystem-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_filesystem-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/windows/libboost_regex-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_regex-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/windows/libboost_regex-mgw34-mt-p-1_39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_regex-mgw34-mt-p-1_39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/windows/libboost_system-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_system-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/binary/windows/libboost_thread-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_thread-1.39.a has changed diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/cerrno.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/cerrno.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,331 @@ +// Boost cerrno.hpp header -------------------------------------------------// + +// Copyright Beman Dawes 2005. +// Use, modification, and distribution is 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) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_CERRNO_HPP +#define BOOST_CERRNO_HPP + +#include + +// supply errno values likely to be missing, particularly on Windows + +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT 9901 +#endif + +#ifndef EADDRINUSE +#define EADDRINUSE 9902 +#endif + +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL 9903 +#endif + +#ifndef EISCONN +#define EISCONN 9904 +#endif + +#ifndef EBADMSG +#define EBADMSG 9905 +#endif + +#ifndef ECONNABORTED +#define ECONNABORTED 9906 +#endif + +#ifndef EALREADY +#define EALREADY 9907 +#endif + +#ifndef ECONNREFUSED +#define ECONNREFUSED 9908 +#endif + +#ifndef ECONNRESET +#define ECONNRESET 9909 +#endif + +#ifndef EDESTADDRREQ +#define EDESTADDRREQ 9910 +#endif + +#ifndef EHOSTUNREACH +#define EHOSTUNREACH 9911 +#endif + +#ifndef EIDRM +#define EIDRM 9912 +#endif + +#ifndef EMSGSIZE +#define EMSGSIZE 9913 +#endif + +#ifndef ENETDOWN +#define ENETDOWN 9914 +#endif + +#ifndef ENETRESET +#define ENETRESET 9915 +#endif + +#ifndef ENETUNREACH +#define ENETUNREACH 9916 +#endif + +#ifndef ENOBUFS +#define ENOBUFS 9917 +#endif + +#ifndef ENOLINK +#define ENOLINK 9918 +#endif + +#ifndef ENODATA +#define ENODATA 9919 +#endif + +#ifndef ENOMSG +#define ENOMSG 9920 +#endif + +#ifndef ENOPROTOOPT +#define ENOPROTOOPT 9921 +#endif + +#ifndef ENOSR +#define ENOSR 9922 +#endif + +#ifndef ENOTSOCK +#define ENOTSOCK 9923 +#endif + +#ifndef ENOSTR +#define ENOSTR 9924 +#endif + +#ifndef ENOTCONN +#define ENOTCONN 9925 +#endif + +#ifndef ENOTSUP +#define ENOTSUP 9926 +#endif + +#ifndef ECANCELED +#define ECANCELED 9927 +#endif + +#ifndef EINPROGRESS +#define EINPROGRESS 9928 +#endif + +#ifndef EOPNOTSUPP +#define EOPNOTSUPP 9929 +#endif + +#ifndef EWOULDBLOCK +#define EWOULDBLOCK 9930 +#endif + +#ifndef EOWNERDEAD +#define EOWNERDEAD 9931 +#endif + +#ifndef EPROTO +#define EPROTO 9932 +#endif + +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT 9933 +#endif + +#ifndef ENOTRECOVERABLE +#define ENOTRECOVERABLE 9934 +#endif + +#ifndef ETIME +#define ETIME 9935 +#endif + +#ifndef ETXTBSY +#define ETXTBSY 9936 +#endif + +#ifndef ETIMEDOUT +#define ETIMEDOUT 9938 +#endif + +#ifndef ELOOP +#define ELOOP 9939 +#endif + +#ifndef EOVERFLOW +#define EOVERFLOW 9940 +#endif + +#ifndef EPROTOTYPE +#define EPROTOTYPE 9941 +#endif + +#ifndef ENOSYS +#define ENOSYS 9942 +#endif + +#ifndef EINVAL +#define EINVAL 9943 +#endif + +#ifndef ERANGE +#define ERANGE 9944 +#endif + +#ifndef EILSEQ +#define EILSEQ 9945 +#endif + +// Windows Mobile doesn't appear to define these: + +#ifndef E2BIG +#define E2BIG 9946 +#endif + +#ifndef EDOM +#define EDOM 9947 +#endif + +#ifndef EFAULT +#define EFAULT 9948 +#endif + +#ifndef EBADF +#define EBADF 9949 +#endif + +#ifndef EPIPE +#define EPIPE 9950 +#endif + +#ifndef EXDEV +#define EXDEV 9951 +#endif + +#ifndef EBUSY +#define EBUSY 9952 +#endif + +#ifndef ENOTEMPTY +#define ENOTEMPTY 9953 +#endif + +#ifndef ENOEXEC +#define ENOEXEC 9954 +#endif + +#ifndef EEXIST +#define EEXIST 9955 +#endif + +#ifndef EFBIG +#define EFBIG 9956 +#endif + +#ifndef ENAMETOOLONG +#define ENAMETOOLONG 9957 +#endif + +#ifndef ENOTTY +#define ENOTTY 9958 +#endif + +#ifndef EINTR +#define EINTR 9959 +#endif + +#ifndef ESPIPE +#define ESPIPE 9960 +#endif + +#ifndef EIO +#define EIO 9961 +#endif + +#ifndef EISDIR +#define EISDIR 9962 +#endif + +#ifndef ECHILD +#define ECHILD 9963 +#endif + +#ifndef ENOLCK +#define ENOLCK 9964 +#endif + +#ifndef ENOSPC +#define ENOSPC 9965 +#endif + +#ifndef ENXIO +#define ENXIO 9966 +#endif + +#ifndef ENODEV +#define ENODEV 9967 +#endif + +#ifndef ENOENT +#define ENOENT 9968 +#endif + +#ifndef ESRCH +#define ESRCH 9969 +#endif + +#ifndef ENOTDIR +#define ENOTDIR 9970 +#endif + +#ifndef ENOMEM +#define ENOMEM 9971 +#endif + +#ifndef EPERM +#define EPERM 9972 +#endif + +#ifndef EACCES +#define EACCES 9973 +#endif + +#ifndef EROFS +#define EROFS 9974 +#endif + +#ifndef EDEADLK +#define EDEADLK 9975 +#endif + +#ifndef EAGAIN +#define EAGAIN 9976 +#endif + +#ifndef ENFILE +#define ENFILE 9977 +#endif + +#ifndef EMFILE +#define EMFILE 9978 +#endif + +#ifndef EMLINK +#define EMLINK 9979 +#endif + +#endif // include guard diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/enable_shared_from_this.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/enable_shared_from_this.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,18 @@ +#ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED +#define BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED + +// +// enable_shared_from_this.hpp +// +// Copyright (c) 2002 Peter Dimov +// +// Distributed under 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 +// +// http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html +// + +#include + +#endif // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/filesystem.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,20 @@ +// boost/filesystem/filesystem.hpp -----------------------------------------// + +// Copyright Beman Dawes 2005 + +// Use, modification, and distribution is 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) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_FILESYSTEM_HPP +#define BOOST_FILESYSTEM_FILESYSTEM_HPP + +#include // includes path.hpp +#include + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/filesystem/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/config.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,113 @@ +// boost/filesystem/config.hpp ---------------------------------------------// + +// Copyright Beman Dawes 2003 + +// Distributed under 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) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_CONFIG_HPP +#define BOOST_FILESYSTEM_CONFIG_HPP + +#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions + +// ability to change namespace aids path_table.cpp ------------------------// +#ifndef BOOST_FILESYSTEM_NAMESPACE +# define BOOST_FILESYSTEM_NAMESPACE filesystem +#endif + +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html + +#include +#include + +// determine platform ------------------------------------------------------// + +// BOOST_CYGWIN_PATH implies BOOST_WINDOWS_PATH and BOOST_POSIX_API + +# if defined(BOOST_CYGWIN_PATH) +# if defined(BOOST_POSIX_PATH) +# error BOOST_POSIX_PATH is invalid when BOOST_CYGWIN_PATH is defined +# endif +# if defined(BOOST_WINDOWS_API) +# error BOOST_WINDOWS_API is invalid when BOOST_CYGWIN_PATH is defined +# endif +# define BOOST_WINDOWS_PATH +# define BOOST_POSIX_API +# endif + +// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use + +# if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API ) +# error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined +# elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API ) +# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) +# define BOOST_WINDOWS_API +# else +# define BOOST_POSIX_API +# endif +# endif + +// BOOST_WINDOWS_PATH enables Windows path syntax recognition + +# if !defined(BOOST_POSIX_PATH) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)) +# define BOOST_WINDOWS_PATH +# endif + +// narrow support only for badly broken compilers or libraries -------------// + +# if defined(BOOST_NO_STD_WSTRING) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STD_LOCALE) || BOOST_WORKAROUND(__BORLANDC__, <0x610) +# define BOOST_FILESYSTEM_NARROW_ONLY +# endif + +// enable dynamic linking on Windows ---------------------------------------// + +# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)) && BOOST_WORKAROUND(__BORLANDC__, <0x610) && defined(__WIN32__) +# error Dynamic linking Boost.Filesystem does not work for Borland; use static linking instead +# endif + +#ifdef BOOST_HAS_DECLSPEC // defined in config system +// we need to import/export our code only if the user has specifically +// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost +// libraries to be dynamically linked, or BOOST_FILESYSTEM_DYN_LINK +// if they want just this one to be dynamically liked: +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK) +// export if this is our own source, otherwise import: +#ifdef BOOST_FILESYSTEM_SOURCE +# define BOOST_FILESYSTEM_DECL __declspec(dllexport) +#else +# define BOOST_FILESYSTEM_DECL __declspec(dllimport) +#endif // BOOST_FILESYSTEM_SOURCE +#endif // DYN_LINK +#endif // BOOST_HAS_DECLSPEC +// +// if BOOST_FILESYSTEM_DECL isn't defined yet define it now: +#ifndef BOOST_FILESYSTEM_DECL +#define BOOST_FILESYSTEM_DECL +#endif + +// enable automatic library variant selection ------------------------------// + +#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB) +// +// Set the name of our library, this will get undef'ed by auto_link.hpp +// once it's done with it: +// +#define BOOST_LIB_NAME boost_filesystem +// +// If we're importing code from a dll, then tell auto_link.hpp about it: +// +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK) +# define BOOST_DYN_LINK +#endif +// +// And include the header that does the work: +// +#include +#endif // auto-linking disabled + +#endif // BOOST_FILESYSTEM_CONFIG_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/filesystem/convenience.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/convenience.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,306 @@ +// boost/filesystem/convenience.hpp ----------------------------------------// + +// Copyright Beman Dawes, 2002-2005 +// Copyright Vladimir Prus, 2002 +// Use, modification, and distribution is 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) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_CONVENIENCE_HPP +#define BOOST_FILESYSTEM_CONVENIENCE_HPP + +#include +#include +#include +#include + +#include // must be the last #include + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY +# define BOOST_FS_FUNC(BOOST_FS_TYPE) \ + template typename boost::enable_if, \ + BOOST_FS_TYPE>::type +# define BOOST_FS_FUNC_STRING BOOST_FS_FUNC(typename Path::string_type) +# define BOOST_FS_TYPENAME typename +# else +# define BOOST_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE + typedef boost::filesystem::path Path; +# define BOOST_FS_FUNC_STRING inline std::string +# define BOOST_FS_TYPENAME +# endif + +namespace boost +{ + namespace filesystem + { + + BOOST_FS_FUNC(bool) create_directories(const Path& ph) + { + if (ph.empty() || exists(ph)) + { + if ( !ph.empty() && !is_directory(ph) ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_directories", ph, + make_error_code( boost::system::posix::file_exists ) ) ); + return false; + } + + // First create branch, by calling ourself recursively + create_directories(ph.parent_path()); + // Now that parent's path exists, create the directory + create_directory(ph); + return true; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + + BOOST_FS_FUNC_STRING extension(const Path& ph) + { + typedef BOOST_FS_TYPENAME Path::string_type string_type; + string_type filename = ph.filename(); + + BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.'); + if (n != string_type::npos) + return filename.substr(n); + else + return string_type(); + } + + BOOST_FS_FUNC_STRING basename(const Path& ph) + { + typedef BOOST_FS_TYPENAME Path::string_type string_type; + string_type filename = ph.filename(); + BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.'); + return filename.substr(0, n); + } + + + BOOST_FS_FUNC(Path) change_extension( const Path & ph, + const BOOST_FS_TYPENAME Path::string_type & new_extension ) + { return ph.parent_path() / (basename(ph) + new_extension); } + +# endif + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // "do-the-right-thing" overloads ---------------------------------------// + + inline bool create_directories(const path& ph) + { return create_directories(ph); } + inline bool create_directories(const wpath& ph) + { return create_directories(ph); } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline std::string extension(const path& ph) + { return extension(ph); } + inline std::wstring extension(const wpath& ph) + { return extension(ph); } + + inline std::string basename(const path& ph) + { return basename( ph ); } + inline std::wstring basename(const wpath& ph) + { return basename( ph ); } + + inline path change_extension( const path & ph, const std::string& new_ex ) + { return change_extension( ph, new_ex ); } + inline wpath change_extension( const wpath & ph, const std::wstring& new_ex ) + { return change_extension( ph, new_ex ); } +# endif + +# endif + + + // basic_recursive_directory_iterator helpers --------------------------// + + namespace detail + { + template< class Path > + struct recur_dir_itr_imp + { + typedef basic_directory_iterator< Path > element_type; + std::stack< element_type, std::vector< element_type > > m_stack; + int m_level; + bool m_no_push; + bool m_no_throw; + + recur_dir_itr_imp() : m_level(0), m_no_push(false), m_no_throw(false) {} + }; + + } // namespace detail + + // basic_recursive_directory_iterator ----------------------------------// + + template< class Path > + class basic_recursive_directory_iterator + : public boost::iterator_facade< + basic_recursive_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag > + { + public: + typedef Path path_type; + + basic_recursive_directory_iterator(){} // creates the "end" iterator + + explicit basic_recursive_directory_iterator( const Path & dir_path ); + basic_recursive_directory_iterator( const Path & dir_path, + system::error_code & ec ); + + int level() const { return m_imp->m_level; } + + void pop(); + void no_push() + { + BOOST_ASSERT( m_imp.get() && "attempt to no_push() on end iterator" ); + m_imp->m_no_push = true; + } + + file_status status() const + { + BOOST_ASSERT( m_imp.get() + && "attempt to call status() on end recursive_iterator" ); + return m_imp->m_stack.top()->status(); + } + + file_status symlink_status() const + { + BOOST_ASSERT( m_imp.get() + && "attempt to call symlink_status() on end recursive_iterator" ); + return m_imp->m_stack.top()->symlink_status(); + } + + private: + + // shared_ptr provides shallow-copy semantics required for InputIterators. + // m_imp.get()==0 indicates the end iterator. + boost::shared_ptr< detail::recur_dir_itr_imp< Path > > m_imp; + + friend class boost::iterator_core_access; + + typename boost::iterator_facade< + basic_recursive_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag >::reference + dereference() const + { + BOOST_ASSERT( m_imp.get() && "attempt to dereference end iterator" ); + return *m_imp->m_stack.top(); + } + + void increment(); + + bool equal( const basic_recursive_directory_iterator & rhs ) const + { return m_imp == rhs.m_imp; } + + }; + + typedef basic_recursive_directory_iterator recursive_directory_iterator; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_recursive_directory_iterator wrecursive_directory_iterator; +# endif + + // basic_recursive_directory_iterator implementation -------------------// + + // constructors + template + basic_recursive_directory_iterator:: + basic_recursive_directory_iterator( const Path & dir_path ) + : m_imp( new detail::recur_dir_itr_imp ) + { + m_imp->m_stack.push( basic_directory_iterator( dir_path ) ); + if ( m_imp->m_stack.top () == basic_directory_iterator() ) + { m_imp.reset (); } + } + + template + basic_recursive_directory_iterator:: + basic_recursive_directory_iterator( const Path & dir_path, + system::error_code & ec ) + : m_imp( new detail::recur_dir_itr_imp ) + { + m_imp->m_no_throw = true; + m_imp->m_stack.push( basic_directory_iterator( dir_path, ec ) ); + if ( m_imp->m_stack.top () == basic_directory_iterator() ) + { m_imp.reset (); } + } + + // increment + template + void basic_recursive_directory_iterator::increment() + { + BOOST_ASSERT( m_imp.get() && "increment on end iterator" ); + + static const basic_directory_iterator end_itr; + + if ( m_imp->m_no_push ) + { m_imp->m_no_push = false; } + else if ( is_directory( m_imp->m_stack.top()->status() ) ) + { + system::error_code ec; +#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610)) + if( m_imp->m_no_throw ) { + m_imp->m_stack.push( + basic_directory_iterator( *m_imp->m_stack.top(), ec ) + ); + } + else { + m_imp->m_stack.push( + basic_directory_iterator( *m_imp->m_stack.top() ) + ); + } +#else + m_imp->m_stack.push( + m_imp->m_no_throw + ? basic_directory_iterator( *m_imp->m_stack.top(), ec ) + : basic_directory_iterator( *m_imp->m_stack.top() ) ); +#endif + if ( m_imp->m_stack.top() != end_itr ) + { + ++m_imp->m_level; + return; + } + m_imp->m_stack.pop(); + } + + while ( !m_imp->m_stack.empty() + && ++m_imp->m_stack.top() == end_itr ) + { + m_imp->m_stack.pop(); + --m_imp->m_level; + } + + if ( m_imp->m_stack.empty() ) m_imp.reset(); // done, so make end iterator + } + + // pop + template + void basic_recursive_directory_iterator::pop() + { + BOOST_ASSERT( m_imp.get() && "pop on end iterator" ); + BOOST_ASSERT( m_imp->m_level > 0 && "pop with level < 1" ); + + static const basic_directory_iterator end_itr; + + do + { + m_imp->m_stack.pop(); + --m_imp->m_level; + } + while ( !m_imp->m_stack.empty() + && ++m_imp->m_stack.top() == end_itr ); + + if ( m_imp->m_stack.empty() ) m_imp.reset(); // done, so make end iterator + } + + } // namespace filesystem +} // namespace boost + +#undef BOOST_FS_FUNC_STRING +#undef BOOST_FS_FUNC + +#include // pops abi_prefix.hpp pragmas +#endif // BOOST_FILESYSTEM_CONVENIENCE_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/filesystem/exception.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/exception.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,9 @@ +// boost/filesystem/exception.hpp -------------------------------------------// + +// Copyright Beman Dawes 2003 +// Use, modification, and distribution is 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) + +// This header is no long used. The contents have been moved to path.hpp. +// It is provided so that user code #includes do not have to be changed. diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/filesystem/fstream.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/fstream.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,584 @@ +// boost/filesystem/fstream.hpp --------------------------------------------// + +// Copyright Beman Dawes 2002. +// Use, modification, and distribution is 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) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_FSTREAM_HPP +#define BOOST_FILESYSTEM_FSTREAM_HPP + +#include // for 8.3 hack (see below) +#include +#include + +#include +#include + +#include // must be the last #include + +// NOTE: fstream.hpp for Boost 1.32.0 and earlier supplied workarounds for +// various compiler problems. They have been removed to ease development of the +// basic i18n functionality. Once the new interface is stable, the workarounds +// will be reinstated for any compilers that otherwise can support the rest of +// the library after internationalization. + +namespace boost +{ + namespace filesystem + { + namespace detail + { +# if defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_NARROW_ONLY) +# if !defined(BOOST_DINKUMWARE_STDLIB) || BOOST_DINKUMWARE_STDLIB < 405 + // The 8.3 hack: + // C++98 does not supply a wchar_t open, so try to get an equivalent + // narrow char name based on the short, so-called 8.3, name. + // Not needed for Dinkumware 405 and later as they do supply wchar_t open. + BOOST_FILESYSTEM_DECL bool create_file_api( const std::wstring & ph, + std::ios_base::openmode mode ); // true if succeeds + BOOST_FILESYSTEM_DECL std::string narrow_path_api( + const std::wstring & ph ); // return is empty if fails + + inline std::string path_proxy( const std::wstring & file_ph, + std::ios_base::openmode mode ) + // Return a non-existant path if cannot supply narrow short path. + // An empty path doesn't work because some Dinkumware versions + // assert the path is non-empty. + { + std::string narrow_ph; + bool created_file( false ); + if ( !exists( file_ph ) + && (mode & std::ios_base::out) != 0 + && create_file_api( file_ph, mode ) ) + { + created_file = true; + } + narrow_ph = narrow_path_api( file_ph ); + if ( narrow_ph.empty() ) + { + if ( created_file ) remove_api( file_ph ); + narrow_ph = "\x01"; + } + return narrow_ph; + } +# else + // Dinkumware 405 and later does supply wchar_t functions + inline const std::wstring & path_proxy( const std::wstring & file_ph, + std::ios_base::openmode ) + { return file_ph; } +# endif +# endif + + inline const std::string & path_proxy( const std::string & file_ph, + std::ios_base::openmode ) + { return file_ph; } + + } // namespace detail + + template < class charT, class traits = std::char_traits > + class basic_filebuf : public std::basic_filebuf + { + private: // disallow copying + basic_filebuf( const basic_filebuf & ); + const basic_filebuf & operator=( const basic_filebuf & ); + public: + basic_filebuf() {} + virtual ~basic_filebuf() {} + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template + typename boost::enable_if, + basic_filebuf *>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + + basic_filebuf * + open( const wpath & file_ph, std::ios_base::openmode mode ); +# endif + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + basic_filebuf * + open( const path & file_ph, std::ios_base::openmode mode ); +# endif + }; + + template < class charT, class traits = std::char_traits > + class basic_ifstream : public std::basic_ifstream + { + private: // disallow copying + basic_ifstream( const basic_ifstream & ); + const basic_ifstream & operator=( const basic_ifstream & ); + public: + basic_ifstream() {} + + // use two signatures, rather than one signature with default second + // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416) + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template + explicit basic_ifstream( const Path & file_ph, + typename boost::enable_if >::type* dummy = 0 ); + + template + basic_ifstream( const Path & file_ph, std::ios_base::openmode mode, + typename boost::enable_if >::type* dummy = 0 ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + + explicit basic_ifstream( const wpath & file_ph ); + basic_ifstream( const wpath & file_ph, std::ios_base::openmode mode ); + void open( const wpath & file_ph ); + void open( const wpath & file_ph, std::ios_base::openmode mode ); +# endif + + explicit basic_ifstream( const path & file_ph ); + basic_ifstream( const path & file_ph, std::ios_base::openmode mode ); +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + void open( const path & file_ph ); + void open( const path & file_ph, std::ios_base::openmode mode ); +# endif + virtual ~basic_ifstream() {} + }; + + template < class charT, class traits = std::char_traits > + class basic_ofstream : public std::basic_ofstream + { + private: // disallow copying + basic_ofstream( const basic_ofstream & ); + const basic_ofstream & operator=( const basic_ofstream & ); + public: + basic_ofstream() {} + + // use two signatures, rather than one signature with default second + // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416) + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + template + explicit basic_ofstream( const Path & file_ph, + typename boost::enable_if >::type* dummy = 0 ); + explicit basic_ofstream( const wpath & file_ph ); + + template + basic_ofstream( const Path & file_ph, std::ios_base::openmode mode, + typename boost::enable_if >::type* dummy = 0 ); + basic_ofstream( const wpath & file_ph, std::ios_base::openmode mode ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph ); + void open( const wpath & file_ph ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + void open( const wpath & file_ph, std::ios_base::openmode mode ); + +# endif + + explicit basic_ofstream( const path & file_ph ); + basic_ofstream( const path & file_ph, std::ios_base::openmode mode ); +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + void open( const path & file_ph ); + void open( const path & file_ph, std::ios_base::openmode mode ); +# endif + virtual ~basic_ofstream() {} + }; + + template < class charT, class traits = std::char_traits > + class basic_fstream : public std::basic_fstream + { + private: // disallow copying + basic_fstream( const basic_fstream & ); + const basic_fstream & operator=( const basic_fstream & ); + public: + basic_fstream() {} + + // use two signatures, rather than one signature with default second + // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416) + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + template + explicit basic_fstream( const Path & file_ph, + typename boost::enable_if >::type* dummy = 0 ); + explicit basic_fstream( const wpath & file_ph ); + + template + basic_fstream( const Path & file_ph, std::ios_base::openmode mode, + typename boost::enable_if >::type* dummy = 0 ); + basic_fstream( const wpath & file_ph, std::ios_base::openmode mode ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph ); + void open( const wpath & file_ph ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + void open( const wpath & file_ph, std::ios_base::openmode mode ); + +# endif + + explicit basic_fstream( const path & file_ph ); + basic_fstream( const path & file_ph, std::ios_base::openmode mode ); +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + void open( const path & file_ph ); + void open( const path & file_ph, std::ios_base::openmode mode ); +# endif + virtual ~basic_fstream() {} + + }; + + typedef basic_filebuf filebuf; + typedef basic_ifstream ifstream; + typedef basic_ofstream ofstream; + typedef basic_fstream fstream; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_filebuf wfilebuf; + typedef basic_ifstream wifstream; + typedef basic_fstream wfstream; + typedef basic_ofstream wofstream; +# endif + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + +// basic_filebuf definitions -----------------------------------------------// + + template + template + typename boost::enable_if, + basic_filebuf *>::type + basic_filebuf::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + return (std::basic_filebuf::open( detail::path_proxy( + file_ph.external_file_string(), mode ).c_str(), mode ) + == 0) ? 0 : this; + } + + template + basic_filebuf * + basic_filebuf::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + return this->BOOST_NESTED_TEMPLATE open( file_ph, mode ); + } + +// basic_ifstream definitions ----------------------------------------------// + + template template + basic_ifstream::basic_ifstream(const Path & file_ph, + typename boost::enable_if >::type* ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ) {} + + template + basic_ifstream::basic_ifstream( const wpath & file_ph ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ) {} + + template template + basic_ifstream::basic_ifstream( const Path & file_ph, + std::ios_base::openmode mode, + typename boost::enable_if >::type* ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ) {} + + template + basic_ifstream::basic_ifstream( const wpath & file_ph, + std::ios_base::openmode mode ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ) {} + + template template + typename boost::enable_if, void>::type + basic_ifstream::open( const Path & file_ph ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ); + } + + template + void basic_ifstream::open( const wpath & file_ph ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ); + } + + template template + typename boost::enable_if, void>::type + basic_ifstream::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ); + } + + template + void basic_ifstream::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ); + } + +// basic_ofstream definitions ----------------------------------------------// + + template template + basic_ofstream::basic_ofstream(const Path & file_ph, + typename boost::enable_if >::type* ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ) {} + + template + basic_ofstream::basic_ofstream( const wpath & file_ph ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ) {} + + template template + basic_ofstream::basic_ofstream( const Path & file_ph, + std::ios_base::openmode mode, + typename boost::enable_if >::type* ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ) {} + + template + basic_ofstream::basic_ofstream( const wpath & file_ph, + std::ios_base::openmode mode ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ) {} + + template template + typename boost::enable_if, void>::type + basic_ofstream::open( const Path & file_ph ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ); + } + + template + void basic_ofstream::open( const wpath & file_ph ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ); + } + + template template + typename boost::enable_if, void>::type + basic_ofstream::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ); + } + + template + void basic_ofstream::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ); + } + +// basic_fstream definitions -----------------------------------------------// + + template template + basic_fstream::basic_fstream(const Path & file_ph, + typename boost::enable_if >::type* ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ) {} + + template + basic_fstream::basic_fstream( const wpath & file_ph ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ) {} + + template template + basic_fstream::basic_fstream( const Path & file_ph, + std::ios_base::openmode mode, + typename boost::enable_if >::type* ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ) {} + + template + basic_fstream::basic_fstream( const wpath & file_ph, + std::ios_base::openmode mode ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ) {} + + template template + typename boost::enable_if, void>::type + basic_fstream::open( const Path & file_ph ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ); + } + + template + void basic_fstream::open( const wpath & file_ph ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ); + } + + template template + typename boost::enable_if, void>::type + basic_fstream::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ); + } + + template + void basic_fstream::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ); + } + +# endif + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + basic_filebuf * + basic_filebuf::open( const path & file_ph, + std::ios_base::openmode mode ) + { + return std::basic_filebuf::open( + file_ph.file_string().c_str(), mode ) == 0 ? 0 : this; + } +# endif + + template + basic_ifstream::basic_ifstream( const path & file_ph ) + : std::basic_ifstream( + file_ph.file_string().c_str(), std::ios_base::in ) {} + + template + basic_ifstream::basic_ifstream( const path & file_ph, + std::ios_base::openmode mode ) + : std::basic_ifstream( + file_ph.file_string().c_str(), mode ) {} + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + void basic_ifstream::open( const path & file_ph ) + { + std::basic_ifstream::open( + file_ph.file_string().c_str(), std::ios_base::in ); + } + + template + void basic_ifstream::open( const path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ifstream::open( + file_ph.file_string().c_str(), mode ); + } +# endif + + template + basic_ofstream::basic_ofstream( const path & file_ph ) + : std::basic_ofstream( + file_ph.file_string().c_str(), std::ios_base::out ) {} + + template + basic_ofstream::basic_ofstream( const path & file_ph, + std::ios_base::openmode mode ) + : std::basic_ofstream( + file_ph.file_string().c_str(), mode ) {} + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + void basic_ofstream::open( const path & file_ph ) + { + std::basic_ofstream::open( + file_ph.file_string().c_str(), std::ios_base::out ); + } + + template + void basic_ofstream::open( const path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ofstream::open( + file_ph.file_string().c_str(), mode ); + } +# endif + + template + basic_fstream::basic_fstream( const path & file_ph ) + : std::basic_fstream( + file_ph.file_string().c_str(), + std::ios_base::in|std::ios_base::out ) {} + + + template + basic_fstream::basic_fstream( const path & file_ph, + std::ios_base::openmode mode ) + : std::basic_fstream( + file_ph.file_string().c_str(), mode ) {} + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + void basic_fstream::open( const path & file_ph ) + { + std::basic_fstream::open( + file_ph.file_string().c_str(), std::ios_base::in|std::ios_base::out ); + } + + template + void basic_fstream::open( const path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_fstream::open( + file_ph.file_string().c_str(), mode ); + } +# endif + } // namespace filesystem +} // namespace boost + +#include // pops abi_prefix.hpp pragmas +#endif // BOOST_FILESYSTEM_FSTREAM_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/filesystem/operations.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/operations.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,1173 @@ +// boost/filesystem/operations.hpp -----------------------------------------// + +// Copyright 2002-2005 Beman Dawes +// Copyright 2002 Jan Langer +// Copyright 2001 Dietmar Kuehl +// +// Distributed under 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) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_OPERATIONS_HPP +#define BOOST_FILESYSTEM_OPERATIONS_HPP + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include // for pair +#include + +#ifdef BOOST_WINDOWS_API +# include +# if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0500 +# define BOOST_FS_HARD_LINK // Default for Windows 2K or later +# endif +#endif + +#include // must be the last #include + +# ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::time_t; } +# endif + +//----------------------------------------------------------------------------// + +namespace boost +{ + namespace filesystem + { + +// typedef boost::filesystem::path Path; needs to be in namespace boost::filesystem +# ifndef BOOST_FILESYSTEM_NARROW_ONLY +# define BOOST_FS_FUNC(BOOST_FS_TYPE) \ + template typename boost::enable_if, \ + BOOST_FS_TYPE>::type +# define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) \ + template inline typename boost::enable_if, \ + BOOST_FS_TYPE>::type +# define BOOST_FS_TYPENAME typename +# else +# define BOOST_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE +# define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE + typedef boost::filesystem::path Path; +# define BOOST_FS_TYPENAME +# endif + + template class basic_directory_iterator; + + // BOOST_FILESYSTEM_NARROW_ONLY needs this: + typedef basic_directory_iterator directory_iterator; + + template class basic_directory_entry; + + enum file_type + { + status_unknown, + file_not_found, + regular_file, + directory_file, + // the following will never be reported by some operating or file systems + symlink_file, + block_file, + character_file, + fifo_file, + socket_file, + type_unknown // file does exist, but isn't one of the above types or + // we don't have strong enough permission to find its type + }; + + class file_status + { + public: + explicit file_status( file_type v = status_unknown ) : m_value(v) {} + + void type( file_type v ) { m_value = v; } + file_type type() const { return m_value; } + + private: + // the internal representation is unspecified so that additional state + // information such as permissions can be added in the future; this + // implementation just uses status_type as the internal representation + + file_type m_value; + }; + + inline bool status_known( file_status f ) { return f.type() != status_unknown; } + inline bool exists( file_status f ) { return f.type() != status_unknown && f.type() != file_not_found; } + inline bool is_regular_file(file_status f){ return f.type() == regular_file; } + inline bool is_directory( file_status f ) { return f.type() == directory_file; } + inline bool is_symlink( file_status f ) { return f.type() == symlink_file; } + inline bool is_other( file_status f ) { return exists(f) && !is_regular_file(f) && !is_directory(f) && !is_symlink(f); } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline bool is_regular( file_status f ) { return f.type() == regular_file; } +# endif + + struct space_info + { + // all values are byte counts + boost::uintmax_t capacity; + boost::uintmax_t free; // <= capacity + boost::uintmax_t available; // <= free + }; + + namespace detail + { + typedef std::pair< system::error_code, bool > + query_pair; + + typedef std::pair< system::error_code, boost::uintmax_t > + uintmax_pair; + + typedef std::pair< system::error_code, std::time_t > + time_pair; + + typedef std::pair< system::error_code, space_info > + space_pair; + + template< class Path > + struct directory_pair + { + typedef std::pair< system::error_code, + typename Path::external_string_type > type; + }; + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + BOOST_FILESYSTEM_DECL bool + symbolic_link_exists_api( const std::string & ); // deprecated +# endif + + BOOST_FILESYSTEM_DECL file_status + status_api( const std::string & ph, system::error_code & ec ); +# ifndef BOOST_WINDOWS_API + BOOST_FILESYSTEM_DECL file_status + symlink_status_api( const std::string & ph, system::error_code & ec ); +# endif + BOOST_FILESYSTEM_DECL query_pair + is_empty_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL query_pair + equivalent_api( const std::string & ph1, const std::string & ph2 ); + BOOST_FILESYSTEM_DECL uintmax_pair + file_size_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL space_pair + space_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL time_pair + last_write_time_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + last_write_time_api( const std::string & ph, std::time_t new_value ); + BOOST_FILESYSTEM_DECL system::error_code + get_current_path_api( std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + set_current_path_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL query_pair + create_directory_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + create_hard_link_api( const std::string & to_ph, + const std::string & from_ph ); + BOOST_FILESYSTEM_DECL system::error_code + create_symlink_api( const std::string & to_ph, + const std::string & from_ph ); + BOOST_FILESYSTEM_DECL system::error_code + remove_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + rename_api( const std::string & from, const std::string & to ); + BOOST_FILESYSTEM_DECL system::error_code + copy_file_api( const std::string & from, const std::string & to ); + +# if defined(BOOST_WINDOWS_API) + + BOOST_FILESYSTEM_DECL system::error_code + get_full_path_name_api( const std::string & ph, std::string & target ); + +# if !defined(BOOST_FILESYSTEM_NARROW_ONLY) + + BOOST_FILESYSTEM_DECL boost::filesystem::file_status + status_api( const std::wstring & ph, system::error_code & ec ); + BOOST_FILESYSTEM_DECL query_pair + is_empty_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL query_pair + equivalent_api( const std::wstring & ph1, const std::wstring & ph2 ); + BOOST_FILESYSTEM_DECL uintmax_pair + file_size_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL space_pair + space_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + get_full_path_name_api( const std::wstring & ph, std::wstring & target ); + BOOST_FILESYSTEM_DECL time_pair + last_write_time_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + last_write_time_api( const std::wstring & ph, std::time_t new_value ); + BOOST_FILESYSTEM_DECL system::error_code + get_current_path_api( std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + set_current_path_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL query_pair + create_directory_api( const std::wstring & ph ); +# ifdef BOOST_FS_HARD_LINK + BOOST_FILESYSTEM_DECL system::error_code + create_hard_link_api( const std::wstring & existing_ph, + const std::wstring & new_ph ); +# endif + BOOST_FILESYSTEM_DECL system::error_code + create_symlink_api( const std::wstring & to_ph, + const std::wstring & from_ph ); + BOOST_FILESYSTEM_DECL system::error_code + remove_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + rename_api( const std::wstring & from, const std::wstring & to ); + BOOST_FILESYSTEM_DECL system::error_code + copy_file_api( const std::wstring & from, const std::wstring & to ); + +# endif +# endif + + template + bool remove_aux( const Path & ph, file_status f ); + + template + unsigned long remove_all_aux( const Path & ph, file_status f ); + + } // namespace detail + +// operations functions ----------------------------------------------------// + + // The non-template overloads enable automatic conversion from std and + // C-style strings. See basic_path constructors. The enable_if for the + // templates implements the famous "do-the-right-thing" rule. + +// query functions ---------------------------------------------------------// + + BOOST_INLINE_FS_FUNC(file_status) + status( const Path & ph, system::error_code & ec ) + { return detail::status_api( ph.external_file_string(), ec ); } + + BOOST_FS_FUNC(file_status) + status( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::status", ph, ec ) ); + return result; + } + + BOOST_INLINE_FS_FUNC(file_status) + symlink_status( const Path & ph, system::error_code & ec ) +# ifdef BOOST_WINDOWS_API + { return detail::status_api( ph.external_file_string(), ec ); } +# else + { return detail::symlink_status_api( ph.external_file_string(), ec ); } +# endif + + BOOST_FS_FUNC(file_status) + symlink_status( const Path & ph ) + { + system::error_code ec; + file_status result( symlink_status( ph, ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::symlink_status", ph, ec ) ); + return result; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline bool symbolic_link_exists( const path & ph ) + { return is_symlink( symlink_status(ph) ); } +# endif + + BOOST_FS_FUNC(bool) exists( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::exists", ph, ec ) ); + return exists( result ); + } + + BOOST_FS_FUNC(bool) is_directory( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_directory", ph, ec ) ); + return is_directory( result ); + } + + BOOST_FS_FUNC(bool) is_regular_file( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_regular_file", ph, ec ) ); + return is_regular_file( result ); + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + BOOST_FS_FUNC(bool) is_regular( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_regular", ph, ec ) ); + return is_regular( result ); + } +# endif + + BOOST_FS_FUNC(bool) is_other( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_other", ph, ec ) ); + return is_other( result ); + } + + BOOST_FS_FUNC(bool) is_symlink( +# ifdef BOOST_WINDOWS_API + const Path & ) + { + return false; +# else + const Path & ph) + { + system::error_code ec; + file_status result( detail::symlink_status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_symlink", ph, ec ) ); + return is_symlink( result ); +# endif + } + + // VC++ 7.0 and earlier has a serious namespace bug that causes a clash + // between boost::filesystem::is_empty and the unrelated type trait + // boost::is_empty. + +# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 + BOOST_FS_FUNC(bool) is_empty( const Path & ph ) +# else + BOOST_FS_FUNC(bool) _is_empty( const Path & ph ) +# endif + { + detail::query_pair result( + detail::is_empty_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_empty", ph, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(bool) equivalent( const Path & ph1, const Path & ph2 ) + { + detail::query_pair result( detail::equivalent_api( + ph1.external_file_string(), ph2.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::equivalent", ph1, ph2, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(boost::uintmax_t) file_size( const Path & ph ) + { + detail::uintmax_pair result + ( detail::file_size_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::file_size", ph, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(space_info) space( const Path & ph ) + { + detail::space_pair result + ( detail::space_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::space", ph, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(std::time_t) last_write_time( const Path & ph ) + { + detail::time_pair result + ( detail::last_write_time_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::last_write_time", ph, result.first ) ); + return result.second; + } + + +// operations --------------------------------------------------------------// + + BOOST_FS_FUNC(bool) create_directory( const Path & dir_ph ) + { + detail::query_pair result( + detail::create_directory_api( dir_ph.external_directory_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_directory", + dir_ph, result.first ) ); + return result.second; + } + +#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK) + BOOST_FS_FUNC(void) + create_hard_link( const Path & to_ph, const Path & from_ph ) + { + system::error_code ec( + detail::create_hard_link_api( + to_ph.external_file_string(), + from_ph.external_file_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_hard_link", + to_ph, from_ph, ec ) ); + } + + BOOST_FS_FUNC(system::error_code) + create_hard_link( const Path & to_ph, const Path & from_ph, + system::error_code & ec ) + { + ec = detail::create_hard_link_api( + to_ph.external_file_string(), + from_ph.external_file_string() ); + return ec; + } +#endif + + BOOST_FS_FUNC(void) + create_symlink( const Path & to_ph, const Path & from_ph ) + { + system::error_code ec( + detail::create_symlink_api( + to_ph.external_file_string(), + from_ph.external_file_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_symlink", + to_ph, from_ph, ec ) ); + } + + BOOST_FS_FUNC(system::error_code) + create_symlink( const Path & to_ph, const Path & from_ph, + system::error_code & ec ) + { + ec = detail::create_symlink_api( + to_ph.external_file_string(), + from_ph.external_file_string() ); + return ec; + } + + BOOST_FS_FUNC(bool) remove( const Path & ph ) + { + system::error_code ec; + file_status f = symlink_status( ph, ec ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::remove", ph, ec ) ); + return detail::remove_aux( ph, f ); + } + + BOOST_FS_FUNC(unsigned long) remove_all( const Path & ph ) + { + system::error_code ec; + file_status f = symlink_status( ph, ec ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::remove_all", ph, ec ) ); + return exists( f ) ? detail::remove_all_aux( ph, f ) : 0; + } + + BOOST_FS_FUNC(void) rename( const Path & from_path, const Path & to_path ) + { + system::error_code ec( detail::rename_api( + from_path.external_directory_string(), + to_path.external_directory_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::rename", + from_path, to_path, ec ) ); + } + + BOOST_FS_FUNC(void) copy_file( const Path & from_path, const Path & to_path ) + { + system::error_code ec( detail::copy_file_api( + from_path.external_directory_string(), + to_path.external_directory_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::copy_file", + from_path, to_path, ec ) ); + } + + template< class Path > + Path current_path() + { + typename Path::external_string_type ph; + system::error_code ec( detail::get_current_path_api( ph ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::current_path", ec ) ); + return Path( Path::traits_type::to_internal( ph ) ); + } + + BOOST_FS_FUNC(void) current_path( const Path & ph ) + { + system::error_code ec( detail::set_current_path_api( + ph.external_directory_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::current_path", ph, ec ) ); + } + + template< class Path > + const Path & initial_path() + { + static Path init_path; + if ( init_path.empty() ) init_path = current_path(); + return init_path; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + // legacy support + inline path current_path() // overload supports pre-i18n apps + { return current_path(); } + inline const path & initial_path() // overload supports pre-i18n apps + { return initial_path(); } +# endif + + BOOST_FS_FUNC(Path) system_complete( const Path & ph ) + { +# ifdef BOOST_WINDOWS_API + if ( ph.empty() ) return ph; + BOOST_FS_TYPENAME Path::external_string_type sys_ph; + system::error_code ec( detail::get_full_path_name_api( ph.external_file_string(), + sys_ph ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::system_complete", ph, ec ) ); + return Path( Path::traits_type::to_internal( sys_ph ) ); +# else + return (ph.empty() || ph.is_complete()) + ? ph : current_path() / ph; +# endif + } + + BOOST_FS_FUNC(Path) + complete( const Path & ph, + const Path & base/* = initial_path() */) + { + BOOST_ASSERT( base.is_complete() + && (ph.is_complete() || !ph.has_root_name()) + && "boost::filesystem::complete() precondition not met" ); +# ifdef BOOST_WINDOWS_PATH + if (ph.empty() || ph.is_complete()) return ph; + if ( !ph.has_root_name() ) + return ph.has_root_directory() + ? Path( base.root_name() ) / ph + : base / ph; + return base / ph; +# else + return (ph.empty() || ph.is_complete()) ? ph : base / ph; +# endif + } + + // VC++ 7.1 had trouble with default arguments, so separate one argument + // signatures are provided as workarounds; the effect is the same. + BOOST_FS_FUNC(Path) complete( const Path & ph ) + { return complete( ph, initial_path() ); } + + BOOST_FS_FUNC(void) + last_write_time( const Path & ph, const std::time_t new_time ) + { + system::error_code ec( detail::last_write_time_api( ph.external_file_string(), + new_time ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::last_write_time", ph, ec ) ); + } + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // "do-the-right-thing" overloads ---------------------------------------// + + inline file_status status( const path & ph ) + { return status( ph ); } + inline file_status status( const wpath & ph ) + { return status( ph ); } + + inline file_status status( const path & ph, system::error_code & ec ) + { return status( ph, ec ); } + inline file_status status( const wpath & ph, system::error_code & ec ) + { return status( ph, ec ); } + + inline file_status symlink_status( const path & ph ) + { return symlink_status( ph ); } + inline file_status symlink_status( const wpath & ph ) + { return symlink_status( ph ); } + + inline file_status symlink_status( const path & ph, system::error_code & ec ) + { return symlink_status( ph, ec ); } + inline file_status symlink_status( const wpath & ph, system::error_code & ec ) + { return symlink_status( ph, ec ); } + + inline bool exists( const path & ph ) { return exists( ph ); } + inline bool exists( const wpath & ph ) { return exists( ph ); } + + inline bool is_directory( const path & ph ) + { return is_directory( ph ); } + inline bool is_directory( const wpath & ph ) + { return is_directory( ph ); } + + inline bool is_regular_file( const path & ph ) + { return is_regular_file( ph ); } + inline bool is_regular_file( const wpath & ph ) + { return is_regular_file( ph ); } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline bool is_regular( const path & ph ) + { return is_regular( ph ); } + inline bool is_regular( const wpath & ph ) + { return is_regular( ph ); } +# endif + + inline bool is_other( const path & ph ) + { return is_other( ph ); } + inline bool is_other( const wpath & ph ) + { return is_other( ph ); } + + inline bool is_symlink( const path & ph ) + { return is_symlink( ph ); } + inline bool is_symlink( const wpath & ph ) + { return is_symlink( ph ); } + + inline bool is_empty( const path & ph ) + { return is_empty( ph ); } + inline bool is_empty( const wpath & ph ) + { return is_empty( ph ); } + + inline bool equivalent( const path & ph1, const path & ph2 ) + { return equivalent( ph1, ph2 ); } + inline bool equivalent( const wpath & ph1, const wpath & ph2 ) + { return equivalent( ph1, ph2 ); } + + inline boost::uintmax_t file_size( const path & ph ) + { return file_size( ph ); } + inline boost::uintmax_t file_size( const wpath & ph ) + { return file_size( ph ); } + + inline space_info space( const path & ph ) + { return space( ph ); } + inline space_info space( const wpath & ph ) + { return space( ph ); } + + inline std::time_t last_write_time( const path & ph ) + { return last_write_time( ph ); } + inline std::time_t last_write_time( const wpath & ph ) + { return last_write_time( ph ); } + + inline bool create_directory( const path & dir_ph ) + { return create_directory( dir_ph ); } + inline bool create_directory( const wpath & dir_ph ) + { return create_directory( dir_ph ); } + +#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK) + inline void create_hard_link( const path & to_ph, + const path & from_ph ) + { return create_hard_link( to_ph, from_ph ); } + inline void create_hard_link( const wpath & to_ph, + const wpath & from_ph ) + { return create_hard_link( to_ph, from_ph ); } + + inline system::error_code create_hard_link( const path & to_ph, + const path & from_ph, system::error_code & ec ) + { return create_hard_link( to_ph, from_ph, ec ); } + inline system::error_code create_hard_link( const wpath & to_ph, + const wpath & from_ph, system::error_code & ec ) + { return create_hard_link( to_ph, from_ph, ec ); } +#endif + + inline void create_symlink( const path & to_ph, + const path & from_ph ) + { return create_symlink( to_ph, from_ph ); } + inline void create_symlink( const wpath & to_ph, + const wpath & from_ph ) + { return create_symlink( to_ph, from_ph ); } + + inline system::error_code create_symlink( const path & to_ph, + const path & from_ph, system::error_code & ec ) + { return create_symlink( to_ph, from_ph, ec ); } + inline system::error_code create_symlink( const wpath & to_ph, + const wpath & from_ph, system::error_code & ec ) + { return create_symlink( to_ph, from_ph, ec ); } + + inline bool remove( const path & ph ) + { return remove( ph ); } + inline bool remove( const wpath & ph ) + { return remove( ph ); } + + inline unsigned long remove_all( const path & ph ) + { return remove_all( ph ); } + inline unsigned long remove_all( const wpath & ph ) + { return remove_all( ph ); } + + inline void rename( const path & from_path, const path & to_path ) + { return rename( from_path, to_path ); } + inline void rename( const wpath & from_path, const wpath & to_path ) + { return rename( from_path, to_path ); } + + inline void copy_file( const path & from_path, const path & to_path ) + { return copy_file( from_path, to_path ); } + inline void copy_file( const wpath & from_path, const wpath & to_path ) + { return copy_file( from_path, to_path ); } + + inline path system_complete( const path & ph ) + { return system_complete( ph ); } + inline wpath system_complete( const wpath & ph ) + { return system_complete( ph ); } + + inline path complete( const path & ph, + const path & base/* = initial_path()*/ ) + { return complete( ph, base ); } + inline wpath complete( const wpath & ph, + const wpath & base/* = initial_path()*/ ) + { return complete( ph, base ); } + + inline path complete( const path & ph ) + { return complete( ph, initial_path() ); } + inline wpath complete( const wpath & ph ) + { return complete( ph, initial_path() ); } + + inline void last_write_time( const path & ph, const std::time_t new_time ) + { last_write_time( ph, new_time ); } + inline void last_write_time( const wpath & ph, const std::time_t new_time ) + { last_write_time( ph, new_time ); } + + inline void current_path( const path & ph ) + { current_path( ph ); } + inline void current_path( const wpath & ph ) + { current_path( ph ); } + +# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY + + namespace detail + { + template + bool remove_aux( const Path & ph, file_status f ) + { + if ( exists( f ) ) + { + system::error_code ec = remove_api( ph.external_file_string() ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::remove", ph, ec ) ); + return true; + } + return false; + } + + template + unsigned long remove_all_aux( const Path & ph, file_status f ) + { + static const boost::filesystem::basic_directory_iterator end_itr; + unsigned long count = 1; + if ( !boost::filesystem::is_symlink( f ) // don't recurse symbolic links + && boost::filesystem::is_directory( f ) ) + { + for ( boost::filesystem::basic_directory_iterator itr( ph ); + itr != end_itr; ++itr ) + { + boost::system::error_code ec; + boost::filesystem::file_status fn = boost::filesystem::symlink_status( itr->path(), ec ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem:remove_all", ph, ec ) ); + count += remove_all_aux( itr->path(), fn ); + } + } + remove_aux( ph, f ); + return count; + } + +// test helper -------------------------------------------------------------// + + // not part of the documented interface because false positives are possible; + // there is no law that says that an OS that has large stat.st_size + // actually supports large file sizes. + BOOST_FILESYSTEM_DECL bool possible_large_file_size_support(); + +// directory_iterator helpers ----------------------------------------------// + +// forwarding functions avoid need for BOOST_FILESYSTEM_DECL for class +// basic_directory_iterator, and so avoid iterator_facade DLL template +// problems. They also overload to the proper external path character type. + + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_first( void *& handle, +#if defined(BOOST_POSIX_API) + void *& buffer, +#endif + const std::string & dir_path, + std::string & target, file_status & fs, file_status & symlink_fs ); + // eof: return==0 && handle==0 + + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_increment( void *& handle, +#if defined(BOOST_POSIX_API) + void *& buffer, +#endif + std::string & target, file_status & fs, file_status & symlink_fs ); + // eof: return==0 && handle==0 + + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_close( void *& handle +#if defined(BOOST_POSIX_API) + , void *& buffer +#endif + ); + // Effects: none if handle==0, otherwise close handle, set handle=0 + +# if defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_NARROW_ONLY) + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_first( void *& handle, const std::wstring & ph, + std::wstring & target, file_status & fs, file_status & symlink_fs ); + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_increment( void *& handle, std::wstring & target, + file_status & fs, file_status & symlink_fs ); +# endif + + template< class Path > + class dir_itr_imp + { + public: + basic_directory_entry m_directory_entry; + void * m_handle; +# ifdef BOOST_POSIX_API + void * m_buffer; // see dir_itr_increment implementation +# endif + dir_itr_imp() : m_handle(0) +# ifdef BOOST_POSIX_API + , m_buffer(0) +# endif + {} + + ~dir_itr_imp() { dir_itr_close( m_handle +#if defined(BOOST_POSIX_API) + , m_buffer +#endif + ); } + }; + + BOOST_FILESYSTEM_DECL system::error_code not_found_error(); + + } // namespace detail + +// basic_directory_iterator ------------------------------------------------// + + template< class Path > + class basic_directory_iterator + : public boost::iterator_facade< + basic_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag > + { + public: + typedef Path path_type; + + basic_directory_iterator(){} // creates the "end" iterator + + explicit basic_directory_iterator( const Path & dir_path ); + basic_directory_iterator( const Path & dir_path, system::error_code & ec ); + + private: + + // shared_ptr provides shallow-copy semantics required for InputIterators. + // m_imp.get()==0 indicates the end iterator. + boost::shared_ptr< detail::dir_itr_imp< Path > > m_imp; + + friend class boost::iterator_core_access; + + typename boost::iterator_facade< + basic_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag >::reference dereference() const + { + BOOST_ASSERT( m_imp.get() && "attempt to dereference end iterator" ); + return m_imp->m_directory_entry; + } + + void increment(); + + bool equal( const basic_directory_iterator & rhs ) const + { return m_imp == rhs.m_imp; } + + system::error_code m_init( const Path & dir_path ); + }; + + typedef basic_directory_iterator< path > directory_iterator; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_directory_iterator< wpath > wdirectory_iterator; +# endif + + // basic_directory_iterator implementation ---------------------------// + + template + system::error_code basic_directory_iterator::m_init( + const Path & dir_path ) + { + if ( dir_path.empty() ) + { + m_imp.reset(); + return detail::not_found_error(); + } + typename Path::external_string_type name; + file_status fs, symlink_fs; + system::error_code ec( detail::dir_itr_first( m_imp->m_handle, +#if defined(BOOST_POSIX_API) + m_imp->m_buffer, +#endif + dir_path.external_directory_string(), + name, fs, symlink_fs ) ); + + if ( ec ) + { + m_imp.reset(); + return ec; + } + + if ( m_imp->m_handle == 0 ) m_imp.reset(); // eof, so make end iterator + else // not eof + { + m_imp->m_directory_entry.assign( dir_path + / Path::traits_type::to_internal( name ), fs, symlink_fs ); + if ( name[0] == dot::value // dot or dot-dot + && (name.size() == 1 + || (name[1] == dot::value + && name.size() == 2)) ) + { increment(); } + } + return boost::system::error_code(); + } + + template + basic_directory_iterator::basic_directory_iterator( + const Path & dir_path ) + : m_imp( new detail::dir_itr_imp ) + { + system::error_code ec( m_init(dir_path) ); + if ( ec ) + { + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::basic_directory_iterator constructor", + dir_path, ec ) ); + } + } + + template + basic_directory_iterator::basic_directory_iterator( + const Path & dir_path, system::error_code & ec ) + : m_imp( new detail::dir_itr_imp ) + { + ec = m_init(dir_path); + } + + template + void basic_directory_iterator::increment() + { + BOOST_ASSERT( m_imp.get() && "attempt to increment end iterator" ); + BOOST_ASSERT( m_imp->m_handle != 0 && "internal program error" ); + + typename Path::external_string_type name; + file_status fs, symlink_fs; + system::error_code ec; + + for (;;) + { + ec = detail::dir_itr_increment( m_imp->m_handle, +#if defined(BOOST_POSIX_API) + m_imp->m_buffer, +#endif + name, fs, symlink_fs ); + if ( ec ) + { + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::basic_directory_iterator increment", + m_imp->m_directory_entry.path().parent_path(), ec ) ); + } + if ( m_imp->m_handle == 0 ) { m_imp.reset(); return; } // eof, make end + if ( !(name[0] == dot::value // !(dot or dot-dot) + && (name.size() == 1 + || (name[1] == dot::value + && name.size() == 2))) ) + { + m_imp->m_directory_entry.replace_filename( + Path::traits_type::to_internal( name ), fs, symlink_fs ); + return; + } + } + } + + // basic_directory_entry -----------------------------------------------// + + template + class basic_directory_entry + { + public: + typedef Path path_type; + typedef typename Path::string_type string_type; + + // compiler generated copy-ctor, copy assignment, and destructor apply + + basic_directory_entry() {} + explicit basic_directory_entry( const path_type & p, + file_status st = file_status(), file_status symlink_st=file_status() ) + : m_path(p), m_status(st), m_symlink_status(symlink_st) + {} + + void assign( const path_type & p, + file_status st, file_status symlink_st ) + { m_path = p; m_status = st; m_symlink_status = symlink_st; } + + void replace_filename( const string_type & s, + file_status st, file_status symlink_st ) + { + m_path.remove_filename(); + m_path /= s; + m_status = st; + m_symlink_status = symlink_st; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + void replace_leaf( const string_type & s, + file_status st, file_status symlink_st ) + { replace_filename( s, st, symlink_st ); } +# endif + + const Path & path() const { return m_path; } + file_status status() const; + file_status status( system::error_code & ec ) const; + file_status symlink_status() const; + file_status symlink_status( system::error_code & ec ) const; + + // conversion simplifies the most common use of basic_directory_entry + operator const path_type &() const { return m_path; } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + // deprecated functions preserve common use cases in legacy code + typename Path::string_type filename() const + { + return path().filename(); + } + typename Path::string_type leaf() const + { + return path().filename(); + } + typename Path::string_type string() const + { + return path().string(); + } +# endif + + private: + path_type m_path; + mutable file_status m_status; // stat()-like + mutable file_status m_symlink_status; // lstat()-like + // note: m_symlink_status is not used by Windows implementation + + }; // basic_directory_status + + typedef basic_directory_entry directory_entry; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_directory_entry wdirectory_entry; +# endif + + // basic_directory_entry implementation --------------------------------// + + template + file_status + basic_directory_entry::status() const + { + if ( !status_known( m_status ) ) + { +# ifndef BOOST_WINDOWS_API + if ( status_known( m_symlink_status ) + && !is_symlink( m_symlink_status ) ) + { m_status = m_symlink_status; } + else { m_status = boost::filesystem::status( m_path ); } +# else + m_status = boost::filesystem::status( m_path ); +# endif + } + return m_status; + } + + template + file_status + basic_directory_entry::status( system::error_code & ec ) const + { + if ( !status_known( m_status ) ) + { +# ifndef BOOST_WINDOWS_API + if ( status_known( m_symlink_status ) + && !is_symlink( m_symlink_status ) ) + { ec = boost::system::error_code();; m_status = m_symlink_status; } + else { m_status = boost::filesystem::status( m_path, ec ); } +# else + m_status = boost::filesystem::status( m_path, ec ); +# endif + } + else ec = boost::system::error_code();; + return m_status; + } + + template + file_status + basic_directory_entry::symlink_status() const + { +# ifndef BOOST_WINDOWS_API + if ( !status_known( m_symlink_status ) ) + { m_symlink_status = boost::filesystem::symlink_status( m_path ); } + return m_symlink_status; +# else + return status(); +# endif + } + + template + file_status + basic_directory_entry::symlink_status( system::error_code & ec ) const + { +# ifndef BOOST_WINDOWS_API + if ( !status_known( m_symlink_status ) ) + { m_symlink_status = boost::filesystem::symlink_status( m_path, ec ); } + else ec = boost::system::error_code();; + return m_symlink_status; +# else + return status( ec ); +# endif + } + } // namespace filesystem +} // namespace boost + +#undef BOOST_FS_FUNC + + +#include // pops abi_prefix.hpp pragmas +#endif // BOOST_FILESYSTEM_OPERATIONS_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/filesystem/path.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/path.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,1507 @@ +// boost/filesystem/path.hpp -----------------------------------------------// + +// Copyright Beman Dawes 2002-2005 +// Copyright Vladimir Prus 2002 + +// Distributed under 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) + +// See library home page at http://www.boost.org/libs/filesystem + +// basic_path's stem(), extension(), and replace_extension() are based on +// basename(), extension(), and change_extension() from the original +// filesystem/convenience.hpp header by Vladimir Prus. + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_PATH_HPP +#define BOOST_FILESYSTEM_PATH_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include +#include // for lexicographical_compare +#include // needed by basic_path inserter and extractor +#include +#include + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY +# include +# endif + +#include // must be the last #include + +//----------------------------------------------------------------------------// + +namespace boost +{ + namespace BOOST_FILESYSTEM_NAMESPACE + { + template class basic_path; + + struct path_traits; + typedef basic_path< std::string, path_traits > path; + + struct path_traits + { + typedef std::string internal_string_type; + typedef std::string external_string_type; + static external_string_type to_external( const path &, + const internal_string_type & src ) { return src; } + static internal_string_type to_internal( + const external_string_type & src ) { return src; } + }; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + struct BOOST_FILESYSTEM_DECL wpath_traits; + + typedef basic_path< std::wstring, wpath_traits > wpath; + + struct BOOST_FILESYSTEM_DECL wpath_traits + { + typedef std::wstring internal_string_type; +# ifdef BOOST_WINDOWS_API + typedef std::wstring external_string_type; + static external_string_type to_external( const wpath &, + const internal_string_type & src ) { return src; } + static internal_string_type to_internal( + const external_string_type & src ) { return src; } +# else + typedef std::string external_string_type; + static external_string_type to_external( const wpath & ph, + const internal_string_type & src ); + static internal_string_type to_internal( + const external_string_type & src ); +# endif + static void imbue( const std::locale & loc ); + static bool imbue( const std::locale & loc, const std::nothrow_t & ); + }; + +# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // path traits ---------------------------------------------------------// + + template struct is_basic_path + { BOOST_STATIC_CONSTANT( bool, value = false ); }; + template<> struct is_basic_path + { BOOST_STATIC_CONSTANT( bool, value = true ); }; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template<> struct is_basic_path + { BOOST_STATIC_CONSTANT( bool, value = true ); }; +# endif + + // These only have to be specialized if Path::string_type::value_type + // is not convertible from char, although specializations may eliminate + // compiler warnings. See ticket 2543. + template struct slash + { BOOST_STATIC_CONSTANT( char, value = '/' ); }; + + template struct dot + { BOOST_STATIC_CONSTANT( char, value = '.' ); }; + + template struct colon + { BOOST_STATIC_CONSTANT( char, value = ':' ); }; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template<> struct slash + { BOOST_STATIC_CONSTANT( wchar_t, value = L'/' ); }; + template<> struct dot + { BOOST_STATIC_CONSTANT( wchar_t, value = L'.' ); }; + template<> struct colon + { BOOST_STATIC_CONSTANT( wchar_t, value = L':' ); }; +# endif + +# ifdef BOOST_WINDOWS_PATH + template struct path_alt_separator + { BOOST_STATIC_CONSTANT( char, value = '\\' ); }; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template<> struct path_alt_separator + { BOOST_STATIC_CONSTANT( wchar_t, value = L'\\' ); }; +# endif +# endif + + // workaround for VC++ 7.0 and earlier issues with nested classes + namespace detail + { + template + class iterator_helper + { + public: + typedef typename Path::iterator iterator; + static void do_increment( iterator & ph ); + static void do_decrement( iterator & ph ); + }; + } + + // basic_path ----------------------------------------------------------// + + template + class basic_path + { + // invariant: m_path valid according to the portable generic path grammar + + // validate template arguments +// TODO: get these working +// BOOST_STATIC_ASSERT( ::boost::is_same::value ); +// BOOST_STATIC_ASSERT( ::boost::is_same::value || ::boost::is_same::value ); + + public: + // compiler generates copy constructor and copy assignment + + typedef basic_path path_type; + typedef String string_type; + typedef typename String::value_type value_type; + typedef Traits traits_type; + typedef typename Traits::external_string_type external_string_type; + + // constructors/destructor + basic_path() {} + basic_path( const string_type & s ) { operator/=( s ); } + basic_path( const value_type * s ) { operator/=( s ); } +# ifndef BOOST_NO_MEMBER_TEMPLATES + template + basic_path( InputIterator first, InputIterator last ) + { append( first, last ); } +# endif + ~basic_path() {} + + // assignments + basic_path & operator=( const string_type & s ) + { +# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, >= 310) + m_path.clear(); +# else + m_path.erase( m_path.begin(), m_path.end() ); +# endif + operator/=( s ); + return *this; + } + basic_path & operator=( const value_type * s ) + { +# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, >= 310) + m_path.clear(); +# else + m_path.erase( m_path.begin(), m_path.end() ); +# endif + operator/=( s ); + return *this; + } +# ifndef BOOST_NO_MEMBER_TEMPLATES + template + basic_path & assign( InputIterator first, InputIterator last ) + { m_path.clear(); append( first, last ); return *this; } +# endif + + // modifiers + basic_path & operator/=( const basic_path & rhs ) { return operator /=( rhs.string().c_str() ); } + basic_path & operator/=( const string_type & rhs ) { return operator /=( rhs.c_str() ); } + basic_path & operator/=( const value_type * s ); +# ifndef BOOST_NO_MEMBER_TEMPLATES + template + basic_path & append( InputIterator first, InputIterator last ); +# endif + + void swap( basic_path & rhs ) + { + m_path.swap( rhs.m_path ); +# ifdef BOOST_CYGWIN_PATH + std::swap( m_cygwin_root, rhs.m_cygwin_root ); +# endif + } + + basic_path & remove_filename(); + basic_path & replace_extension( const string_type & new_extension = string_type() ); + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + basic_path & remove_leaf() { return remove_filename(); } +# endif + + // observers + const string_type & string() const { return m_path; } + const string_type file_string() const; + const string_type directory_string() const { return file_string(); } + + const external_string_type external_file_string() const { return Traits::to_external( *this, file_string() ); } + const external_string_type external_directory_string() const { return Traits::to_external( *this, directory_string() ); } + + basic_path root_path() const; + string_type root_name() const; + string_type root_directory() const; + basic_path relative_path() const; + basic_path parent_path() const; + string_type filename() const; + string_type stem() const; + string_type extension() const; + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + string_type leaf() const { return filename(); } + basic_path branch_path() const { return parent_path(); } + bool has_leaf() const { return !m_path.empty(); } + bool has_branch_path() const { return !parent_path().empty(); } +# endif + + bool empty() const { return m_path.empty(); } // name consistent with std containers + bool is_complete() const; + bool has_root_path() const; + bool has_root_name() const; + bool has_root_directory() const; + bool has_relative_path() const { return !relative_path().empty(); } + bool has_filename() const { return !m_path.empty(); } + bool has_parent_path() const { return !parent_path().empty(); } + + // iterators + class iterator : public boost::iterator_facade< + iterator, + string_type const, + boost::bidirectional_traversal_tag > + { + private: + friend class boost::iterator_core_access; + friend class boost::BOOST_FILESYSTEM_NAMESPACE::basic_path; + + const string_type & dereference() const + { return m_name; } + bool equal( const iterator & rhs ) const + { return m_path_ptr == rhs.m_path_ptr && m_pos == rhs.m_pos; } + + friend class boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper; + + void increment() + { + boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper::do_increment( + *this ); + } + void decrement() + { + boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper::do_decrement( + *this ); + } + + string_type m_name; // current element + const basic_path * m_path_ptr; // path being iterated over + typename string_type::size_type m_pos; // position of name in + // path_ptr->string(). The + // end() iterator is indicated by + // pos == path_ptr->m_path.size() + }; // iterator + + typedef iterator const_iterator; + + iterator begin() const; + iterator end() const; + + private: + // Note: This is an implementation for POSIX and Windows, where there + // are only minor differences between generic and native path grammars. + // Private members might be quite different in other implementations, + // particularly where there were wide differences between portable and + // native path formats, or between file_string() and + // directory_string() formats, or simply that the implementation + // was willing expend additional memory to achieve greater speed for + // some operations at the expense of other operations. + + string_type m_path; // invariant: portable path grammar + // on Windows, backslashes converted to slashes + +# ifdef BOOST_CYGWIN_PATH + bool m_cygwin_root; // if present, m_path[0] was slash. note: initialization + // done by append +# endif + + void m_append_separator_if_needed(); + void m_append( value_type value ); // converts Windows alt_separator + + // Was qualified; como433beta8 reports: + // warning #427-D: qualified name is not allowed in member declaration + friend class iterator; + friend class boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper; + + // Deprecated features ease transition for existing code. Don't use these + // in new code. +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + public: + typedef bool (*name_check)( const std::string & name ); + basic_path( const string_type & str, name_check ) { operator/=( str ); } + basic_path( const typename string_type::value_type * s, name_check ) + { operator/=( s );} + string_type native_file_string() const { return file_string(); } + string_type native_directory_string() const { return directory_string(); } + static bool default_name_check_writable() { return false; } + static void default_name_check( name_check ) {} + static name_check default_name_check() { return 0; } + basic_path & canonize(); + basic_path & normalize(); +# endif + }; + + // basic_path non-member functions ---------------------------------------// + + template< class String, class Traits > + inline void swap( basic_path & lhs, + basic_path & rhs ) { lhs.swap( rhs ); } + + template< class String, class Traits > + bool operator<( const basic_path & lhs, const basic_path & rhs ) + { + return std::lexicographical_compare( + lhs.begin(), lhs.end(), rhs.begin(), rhs.end() ); + } + + template< class String, class Traits > + bool operator<( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) + { + basic_path tmp( lhs ); + return std::lexicographical_compare( + tmp.begin(), tmp.end(), rhs.begin(), rhs.end() ); + } + + template< class String, class Traits > + bool operator<( const typename basic_path::string_type & lhs, + const basic_path & rhs ) + { + basic_path tmp( lhs ); + return std::lexicographical_compare( + tmp.begin(), tmp.end(), rhs.begin(), rhs.end() ); + } + + template< class String, class Traits > + bool operator<( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { + basic_path tmp( rhs ); + return std::lexicographical_compare( + lhs.begin(), lhs.end(), tmp.begin(), tmp.end() ); + } + + template< class String, class Traits > + bool operator<( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { + basic_path tmp( rhs ); + return std::lexicographical_compare( + lhs.begin(), lhs.end(), tmp.begin(), tmp.end() ); + } + + // operator == uses string compare rather than !(lhs < rhs) && !(rhs < lhs) because + // the result is the same yet the direct string compare is much more efficient that + // lexicographical_compare, and lexicographical_compare used twice at that. + + template< class String, class Traits > + inline bool operator==( const basic_path & lhs, const basic_path & rhs ) + { + return lhs.string() == rhs.string(); + } + + template< class String, class Traits > + inline bool operator==( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) + { + return lhs == rhs.string(); + } + + template< class String, class Traits > + inline bool operator==( const typename basic_path::string_type & lhs, + const basic_path & rhs ) + { + return lhs == rhs.string(); + } + + template< class String, class Traits > + inline bool operator==( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { + return lhs.string() == rhs; + } + + template< class String, class Traits > + inline bool operator==( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { + return lhs.string() == rhs; + } + + template< class String, class Traits > + inline bool operator!=( const basic_path & lhs, + const basic_path & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const typename basic_path::string_type & lhs, + const basic_path & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator>( const basic_path & lhs, const basic_path & rhs ) { return rhs < lhs; } + + template< class String, class Traits > + inline bool operator>( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) { return rhs < basic_path(lhs); } + + template< class String, class Traits > + inline bool operator>( const typename basic_path::string_type & lhs, + const basic_path & rhs ) { return rhs < basic_path(lhs); } + + template< class String, class Traits > + inline bool operator>( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return basic_path(rhs) < lhs; } + + template< class String, class Traits > + inline bool operator>( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return basic_path(rhs) < lhs; } + + template< class String, class Traits > + inline bool operator<=( const basic_path & lhs, const basic_path & rhs ) { return !(rhs < lhs); } + + template< class String, class Traits > + inline bool operator<=( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) { return !(rhs < basic_path(lhs)); } + + template< class String, class Traits > + inline bool operator<=( const typename basic_path::string_type & lhs, + const basic_path & rhs ) { return !(rhs < basic_path(lhs)); } + + template< class String, class Traits > + inline bool operator<=( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return !(basic_path(rhs) < lhs); } + + template< class String, class Traits > + inline bool operator<=( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return !(basic_path(rhs) < lhs); } + + template< class String, class Traits > + inline bool operator>=( const basic_path & lhs, const basic_path & rhs ) { return !(lhs < rhs); } + + template< class String, class Traits > + inline bool operator>=( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) { return !(lhs < basic_path(rhs)); } + + template< class String, class Traits > + inline bool operator>=( const typename basic_path::string_type & lhs, + const basic_path & rhs ) { return !(lhs < basic_path(rhs)); } + + template< class String, class Traits > + inline bool operator>=( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return !(basic_path(lhs) < rhs); } + + template< class String, class Traits > + inline bool operator>=( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return !(basic_path(lhs) < rhs); } + + // operator / + + template< class String, class Traits > + inline basic_path operator/( + const basic_path & lhs, + const basic_path & rhs ) + { return basic_path( lhs ) /= rhs; } + + template< class String, class Traits > + inline basic_path operator/( + const basic_path & lhs, + const typename String::value_type * rhs ) + { return basic_path( lhs ) /= + basic_path( rhs ); } + + template< class String, class Traits > + inline basic_path operator/( + const basic_path & lhs, const String & rhs ) + { return basic_path( lhs ) /= + basic_path( rhs ); } + + template< class String, class Traits > + inline basic_path operator/( + const typename String::value_type * lhs, + const basic_path & rhs ) + { return basic_path( lhs ) /= rhs; } + + template< class String, class Traits > + inline basic_path operator/( + const String & lhs, const basic_path & rhs ) + { return basic_path( lhs ) /= rhs; } + + // inserters and extractors --------------------------------------------// + +// bypass VC++ 7.0 and earlier, and broken Borland compilers +# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__BORLANDC__, < 0x610) + template< class Path > + std::basic_ostream< typename Path::string_type::value_type, + typename Path::string_type::traits_type > & + operator<< + ( std::basic_ostream< typename Path::string_type::value_type, + typename Path::string_type::traits_type >& os, const Path & ph ) + { + os << ph.string(); + return os; + } + + template< class Path > + std::basic_istream< typename Path::string_type::value_type, + typename Path::string_type::traits_type > & + operator>> + ( std::basic_istream< typename Path::string_type::value_type, + typename Path::string_type::traits_type >& is, Path & ph ) + { + typename Path::string_type str; + is >> str; + ph = str; + return is; + } +# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + template< class String, class Traits > + std::basic_ostream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type > & + operator<< + ( std::basic_ostream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type >& os, + const basic_path< String, Traits > & ph ) + { + os << ph.string(); + return os; + } + + template< class String, class Traits > + std::basic_istream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type > & + operator>> + ( std::basic_istream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type> & is, + basic_path< String, Traits > & ph ) + { + String str; + is >> str; + ph = str; + return is; + } +# endif + + // basic_filesystem_error helpers --------------------------------------// + + // Originally choice of implementation was done via specialization of + // basic_filesystem_error::what(). Several compilers (GCC, aCC, etc.) + // couldn't handle that, so the choice is now accomplished by overloading. + + namespace detail + { + // BOOST_FILESYSTEM_DECL version works for VC++ but not GCC. Go figure! + inline + const char * what( const char * sys_err_what, + const path & path1_arg, const path & path2_arg, std::string & target ) + { + try + { + if ( target.empty() ) + { + target = sys_err_what; + if ( !path1_arg.empty() ) + { + target += ": \""; + target += path1_arg.file_string(); + target += "\""; + } + if ( !path2_arg.empty() ) + { + target += ", \""; + target += path2_arg.file_string(); + target += "\""; + } + } + return target.c_str(); + } + catch (...) + { + return sys_err_what; + } + } + + template + const char * what( const char * sys_err_what, + const Path & /*path1_arg*/, const Path & /*path2_arg*/, std::string & /*target*/ ) + { + return sys_err_what; + } + } + + // basic_filesystem_error ----------------------------------------------// + + template + class basic_filesystem_error : public system::system_error + { + // see http://www.boost.org/more/error_handling.html for design rationale + public: + // compiler generates copy constructor and copy assignment + + typedef Path path_type; + + basic_filesystem_error( const std::string & what_arg, + system::error_code ec ); + + basic_filesystem_error( const std::string & what_arg, + const path_type & path1_arg, system::error_code ec ); + + basic_filesystem_error( const std::string & what_arg, const path_type & path1_arg, + const path_type & path2_arg, system::error_code ec ); + + ~basic_filesystem_error() throw() {} + + const path_type & path1() const + { + static const path_type empty_path; + return m_imp_ptr.get() ? m_imp_ptr->m_path1 : empty_path ; + } + const path_type & path2() const + { + static const path_type empty_path; + return m_imp_ptr.get() ? m_imp_ptr->m_path2 : empty_path ; + } + + const char * what() const throw() + { + if ( !m_imp_ptr.get() ) + return system::system_error::what(); + return detail::what( system::system_error::what(), m_imp_ptr->m_path1, + m_imp_ptr->m_path2, m_imp_ptr->m_what ); + } + + private: + struct m_imp + { + path_type m_path1; // may be empty() + path_type m_path2; // may be empty() + std::string m_what; // not built until needed + }; + boost::shared_ptr m_imp_ptr; + }; + + typedef basic_filesystem_error filesystem_error; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_filesystem_error wfilesystem_error; +# endif + + // path::name_checks -----------------------------------------------------// + + BOOST_FILESYSTEM_DECL bool portable_posix_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool windows_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool portable_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool portable_directory_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool portable_file_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool native( const std::string & name ); + inline bool no_check( const std::string & ) + { return true; } + +// implementation -----------------------------------------------------------// + + namespace detail + { + + // is_separator helper ------------------------------------------------// + + template + inline bool is_separator( typename Path::string_type::value_type c ) + { + return c == slash::value +# ifdef BOOST_WINDOWS_PATH + || c == path_alt_separator::value +# endif + ; + } + + // filename_pos helper ----------------------------------------------------// + + template + typename String::size_type filename_pos( + const String & str, // precondition: portable generic path grammar + typename String::size_type end_pos ) // end_pos is past-the-end position + // return 0 if str itself is filename (or empty) + { + typedef typename + boost::BOOST_FILESYSTEM_NAMESPACE::basic_path path_type; + + // case: "//" + if ( end_pos == 2 + && str[0] == slash::value + && str[1] == slash::value ) return 0; + + // case: ends in "/" + if ( end_pos && str[end_pos-1] == slash::value ) + return end_pos-1; + + // set pos to start of last element + typename String::size_type pos( + str.find_last_of( slash::value, end_pos-1 ) ); +# ifdef BOOST_WINDOWS_PATH + if ( pos == String::npos ) + pos = str.find_last_of( path_alt_separator::value, end_pos-1 ); + if ( pos == String::npos ) + pos = str.find_last_of( colon::value, end_pos-2 ); +# endif + + return ( pos == String::npos // path itself must be a filename (or empty) + || (pos == 1 && str[0] == slash::value) ) // or net + ? 0 // so filename is entire string + : pos + 1; // or starts after delimiter + } + + // first_element helper -----------------------------------------------// + // sets pos and len of first element, excluding extra separators + // if src.empty(), sets pos,len, to 0,0. + + template + void first_element( + const String & src, // precondition: portable generic path grammar + typename String::size_type & element_pos, + typename String::size_type & element_size, +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1310 ) // VC++ 7.1 + typename String::size_type size = String::npos +# else + typename String::size_type size = -1 +# endif + ) + { + if ( size == String::npos ) size = src.size(); + element_pos = 0; + element_size = 0; + if ( src.empty() ) return; + + typedef typename boost::BOOST_FILESYSTEM_NAMESPACE::basic_path path_type; + + typename String::size_type cur(0); + + // deal with // [network] + if ( size >= 2 && src[0] == slash::value + && src[1] == slash::value + && (size == 2 + || src[2] != slash::value) ) + { + cur += 2; + element_size += 2; + } + + // leading (not non-network) separator + else if ( src[0] == slash::value ) + { + ++element_size; + // bypass extra leading separators + while ( cur+1 < size + && src[cur+1] == slash::value ) + { + ++cur; + ++element_pos; + } + return; + } + + // at this point, we have either a plain name, a network name, + // or (on Windows only) a device name + + // find the end + while ( cur < size +# ifdef BOOST_WINDOWS_PATH + && src[cur] != colon::value +# endif + && src[cur] != slash::value ) + { + ++cur; + ++element_size; + } + +# ifdef BOOST_WINDOWS_PATH + if ( cur == size ) return; + // include device delimiter + if ( src[cur] == colon::value ) + { ++element_size; } +# endif + + return; + } + + // root_directory_start helper ----------------------------------------// + + template + typename String::size_type root_directory_start( + const String & s, // precondition: portable generic path grammar + typename String::size_type size ) + // return npos if no root_directory found + { + typedef typename boost::BOOST_FILESYSTEM_NAMESPACE::basic_path path_type; + +# ifdef BOOST_WINDOWS_PATH + // case "c:/" + if ( size > 2 + && s[1] == colon::value + && s[2] == slash::value ) return 2; +# endif + + // case "//" + if ( size == 2 + && s[0] == slash::value + && s[1] == slash::value ) return String::npos; + + // case "//net {/}" + if ( size > 3 + && s[0] == slash::value + && s[1] == slash::value + && s[2] != slash::value ) + { + typename String::size_type pos( + s.find( slash::value, 2 ) ); + return pos < size ? pos : String::npos; + } + + // case "/" + if ( size > 0 && s[0] == slash::value ) return 0; + + return String::npos; + } + + // is_non_root_slash helper -------------------------------------------// + + template + bool is_non_root_slash( const String & str, + typename String::size_type pos ) // pos is position of the slash + { + typedef typename + boost::BOOST_FILESYSTEM_NAMESPACE::basic_path + path_type; + + assert( !str.empty() && str[pos] == slash::value + && "precondition violation" ); + + // subsequent logic expects pos to be for leftmost slash of a set + while ( pos > 0 && str[pos-1] == slash::value ) + --pos; + + return pos != 0 + && (pos <= 2 || str[1] != slash::value + || str.find( slash::value, 2 ) != pos) +# ifdef BOOST_WINDOWS_PATH + && (pos !=2 || str[1] != colon::value) +# endif + ; + } + } // namespace detail + + // decomposition functions ----------------------------------------------// + + template + String basic_path::filename() const + { + typename String::size_type end_pos( + detail::filename_pos( m_path, m_path.size() ) ); + return (m_path.size() + && end_pos + && m_path[end_pos] == slash::value + && detail::is_non_root_slash< String, Traits >(m_path, end_pos)) + ? String( 1, dot::value ) + : m_path.substr( end_pos ); + } + + template + String basic_path::stem() const + { + string_type name = filename(); + typename string_type::size_type n = name.rfind('.'); + return name.substr(0, n); + } + + template + String basic_path::extension() const + { + string_type name = filename(); + typename string_type::size_type n = name.rfind('.'); + if (n != string_type::npos) + return name.substr(n); + else + return string_type(); + } + + template + basic_path basic_path::parent_path() const + { + typename String::size_type end_pos( + detail::filename_pos( m_path, m_path.size() ) ); + + bool filename_was_separator( m_path.size() + && m_path[end_pos] == slash::value ); + + // skip separators unless root directory + typename string_type::size_type root_dir_pos( detail::root_directory_start + ( m_path, end_pos ) ); + for ( ; + end_pos > 0 + && (end_pos-1) != root_dir_pos + && m_path[end_pos-1] == slash::value + ; + --end_pos ) {} + + return (end_pos == 1 && root_dir_pos == 0 && filename_was_separator) + ? path_type() + : path_type( m_path.substr( 0, end_pos ) ); + } + + template + basic_path basic_path::relative_path() const + { + iterator itr( begin() ); + for ( ; itr.m_pos != m_path.size() + && (itr.m_name[0] == slash::value +# ifdef BOOST_WINDOWS_PATH + || itr.m_name[itr.m_name.size()-1] + == colon::value +# endif + ); ++itr ) {} + + return basic_path( m_path.substr( itr.m_pos ) ); + } + + template + String basic_path::root_name() const + { + iterator itr( begin() ); + + return ( itr.m_pos != m_path.size() + && ( + ( itr.m_name.size() > 1 + && itr.m_name[0] == slash::value + && itr.m_name[1] == slash::value + ) +# ifdef BOOST_WINDOWS_PATH + || itr.m_name[itr.m_name.size()-1] + == colon::value +# endif + ) ) + ? *itr + : String(); + } + + template + String basic_path::root_directory() const + { + typename string_type::size_type start( + detail::root_directory_start( m_path, m_path.size() ) ); + + return start == string_type::npos + ? string_type() + : m_path.substr( start, 1 ); + } + + template + basic_path basic_path::root_path() const + { + // even on POSIX, root_name() is non-empty() on network paths + return basic_path( root_name() ) /= root_directory(); + } + + // path query functions -------------------------------------------------// + + template + inline bool basic_path::is_complete() const + { +# ifdef BOOST_WINDOWS_PATH + return has_root_name() && has_root_directory(); +# else + return has_root_directory(); +# endif + } + + template + inline bool basic_path::has_root_path() const + { + return !root_path().empty(); + } + + template + inline bool basic_path::has_root_name() const + { + return !root_name().empty(); + } + + template + inline bool basic_path::has_root_directory() const + { + return !root_directory().empty(); + } + + // append ---------------------------------------------------------------// + + template + void basic_path::m_append_separator_if_needed() + // requires: !empty() + { + if ( +# ifdef BOOST_WINDOWS_PATH + *(m_path.end()-1) != colon::value && +# endif + *(m_path.end()-1) != slash::value ) + { + m_path += slash::value; + } + } + + template + void basic_path::m_append( value_type value ) + { +# ifdef BOOST_CYGWIN_PATH + if ( m_path.empty() ) m_cygwin_root = (value == slash::value); +# endif + +# ifdef BOOST_WINDOWS_PATH + // for BOOST_WINDOWS_PATH, convert alt_separator ('\') to separator ('/') + m_path += ( value == path_alt_separator::value + ? slash::value + : value ); +# else + m_path += value; +# endif + } + + // except that it wouldn't work for BOOST_NO_MEMBER_TEMPLATES compilers, + // the append() member template could replace this code. + template + basic_path & basic_path::operator /= + ( const value_type * next_p ) + { + // ignore escape sequence on POSIX or Windows + if ( *next_p == slash::value + && *(next_p+1) == slash::value + && *(next_p+2) == colon::value ) next_p += 3; + + // append slash::value if needed + if ( !empty() && *next_p != 0 + && !detail::is_separator( *next_p ) ) + { m_append_separator_if_needed(); } + + for ( ; *next_p != 0; ++next_p ) m_append( *next_p ); + return *this; + } + +# ifndef BOOST_NO_MEMBER_TEMPLATES + template template + basic_path & basic_path::append( + InputIterator first, InputIterator last ) + { + // append slash::value if needed + if ( !empty() && first != last + && !detail::is_separator( *first ) ) + { m_append_separator_if_needed(); } + + // song-and-dance to avoid violating InputIterator requirements + // (which prohibit lookahead) in detecting a possible escape sequence + // (escape sequences are simply ignored on POSIX and Windows) + bool was_escape_sequence(true); + std::size_t append_count(0); + typename String::size_type initial_pos( m_path.size() ); + + for ( ; first != last && *first; ++first ) + { + if ( append_count == 0 && *first != slash::value ) + was_escape_sequence = false; + if ( append_count == 1 && *first != slash::value ) + was_escape_sequence = false; + if ( append_count == 2 && *first != colon::value ) + was_escape_sequence = false; + m_append( *first ); + ++append_count; + } + + // erase escape sequence if any + if ( was_escape_sequence && append_count >= 3 ) + m_path.erase( initial_pos, 3 ); + + return *this; + } +# endif + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + + // canonize ------------------------------------------------------------// + + template + basic_path & basic_path::canonize() + { + static const typename string_type::value_type dot_str[] + = { dot::value, 0 }; + + if ( m_path.empty() ) return *this; + + path_type temp; + + for ( iterator itr( begin() ); itr != end(); ++itr ) + { + temp /= *itr; + }; + + if ( temp.empty() ) temp /= dot_str; + m_path = temp.m_path; + return *this; + } + + // normalize ------------------------------------------------------------// + + template + basic_path & basic_path::normalize() + { + static const typename string_type::value_type dot_str[] + = { dot::value, 0 }; + + if ( m_path.empty() ) return *this; + + path_type temp; + iterator start( begin() ); + iterator last( end() ); + iterator stop( last-- ); + for ( iterator itr( start ); itr != stop; ++itr ) + { + // ignore "." except at start and last + if ( itr->size() == 1 + && (*itr)[0] == dot::value + && itr != start + && itr != last ) continue; + + // ignore a name and following ".." + if ( !temp.empty() + && itr->size() == 2 + && (*itr)[0] == dot::value + && (*itr)[1] == dot::value ) // dot dot + { + string_type lf( temp.filename() ); + if ( lf.size() > 0 + && (lf.size() != 1 + || (lf[0] != dot::value + && lf[0] != slash::value)) + && (lf.size() != 2 + || (lf[0] != dot::value + && lf[1] != dot::value +# ifdef BOOST_WINDOWS_PATH + && lf[1] != colon::value +# endif + ) + ) + ) + { + temp.remove_filename(); + // if not root directory, must also remove "/" if any + if ( temp.m_path.size() > 0 + && temp.m_path[temp.m_path.size()-1] + == slash::value ) + { + typename string_type::size_type rds( + detail::root_directory_start( temp.m_path, + temp.m_path.size() ) ); + if ( rds == string_type::npos + || rds != temp.m_path.size()-1 ) + { temp.m_path.erase( temp.m_path.size()-1 ); } + } + + iterator next( itr ); + if ( temp.empty() && ++next != stop + && next == last && *last == dot_str ) temp /= dot_str; + continue; + } + } + + temp /= *itr; + }; + + if ( temp.empty() ) temp /= dot_str; + m_path = temp.m_path; + return *this; + } + +# endif + + // modifiers ------------------------------------------------------------// + + template + basic_path & basic_path::remove_filename() + { + m_path.erase( + detail::filename_pos( m_path, m_path.size() ) ); + return *this; + } + + template + basic_path & + basic_path::replace_extension( const string_type & new_ext ) + { + // erase existing extension if any + string_type old_ext = extension(); + if ( !old_ext.empty() ) + m_path.erase( m_path.size() - old_ext.size() ); + + if ( !new_ext.empty() && new_ext[0] != dot::value ) + m_path += dot::value; + + m_path += new_ext; + + return *this; + } + + + // path conversion functions --------------------------------------------// + + template + const String + basic_path::file_string() const + { +# ifdef BOOST_WINDOWS_PATH + // for Windows, use the alternate separator, and bypass extra + // root separators + + typename string_type::size_type root_dir_start( + detail::root_directory_start( m_path, m_path.size() ) ); + bool in_root( root_dir_start != string_type::npos ); + String s; + for ( typename string_type::size_type pos( 0 ); + pos != m_path.size(); ++pos ) + { + // special case // [net] + if ( pos == 0 && m_path.size() > 1 + && m_path[0] == slash::value + && m_path[1] == slash::value + && ( m_path.size() == 2 + || !detail::is_separator( m_path[2] ) + ) ) + { + ++pos; + s += path_alt_separator::value; + s += path_alt_separator::value; + continue; + } + + // bypass extra root separators + if ( in_root ) + { + if ( s.size() > 0 + && s[s.size()-1] == path_alt_separator::value + && m_path[pos] == slash::value + ) continue; + } + + if ( m_path[pos] == slash::value ) + s += path_alt_separator::value; + else + s += m_path[pos]; + + if ( pos > root_dir_start + && m_path[pos] == slash::value ) + { in_root = false; } + } +# ifdef BOOST_CYGWIN_PATH + if ( m_cygwin_root ) s[0] = slash::value; +# endif + return s; +# else + return m_path; +# endif + } + + // iterator functions ---------------------------------------------------// + + template + typename basic_path::iterator basic_path::begin() const + { + iterator itr; + itr.m_path_ptr = this; + typename string_type::size_type element_size; + detail::first_element( m_path, itr.m_pos, element_size ); + itr.m_name = m_path.substr( itr.m_pos, element_size ); + return itr; + } + + template + typename basic_path::iterator basic_path::end() const + { + iterator itr; + itr.m_path_ptr = this; + itr.m_pos = m_path.size(); + return itr; + } + + namespace detail + { + // do_increment ------------------------------------------------------// + + template + void iterator_helper::do_increment( iterator & itr ) + { + typedef typename Path::string_type string_type; + typedef typename Path::traits_type traits_type; + + assert( itr.m_pos < itr.m_path_ptr->m_path.size() && "basic_path::iterator increment past end()" ); + + bool was_net( itr.m_name.size() > 2 + && itr.m_name[0] == slash::value + && itr.m_name[1] == slash::value + && itr.m_name[2] != slash::value ); + + // increment to position past current element + itr.m_pos += itr.m_name.size(); + + // if end reached, create end iterator + if ( itr.m_pos == itr.m_path_ptr->m_path.size() ) + { + itr.m_name.erase( itr.m_name.begin(), itr.m_name.end() ); // VC++ 6.0 lib didn't supply clear() + return; + } + + // process separator (Windows drive spec is only case not a separator) + if ( itr.m_path_ptr->m_path[itr.m_pos] == slash::value ) + { + // detect root directory + if ( was_net + # ifdef BOOST_WINDOWS_PATH + // case "c:/" + || itr.m_name[itr.m_name.size()-1] == colon::value + # endif + ) + { + itr.m_name = slash::value; + return; + } + + // bypass separators + while ( itr.m_pos != itr.m_path_ptr->m_path.size() + && itr.m_path_ptr->m_path[itr.m_pos] == slash::value ) + { ++itr.m_pos; } + + // detect trailing separator, and treat it as ".", per POSIX spec + if ( itr.m_pos == itr.m_path_ptr->m_path.size() + && detail::is_non_root_slash< string_type, traits_type >( + itr.m_path_ptr->m_path, itr.m_pos-1 ) ) + { + --itr.m_pos; + itr.m_name = dot::value; + return; + } + } + + // get next element + typename string_type::size_type end_pos( + itr.m_path_ptr->m_path.find( slash::value, itr.m_pos ) ); + itr.m_name = itr.m_path_ptr->m_path.substr( itr.m_pos, end_pos - itr.m_pos ); + } + + // do_decrement ------------------------------------------------------// + + template + void iterator_helper::do_decrement( iterator & itr ) + { + assert( itr.m_pos && "basic_path::iterator decrement past begin()" ); + + typedef typename Path::string_type string_type; + typedef typename Path::traits_type traits_type; + + typename string_type::size_type end_pos( itr.m_pos ); + + typename string_type::size_type root_dir_pos( + detail::root_directory_start( + itr.m_path_ptr->m_path, end_pos ) ); + + // if at end and there was a trailing non-root '/', return "." + if ( itr.m_pos == itr.m_path_ptr->m_path.size() + && itr.m_path_ptr->m_path.size() > 1 + && itr.m_path_ptr->m_path[itr.m_pos-1] == slash::value + && detail::is_non_root_slash< string_type, traits_type >( + itr.m_path_ptr->m_path, itr.m_pos-1 ) + ) + { + --itr.m_pos; + itr.m_name = dot::value; + return; + } + + // skip separators unless root directory + for ( + ; + end_pos > 0 + && (end_pos-1) != root_dir_pos + && itr.m_path_ptr->m_path[end_pos-1] == slash::value + ; + --end_pos ) {} + + itr.m_pos = detail::filename_pos + ( itr.m_path_ptr->m_path, end_pos ); + itr.m_name = itr.m_path_ptr->m_path.substr( itr.m_pos, end_pos - itr.m_pos ); + } + } // namespace detail + + // basic_filesystem_error implementation --------------------------------// + + template + basic_filesystem_error::basic_filesystem_error( + const std::string & what_arg, system::error_code ec ) + : system::system_error(ec, what_arg) + { + try + { + m_imp_ptr.reset( new m_imp ); + } + catch (...) { m_imp_ptr.reset(); } + } + + template + basic_filesystem_error::basic_filesystem_error( + const std::string & what_arg, const path_type & path1_arg, + system::error_code ec ) + : system::system_error(ec, what_arg) + { + try + { + m_imp_ptr.reset( new m_imp ); + m_imp_ptr->m_path1 = path1_arg; + } + catch (...) { m_imp_ptr.reset(); } + } + + template + basic_filesystem_error::basic_filesystem_error( + const std::string & what_arg, const path_type & path1_arg, + const path_type & path2_arg, system::error_code ec ) + : system::system_error(ec, what_arg) + { + try + { + m_imp_ptr.reset( new m_imp ); + m_imp_ptr->m_path1 = path1_arg; + m_imp_ptr->m_path2 = path2_arg; + } + catch (...) { m_imp_ptr.reset(); } + } + + } // namespace BOOST_FILESYSTEM_NAMESPACE +} // namespace boost + +#include // pops abi_prefix.hpp pragmas + +#endif // BOOST_FILESYSTEM_PATH_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/none.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/none.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,28 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Distributed under 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) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_NONE_17SEP2003_HPP +#define BOOST_NONE_17SEP2003_HPP + +#include "boost/none_t.hpp" + +// NOTE: Borland users have to include this header outside any precompiled headers +// (bcc<=5.64 cannot include instance data in a precompiled header) +// -- * To be verified, now that there's no unnamed namespace + +namespace boost { + +none_t const none = ((none_t)0) ; + +} // namespace boost + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/none_t.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/none_t.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,24 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is 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) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_NONE_T_17SEP2003_HPP +#define BOOST_NONE_T_17SEP2003_HPP + +namespace boost { + +namespace detail { struct none_helper{}; } + +typedef int detail::none_helper::*none_t ; + +} // namespace boost + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/optional.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,18 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is 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) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_FLC_19NOV2002_HPP + +#include "boost/optional/optional.hpp" + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/optional/optional.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional/optional.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,922 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is 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) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP + +#include +#include + +#include "boost/config.hpp" +#include "boost/assert.hpp" +#include "boost/type.hpp" +#include "boost/type_traits/alignment_of.hpp" +#include "boost/type_traits/type_with_alignment.hpp" +#include "boost/type_traits/remove_reference.hpp" +#include "boost/type_traits/is_reference.hpp" +#include "boost/mpl/if.hpp" +#include "boost/mpl/bool.hpp" +#include "boost/mpl/not.hpp" +#include "boost/detail/reference_content.hpp" +#include "boost/none.hpp" +#include "boost/utility/compare_pointees.hpp" + +#include "boost/optional/optional_fwd.hpp" + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1200) +// VC6.0 has the following bug: +// When a templated assignment operator exist, an implicit conversion +// constructing an optional is used when assigment of the form: +// optional opt ; opt = T(...); +// is compiled. +// However, optional's ctor is _explicit_ and the assignemt shouldn't compile. +// Therefore, for VC6.0 templated assignment is disabled. +// +#define BOOST_OPTIONAL_NO_CONVERTING_ASSIGNMENT +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300) +// VC7.0 has the following bug: +// When both a non-template and a template copy-ctor exist +// and the templated version is made 'explicit', the explicit is also +// given to the non-templated version, making the class non-implicitely-copyable. +// +#define BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION,<=700) +// AFAICT only VC7.1 correctly resolves the overload set +// that includes the in-place factory taking functions, +// so for the other VC versions, in-place factory support +// is disabled +#define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT +#endif + +#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551) +// BCB (5.5.1) cannot parse the nested template struct in an inplace factory. +#define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT +#endif + +#if !defined(BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT) \ + && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581) ) +// BCB (up to 5.64) has the following bug: +// If there is a member function/operator template of the form +// template mfunc( Expr expr ) ; +// some calls are resolved to this even if there are other better matches. +// The effect of this bug is that calls to converting ctors and assignments +// are incrorrectly sink to this general catch-all member function template as shown above. +#define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION +#endif + +// Daniel Wallin discovered that bind/apply.hpp badly interacts with the apply<> +// member template of a factory as used in the optional<> implementation. +// He proposed this simple fix which is to move the call to apply<> outside +// namespace boost. +namespace boost_optional_detail +{ + template + void construct(Factory const& factory, void* address) + { + factory.BOOST_NESTED_TEMPLATE apply(address); + } +} + + +namespace boost { + +class in_place_factory_base ; +class typed_in_place_factory_base ; + +namespace optional_detail { + +// This local class is used instead of that in "aligned_storage.hpp" +// because I've found the 'official' class to ICE BCB5.5 +// when some types are used with optional<> +// (due to sizeof() passed down as a non-type template parameter) +template +class aligned_storage +{ + // Borland ICEs if unnamed unions are used for this! + union dummy_u + { + char data[ sizeof(T) ]; + BOOST_DEDUCED_TYPENAME type_with_alignment< + ::boost::alignment_of::value >::type aligner_; + } dummy_ ; + + public: + + void const* address() const { return &dummy_.data[0]; } + void * address() { return &dummy_.data[0]; } +} ; + +template +struct types_when_isnt_ref +{ + typedef T const& reference_const_type ; + typedef T & reference_type ; + typedef T const* pointer_const_type ; + typedef T * pointer_type ; + typedef T const& argument_type ; +} ; +template +struct types_when_is_ref +{ + typedef BOOST_DEDUCED_TYPENAME remove_reference::type raw_type ; + + typedef raw_type& reference_const_type ; + typedef raw_type& reference_type ; + typedef raw_type* pointer_const_type ; + typedef raw_type* pointer_type ; + typedef raw_type& argument_type ; +} ; + +struct optional_tag {} ; + +template +class optional_base : public optional_tag +{ + private : + + typedef +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + BOOST_DEDUCED_TYPENAME +#endif + ::boost::detail::make_reference_content::type internal_type ; + + typedef aligned_storage storage_type ; + + typedef types_when_isnt_ref types_when_not_ref ; + typedef types_when_is_ref types_when_ref ; + + typedef optional_base this_type ; + + protected : + + typedef T value_type ; + + typedef mpl::true_ is_reference_tag ; + typedef mpl::false_ is_not_reference_tag ; + + typedef BOOST_DEDUCED_TYPENAME is_reference::type is_reference_predicate ; + + typedef BOOST_DEDUCED_TYPENAME mpl::if_::type types ; + + typedef bool (this_type::*unspecified_bool_type)() const; + + typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ; + typedef BOOST_DEDUCED_TYPENAME types::reference_const_type reference_const_type ; + typedef BOOST_DEDUCED_TYPENAME types::pointer_type pointer_type ; + typedef BOOST_DEDUCED_TYPENAME types::pointer_const_type pointer_const_type ; + typedef BOOST_DEDUCED_TYPENAME types::argument_type argument_type ; + + // Creates an optional uninitialized. + // No-throw + optional_base() + : + m_initialized(false) {} + + // Creates an optional uninitialized. + // No-throw + optional_base ( none_t ) + : + m_initialized(false) {} + + // Creates an optional initialized with 'val'. + // Can throw if T::T(T const&) does + optional_base ( argument_type val ) + : + m_initialized(false) + { + construct(val); + } + + // Creates an optional initialized with 'val' IFF cond is true, otherwise creates an uninitialzed optional. + // Can throw if T::T(T const&) does + optional_base ( bool cond, argument_type val ) + : + m_initialized(false) + { + if ( cond ) + construct(val); + } + + // Creates a deep copy of another optional + // Can throw if T::T(T const&) does + optional_base ( optional_base const& rhs ) + : + m_initialized(false) + { + if ( rhs.is_initialized() ) + construct(rhs.get_impl()); + } + + + // This is used for both converting and in-place constructions. + // Derived classes use the 'tag' to select the appropriate + // implementation (the correct 'construct()' overload) + template + explicit optional_base ( Expr const& expr, Expr const* tag ) + : + m_initialized(false) + { + construct(expr,tag); + } + + + + // No-throw (assuming T::~T() doesn't) + ~optional_base() { destroy() ; } + + // Assigns from another optional (deep-copies the rhs value) + void assign ( optional_base const& rhs ) + { + if (is_initialized()) + { + if ( rhs.is_initialized() ) + assign_value(rhs.get_impl(), is_reference_predicate() ); + else destroy(); + } + else + { + if ( rhs.is_initialized() ) + construct(rhs.get_impl()); + } + } + + // Assigns from another _convertible_ optional (deep-copies the rhs value) + template + void assign ( optional const& rhs ) + { + if (is_initialized()) + { + if ( rhs.is_initialized() ) + assign_value(static_cast(rhs.get()), is_reference_predicate() ); + else destroy(); + } + else + { + if ( rhs.is_initialized() ) + construct(static_cast(rhs.get())); + } + } + + // Assigns from a T (deep-copies the rhs value) + void assign ( argument_type val ) + { + if (is_initialized()) + assign_value(val, is_reference_predicate() ); + else construct(val); + } + + // Assigns from "none", destroying the current value, if any, leaving this UNINITIALIZED + // No-throw (assuming T::~T() doesn't) + void assign ( none_t ) { destroy(); } + +#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT + template + void assign_expr ( Expr const& expr, Expr const* tag ) + { + if (is_initialized()) + assign_expr_to_initialized(expr,tag); + else construct(expr,tag); + } +#endif + + public : + + // Destroys the current value, if any, leaving this UNINITIALIZED + // No-throw (assuming T::~T() doesn't) + void reset() { destroy(); } + + // Replaces the current value -if any- with 'val' + void reset ( argument_type val ) { assign(val); } + + // Returns a pointer to the value if this is initialized, otherwise, + // returns NULL. + // No-throw + pointer_const_type get_ptr() const { return m_initialized ? get_ptr_impl() : 0 ; } + pointer_type get_ptr() { return m_initialized ? get_ptr_impl() : 0 ; } + + bool is_initialized() const { return m_initialized ; } + + protected : + + void construct ( argument_type val ) + { + new (m_storage.address()) internal_type(val) ; + m_initialized = true ; + } + +#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT + // Constructs in-place using the given factory + template + void construct ( Expr const& factory, in_place_factory_base const* ) + { + BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ; + boost_optional_detail::construct(factory, m_storage.address()); + m_initialized = true ; + } + + // Constructs in-place using the given typed factory + template + void construct ( Expr const& factory, typed_in_place_factory_base const* ) + { + BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ; + factory.apply(m_storage.address()) ; + m_initialized = true ; + } + + template + void assign_expr_to_initialized ( Expr const& factory, in_place_factory_base const* tag ) + { + destroy(); + construct(factory,tag); + } + + // Constructs in-place using the given typed factory + template + void assign_expr_to_initialized ( Expr const& factory, typed_in_place_factory_base const* tag ) + { + destroy(); + construct(factory,tag); + } +#endif + + // Constructs using any expression implicitely convertible to the single argument + // of a one-argument T constructor. + // Converting constructions of optional from optional uses this function with + // 'Expr' being of type 'U' and relying on a converting constructor of T from U. + template + void construct ( Expr const& expr, void const* ) + { + new (m_storage.address()) internal_type(expr) ; + m_initialized = true ; + } + + // Assigns using a form any expression implicitely convertible to the single argument + // of a T's assignment operator. + // Converting assignments of optional from optional uses this function with + // 'Expr' being of type 'U' and relying on a converting assignment of T from U. + template + void assign_expr_to_initialized ( Expr const& expr, void const* ) + { + assign_value(expr, is_reference_predicate()); + } + +#ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION + // BCB5.64 (and probably lower versions) workaround. + // The in-place factories are supported by means of catch-all constructors + // and assignment operators (the functions are parameterized in terms of + // an arbitrary 'Expr' type) + // This compiler incorrectly resolves the overload set and sinks optional and optional + // to the 'Expr'-taking functions even though explicit overloads are present for them. + // Thus, the following overload is needed to properly handle the case when the 'lhs' + // is another optional. + // + // For VC<=70 compilers this workaround dosen't work becasue the comnpiler issues and error + // instead of choosing the wrong overload + // + // Notice that 'Expr' will be optional or optional (but not optional_base<..>) + template + void construct ( Expr const& expr, optional_tag const* ) + { + if ( expr.is_initialized() ) + { + // An exception can be thrown here. + // It it happens, THIS will be left uninitialized. + new (m_storage.address()) internal_type(expr.get()) ; + m_initialized = true ; + } + } +#endif + + void assign_value ( argument_type val, is_not_reference_tag ) { get_impl() = val; } + void assign_value ( argument_type val, is_reference_tag ) { construct(val); } + + void destroy() + { + if ( m_initialized ) + destroy_impl(is_reference_predicate()) ; + } + + unspecified_bool_type safe_bool() const { return m_initialized ? &this_type::is_initialized : 0 ; } + + reference_const_type get_impl() const { return dereference(get_object(), is_reference_predicate() ) ; } + reference_type get_impl() { return dereference(get_object(), is_reference_predicate() ) ; } + + pointer_const_type get_ptr_impl() const { return cast_ptr(get_object(), is_reference_predicate() ) ; } + pointer_type get_ptr_impl() { return cast_ptr(get_object(), is_reference_predicate() ) ; } + + private : + + // internal_type can be either T or reference_content + internal_type const* get_object() const { return static_cast(m_storage.address()); } + internal_type * get_object() { return static_cast (m_storage.address()); } + + // reference_content lacks an implicit conversion to T&, so the following is needed to obtain a proper reference. + reference_const_type dereference( internal_type const* p, is_not_reference_tag ) const { return *p ; } + reference_type dereference( internal_type* p, is_not_reference_tag ) { return *p ; } + reference_const_type dereference( internal_type const* p, is_reference_tag ) const { return p->get() ; } + reference_type dereference( internal_type* p, is_reference_tag ) { return p->get() ; } + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581)) + void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->internal_type::~internal_type() ; m_initialized = false ; } +#else + void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->T::~T() ; m_initialized = false ; } +#endif + + void destroy_impl ( is_reference_tag ) { m_initialized = false ; } + + // If T is of reference type, trying to get a pointer to the held value must result in a compile-time error. + // Decent compilers should disallow conversions from reference_content* to T*, but just in case, + // the following olverloads are used to filter out the case and guarantee an error in case of T being a reference. + pointer_const_type cast_ptr( internal_type const* p, is_not_reference_tag ) const { return p ; } + pointer_type cast_ptr( internal_type * p, is_not_reference_tag ) { return p ; } + pointer_const_type cast_ptr( internal_type const* p, is_reference_tag ) const { return &p->get() ; } + pointer_type cast_ptr( internal_type * p, is_reference_tag ) { return &p->get() ; } + + bool m_initialized ; + storage_type m_storage ; +} ; + +} // namespace optional_detail + +template +class optional : public optional_detail::optional_base +{ + typedef optional_detail::optional_base base ; + + typedef BOOST_DEDUCED_TYPENAME base::unspecified_bool_type unspecified_bool_type ; + + public : + + typedef optional this_type ; + + typedef BOOST_DEDUCED_TYPENAME base::value_type value_type ; + typedef BOOST_DEDUCED_TYPENAME base::reference_type reference_type ; + typedef BOOST_DEDUCED_TYPENAME base::reference_const_type reference_const_type ; + typedef BOOST_DEDUCED_TYPENAME base::pointer_type pointer_type ; + typedef BOOST_DEDUCED_TYPENAME base::pointer_const_type pointer_const_type ; + typedef BOOST_DEDUCED_TYPENAME base::argument_type argument_type ; + + // Creates an optional uninitialized. + // No-throw + optional() : base() {} + + // Creates an optional uninitialized. + // No-throw + optional( none_t none_ ) : base(none_) {} + + // Creates an optional initialized with 'val'. + // Can throw if T::T(T const&) does + optional ( argument_type val ) : base(val) {} + + // Creates an optional initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional. + // Can throw if T::T(T const&) does + optional ( bool cond, argument_type val ) : base(cond,val) {} + +#ifndef BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR + // NOTE: MSVC needs templated versions first + + // Creates a deep copy of another convertible optional + // Requires a valid conversion from U to T. + // Can throw if T::T(U const&) does + template + explicit optional ( optional const& rhs ) + : + base() + { + if ( rhs.is_initialized() ) + this->construct(rhs.get()); + } +#endif + +#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT + // Creates an optional with an expression which can be either + // (a) An instance of InPlaceFactory (i.e. in_place(a,b,...,n); + // (b) An instance of TypedInPlaceFactory ( i.e. in_place(a,b,...,n); + // (c) Any expression implicitely convertible to the single type + // of a one-argument T's constructor. + // (d*) Weak compilers (BCB) might also resolved Expr as optional and optional + // even though explicit overloads are present for these. + // Depending on the above some T ctor is called. + // Can throw is the resolved T ctor throws. + template + explicit optional ( Expr const& expr ) : base(expr,&expr) {} +#endif + + // Creates a deep copy of another optional + // Can throw if T::T(T const&) does + optional ( optional const& rhs ) : base(rhs) {} + + // No-throw (assuming T::~T() doesn't) + ~optional() {} + +#if !defined(BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT) && !defined(BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION) + // Assigns from an expression. See corresponding constructor. + // Basic Guarantee: If the resolved T ctor throws, this is left UNINITIALIZED + template + optional& operator= ( Expr expr ) + { + this->assign_expr(expr,&expr); + return *this ; + } +#endif + + +#ifndef BOOST_OPTIONAL_NO_CONVERTING_ASSIGNMENT + // Assigns from another convertible optional (converts && deep-copies the rhs value) + // Requires a valid conversion from U to T. + // Basic Guarantee: If T::T( U const& ) throws, this is left UNINITIALIZED + template + optional& operator= ( optional const& rhs ) + { + this->assign(rhs); + return *this ; + } +#endif + + // Assigns from another optional (deep-copies the rhs value) + // Basic Guarantee: If T::T( T const& ) throws, this is left UNINITIALIZED + // (NOTE: On BCB, this operator is not actually called and left is left UNMODIFIED in case of a throw) + optional& operator= ( optional const& rhs ) + { + this->assign( rhs ) ; + return *this ; + } + + // Assigns from a T (deep-copies the rhs value) + // Basic Guarantee: If T::( T const& ) throws, this is left UNINITIALIZED + optional& operator= ( argument_type val ) + { + this->assign( val ) ; + return *this ; + } + + // Assigns from a "none" + // Which destroys the current value, if any, leaving this UNINITIALIZED + // No-throw (assuming T::~T() doesn't) + optional& operator= ( none_t none_ ) + { + this->assign( none_ ) ; + return *this ; + } + + // Returns a reference to the value if this is initialized, otherwise, + // the behaviour is UNDEFINED + // No-throw + reference_const_type get() const { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); } + reference_type get() { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); } + + // Returns a copy of the value if this is initialized, 'v' otherwise + reference_const_type get_value_or ( reference_const_type v ) const { return this->is_initialized() ? get() : v ; } + reference_type get_value_or ( reference_type v ) { return this->is_initialized() ? get() : v ; } + + // Returns a pointer to the value if this is initialized, otherwise, + // the behaviour is UNDEFINED + // No-throw + pointer_const_type operator->() const { BOOST_ASSERT(this->is_initialized()) ; return this->get_ptr_impl() ; } + pointer_type operator->() { BOOST_ASSERT(this->is_initialized()) ; return this->get_ptr_impl() ; } + + // Returns a reference to the value if this is initialized, otherwise, + // the behaviour is UNDEFINED + // No-throw + reference_const_type operator *() const { return this->get() ; } + reference_type operator *() { return this->get() ; } + + // implicit conversion to "bool" + // No-throw + operator unspecified_bool_type() const { return this->safe_bool() ; } + + // This is provided for those compilers which don't like the conversion to bool + // on some contexts. + bool operator!() const { return !this->is_initialized() ; } +} ; + +// Returns optional(v) +template +inline +optional make_optional ( T const& v ) +{ + return optional(v); +} + +// Returns optional(cond,v) +template +inline +optional make_optional ( bool cond, T const& v ) +{ + return optional(cond,v); +} + +// Returns a reference to the value if this is initialized, otherwise, the behaviour is UNDEFINED. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_const_type +get ( optional const& opt ) +{ + return opt.get() ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_type +get ( optional& opt ) +{ + return opt.get() ; +} + +// Returns a pointer to the value if this is initialized, otherwise, returns NULL. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_const_type +get ( optional const* opt ) +{ + return opt->get_ptr() ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_type +get ( optional* opt ) +{ + return opt->get_ptr() ; +} + +// Returns a reference to the value if this is initialized, otherwise, the behaviour is UNDEFINED. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_const_type +get_optional_value_or ( optional const& opt, BOOST_DEDUCED_TYPENAME optional::reference_const_type v ) +{ + return opt.get_value_or(v) ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_type +get_optional_value_or ( optional& opt, BOOST_DEDUCED_TYPENAME optional::reference_type v ) +{ + return opt.get_value_or(v) ; +} + +// Returns a pointer to the value if this is initialized, otherwise, returns NULL. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_const_type +get_pointer ( optional const& opt ) +{ + return opt.get_ptr() ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_type +get_pointer ( optional& opt ) +{ + return opt.get_ptr() ; +} + +// optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values). +// WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointess() in generic code instead. + + +// +// optional vs optional cases +// + +template +inline +bool operator == ( optional const& x, optional const& y ) +{ return equal_pointees(x,y); } + +template +inline +bool operator < ( optional const& x, optional const& y ) +{ return less_pointees(x,y); } + +template +inline +bool operator != ( optional const& x, optional const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( optional const& x, optional const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( optional const& x, optional const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( optional const& x, optional const& y ) +{ return !( x < y ) ; } + + +// +// optional vs T cases +// +template +inline +bool operator == ( optional const& x, T const& y ) +{ return equal_pointees(x, optional(y)); } + +template +inline +bool operator < ( optional const& x, T const& y ) +{ return less_pointees(x, optional(y)); } + +template +inline +bool operator != ( optional const& x, T const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( optional const& x, T const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( optional const& x, T const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( optional const& x, T const& y ) +{ return !( x < y ) ; } + +// +// T vs optional cases +// + +template +inline +bool operator == ( T const& x, optional const& y ) +{ return equal_pointees( optional(x), y ); } + +template +inline +bool operator < ( T const& x, optional const& y ) +{ return less_pointees( optional(x), y ); } + +template +inline +bool operator != ( T const& x, optional const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( T const& x, optional const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( T const& x, optional const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( T const& x, optional const& y ) +{ return !( x < y ) ; } + + +// +// optional vs none cases +// + +template +inline +bool operator == ( optional const& x, none_t ) +{ return equal_pointees(x, optional() ); } + +template +inline +bool operator < ( optional const& x, none_t ) +{ return less_pointees(x,optional() ); } + +template +inline +bool operator != ( optional const& x, none_t y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( optional const& x, none_t y ) +{ return y < x ; } + +template +inline +bool operator <= ( optional const& x, none_t y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( optional const& x, none_t y ) +{ return !( x < y ) ; } + +// +// none vs optional cases +// + +template +inline +bool operator == ( none_t x, optional const& y ) +{ return equal_pointees(optional() ,y); } + +template +inline +bool operator < ( none_t x, optional const& y ) +{ return less_pointees(optional() ,y); } + +template +inline +bool operator != ( none_t x, optional const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( none_t x, optional const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( none_t x, optional const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( none_t x, optional const& y ) +{ return !( x < y ) ; } + +// +// The following swap implementation follows the GCC workaround as found in +// "boost/detail/compressed_pair.hpp" +// +namespace optional_detail { + +// GCC < 3.2 gets the using declaration at namespace scope (FLC, DWA) +#if BOOST_WORKAROUND(__GNUC__, < 3) \ + || BOOST_WORKAROUND(__GNUC__, == 3) && __GNUC_MINOR__ <= 2 + using std::swap; +#define BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE +#endif + +// optional's swap: +// If both are initialized, calls swap(T&, T&). If this swap throws, both will remain initialized but their values are now unspecified. +// If only one is initialized, calls U.reset(*I), THEN I.reset(). +// If U.reset(*I) throws, both are left UNCHANGED (U is kept uinitialized and I is never reset) +// If both are uninitialized, do nothing (no-throw) +template +inline +void optional_swap ( optional& x, optional& y ) +{ + if ( !x && !!y ) + { + x.reset(*y); + y.reset(); + } + else if ( !!x && !y ) + { + y.reset(*x); + x.reset(); + } + else if ( !!x && !!y ) + { +// GCC > 3.2 and all other compilers have the using declaration at function scope (FLC) +#ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE + // allow for Koenig lookup + using std::swap ; +#endif + swap(*x,*y); + } +} + +} // namespace optional_detail + +template inline void swap ( optional& x, optional& y ) +{ + optional_detail::optional_swap(x,y); +} + + +} // namespace boost + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/optional/optional_fwd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional/optional_fwd.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,22 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is 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) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP + +namespace boost { + +template class optional ; + +} // namespace boost + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/optional/optional_io.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional/optional_io.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,84 @@ +// Copyright (C) 2005, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is 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) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP + +#if defined __GNUC__ +# if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97) +# define BOOST_OPTIONAL_NO_TEMPLATED_STREAMS +# endif +#endif // __GNUC__ + +#if defined BOOST_OPTIONAL_NO_TEMPLATED_STREAMS +# include +#else +# include +# include +#endif + + +#include "boost/optional/optional.hpp" +#include "boost/utility/value_init.hpp" + +namespace boost +{ + +#if defined (BOOST_NO_TEMPLATED_STREAMS) +template +inline std::ostream& operator<<(std::ostream& out, optional const& v) +#else +template +inline +std::basic_ostream& +operator<<(std::basic_ostream& out, optional const& v) +#endif +{ + if ( out.good() ) + { + if ( !v ) + out << "--" ; + else out << ' ' << *v ; + } + + return out; +} + +#if defined (BOOST_NO_TEMPLATED_STREAMS) +template +inline std::istream& operator>>(std::istream& in, optional& v) +#else +template +inline +std::basic_istream& +operator>>(std::basic_istream& in, optional& v) +#endif +{ + if ( in.good() ) + { + int d = in.get(); + if ( d == ' ' ) + { + T x ; + in >> x; + v = x ; + } + else + v = optional() ; + } + + return in; +} + +} // namespace boost + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,37 @@ +/* + * + * 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/libs/regex for documentation. + * FILE regex.cpp + * VERSION see + * DESCRIPTION: Declares boost::basic_regex<> and associated + * functions and classes. This header is the main + * entry point for the template regex code. + */ + + +/* start with C compatibility API */ + +#ifndef BOOST_RE_REGEX_HPP +#define BOOST_RE_REGEX_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include + +#endif // include + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/concepts.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/concepts.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,870 @@ +/* + * + * 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 concepts.hpp + * VERSION see + * DESCRIPTION: Declares regular expression concepts. + */ + +#ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED +#define BOOST_REGEX_CONCEPTS_HPP_INCLUDED + +#include +#include +#include +#include +#include +#ifndef BOOST_TEST_TR1_REGEX +#include +#endif +#include +#include +#include + +namespace boost{ + +// +// bitmask_archetype: +// this can be either an integer type, an enum, or a std::bitset, +// we use the latter as the architype as it offers the "strictest" +// of the possible interfaces: +// +typedef std::bitset<512> bitmask_archetype; +// +// char_architype: +// A strict model for the character type interface. +// +struct char_architype +{ + // default constructable: + char_architype(); + // copy constructable / assignable: + char_architype(const char_architype&); + char_architype& operator=(const char_architype&); + // constructable from an integral value: + char_architype(unsigned long val); + // comparable: + bool operator==(const char_architype&)const; + bool operator!=(const char_architype&)const; + bool operator<(const char_architype&)const; + bool operator<=(const char_architype&)const; + bool operator>=(const char_architype&)const; + bool operator>(const char_architype&)const; + // conversion to integral type: + operator long()const; +}; +// +// char_architype can not be used with basic_string: +// +} // namespace boost +namespace std{ + template<> struct char_traits + { + // The intent is that this template is not instantiated, + // but this typedef gives us a chance of compilation in + // case it is: + typedef boost::char_architype char_type; + }; +} +namespace boost{ +// +// regex_traits_architype: +// A strict interpretation of the regular expression traits class requirements. +// +template +struct regex_traits_architype +{ +public: + regex_traits_architype(); + typedef charT char_type; + // typedef std::size_t size_type; + typedef std::vector string_type; + typedef copy_constructible_archetype > locale_type; + typedef bitmask_archetype char_class_type; + + static std::size_t length(const char_type* ) { return 0; } + + charT translate(charT ) const { return charT(); } + charT translate_nocase(charT ) const { return static_object::get(); } + + template + string_type transform(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + template + string_type transform_primary(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + + template + char_class_type lookup_classname(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + template + string_type lookup_collatename(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + + bool isctype(charT, char_class_type) const + { return false; } + int value(charT, int) const + { return 0; } + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return static_object::get(); } + +private: + // this type is not copyable: + regex_traits_architype(const regex_traits_architype&); + regex_traits_architype& operator=(const regex_traits_architype&); +}; + +// +// alter this to std::tr1, to test a std implementation: +// +#ifndef BOOST_TEST_TR1_REGEX +namespace global_regex_namespace = ::boost; +#else +namespace global_regex_namespace = ::std::tr1; +#endif + +template +struct BitmaskConcept +{ + void constraints() + { + function_requires >(); + function_requires >(); + + m_mask1 = m_mask2 | m_mask3; + m_mask1 = m_mask2 & m_mask3; + m_mask1 = m_mask2 ^ m_mask3; + + m_mask1 = ~m_mask2; + + m_mask1 |= m_mask2; + m_mask1 &= m_mask2; + m_mask1 ^= m_mask2; + } + Bitmask m_mask1, m_mask2, m_mask3; +}; + +template +struct RegexTraitsConcept +{ + RegexTraitsConcept(); + // required typedefs: + typedef typename traits::char_type char_type; + // typedef typename traits::size_type size_type; + typedef typename traits::string_type string_type; + typedef typename traits::locale_type locale_type; + typedef typename traits::char_class_type char_class_type; + + void constraints() + { + //function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + + std::size_t n = traits::length(m_pointer); + ignore_unused_variable_warning(n); + + char_type c = m_ctraits.translate(m_char); + ignore_unused_variable_warning(c); + c = m_ctraits.translate_nocase(m_char); + + //string_type::foobar bar; + string_type s1 = m_ctraits.transform(m_pointer, m_pointer); + ignore_unused_variable_warning(s1); + + string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer); + ignore_unused_variable_warning(s2); + + char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer); + ignore_unused_variable_warning(cc); + + string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer); + ignore_unused_variable_warning(s3); + + bool b = m_ctraits.isctype(m_char, cc); + ignore_unused_variable_warning(b); + + int v = m_ctraits.value(m_char, 16); + ignore_unused_variable_warning(v); + + locale_type l(m_ctraits.getloc()); + m_traits.imbue(l); + ignore_unused_variable_warning(l); + } + traits m_traits; + const traits m_ctraits; + const char_type* m_pointer; + char_type m_char; +private: + RegexTraitsConcept& operator=(RegexTraitsConcept&); +}; + +// +// helper class to compute what traits class a regular expression type is using: +// +template +struct regex_traits_computer; + +template +struct regex_traits_computer< global_regex_namespace::basic_regex > +{ + typedef traits type; +}; + +// +// BaseRegexConcept does not test anything dependent on basic_string, +// in case our charT does not have an associated char_traits: +// +template +struct BaseRegexConcept +{ + typedef typename Regex::value_type value_type; + //typedef typename Regex::size_type size_type; + typedef typename Regex::flag_type flag_type; + typedef typename Regex::locale_type locale_type; + typedef input_iterator_archetype input_iterator_type; + + // derived test types: + typedef const value_type* pointer_type; + typedef bidirectional_iterator_archetype BidiIterator; + typedef global_regex_namespace::sub_match sub_match_type; + typedef global_regex_namespace::match_results match_results_type; + typedef output_iterator_archetype OutIterator; + typedef typename regex_traits_computer::type traits_type; + typedef global_regex_namespace::regex_iterator regex_iterator_type; + typedef global_regex_namespace::regex_token_iterator regex_token_iterator_type; + + void global_constraints() + { + // + // test non-template components: + // + function_requires >(); + global_regex_namespace::regex_constants::syntax_option_type opts + = global_regex_namespace::regex_constants::icase + | global_regex_namespace::regex_constants::nosubs + | global_regex_namespace::regex_constants::optimize + | global_regex_namespace::regex_constants::collate + | global_regex_namespace::regex_constants::ECMAScript + | global_regex_namespace::regex_constants::basic + | global_regex_namespace::regex_constants::extended + | global_regex_namespace::regex_constants::awk + | global_regex_namespace::regex_constants::grep + | global_regex_namespace::regex_constants::egrep; + ignore_unused_variable_warning(opts); + + function_requires >(); + global_regex_namespace::regex_constants::match_flag_type mopts + = global_regex_namespace::regex_constants::match_default + | global_regex_namespace::regex_constants::match_not_bol + | global_regex_namespace::regex_constants::match_not_eol + | global_regex_namespace::regex_constants::match_not_bow + | global_regex_namespace::regex_constants::match_not_eow + | global_regex_namespace::regex_constants::match_any + | global_regex_namespace::regex_constants::match_not_null + | global_regex_namespace::regex_constants::match_continuous + | global_regex_namespace::regex_constants::match_prev_avail + | global_regex_namespace::regex_constants::format_default + | global_regex_namespace::regex_constants::format_sed + | global_regex_namespace::regex_constants::format_no_copy + | global_regex_namespace::regex_constants::format_first_only; + ignore_unused_variable_warning(mopts); + + BOOST_STATIC_ASSERT((::boost::is_enum::value)); + global_regex_namespace::regex_constants::error_type e1 = global_regex_namespace::regex_constants::error_collate; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_ctype; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_escape; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_backref; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_brack; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_paren; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_brace; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_badbrace; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_range; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_space; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_badrepeat; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_complexity; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_stack; + ignore_unused_variable_warning(e1); + + BOOST_STATIC_ASSERT((::boost::is_base_and_derived::value )); + const global_regex_namespace::regex_error except(e1); + e1 = except.code(); + + typedef typename Regex::value_type value_type; + function_requires< RegexTraitsConcept > >(); + function_requires< BaseRegexConcept > >(); + } + void constraints() + { + global_constraints(); + + BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value)); + flag_type opts + = Regex::icase + | Regex::nosubs + | Regex::optimize + | Regex::collate + | Regex::ECMAScript + | Regex::basic + | Regex::extended + | Regex::awk + | Regex::grep + | Regex::egrep; + ignore_unused_variable_warning(opts); + + function_requires >(); + function_requires >(); + + // Regex constructors: + Regex e1(m_pointer); + ignore_unused_variable_warning(e1); + Regex e2(m_pointer, m_flags); + ignore_unused_variable_warning(e2); + Regex e3(m_pointer, m_size, m_flags); + ignore_unused_variable_warning(e3); + Regex e4(in1, in2); + ignore_unused_variable_warning(e4); + Regex e5(in1, in2, m_flags); + ignore_unused_variable_warning(e5); + + // assign etc: + Regex e; + e = m_pointer; + e = e1; + e.assign(e1); + e.assign(m_pointer); + e.assign(m_pointer, m_flags); + e.assign(m_pointer, m_size, m_flags); + e.assign(in1, in2); + e.assign(in1, in2, m_flags); + + // access: + const Regex ce; + unsigned i = ce.mark_count(); + ignore_unused_variable_warning(i); + m_flags = ce.flags(); + e.imbue(ce.getloc()); + e.swap(e1); + + global_regex_namespace::swap(e, e1); + + // sub_match: + BOOST_STATIC_ASSERT((::boost::is_base_and_derived, sub_match_type>::value)); + typedef typename sub_match_type::value_type sub_value_type; + typedef typename sub_match_type::difference_type sub_diff_type; + typedef typename sub_match_type::iterator sub_iter_type; + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + bool b = m_sub.matched; + ignore_unused_variable_warning(b); + BidiIterator bi = m_sub.first; + ignore_unused_variable_warning(bi); + bi = m_sub.second; + ignore_unused_variable_warning(bi); + sub_diff_type diff = m_sub.length(); + ignore_unused_variable_warning(diff); + // match_results tests: + typedef typename match_results_type::value_type mr_value_type; + typedef typename match_results_type::const_reference mr_const_reference; + typedef typename match_results_type::reference mr_reference; + typedef typename match_results_type::const_iterator mr_const_iterator; + typedef typename match_results_type::iterator mr_iterator; + typedef typename match_results_type::difference_type mr_difference_type; + typedef typename match_results_type::size_type mr_size_type; + typedef typename match_results_type::allocator_type mr_allocator_type; + typedef typename match_results_type::char_type mr_char_type; + typedef typename match_results_type::string_type mr_string_type; + + match_results_type m1; + mr_allocator_type at; + match_results_type m2(at); + match_results_type m3(m1); + m1 = m2; + + int ival = 0; + + mr_size_type mrs = m_cresults.size(); + ignore_unused_variable_warning(mrs); + mrs = m_cresults.max_size(); + ignore_unused_variable_warning(mrs); + b = m_cresults.empty(); + ignore_unused_variable_warning(b); + mr_difference_type mrd = m_cresults.length(); + ignore_unused_variable_warning(mrd); + mrd = m_cresults.length(ival); + ignore_unused_variable_warning(mrd); + mrd = m_cresults.position(); + ignore_unused_variable_warning(mrd); + mrd = m_cresults.position(mrs); + ignore_unused_variable_warning(mrd); + + mr_const_reference mrcr = m_cresults[ival]; + ignore_unused_variable_warning(mrcr); + mr_const_reference mrcr2 = m_cresults.prefix(); + ignore_unused_variable_warning(mrcr2); + mr_const_reference mrcr3 = m_cresults.suffix(); + ignore_unused_variable_warning(mrcr3); + mr_const_iterator mrci = m_cresults.begin(); + ignore_unused_variable_warning(mrci); + mrci = m_cresults.end(); + ignore_unused_variable_warning(mrci); + + mr_allocator_type at2 = m_cresults.get_allocator(); + m_results.swap(m_results); + global_regex_namespace::swap(m_results, m_results); + + // regex_match: + b = global_regex_namespace::regex_match(m_in, m_in, m_results, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_in, m_in, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, e, m_mft); + ignore_unused_variable_warning(b); + // regex_search: + b = global_regex_namespace::regex_search(m_in, m_in, m_results, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_in, m_in, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, e, m_mft); + ignore_unused_variable_warning(b); + + // regex_iterator: + typedef typename regex_iterator_type::regex_type rit_regex_type; + typedef typename regex_iterator_type::value_type rit_value_type; + typedef typename regex_iterator_type::difference_type rit_difference_type; + typedef typename regex_iterator_type::pointer rit_pointer; + typedef typename regex_iterator_type::reference rit_reference; + typedef typename regex_iterator_type::iterator_category rit_iterator_category; + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_convertible::value)); + // this takes care of most of the checks needed: + function_requires >(); + regex_iterator_type iter1(m_in, m_in, e); + ignore_unused_variable_warning(iter1); + regex_iterator_type iter2(m_in, m_in, e, m_mft); + ignore_unused_variable_warning(iter2); + + // regex_token_iterator: + typedef typename regex_token_iterator_type::regex_type rtit_regex_type; + typedef typename regex_token_iterator_type::value_type rtit_value_type; + typedef typename regex_token_iterator_type::difference_type rtit_difference_type; + typedef typename regex_token_iterator_type::pointer rtit_pointer; + typedef typename regex_token_iterator_type::reference rtit_reference; + typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category; + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_convertible::value)); + // this takes care of most of the checks needed: + function_requires >(); + regex_token_iterator_type ti1(m_in, m_in, e); + ignore_unused_variable_warning(ti1); + regex_token_iterator_type ti2(m_in, m_in, e, 0); + ignore_unused_variable_warning(ti2); + regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft); + ignore_unused_variable_warning(ti3); + std::vector subs; + regex_token_iterator_type ti4(m_in, m_in, e, subs); + ignore_unused_variable_warning(ti4); + regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft); + ignore_unused_variable_warning(ti5); + static const int i_array[3] = { 1, 2, 3, }; + regex_token_iterator_type ti6(m_in, m_in, e, i_array); + ignore_unused_variable_warning(ti6); + regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft); + ignore_unused_variable_warning(ti7); + } + + pointer_type m_pointer; + flag_type m_flags; + std::size_t m_size; + input_iterator_type in1, in2; + const sub_match_type m_sub; + const value_type m_char; + match_results_type m_results; + const match_results_type m_cresults; + OutIterator m_out; + BidiIterator m_in; + global_regex_namespace::regex_constants::match_flag_type m_mft; + global_regex_namespace::match_results m_pmatch; + + BaseRegexConcept(); + BaseRegexConcept(const BaseRegexConcept&); + BaseRegexConcept& operator=(const BaseRegexConcept&); +}; + +// +// RegexConcept: +// Test every interface in the std: +// +template +struct RegexConcept +{ + typedef typename Regex::value_type value_type; + //typedef typename Regex::size_type size_type; + typedef typename Regex::flag_type flag_type; + typedef typename Regex::locale_type locale_type; + + // derived test types: + typedef const value_type* pointer_type; + typedef std::basic_string string_type; + typedef boost::bidirectional_iterator_archetype BidiIterator; + typedef global_regex_namespace::sub_match sub_match_type; + typedef global_regex_namespace::match_results match_results_type; + typedef output_iterator_archetype OutIterator; + + + void constraints() + { + function_requires >(); + // string based construct: + Regex e1(m_string); + ignore_unused_variable_warning(e1); + Regex e2(m_string, m_flags); + ignore_unused_variable_warning(e2); + + // assign etc: + Regex e; + e = m_string; + e.assign(m_string); + e.assign(m_string, m_flags); + + // sub_match: + string_type s(m_sub); + ignore_unused_variable_warning(s); + s = m_sub.str(); + ignore_unused_variable_warning(s); + int i = m_sub.compare(m_string); + ignore_unused_variable_warning(i); + + int i2 = m_sub.compare(m_sub); + ignore_unused_variable_warning(i2); + i2 = m_sub.compare(m_pointer); + ignore_unused_variable_warning(i2); + + bool b = m_sub == m_sub; + ignore_unused_variable_warning(b); + b = m_sub != m_sub; + ignore_unused_variable_warning(b); + b = m_sub <= m_sub; + ignore_unused_variable_warning(b); + b = m_sub <= m_sub; + ignore_unused_variable_warning(b); + b = m_sub > m_sub; + ignore_unused_variable_warning(b); + b = m_sub >= m_sub; + ignore_unused_variable_warning(b); + + b = m_sub == m_pointer; + ignore_unused_variable_warning(b); + b = m_sub != m_pointer; + ignore_unused_variable_warning(b); + b = m_sub <= m_pointer; + ignore_unused_variable_warning(b); + b = m_sub <= m_pointer; + ignore_unused_variable_warning(b); + b = m_sub > m_pointer; + ignore_unused_variable_warning(b); + b = m_sub >= m_pointer; + ignore_unused_variable_warning(b); + + b = m_pointer == m_sub; + ignore_unused_variable_warning(b); + b = m_pointer != m_sub; + ignore_unused_variable_warning(b); + b = m_pointer <= m_sub; + ignore_unused_variable_warning(b); + b = m_pointer <= m_sub; + ignore_unused_variable_warning(b); + b = m_pointer > m_sub; + ignore_unused_variable_warning(b); + b = m_pointer >= m_sub; + ignore_unused_variable_warning(b); + + b = m_sub == m_char; + ignore_unused_variable_warning(b); + b = m_sub != m_char; + ignore_unused_variable_warning(b); + b = m_sub <= m_char; + ignore_unused_variable_warning(b); + b = m_sub <= m_char; + ignore_unused_variable_warning(b); + b = m_sub > m_char; + ignore_unused_variable_warning(b); + b = m_sub >= m_char; + ignore_unused_variable_warning(b); + + b = m_char == m_sub; + ignore_unused_variable_warning(b); + b = m_char != m_sub; + ignore_unused_variable_warning(b); + b = m_char <= m_sub; + ignore_unused_variable_warning(b); + b = m_char <= m_sub; + ignore_unused_variable_warning(b); + b = m_char > m_sub; + ignore_unused_variable_warning(b); + b = m_char >= m_sub; + ignore_unused_variable_warning(b); + + b = m_sub == m_string; + ignore_unused_variable_warning(b); + b = m_sub != m_string; + ignore_unused_variable_warning(b); + b = m_sub <= m_string; + ignore_unused_variable_warning(b); + b = m_sub <= m_string; + ignore_unused_variable_warning(b); + b = m_sub > m_string; + ignore_unused_variable_warning(b); + b = m_sub >= m_string; + ignore_unused_variable_warning(b); + + b = m_string == m_sub; + ignore_unused_variable_warning(b); + b = m_string != m_sub; + ignore_unused_variable_warning(b); + b = m_string <= m_sub; + ignore_unused_variable_warning(b); + b = m_string <= m_sub; + ignore_unused_variable_warning(b); + b = m_string > m_sub; + ignore_unused_variable_warning(b); + b = m_string >= m_sub; + ignore_unused_variable_warning(b); + + // match results: + m_string = m_results.str(); + ignore_unused_variable_warning(m_string); + m_string = m_results.str(0); + ignore_unused_variable_warning(m_string); + m_out = m_cresults.format(m_out, m_string); + m_out = m_cresults.format(m_out, m_string, m_mft); + m_string = m_cresults.format(m_string); + ignore_unused_variable_warning(m_string); + m_string = m_cresults.format(m_string, m_mft); + ignore_unused_variable_warning(m_string); + + // regex_match: + b = global_regex_namespace::regex_match(m_string, m_smatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_string, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_string, e, m_mft); + ignore_unused_variable_warning(b); + + // regex_search: + b = global_regex_namespace::regex_search(m_string, m_smatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_string, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_string, e, m_mft); + ignore_unused_variable_warning(b); + + // regex_replace: + m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft); + m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string); + m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft); + ignore_unused_variable_warning(m_string); + m_string = global_regex_namespace::regex_replace(m_string, e, m_string); + ignore_unused_variable_warning(m_string); + + } + + flag_type m_flags; + string_type m_string; + const sub_match_type m_sub; + match_results_type m_results; + pointer_type m_pointer; + value_type m_char; + const match_results_type m_cresults; + OutIterator m_out; + BidiIterator m_in; + global_regex_namespace::regex_constants::match_flag_type m_mft; + global_regex_namespace::match_results m_smatch; + + RegexConcept(); + RegexConcept(const RegexConcept&); + RegexConcept& operator=(const RegexConcept&); +}; + +#ifndef BOOST_REGEX_TEST_STD +// +// BoostRegexConcept: +// Test every interface in the Boost implementation: +// +template +struct BoostRegexConcept +{ + typedef typename Regex::value_type value_type; + typedef typename Regex::size_type size_type; + typedef typename Regex::flag_type flag_type; + typedef typename Regex::locale_type locale_type; + + // derived test types: + typedef const value_type* pointer_type; + typedef std::basic_string string_type; + typedef typename Regex::const_iterator const_iterator; + typedef bidirectional_iterator_archetype BidiIterator; + typedef global_regex_namespace::sub_match sub_match_type; + typedef global_regex_namespace::match_results match_results_type; + + void constraints() + { + global_regex_namespace::regex_constants::match_flag_type mopts + = global_regex_namespace::regex_constants::match_default + | global_regex_namespace::regex_constants::match_not_bol + | global_regex_namespace::regex_constants::match_not_eol + | global_regex_namespace::regex_constants::match_not_bow + | global_regex_namespace::regex_constants::match_not_eow + | global_regex_namespace::regex_constants::match_any + | global_regex_namespace::regex_constants::match_not_null + | global_regex_namespace::regex_constants::match_continuous + | global_regex_namespace::regex_constants::match_partial + | global_regex_namespace::regex_constants::match_prev_avail + | global_regex_namespace::regex_constants::format_default + | global_regex_namespace::regex_constants::format_sed + | global_regex_namespace::regex_constants::format_perl + | global_regex_namespace::regex_constants::format_no_copy + | global_regex_namespace::regex_constants::format_first_only; + + (void)mopts; + + function_requires >(); + const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate); + std::ptrdiff_t pt = except.position(); + ignore_unused_variable_warning(pt); + const Regex ce, ce2; +#ifndef BOOST_NO_STD_LOCALE + m_stream << ce; +#endif + unsigned i = ce.error_code(); + ignore_unused_variable_warning(i); + pointer_type p = ce.expression(); + ignore_unused_variable_warning(p); + int i2 = ce.compare(ce2); + ignore_unused_variable_warning(i2); + bool b = ce == ce2; + ignore_unused_variable_warning(b); + b = ce.empty(); + ignore_unused_variable_warning(b); + b = ce != ce2; + ignore_unused_variable_warning(b); + b = ce < ce2; + ignore_unused_variable_warning(b); + b = ce > ce2; + ignore_unused_variable_warning(b); + b = ce <= ce2; + ignore_unused_variable_warning(b); + b = ce >= ce2; + ignore_unused_variable_warning(b); + i = ce.status(); + ignore_unused_variable_warning(i); + size_type s = ce.max_size(); + ignore_unused_variable_warning(s); + s = ce.size(); + ignore_unused_variable_warning(s); + const_iterator pi = ce.begin(); + ignore_unused_variable_warning(pi); + pi = ce.end(); + ignore_unused_variable_warning(pi); + string_type s2 = ce.str(); + ignore_unused_variable_warning(s2); + + m_string = m_sub + m_sub; + ignore_unused_variable_warning(m_string); + m_string = m_sub + m_pointer; + ignore_unused_variable_warning(m_string); + m_string = m_pointer + m_sub; + ignore_unused_variable_warning(m_string); + m_string = m_sub + m_string; + ignore_unused_variable_warning(m_string); + m_string = m_string + m_sub; + ignore_unused_variable_warning(m_string); + m_string = m_sub + m_char; + ignore_unused_variable_warning(m_string); + m_string = m_char + m_sub; + ignore_unused_variable_warning(m_string); + +#ifndef BOOST_NO_STD_LOCALE + m_stream << m_sub; + m_stream << m_cresults; +#endif + } + + std::basic_ostream m_stream; + sub_match_type m_sub; + pointer_type m_pointer; + string_type m_string; + const value_type m_char; + match_results_type m_results; + const match_results_type m_cresults; + + BoostRegexConcept(); + BoostRegexConcept(const BoostRegexConcept&); + BoostRegexConcept& operator=(const BoostRegexConcept&); +}; + +#endif // BOOST_REGEX_TEST_STD + +} + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/config.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,417 @@ +/* + * + * 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 config.hpp + * VERSION see + * DESCRIPTION: regex extended config setup. + */ + +#ifndef BOOST_REGEX_CONFIG_HPP +#define BOOST_REGEX_CONFIG_HPP +/* + * Borland C++ Fix/error check + * this has to go *before* we include any std lib headers: + */ +#if defined(__BORLANDC__) +# include +#endif + +/***************************************************************************** + * + * Include all the headers we need here: + * + ****************************************************************************/ + +#ifdef __cplusplus + +# ifndef BOOST_REGEX_USER_CONFIG +# define BOOST_REGEX_USER_CONFIG +# endif + +# include BOOST_REGEX_USER_CONFIG + +# include + +#else + /* + * C build, + * don't include because that may + * do C++ specific things in future... + */ +# include +# include +# ifdef _MSC_VER +# define BOOST_MSVC _MSC_VER +# endif +#endif + +/***************************************************************************** + * + * Boilerplate regex config options: + * + ****************************************************************************/ + +/* Obsolete macro, use BOOST_VERSION instead: */ +#define BOOST_RE_VERSION 320 + +/* fix: */ +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +/* + * Fix for gcc prior to 3.4: std::ctype doesn't allow + * masks to be combined, for example: + * std::use_facet >.is(std::ctype_base::lower|std::ctype_base::upper, L'a'); + * returns *false*. + */ +#ifdef __GLIBCPP__ +# define BOOST_REGEX_BUGGY_CTYPE_FACET +#endif + +/* + * Intel C++ before 8.0 ends up with unresolved externals unless we turn off + * extern template support: + */ +#if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800) +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +#endif +/* + * Visual C++ doesn't support external templates with C++ extensions turned off: + */ +#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +#endif + +/* + * If there isn't good enough wide character support then there will + * be no wide character regular expressions: + */ +#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) +# if !defined(BOOST_NO_WREGEX) +# define BOOST_NO_WREGEX +# endif +#else +# if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) + /* STLPort on IRIX is misconfigured: does not compile + * as a temporary fix include instead and prevent inclusion + * of STLPort version of */ +# include +# define __STLPORT_CWCTYPE +# define _STLP_CWCTYPE +# endif + +#ifdef __cplusplus +# include +#endif + +#endif + +/* + * If Win32 support has been disabled for boost in general, then + * it is for regex in particular: + */ +#if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32) +# define BOOST_REGEX_NO_W32 +#endif + +/* disable our own file-iterators and mapfiles if we can't + * support them: */ +#if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)) +# define BOOST_REGEX_NO_FILEITER +#endif + +/* backwards compatibitity: */ +#if defined(BOOST_RE_NO_LIB) +# define BOOST_REGEX_NO_LIB +#endif + +#if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__)) +/* gcc on win32 has problems if you include + (sporadically generates bad code). */ +# define BOOST_REGEX_NO_W32 +#endif +#if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS) +# define BOOST_REGEX_NO_W32 +#endif + +/***************************************************************************** + * + * Wide character workarounds: + * + ****************************************************************************/ + +/* + * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users + * code may be built with wchar_t as unsigned short: basically when we're building + * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions + * of the non-inline functions in the library, so that users can still link to the lib, + * irrespective of whether their own code is built with /Zc:wchar_t. + */ +#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER) +# define BOOST_REGEX_HAS_OTHER_WCHAR_T +# ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4251 4231 4660) +# endif +# ifdef _DLL +# include + extern template class __declspec(dllimport) std::basic_string; +# endif +# ifdef BOOST_MSVC +# pragma warning(pop) +# endif +#endif + + +/***************************************************************************** + * + * Set up dll import/export options: + * + ****************************************************************************/ + +#if defined(BOOST_HAS_DECLSPEC) && (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK) +# if defined(BOOST_REGEX_SOURCE) +# define BOOST_REGEX_DECL __declspec(dllexport) +# define BOOST_REGEX_BUILD_DLL +# else +# define BOOST_REGEX_DECL __declspec(dllimport) +# endif +#endif + +#ifndef BOOST_REGEX_DECL +# define BOOST_REGEX_DECL +#endif + +#if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus) +# define BOOST_LIB_NAME boost_regex +# if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) +# define BOOST_DYN_LINK +# endif +# ifdef BOOST_REGEX_DIAG +# define BOOST_LIB_DIAGNOSTIC +# endif +# include +#endif + +/***************************************************************************** + * + * Set up function call type: + * + ****************************************************************************/ + +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS) +#if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) +# define BOOST_REGEX_CALL __cdecl +#else +# define BOOST_REGEX_CALL __fastcall +#endif +# define BOOST_REGEX_CCALL __cdecl +#endif + +#if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32) +# define BOOST_REGEX_CALL __fastcall +# define BOOST_REGEX_CCALL __stdcall +#endif + +#ifndef BOOST_REGEX_CALL +# define BOOST_REGEX_CALL +#endif +#ifndef BOOST_REGEX_CCALL +#define BOOST_REGEX_CCALL +#endif + +/***************************************************************************** + * + * Set up localisation model: + * + ****************************************************************************/ + +/* backwards compatibility: */ +#ifdef BOOST_RE_LOCALE_C +# define BOOST_REGEX_USE_C_LOCALE +#endif + +#ifdef BOOST_RE_LOCALE_CPP +# define BOOST_REGEX_USE_CPP_LOCALE +#endif + +/* Win32 defaults to native Win32 locale: */ +#if defined(_WIN32) && !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_REGEX_NO_W32) +# define BOOST_REGEX_USE_WIN32_LOCALE +#endif +/* otherwise use C++ locale if supported: */ +#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE) +# define BOOST_REGEX_USE_CPP_LOCALE +#endif +/* otherwise use C+ locale: */ +#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) +# define BOOST_REGEX_USE_C_LOCALE +#endif + +#ifndef BOOST_REGEX_MAX_STATE_COUNT +# define BOOST_REGEX_MAX_STATE_COUNT 100000000 +#endif + + +/***************************************************************************** + * + * Error Handling for exception free compilers: + * + ****************************************************************************/ + +#ifdef BOOST_NO_EXCEPTIONS +/* + * If there are no exceptions then we must report critical-errors + * the only way we know how; by terminating. + */ +#include +#include +#include + +# define BOOST_REGEX_NOEH_ASSERT(x)\ +if(0 == (x))\ +{\ + std::string s("Error: critical regex++ failure in: ");\ + s.append(#x);\ + std::runtime_error e(s);\ + boost::throw_exception(e);\ +} +#else +/* + * With exceptions then error handling is taken care of and + * there is no need for these checks: + */ +# define BOOST_REGEX_NOEH_ASSERT(x) +#endif + + +/***************************************************************************** + * + * Stack protection under MS Windows: + * + ****************************************************************************/ + +#if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3) +# if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \ + && !defined(__GNUC__) \ + && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \ + && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003)) +# define BOOST_REGEX_HAS_MS_STACK_GUARD +# endif +#elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD) +# undef BOOST_REGEX_HAS_MS_STACK_GUARD +#endif + +#if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD) + +namespace boost{ +namespace re_detail{ + +BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page(); + +} +} + +#endif + + +/***************************************************************************** + * + * Algorithm selection and configuration: + * + ****************************************************************************/ + +#if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE) +# if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)) +# define BOOST_REGEX_RECURSIVE +# else +# define BOOST_REGEX_NON_RECURSIVE +# endif +#endif + +#ifdef BOOST_REGEX_NON_RECURSIVE +# ifdef BOOST_REGEX_RECURSIVE +# error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE" +# endif +# ifndef BOOST_REGEX_BLOCKSIZE +# define BOOST_REGEX_BLOCKSIZE 4096 +# endif +# if BOOST_REGEX_BLOCKSIZE < 512 +# error "BOOST_REGEX_BLOCKSIZE must be at least 512" +# endif +# ifndef BOOST_REGEX_MAX_BLOCKS +# define BOOST_REGEX_MAX_BLOCKS 1024 +# endif +# ifdef BOOST_REGEX_HAS_MS_STACK_GUARD +# undef BOOST_REGEX_HAS_MS_STACK_GUARD +# endif +# ifndef BOOST_REGEX_MAX_CACHE_BLOCKS +# define BOOST_REGEX_MAX_CACHE_BLOCKS 16 +# endif +#endif + + +/***************************************************************************** + * + * helper memory allocation functions: + * + ****************************************************************************/ + +#if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE) +namespace boost{ namespace re_detail{ + +BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block(); +BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*); + +}} /* namespaces */ +#endif + +/***************************************************************************** + * + * Diagnostics: + * + ****************************************************************************/ + +#ifdef BOOST_REGEX_CONFIG_INFO +BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info(); +#endif + +#if defined(BOOST_REGEX_DIAG) +# pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL)) +# pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL)) +# pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL)) +#ifdef BOOST_REGEX_USE_C_LOCALE +# pragma message ("Using C locale in regex traits class") +#elif BOOST_REGEX_USE_CPP_LOCALE +# pragma message ("Using C++ locale in regex traits class") +#else +# pragma message ("Using Win32 locale in regex traits class") +#endif +#if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) +# pragma message ("Dynamic linking enabled") +#endif +#if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB) +# pragma message ("Auto-linking disabled") +#endif +#ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES +# pragma message ("Extern templates disabled") +#endif + +#endif + +#endif + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/config/borland.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/config/borland.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,72 @@ +/* + * + * 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 boost/regex/config/borland.hpp + * VERSION see + * DESCRIPTION: regex borland-specific config setup. + */ + + +#if defined(__BORLANDC__) +# if (__BORLANDC__ == 0x550) || (__BORLANDC__ == 0x551) + // problems with std::basic_string and dll RTL: +# if defined(_RTLDLL) && defined(_RWSTD_COMPILE_INSTANTIATE) +# ifdef BOOST_REGEX_BUILD_DLL +# error _RWSTD_COMPILE_INSTANTIATE must not be defined when building regex++ as a DLL +# else +# pragma message("Defining _RWSTD_COMPILE_INSTANTIATE when linking to the DLL version of the RTL may produce memory corruption problems in std::basic_string, as a result of separate versions of basic_string's static data in the RTL and you're exe/dll: be warned!!") +# endif +# endif +# ifndef _RTLDLL + // this is harmless for a staic link: +# define _RWSTD_COMPILE_INSTANTIATE +# endif + // external templates cause problems for some reason: +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +# endif +# if (__BORLANDC__ <= 0x540) && !defined(BOOST_REGEX_NO_LIB) && !defined(_NO_VCL) + // C++ Builder 4 and earlier, we can't tell whether we should be using + // the VCL runtime or not, do a static link instead: +# define BOOST_REGEX_STATIC_LINK +# endif + // + // VCL support: + // if we're building a console app then there can't be any VCL (can there?) +# if !defined(__CONSOLE__) && !defined(_NO_VCL) +# define BOOST_REGEX_USE_VCL +# endif + // + // if this isn't Win32 then don't automatically select link + // libraries: + // +# ifndef _Windows +# ifndef BOOST_REGEX_NO_LIB +# define BOOST_REGEX_NO_LIB +# endif +# ifndef BOOST_REGEX_STATIC_LINK +# define BOOST_REGEX_STATIC_LINK +# endif +# endif + +#if __BORLANDC__ < 0x600 +// +// string workarounds: +// +#include +#undef strcmp +#undef strcpy +#endif + +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/config/cwchar.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/config/cwchar.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,207 @@ +/* + * + * 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 boost/regex/config/cwchar.hpp + * VERSION see + * DESCRIPTION: regex wide character string fixes. + */ + +#ifndef BOOST_REGEX_CONFIG_CWCHAR_HPP +#define BOOST_REGEX_CONFIG_CWCHAR_HPP + +#include +#include +#include + +#if defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) +// apparently this is required for the RW STL on Linux: +#undef iswalnum +#undef iswalpha +#undef iswblank +#undef iswcntrl +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef iswctype +#undef towlower +#undef towupper +#undef towctrans +#undef wctrans +#undef wctype +#endif + +namespace std{ + +#ifndef BOOST_NO_STDC_NAMESPACE +extern "C"{ +#endif + +#ifdef iswalnum +inline int (iswalnum)(wint_t i) +{ return iswalnum(i); } +#undef iswalnum +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswalnum; +#endif + +#ifdef iswalpha +inline int (iswalpha)(wint_t i) +{ return iswalpha(i); } +#undef iswalpha +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswalpha; +#endif + +#ifdef iswcntrl +inline int (iswcntrl)(wint_t i) +{ return iswcntrl(i); } +#undef iswcntrl +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswcntrl; +#endif + +#ifdef iswdigit +inline int (iswdigit)(wint_t i) +{ return iswdigit(i); } +#undef iswdigit +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswdigit; +#endif + +#ifdef iswgraph +inline int (iswgraph)(wint_t i) +{ return iswgraph(i); } +#undef iswgraph +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswgraph; +#endif + +#ifdef iswlower +inline int (iswlower)(wint_t i) +{ return iswlower(i); } +#undef iswlower +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswlower; +#endif + +#ifdef iswprint +inline int (iswprint)(wint_t i) +{ return iswprint(i); } +#undef iswprint +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswprint; +#endif + +#ifdef iswpunct +inline int (iswpunct)(wint_t i) +{ return iswpunct(i); } +#undef iswpunct +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswpunct; +#endif + +#ifdef iswspace +inline int (iswspace)(wint_t i) +{ return iswspace(i); } +#undef iswspace +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswspace; +#endif + +#ifdef iswupper +inline int (iswupper)(wint_t i) +{ return iswupper(i); } +#undef iswupper +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswupper; +#endif + +#ifdef iswxdigit +inline int (iswxdigit)(wint_t i) +{ return iswxdigit(i); } +#undef iswxdigit +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswxdigit; +#endif + +#ifdef towlower +inline wint_t (towlower)(wint_t i) +{ return towlower(i); } +#undef towlower +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::towlower; +#endif + +#ifdef towupper +inline wint_t (towupper)(wint_t i) +{ return towupper(i); } +#undef towupper +#elif defined(BOOST_NO_STDC_NAMESPACE) +using :: towupper; +#endif + +#ifdef wcscmp +inline int (wcscmp)(const wchar_t *p1, const wchar_t *p2) +{ return wcscmp(p1,p2); } +#undef wcscmp +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcscmp; +#endif + +#ifdef wcscoll +inline int (wcscoll)(const wchar_t *p1, const wchar_t *p2) +{ return wcscoll(p1,p2); } +#undef wcscoll +#elif defined(BOOST_NO_STDC_NAMESPACE) && !defined(UNDER_CE) +using ::wcscoll; +#endif + +#ifdef wcscpy +inline wchar_t *(wcscpy)(wchar_t *p1, const wchar_t *p2) +{ return wcscpy(p1,p2); } +#undef wcscpy +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcscpy; +#endif + +#ifdef wcslen +inline size_t (wcslen)(const wchar_t *p) +{ return wcslen(p); } +#undef wcslen +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcslen; +#endif + +#ifdef wcsxfrm +size_t wcsxfrm(wchar_t *p1, const wchar_t *p2, size_t s) +{ return wcsxfrm(p1,p2,s); } +#undef wcsxfrm +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcsxfrm; +#endif + + +#ifndef BOOST_NO_STDC_NAMESPACE +} // extern "C" +#endif + +} // namespace std + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/icu.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/icu.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,1017 @@ +/* + * + * 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.hpp + * VERSION see + * DESCRIPTION: Unicode regular expressions on top of the ICU Library. + */ + +#ifndef BOOST_REGEX_ICU_HPP +#define BOOST_REGEX_ICU_HPP + +#include +#include +#include +#include +#include +#include +#include + + +namespace boost{ + +namespace re_detail{ + +// +// Implementation details: +// +class BOOST_REGEX_DECL icu_regex_traits_implementation +{ + typedef UChar32 char_type; + typedef std::size_t size_type; + typedef std::vector string_type; + typedef U_NAMESPACE_QUALIFIER Locale locale_type; + typedef boost::uint_least32_t char_class_type; +public: + icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& l) + : m_locale(l) + { + UErrorCode success = U_ZERO_ERROR; + m_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); + if(U_SUCCESS(success) == 0) + init_error(); + m_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::IDENTICAL); + success = U_ZERO_ERROR; + m_primary_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); + if(U_SUCCESS(success) == 0) + init_error(); + m_primary_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::PRIMARY); + } + U_NAMESPACE_QUALIFIER Locale getloc()const + { + return m_locale; + } + string_type do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const; + string_type transform(const char_type* p1, const char_type* p2) const + { + return do_transform(p1, p2, m_collator.get()); + } + string_type transform_primary(const char_type* p1, const char_type* p2) const + { + return do_transform(p1, p2, m_primary_collator.get()); + } +private: + void init_error() + { + std::runtime_error e("Could not initialize ICU resources"); + boost::throw_exception(e); + } + U_NAMESPACE_QUALIFIER Locale m_locale; // The ICU locale that we're using + boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator; // The full collation object + boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator; // The primary collation object +}; + +inline boost::shared_ptr get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc) +{ + return boost::shared_ptr(new icu_regex_traits_implementation(loc)); +} + +} + +class BOOST_REGEX_DECL icu_regex_traits +{ +public: + typedef UChar32 char_type; + typedef std::size_t size_type; + typedef std::vector string_type; + typedef U_NAMESPACE_QUALIFIER Locale locale_type; +#ifdef BOOST_NO_INT64_T + typedef std::bitset<64> char_class_type; +#else + typedef boost::uint64_t char_class_type; +#endif + + struct boost_extensions_tag{}; + + icu_regex_traits() + : m_pimpl(re_detail::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale())) + { + } + static size_type length(const char_type* p); + + ::boost::regex_constants::syntax_type syntax_type(char_type c)const + { + return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_syntax_type(static_cast(c)) : regex_constants::syntax_char; + } + ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c) const + { + return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_escape_syntax_type(static_cast(c)) : regex_constants::syntax_char; + } + char_type translate(char_type c) const + { + return c; + } + char_type translate_nocase(char_type c) const + { + return ::u_tolower(c); + } + char_type translate(char_type c, bool icase) const + { + return icase ? translate_nocase(c) : translate(c); + } + char_type tolower(char_type c) const + { + return ::u_tolower(c); + } + char_type toupper(char_type c) const + { + return ::u_toupper(c); + } + string_type transform(const char_type* p1, const char_type* p2) const + { + return m_pimpl->transform(p1, p2); + } + string_type transform_primary(const char_type* p1, const char_type* p2) const + { + return m_pimpl->transform_primary(p1, p2); + } + char_class_type lookup_classname(const char_type* p1, const char_type* p2) const; + string_type lookup_collatename(const char_type* p1, const char_type* p2) const; + bool isctype(char_type c, char_class_type f) const; + int toi(const char_type*& p1, const char_type* p2, int radix)const + { + return re_detail::global_toi(p1, p2, radix, *this); + } + int value(char_type c, int radix)const + { + return u_digit(c, static_cast< ::int8_t>(radix)); + } + locale_type imbue(locale_type l) + { + locale_type result(m_pimpl->getloc()); + m_pimpl = re_detail::get_icu_regex_traits_implementation(l); + return result; + } + locale_type getloc()const + { + return locale_type(); + } + std::string error_string(::boost::regex_constants::error_type n) const + { + return re_detail::get_default_error_string(n); + } +private: + icu_regex_traits(const icu_regex_traits&); + icu_regex_traits& operator=(const icu_regex_traits&); + + // + // define the bitmasks offsets we need for additional character properties: + // + enum{ + offset_blank = U_CHAR_CATEGORY_COUNT, + offset_space = U_CHAR_CATEGORY_COUNT+1, + offset_xdigit = U_CHAR_CATEGORY_COUNT+2, + offset_underscore = U_CHAR_CATEGORY_COUNT+3, + offset_unicode = U_CHAR_CATEGORY_COUNT+4, + offset_any = U_CHAR_CATEGORY_COUNT+5, + offset_ascii = U_CHAR_CATEGORY_COUNT+6 + }; + + // + // and now the masks: + // + static const char_class_type mask_blank; + static const char_class_type mask_space; + static const char_class_type mask_xdigit; + static const char_class_type mask_underscore; + static const char_class_type mask_unicode; + static const char_class_type mask_any; + static const char_class_type mask_ascii; + + static char_class_type lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2); + + boost::shared_ptr< ::boost::re_detail::icu_regex_traits_implementation> m_pimpl; +}; + +} // namespace boost + +// +// template instances: +// +#define BOOST_REGEX_CHAR_T UChar32 +#undef BOOST_REGEX_TRAITS_T +#define BOOST_REGEX_TRAITS_T , icu_regex_traits +#define BOOST_REGEX_ICU_INSTANCES +#ifdef BOOST_REGEX_ICU_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#undef BOOST_REGEX_TRAITS_T +#undef BOOST_REGEX_ICU_INSTANCES +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif + +namespace boost{ + +// types: +typedef basic_regex< ::UChar32, icu_regex_traits> u32regex; +typedef match_results u32match; +typedef match_results u16match; + +// +// Construction of 32-bit regex types from UTF-8 and UTF-16 primitives: +// +namespace re_detail{ + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<1>*) +{ + typedef boost::u8_to_u32_iterator conv_type; + return u32regex(conv_type(i), conv_type(j), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<2>*) +{ + typedef boost::u16_to_u32_iterator conv_type; + return u32regex(conv_type(i), conv_type(j), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<4>*) +{ + return u32regex(i, j, opt); +} +#else +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<1>*) +{ + typedef boost::u8_to_u32_iterator conv_type; + typedef std::vector vector_type; + vector_type v; + conv_type a(i), b(j); + while(a != b) + { + v.push_back(*a); + ++a; + } + if(v.size()) + return u32regex(&*v.begin(), v.size(), opt); + return u32regex(static_cast(0), static_cast(0), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<2>*) +{ + typedef boost::u16_to_u32_iterator conv_type; + typedef std::vector vector_type; + vector_type v; + conv_type a(i), b(j); + while(a != b) + { + v.push_back(*a); + ++a; + } + if(v.size()) + return u32regex(&*v.begin(), v.size(), opt); + return u32regex(static_cast(0), static_cast(0), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<4>*) +{ + typedef std::vector vector_type; + vector_type v; + while(i != j) + { + v.push_back((UCHAR32)(*i)); + ++a; + } + if(v.size()) + return u32regex(&*v.begin(), v.size(), opt); + return u32regex(static_cast(0), static_cast(0), opt); +} +#endif +} + +// +// Construction from an iterator pair: +// +template +inline u32regex make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt) +{ + return re_detail::do_make_u32regex(i, j, opt, static_cast const*>(0)); +} +// +// construction from UTF-8 nul-terminated strings: +// +inline u32regex make_u32regex(const char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + std::strlen(p), opt, static_cast const*>(0)); +} +inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + std::strlen(reinterpret_cast(p)), opt, static_cast const*>(0)); +} +// +// construction from UTF-16 nul-terminated strings: +// +#ifndef BOOST_NO_WREGEX +inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast const*>(0)); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + u_strlen(p), opt, static_cast const*>(0)); +} +#endif +// +// construction from basic_string class-template: +// +template +inline u32regex make_u32regex(const std::basic_string& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(s.begin(), s.end(), opt, static_cast const*>(0)); +} +// +// Construction from ICU string type: +// +inline u32regex make_u32regex(const UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast const*>(0)); +} + +// +// regex_match overloads that widen the character type as appropriate: +// +namespace re_detail{ +template +void copy_results(MR1& out, MR2 const& in) +{ + // copy results from an adapted MR2 match_results: + out.set_size(in.size(), in.prefix().first.base(), in.suffix().second.base()); + out.set_base(in.base().base()); + for(int i = 0; i < (int)in.size(); ++i) + { + if(in[i].matched) + { + out.set_first(in[i].first.base(), i); + out.set_second(in[i].second.base(), i); + } + } +} + +template +inline bool do_regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + boost::mpl::int_<4> const*) +{ + return ::boost::regex_match(first, last, m, e, flags); +} +template +bool do_regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + boost::mpl::int_<2> const*) +{ + typedef u16_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +template +bool do_regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + boost::mpl::int_<1> const*) +{ + typedef u8_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +} // namespace re_detail + +template +inline bool u32regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(first, last, m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const UChar* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_match(const wchar_t* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const unsigned char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const std::string& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_match(const std::wstring& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const UnicodeString& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); +} +// +// regex_match overloads that do not return what matched: +// +template +inline bool u32regex_match(BidiIterator first, BidiIterator last, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(first, last, m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const UChar* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_match(const wchar_t* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const unsigned char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const std::string& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_match(const std::wstring& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const UnicodeString& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); +} + +// +// regex_search overloads that widen the character type as appropriate: +// +namespace re_detail{ +template +inline bool do_regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base, + boost::mpl::int_<4> const*) +{ + return ::boost::regex_search(first, last, m, e, flags, base); +} +template +bool do_regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base, + boost::mpl::int_<2> const*) +{ + typedef u16_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base)); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +template +bool do_regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base, + boost::mpl::int_<1> const*) +{ + typedef u8_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base)); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +} + +template +inline bool u32regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast const*>(0)); +} +template +inline bool u32regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base) +{ + return re_detail::do_regex_search(first, last, m, e, flags, base, static_cast const*>(0)); +} +inline bool u32regex_search(const UChar* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_search(const wchar_t* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const unsigned char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const std::string& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_search(const std::wstring& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const UnicodeString& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); +} +template +inline bool u32regex_search(BidiIterator first, BidiIterator last, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast const*>(0)); +} +inline bool u32regex_search(const UChar* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_search(const wchar_t* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const unsigned char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const std::string& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_search(const std::wstring& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const UnicodeString& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); +} + +// +// overloads for regex_replace with utf-8 and utf-16 data types: +// +namespace re_detail{ +template +inline std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator > + make_utf32_seq(I i, I j, mpl::int_<1> const*) +{ + return std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator >(boost::u8_to_u32_iterator(i), boost::u8_to_u32_iterator(j)); +} +template +inline std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator > + make_utf32_seq(I i, I j, mpl::int_<2> const*) +{ + return std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator >(boost::u16_to_u32_iterator(i), boost::u16_to_u32_iterator(j)); +} +template +inline std::pair< I, I > + make_utf32_seq(I i, I j, mpl::int_<4> const*) +{ + return std::pair< I, I >(i, j); +} +template +inline std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator > + make_utf32_seq(const charT* p, mpl::int_<1> const*) +{ + return std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator >(boost::u8_to_u32_iterator(p), boost::u8_to_u32_iterator(p+std::strlen((const char*)p))); +} +template +inline std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator > + make_utf32_seq(const charT* p, mpl::int_<2> const*) +{ + return std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator >(boost::u16_to_u32_iterator(p), boost::u16_to_u32_iterator(p+u_strlen((const UChar*)p))); +} +template +inline std::pair< const charT*, const charT* > + make_utf32_seq(const charT* p, mpl::int_<4> const*) +{ + return std::pair< const charT*, const charT* >(p, p+icu_regex_traits::length((UChar32 const*)p)); +} +template +inline OutputIterator make_utf32_out(OutputIterator o, mpl::int_<4> const*) +{ + return o; +} +template +inline utf16_output_iterator make_utf32_out(OutputIterator o, mpl::int_<2> const*) +{ + return o; +} +template +inline utf8_output_iterator make_utf32_out(OutputIterator o, mpl::int_<1> const*) +{ + return o; +} + +template +OutputIterator do_regex_replace(OutputIterator out, + std::pair const& in, + const u32regex& e, + const std::pair& fmt, + match_flag_type flags + ) +{ + // unfortunately we have to copy the format string in order to pass in onward: + std::vector f; +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + f.assign(fmt.first, fmt.second); +#else + f.clear(); + I2 pos = fmt.first; + while(pos != fmt.second) + f.push_back(*pos++); +#endif + + regex_iterator i(in.first, in.second, e, flags); + regex_iterator j; + if(i == j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(in.first, in.second, out); + } + else + { + I1 last_m = in.first; + while(i != j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(i->prefix().first, i->prefix().second, out); + if(f.size()) + out = ::boost::re_detail::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); + else + out = ::boost::re_detail::regex_format_imp(out, *i, static_cast(0), static_cast(0), flags, e.get_traits()); + last_m = (*i)[0].second; + if(flags & regex_constants::format_first_only) + break; + ++i; + } + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(last_m, in.second, out); + } + return out; +} +template +inline const BaseIterator& extract_output_base(const BaseIterator& b) +{ + return b; +} +template +inline BaseIterator extract_output_base(const utf8_output_iterator& b) +{ + return b.base(); +} +template +inline BaseIterator extract_output_base(const utf16_output_iterator& b) +{ + return b.base(); +} +} // re_detail + +template +inline OutputIterator u32regex_replace(OutputIterator out, + BidirectionalIterator first, + BidirectionalIterator last, + const u32regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + return re_detail::extract_output_base +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + +#endif + ( + re_detail::do_regex_replace( + re_detail::make_utf32_out(out, static_cast const*>(0)), + re_detail::make_utf32_seq(first, last, static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt, static_cast const*>(0)), + flags) + ); +} + +template +inline OutputIterator u32regex_replace(OutputIterator out, + Iterator first, + Iterator last, + const u32regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return re_detail::extract_output_base +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + +#endif + ( + re_detail::do_regex_replace( + re_detail::make_utf32_out(out, static_cast const*>(0)), + re_detail::make_utf32_seq(first, last, static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt.begin(), fmt.end(), static_cast const*>(0)), + flags) + ); +} + +template +inline OutputIterator u32regex_replace(OutputIterator out, + Iterator first, + Iterator last, + const u32regex& e, + const UnicodeString& fmt, + match_flag_type flags = match_default) +{ + return re_detail::extract_output_base +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + +#endif + ( + re_detail::do_regex_replace( + re_detail::make_utf32_out(out, static_cast const*>(0)), + re_detail::make_utf32_seq(first, last, static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast const*>(0)), + flags) + ); +} + +template +std::basic_string u32regex_replace(const std::basic_string& s, + const u32regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + u32regex_replace(i, s.begin(), s.end(), e, fmt, flags); + return result; +} + +template +std::basic_string u32regex_replace(const std::basic_string& s, + const u32regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + u32regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); + return result; +} + +namespace re_detail{ + +class unicode_string_out_iterator +{ + UnicodeString* out; +public: + unicode_string_out_iterator(UnicodeString& s) : out(&s) {} + unicode_string_out_iterator& operator++() { return *this; } + unicode_string_out_iterator& operator++(int) { return *this; } + unicode_string_out_iterator& operator*() { return *this; } + unicode_string_out_iterator& operator=(UChar v) + { + *out += v; + return *this; + } + typedef std::ptrdiff_t difference_type; + typedef UChar value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::output_iterator_tag iterator_category; +}; + +} + +inline UnicodeString u32regex_replace(const UnicodeString& s, + const u32regex& e, + const UChar* fmt, + match_flag_type flags = match_default) +{ + UnicodeString result; + re_detail::unicode_string_out_iterator i(result); + u32regex_replace(i, s.getBuffer(), s.getBuffer()+s.length(), e, fmt, flags); + return result; +} + +inline UnicodeString u32regex_replace(const UnicodeString& s, + const u32regex& e, + const UnicodeString& fmt, + match_flag_type flags = match_default) +{ + UnicodeString result; + re_detail::unicode_string_out_iterator i(result); + re_detail::do_regex_replace( + re_detail::make_utf32_out(i, static_cast const*>(0)), + re_detail::make_utf32_seq(s.getBuffer(), s.getBuffer()+s.length(), static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast const*>(0)), + flags); + return result; +} + +} // namespace boost. + +#include +#include + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/mfc.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/mfc.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,190 @@ +/* + * + * 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 mfc.hpp + * VERSION see + * DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex. + */ + +#ifndef BOOST_REGEX_MFC_HPP +#define BOOST_REGEX_MFC_HPP + +#include +#include + +namespace boost{ + +// +// define the types used for TCHAR's: +typedef basic_regex tregex; +typedef match_results tmatch; +typedef regex_iterator tregex_iterator; +typedef regex_token_iterator tregex_token_iterator; + +#if _MSC_VER >= 1310 +#define SIMPLE_STRING_PARAM class B, bool b +#define SIMPLE_STRING_ARG_LIST B, b +#else +#define SIMPLE_STRING_PARAM class B +#define SIMPLE_STRING_ARG_LIST B +#endif + +// +// define regex creation functions: +// +template +inline basic_regex +make_regex(const ATL::CSimpleStringT& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal) +{ + basic_regex result(s.GetString(), s.GetString() + s.GetLength(), f); + return result; +} +// +// regex_match overloads: +// +template +inline bool regex_match(const ATL::CSimpleStringT& s, + match_results& what, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_match(s.GetString(), + s.GetString() + s.GetLength(), + what, + e, + f); +} + +template +inline bool regex_match(const ATL::CSimpleStringT& s, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_match(s.GetString(), + s.GetString() + s.GetLength(), + e, + f); +} +// +// regex_search overloads: +// +template +inline bool regex_search(const ATL::CSimpleStringT& s, + match_results& what, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_search(s.GetString(), + s.GetString() + s.GetLength(), + what, + e, + f); +} + +template +inline bool regex_search(const ATL::CSimpleStringT& s, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_search(s.GetString(), + s.GetString() + s.GetLength(), + e, + f); +} +// +// regex_iterator creation: +// +template +inline regex_iterator +make_regex_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, f); + return result; +} + +template +inline regex_token_iterator + make_regex_token_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, int sub = 0, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_token_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f); + return result; +} + +template +inline regex_token_iterator +make_regex_token_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, const std::vector& subs, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_token_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f); + return result; +} + +template +inline regex_token_iterator +make_regex_token_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, const int (& subs)[N], ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_token_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f); + return result; +} + +template +OutputIterator regex_replace(OutputIterator out, + BidirectionalIterator first, + BidirectionalIterator last, + const basic_regex& e, + const ATL::CSimpleStringT& fmt, + match_flag_type flags = match_default) +{ + return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags); +} + +namespace re_detail{ + +template +class mfc_string_out_iterator +{ + ATL::CSimpleStringT* out; +public: + mfc_string_out_iterator(ATL::CSimpleStringT& s) : out(&s) {} + mfc_string_out_iterator& operator++() { return *this; } + mfc_string_out_iterator& operator++(int) { return *this; } + mfc_string_out_iterator& operator*() { return *this; } + mfc_string_out_iterator& operator=(B v) + { + out->AppendChar(v); + return *this; + } + typedef std::ptrdiff_t difference_type; + typedef B value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::output_iterator_tag iterator_category; +}; + +} + +template +ATL::CSimpleStringT regex_replace(const ATL::CSimpleStringT& s, + const basic_regex& e, + const ATL::CSimpleStringT& fmt, + match_flag_type flags = match_default) +{ + ATL::CSimpleStringT result(s.GetManager()); + re_detail::mfc_string_out_iterator i(result); + regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags); + return result; +} + +} // namespace boost. + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/pattern_except.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pattern_except.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,100 @@ +/* + * + * 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 pattern_except.hpp + * VERSION see + * DESCRIPTION: Declares pattern-matching exception classes. + */ + +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#define BOOST_RE_PAT_EXCEPT_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include +#include +#include + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4275) +#endif +class BOOST_REGEX_DECL regex_error : public std::runtime_error +{ +public: + explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0); + explicit regex_error(regex_constants::error_type err); + ~regex_error() throw(); + regex_constants::error_type code()const + { return m_error_code; } + std::ptrdiff_t position()const + { return m_position; } + void raise()const; +private: + regex_constants::error_type m_error_code; + std::ptrdiff_t m_position; +}; + +typedef regex_error bad_pattern; +typedef regex_error bad_expression; + +namespace re_detail{ + +BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex); + +template +void raise_error(const traits& t, regex_constants::error_type code) +{ + (void)t; // warning suppression + std::runtime_error e(t.error_string(code)); + ::boost::re_detail::raise_runtime_error(e); +} + +} + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/pending/object_cache.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pending/object_cache.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,163 @@ +/* + * + * 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 object_cache.hpp + * VERSION see + * DESCRIPTION: Implements a generic object cache. + */ + +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#define BOOST_REGEX_OBJECT_CACHE_HPP + +#include +#include +#include +#include +#include +#include +#ifdef BOOST_HAS_THREADS +#include +#endif + +namespace boost{ + +template +class object_cache +{ +public: + typedef std::pair< ::boost::shared_ptr, Key const*> value_type; + typedef std::list list_type; + typedef typename list_type::iterator list_iterator; + typedef std::map map_type; + typedef typename map_type::iterator map_iterator; + typedef typename list_type::size_type size_type; + static boost::shared_ptr get(const Key& k, size_type max_cache_size); + +private: + static boost::shared_ptr do_get(const Key& k, size_type max_cache_size); + + struct data + { + list_type cont; + map_type index; + }; + + // Needed by compilers not implementing the resolution to DR45. For reference, + // see http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45. + friend struct data; +}; + +template +boost::shared_ptr object_cache::get(const Key& k, size_type max_cache_size) +{ +#ifdef BOOST_HAS_THREADS + static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT; + + boost::static_mutex::scoped_lock l(mut); + if(l) + { + return do_get(k, max_cache_size); + } + // + // what do we do if the lock fails? + // for now just throw, but we should never really get here... + // + ::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock")); + return boost::shared_ptr(); +#else + return do_get(k, max_cache_size); +#endif +} + +template +boost::shared_ptr object_cache::do_get(const Key& k, size_type max_cache_size) +{ + typedef typename object_cache::data object_data; + typedef typename map_type::size_type map_size_type; + static object_data s_data; + + // + // see if the object is already in the cache: + // + map_iterator mpos = s_data.index.find(k); + if(mpos != s_data.index.end()) + { + // + // Eureka! + // We have a cached item, bump it up the list and return it: + // + if(--(s_data.cont.end()) != mpos->second) + { + // splice out the item we want to move: + list_type temp; + temp.splice(temp.end(), s_data.cont, mpos->second); + // and now place it at the end of the list: + s_data.cont.splice(s_data.cont.end(), temp, temp.begin()); + BOOST_ASSERT(*(s_data.cont.back().second) == k); + // update index with new position: + mpos->second = --(s_data.cont.end()); + BOOST_ASSERT(&(mpos->first) == mpos->second->second); + BOOST_ASSERT(&(mpos->first) == s_data.cont.back().second); + } + return s_data.cont.back().first; + } + // + // if we get here then the item is not in the cache, + // so create it: + // + boost::shared_ptr result(new Object(k)); + // + // Add it to the list, and index it: + // + s_data.cont.push_back(value_type(result, static_cast(0))); + s_data.index.insert(std::make_pair(k, --(s_data.cont.end()))); + s_data.cont.back().second = &(s_data.index.find(k)->first); + map_size_type s = s_data.index.size(); + BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_ASSERT(s_data.index.find(k)->first == k); + if(s > max_cache_size) + { + // + // We have too many items in the list, so we need to start + // popping them off the back of the list, but only if they're + // being held uniquely by us: + // + list_iterator pos = s_data.cont.begin(); + list_iterator last = s_data.cont.end(); + while((pos != last) && (s > max_cache_size)) + { + if(pos->first.unique()) + { + list_iterator condemmed(pos); + ++pos; + // now remove the items from our containers, + // then order has to be as follows: + BOOST_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end()); + s_data.index.erase(*(condemmed->second)); + s_data.cont.erase(condemmed); + --s; + } + else + --pos; + } + BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_ASSERT(s_data.index.find(k)->first == k); + } + return result; +} + +} + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/pending/static_mutex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pending/static_mutex.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,184 @@ +/* + * + * 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.hpp + * VERSION see + * DESCRIPTION: Declares static_mutex lock type, there are three different + * implementations: POSIX pthreads, WIN32 threads, and portable, + * these are described in more detail below. + */ + +#ifndef BOOST_REGEX_STATIC_MUTEX_HPP +#define BOOST_REGEX_STATIC_MUTEX_HPP + +#include +#include // dll import/export options. + +#ifdef BOOST_HAS_PTHREADS +#include +#endif + +#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER) +// +// pthreads version: +// simple wrap around a pthread_mutex_t initialized with +// PTHREAD_MUTEX_INITIALIZER. +// +namespace boost{ + +class BOOST_REGEX_DECL scoped_static_mutex_lock; + +class static_mutex +{ +public: + typedef scoped_static_mutex_lock scoped_lock; + pthread_mutex_t m_mutex; +}; + +#define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, } + +class BOOST_REGEX_DECL scoped_static_mutex_lock +{ +public: + scoped_static_mutex_lock(static_mutex& mut, bool lk = true); + ~scoped_static_mutex_lock(); + inline bool locked()const + { + return m_have_lock; + } + inline operator void const*()const + { + return locked() ? this : 0; + } + void lock(); + void unlock(); +private: + static_mutex& m_mutex; + bool m_have_lock; +}; + + +} // namespace boost +#elif defined(BOOST_HAS_WINTHREADS) +// +// Win32 version: +// Use a 32-bit int as a lock, along with a test-and-set +// implementation using InterlockedCompareExchange. +// + +#include + +namespace boost{ + +class BOOST_REGEX_DECL scoped_static_mutex_lock; + +class static_mutex +{ +public: + typedef scoped_static_mutex_lock scoped_lock; + boost::int32_t m_mutex; +}; + +#define BOOST_STATIC_MUTEX_INIT { 0, } + +class BOOST_REGEX_DECL scoped_static_mutex_lock +{ +public: + scoped_static_mutex_lock(static_mutex& mut, bool lk = true); + ~scoped_static_mutex_lock(); + operator void const*()const; + bool locked()const; + void lock(); + void unlock(); +private: + static_mutex& m_mutex; + bool m_have_lock; + scoped_static_mutex_lock(const scoped_static_mutex_lock&); + scoped_static_mutex_lock& operator=(const scoped_static_mutex_lock&); +}; + +inline scoped_static_mutex_lock::operator void const*()const +{ + return locked() ? this : 0; +} + +inline bool scoped_static_mutex_lock::locked()const +{ + return m_have_lock; +} + +} // namespace + +#else +// +// Portable version of a static mutex based on Boost.Thread library: +// This has to use a single mutex shared by all instances of static_mutex +// because boost::call_once doesn't alow us to pass instance information +// down to the initialisation proceedure. In fact the initialisation routine +// may need to be called more than once - but only once per instance. +// +// Since this preprocessor path is almost never taken, we hide these header +// dependencies so that build tools don't find them. +// +#define B1 +#define B2 +#include B1 +#include B2 +#undef B1 +#undef B2 + +namespace boost{ + +class BOOST_REGEX_DECL scoped_static_mutex_lock; +extern "C" BOOST_REGEX_DECL void free_static_mutex(); + +class BOOST_REGEX_DECL static_mutex +{ +public: + typedef scoped_static_mutex_lock scoped_lock; + static void init(); + static boost::recursive_mutex* m_pmutex; + static boost::once_flag m_once; +}; + +#define BOOST_STATIC_MUTEX_INIT { } + +class BOOST_REGEX_DECL scoped_static_mutex_lock +{ +public: + scoped_static_mutex_lock(static_mutex& mut, bool lk = true); + ~scoped_static_mutex_lock(); + operator void const*()const; + bool locked()const; + void lock(); + void unlock(); +private: + boost::recursive_mutex::scoped_lock* m_plock; + bool m_have_lock; +}; + +inline scoped_static_mutex_lock::operator void const*()const +{ + return locked() ? this : 0; +} + +inline bool scoped_static_mutex_lock::locked()const +{ + return m_have_lock; +} + +} // namespace + +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/pending/unicode_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pending/unicode_iterator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,692 @@ +/* + * + * 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 unicode_iterator.hpp + * VERSION see + * DESCRIPTION: Iterator adapters for converting between different Unicode encodings. + */ + +/**************************************************************************** + +Contents: +~~~~~~~~~ + +1) Read Only, Input Adapters: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +template +class u32_to_u8_iterator; + +Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-8. + +template +class u8_to_u32_iterator; + +Adapts sequence of UTF-8 code points to "look like" a sequence of UTF-32. + +template +class u32_to_u16_iterator; + +Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-16. + +template +class u16_to_u32_iterator; + +Adapts sequence of UTF-16 code points to "look like" a sequence of UTF-32. + +2) Single pass output iterator adapters: + +template +class utf8_output_iterator; + +Accepts UTF-32 code points and forwards them on as UTF-8 code points. + +template +class utf16_output_iterator; + +Accepts UTF-32 code points and forwards them on as UTF-16 code points. + +****************************************************************************/ + +#ifndef BOOST_REGEX_UNICODE_ITERATOR_HPP +#define BOOST_REGEX_UNICODE_ITERATOR_HPP +#include +#include +#include +#include +#include +#include +#ifndef BOOST_NO_STD_LOCALE +#include +#include +#endif +#include // CHAR_BIT + +namespace boost{ + +namespace detail{ + +static const ::boost::uint16_t high_surrogate_base = 0xD7C0u; +static const ::boost::uint16_t low_surrogate_base = 0xDC00u; +static const ::boost::uint32_t ten_bit_mask = 0x3FFu; + +inline bool is_high_surrogate(::boost::uint16_t v) +{ + return (v & 0xFC00u) == 0xd800u; +} +inline bool is_low_surrogate(::boost::uint16_t v) +{ + return (v & 0xFC00u) == 0xdc00u; +} +template +inline bool is_surrogate(T v) +{ + return (v & 0xF800u) == 0xd800; +} + +inline unsigned utf8_byte_count(boost::uint8_t c) +{ + // if the most significant bit with a zero in it is in position + // 8-N then there are N bytes in this UTF-8 sequence: + boost::uint8_t mask = 0x80u; + unsigned result = 0; + while(c & mask) + { + ++result; + mask >>= 1; + } + return (result == 0) ? 1 : ((result > 4) ? 4 : result); +} + +inline unsigned utf8_trailing_byte_count(boost::uint8_t c) +{ + return utf8_byte_count(c) - 1; +} + +inline void invalid_utf32_code_point(::boost::uint32_t val) +{ +#ifndef BOOST_NO_STD_LOCALE + std::stringstream ss; + ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence"; + std::out_of_range e(ss.str()); +#else + std::out_of_range e("Invalid UTF-32 code point encountered while trying to encode UTF-16 sequence"); +#endif + boost::throw_exception(e); +} + + +} // namespace detail + +template +class u32_to_u16_iterator + : public boost::iterator_facade, U16Type, std::bidirectional_iterator_tag, const U16Type> +{ + typedef boost::iterator_facade, U16Type, std::bidirectional_iterator_tag, const U16Type> base_type; + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32); + BOOST_STATIC_ASSERT(sizeof(U16Type)*CHAR_BIT == 16); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_current == 2) + extract_current(); + return m_values[m_current]; + } + bool equal(const u32_to_u16_iterator& that)const + { + if(m_position == that.m_position) + { + // Both m_currents must be equal, or both even + // this is the same as saying their sum must be even: + return (m_current + that.m_current) & 1u ? false : true; + } + return false; + } + void increment() + { + // if we have a pending read then read now, so that we know whether + // to skip a position, or move to a low-surrogate: + if(m_current == 2) + { + // pending read: + extract_current(); + } + // move to the next surrogate position: + ++m_current; + // if we've reached the end skip a position: + if(m_values[m_current] == 0) + { + m_current = 2; + ++m_position; + } + } + void decrement() + { + if(m_current != 1) + { + // decrementing an iterator always leads to a valid position: + --m_position; + extract_current(); + m_current = m_values[1] ? 1 : 0; + } + else + { + m_current = 0; + } + } + BaseIterator base()const + { + return m_position; + } + // construct: + u32_to_u16_iterator() : m_position(), m_current(0) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + } + u32_to_u16_iterator(BaseIterator b) : m_position(b), m_current(2) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + } +private: + + void extract_current()const + { + // begin by checking for a code point out of range: + ::boost::uint32_t v = *m_position; + if(v >= 0x10000u) + { + if(v > 0x10FFFFu) + detail::invalid_utf32_code_point(*m_position); + // split into two surrogates: + m_values[0] = static_cast(v >> 10) + detail::high_surrogate_base; + m_values[1] = static_cast(v & detail::ten_bit_mask) + detail::low_surrogate_base; + m_current = 0; + BOOST_ASSERT(detail::is_high_surrogate(m_values[0])); + BOOST_ASSERT(detail::is_low_surrogate(m_values[1])); + } + else + { + // 16-bit code point: + m_values[0] = static_cast(*m_position); + m_values[1] = 0; + m_current = 0; + // value must not be a surrogate: + if(detail::is_surrogate(m_values[0])) + detail::invalid_utf32_code_point(*m_position); + } + } + BaseIterator m_position; + mutable U16Type m_values[3]; + mutable unsigned m_current; +}; + +template +class u16_to_u32_iterator + : public boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> +{ + typedef boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type; + // special values for pending iterator reads: + BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu); + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 16); + BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_value == pending_read) + extract_current(); + return m_value; + } + bool equal(const u16_to_u32_iterator& that)const + { + return m_position == that.m_position; + } + void increment() + { + // skip high surrogate first if there is one: + if(detail::is_high_surrogate(*m_position)) ++m_position; + ++m_position; + m_value = pending_read; + } + void decrement() + { + --m_position; + // if we have a low surrogate then go back one more: + if(detail::is_low_surrogate(*m_position)) + --m_position; + m_value = pending_read; + } + BaseIterator base()const + { + return m_position; + } + // construct: + u16_to_u32_iterator() : m_position() + { + m_value = pending_read; + } + u16_to_u32_iterator(BaseIterator b) : m_position(b) + { + m_value = pending_read; + } +private: + static void invalid_code_point(::boost::uint16_t val) + { +#ifndef BOOST_NO_STD_LOCALE + std::stringstream ss; + ss << "Misplaced UTF-16 surrogate U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-32 sequence"; + std::out_of_range e(ss.str()); +#else + std::out_of_range e("Misplaced UTF-16 surrogate encountered while trying to encode UTF-32 sequence"); +#endif + boost::throw_exception(e); + } + void extract_current()const + { + m_value = static_cast(static_cast< ::boost::uint16_t>(*m_position)); + // if the last value is a high surrogate then adjust m_position and m_value as needed: + if(detail::is_high_surrogate(*m_position)) + { + // precondition; next value must have be a low-surrogate: + BaseIterator next(m_position); + ::boost::uint16_t t = *++next; + if((t & 0xFC00u) != 0xDC00u) + invalid_code_point(t); + m_value = (m_value - detail::high_surrogate_base) << 10; + m_value |= (static_cast(static_cast< ::boost::uint16_t>(t)) & detail::ten_bit_mask); + } + // postcondition; result must not be a surrogate: + if(detail::is_surrogate(m_value)) + invalid_code_point(static_cast< ::boost::uint16_t>(m_value)); + } + BaseIterator m_position; + mutable U32Type m_value; +}; + +template +class u32_to_u8_iterator + : public boost::iterator_facade, U8Type, std::bidirectional_iterator_tag, const U8Type> +{ + typedef boost::iterator_facade, U8Type, std::bidirectional_iterator_tag, const U8Type> base_type; + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32); + BOOST_STATIC_ASSERT(sizeof(U8Type)*CHAR_BIT == 8); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_current == 4) + extract_current(); + return m_values[m_current]; + } + bool equal(const u32_to_u8_iterator& that)const + { + if(m_position == that.m_position) + { + // either the m_current's must be equal, or one must be 0 and + // the other 4: which means neither must have bits 1 or 2 set: + return (m_current == that.m_current) + || (((m_current | that.m_current) & 3) == 0); + } + return false; + } + void increment() + { + // if we have a pending read then read now, so that we know whether + // to skip a position, or move to a low-surrogate: + if(m_current == 4) + { + // pending read: + extract_current(); + } + // move to the next surrogate position: + ++m_current; + // if we've reached the end skip a position: + if(m_values[m_current] == 0) + { + m_current = 4; + ++m_position; + } + } + void decrement() + { + if((m_current & 3) == 0) + { + --m_position; + extract_current(); + m_current = 3; + while(m_current && (m_values[m_current] == 0)) + --m_current; + } + else + --m_current; + } + BaseIterator base()const + { + return m_position; + } + // construct: + u32_to_u8_iterator() : m_position(), m_current(0) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + m_values[3] = 0; + m_values[4] = 0; + } + u32_to_u8_iterator(BaseIterator b) : m_position(b), m_current(4) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + m_values[3] = 0; + m_values[4] = 0; + } +private: + + void extract_current()const + { + boost::uint32_t c = *m_position; + if(c > 0x10FFFFu) + detail::invalid_utf32_code_point(c); + if(c < 0x80u) + { + m_values[0] = static_cast(c); + m_values[1] = static_cast(0u); + m_values[2] = static_cast(0u); + m_values[3] = static_cast(0u); + } + else if(c < 0x800u) + { + m_values[0] = static_cast(0xC0u + (c >> 6)); + m_values[1] = static_cast(0x80u + (c & 0x3Fu)); + m_values[2] = static_cast(0u); + m_values[3] = static_cast(0u); + } + else if(c < 0x10000u) + { + m_values[0] = static_cast(0xE0u + (c >> 12)); + m_values[1] = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + m_values[2] = static_cast(0x80u + (c & 0x3Fu)); + m_values[3] = static_cast(0u); + } + else + { + m_values[0] = static_cast(0xF0u + (c >> 18)); + m_values[1] = static_cast(0x80u + ((c >> 12) & 0x3Fu)); + m_values[2] = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + m_values[3] = static_cast(0x80u + (c & 0x3Fu)); + } + m_current= 0; + } + BaseIterator m_position; + mutable U8Type m_values[5]; + mutable unsigned m_current; +}; + +template +class u8_to_u32_iterator + : public boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> +{ + typedef boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type; + // special values for pending iterator reads: + BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu); + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 8); + BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_value == pending_read) + extract_current(); + return m_value; + } + bool equal(const u8_to_u32_iterator& that)const + { + return m_position == that.m_position; + } + void increment() + { + // skip high surrogate first if there is one: + unsigned c = detail::utf8_byte_count(*m_position); + std::advance(m_position, c); + m_value = pending_read; + } + void decrement() + { + // Keep backtracking until we don't have a trailing character: + unsigned count = 0; + while((*--m_position & 0xC0u) == 0x80u) ++count; + // now check that the sequence was valid: + if(count != detail::utf8_trailing_byte_count(*m_position)) + invalid_sequnce(); + m_value = pending_read; + } + BaseIterator base()const + { + return m_position; + } + // construct: + u8_to_u32_iterator() : m_position() + { + m_value = pending_read; + } + u8_to_u32_iterator(BaseIterator b) : m_position(b) + { + m_value = pending_read; + } +private: + static void invalid_sequnce() + { + std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character"); + boost::throw_exception(e); + } + void extract_current()const + { + m_value = static_cast(static_cast< ::boost::uint8_t>(*m_position)); + // we must not have a continuation character: + if((m_value & 0xC0u) == 0x80u) + invalid_sequnce(); + // see how many extra byts we have: + unsigned extra = detail::utf8_trailing_byte_count(*m_position); + // extract the extra bits, 6 from each extra byte: + BaseIterator next(m_position); + for(unsigned c = 0; c < extra; ++c) + { + ++next; + m_value <<= 6; + m_value += static_cast(*next) & 0x3Fu; + } + // we now need to remove a few of the leftmost bits, but how many depends + // upon how many extra bytes we've extracted: + static const boost::uint32_t masks[4] = + { + 0x7Fu, + 0x7FFu, + 0xFFFFu, + 0x1FFFFFu, + }; + m_value &= masks[extra]; + // check the result: + if(m_value > static_cast(0x10FFFFu)) + invalid_sequnce(); + } + BaseIterator m_position; + mutable U32Type m_value; +}; + +template +class utf16_output_iterator +{ +public: + typedef void difference_type; + typedef void value_type; + typedef boost::uint32_t* pointer; + typedef boost::uint32_t& reference; + typedef std::output_iterator_tag iterator_category; + + utf16_output_iterator(const BaseIterator& b) + : m_position(b){} + utf16_output_iterator(const utf16_output_iterator& that) + : m_position(that.m_position){} + utf16_output_iterator& operator=(const utf16_output_iterator& that) + { + m_position = that.m_position; + return *this; + } + const utf16_output_iterator& operator*()const + { + return *this; + } + void operator=(boost::uint32_t val)const + { + push(val); + } + utf16_output_iterator& operator++() + { + return *this; + } + utf16_output_iterator& operator++(int) + { + return *this; + } + BaseIterator base()const + { + return m_position; + } +private: + void push(boost::uint32_t v)const + { + if(v >= 0x10000u) + { + // begin by checking for a code point out of range: + if(v > 0x10FFFFu) + detail::invalid_utf32_code_point(v); + // split into two surrogates: + *m_position++ = static_cast(v >> 10) + detail::high_surrogate_base; + *m_position++ = static_cast(v & detail::ten_bit_mask) + detail::low_surrogate_base; + } + else + { + // 16-bit code point: + // value must not be a surrogate: + if(detail::is_surrogate(v)) + detail::invalid_utf32_code_point(v); + *m_position++ = static_cast(v); + } + } + mutable BaseIterator m_position; +}; + +template +class utf8_output_iterator +{ +public: + typedef void difference_type; + typedef void value_type; + typedef boost::uint32_t* pointer; + typedef boost::uint32_t& reference; + typedef std::output_iterator_tag iterator_category; + + utf8_output_iterator(const BaseIterator& b) + : m_position(b){} + utf8_output_iterator(const utf8_output_iterator& that) + : m_position(that.m_position){} + utf8_output_iterator& operator=(const utf8_output_iterator& that) + { + m_position = that.m_position; + return *this; + } + const utf8_output_iterator& operator*()const + { + return *this; + } + void operator=(boost::uint32_t val)const + { + push(val); + } + utf8_output_iterator& operator++() + { + return *this; + } + utf8_output_iterator& operator++(int) + { + return *this; + } + BaseIterator base()const + { + return m_position; + } +private: + void push(boost::uint32_t c)const + { + if(c > 0x10FFFFu) + detail::invalid_utf32_code_point(c); + if(c < 0x80u) + { + *m_position++ = static_cast(c); + } + else if(c < 0x800u) + { + *m_position++ = static_cast(0xC0u + (c >> 6)); + *m_position++ = static_cast(0x80u + (c & 0x3Fu)); + } + else if(c < 0x10000u) + { + *m_position++ = static_cast(0xE0u + (c >> 12)); + *m_position++ = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + *m_position++ = static_cast(0x80u + (c & 0x3Fu)); + } + else + { + *m_position++ = static_cast(0xF0u + (c >> 18)); + *m_position++ = static_cast(0x80u + ((c >> 12) & 0x3Fu)); + *m_position++ = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + *m_position++ = static_cast(0x80u + (c & 0x3Fu)); + } + } + mutable BaseIterator m_position; +}; + +} // namespace boost + +#endif // BOOST_REGEX_UNICODE_ITERATOR_HPP + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/regex_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,35 @@ +/* + * + * 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 regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits classes. + */ + +#ifndef BOOST_REGEX_TRAITS_HPP +#define BOOST_REGEX_TRAITS_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +# include +#endif + +# ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED +# include +# endif + +#endif // include + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/user.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/user.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,90 @@ +/* + * + * 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 user.hpp + * VERSION see + * DESCRIPTION: User settable options. + */ + +// define if you want the regex library to use the C locale +// even on Win32: +// #define BOOST_REGEX_USE_C_LOCALE + +// define this is you want the regex library to use the C++ +// locale: +// #define BOOST_REGEX_USE_CPP_LOCALE + +// define this if the runtime library is a dll, and you +// want BOOST_REGEX_DYN_LINK to set up dll exports/imports +// with __declspec(dllexport)/__declspec(dllimport.) +// #define BOOST_REGEX_HAS_DLL_RUNTIME + +// define this if you want to dynamically link to regex, +// if the runtime library is also a dll (Probably Win32 specific, +// and has no effect unless BOOST_REGEX_HAS_DLL_RUNTIME is set): +// #define BOOST_REGEX_DYN_LINK + +// define this if you don't want the lib to automatically +// select its link libraries: +// #define BOOST_REGEX_NO_LIB + +// define this if templates with switch statements cause problems: +// #define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE + +// define this to disable Win32 support when available: +// #define BOOST_REGEX_NO_W32 + +// define this if bool is not a real type: +// #define BOOST_REGEX_NO_BOOL + +// define this if no template instances are to be placed in +// the library rather than users object files: +// #define BOOST_REGEX_NO_EXTERNAL_TEMPLATES + +// define this if the forward declarations in regex_fwd.hpp +// cause more problems than they are worth: +// #define BOOST_REGEX_NO_FWD + +// define this if your compiler supports MS Windows structured +// exception handling. +// #define BOOST_REGEX_HAS_MS_STACK_GUARD + +// define this if you want to use the recursive algorithm +// even if BOOST_REGEX_HAS_MS_STACK_GUARD is not defined. +// #define BOOST_REGEX_RECURSIVE + +// define this if you want to use the non-recursive +// algorithm, even if the recursive version would be the default. +// #define BOOST_REGEX_NON_RECURSIVE + +// define this if you want to set the size of the memory blocks +// used by the non-recursive algorithm. +// #define BOOST_REGEX_BLOCKSIZE 4096 + +// define this if you want to set the maximum number of memory blocks +// used by the non-recursive algorithm. +// #define BOOST_REGEX_MAX_BLOCKS 1024 + +// define this if you want to set the maximum number of memory blocks +// cached by the non-recursive algorithm: Normally this is 16, but can be +// higher if you have multiple threads all using boost.regex, or lower +// if you don't want boost.regex to cache memory. +// #define BOOST_REGEX_MAX_CACHE_BLOCKS 16 + +// define this if you want to be able to access extended capture +// information in your sub_match's (caution this will slow things +// down quite a bit). +// #define BOOST_REGEX_MATCH_EXTRA + +// define this if you want to enable support for Unicode via ICU. +// #define BOOST_HAS_ICU diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,669 @@ +/* + * + * Copyright (c) 1998-2004 + * John Maddock + * + * Distributed under 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 basic_regex.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660 4800) +#endif + +namespace re_detail{ + +// +// forward declaration, we will need this one later: +// +template +class basic_regex_parser; + +// +// class regex_data: +// represents the data we wish to expose to the matching algorithms. +// +template +struct regex_data +{ + typedef regex_constants::syntax_option_type flag_type; + typedef std::size_t size_type; + + regex_data(const ::boost::shared_ptr< + ::boost::regex_traits_wrapper >& t) + : m_ptraits(t), m_expression(0), m_expression_len(0) {} + regex_data() + : m_ptraits(new ::boost::regex_traits_wrapper()), m_expression(0), m_expression_len(0) {} + + ::boost::shared_ptr< + ::boost::regex_traits_wrapper + > m_ptraits; // traits class instance + flag_type m_flags; // flags with which we were compiled + int m_status; // error code (0 implies OK). + const charT* m_expression; // the original expression + std::ptrdiff_t m_expression_len; // the length of the original expression + size_type m_mark_count; // the number of marked sub-expressions + re_detail::re_syntax_base* m_first_state; // the first state of the machine + unsigned m_restart_type; // search optimisation type + unsigned char m_startmap[1 << CHAR_BIT]; // which characters can start a match + unsigned int m_can_be_null; // whether we can match a null string + re_detail::raw_storage m_data; // the buffer in which our states are constructed + typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character + std::vector< + std::pair< + std::size_t, std::size_t> > m_subs; // Position of sub-expressions within the *string*. +}; +// +// class basic_regex_implementation +// pimpl implementation class for basic_regex. +// +template +class basic_regex_implementation + : public regex_data +{ +public: + typedef regex_constants::syntax_option_type flag_type; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef typename traits::locale_type locale_type; + typedef const charT* const_iterator; + + basic_regex_implementation(){} + basic_regex_implementation(const ::boost::shared_ptr< + ::boost::regex_traits_wrapper >& t) + : regex_data(t) {} + void assign(const charT* arg_first, + const charT* arg_last, + flag_type f) + { + regex_data* pdat = this; + basic_regex_parser parser(pdat); + parser.parse(arg_first, arg_last, f); + } + + locale_type BOOST_REGEX_CALL imbue(locale_type l) + { + return this->m_ptraits->imbue(l); + } + locale_type BOOST_REGEX_CALL getloc()const + { + return this->m_ptraits->getloc(); + } + std::basic_string BOOST_REGEX_CALL str()const + { + std::basic_string result; + if(this->m_status == 0) + result = std::basic_string(this->m_expression, this->m_expression_len); + return result; + } + const_iterator BOOST_REGEX_CALL expression()const + { + return this->m_expression; + } + std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const + { + if(n == 0) + throw std::out_of_range("0 is not a valid subexpression index."); + const std::pair& pi = this->m_subs.at(n - 1); + std::pair p(expression() + pi.first, expression() + pi.second); + return p; + } + // + // begin, end: + const_iterator BOOST_REGEX_CALL begin()const + { + return (!this->m_status ? 0 : this->m_expression); + } + const_iterator BOOST_REGEX_CALL end()const + { + return (!this->m_status ? 0 : this->m_expression + this->m_expression_len); + } + flag_type BOOST_REGEX_CALL flags()const + { + return this->m_flags; + } + size_type BOOST_REGEX_CALL size()const + { + return this->m_expression_len; + } + int BOOST_REGEX_CALL status()const + { + return this->m_status; + } + size_type BOOST_REGEX_CALL mark_count()const + { + return this->m_mark_count; + } + const re_detail::re_syntax_base* get_first_state()const + { + return this->m_first_state; + } + unsigned get_restart_type()const + { + return this->m_restart_type; + } + const unsigned char* get_map()const + { + return this->m_startmap; + } + const ::boost::regex_traits_wrapper& get_traits()const + { + return *(this->m_ptraits); + } + bool can_be_null()const + { + return this->m_can_be_null; + } + const regex_data& get_data()const + { + basic_regex_implementation const* p = this; + return *static_cast*>(p); + } +}; + +} // namespace re_detail +// +// class basic_regex: +// represents the compiled +// regular expression: +// + +#ifdef BOOST_REGEX_NO_FWD +template > +#else +template +#endif +class basic_regex : public regbase +{ +public: + // typedefs: + typedef std::size_t traits_size_type; + typedef typename traits::string_type traits_string_type; + typedef charT char_type; + typedef traits traits_type; + + typedef charT value_type; + typedef charT& reference; + typedef const charT& const_reference; + typedef const charT* const_iterator; + typedef const_iterator iterator; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef regex_constants::syntax_option_type flag_type; + // locale_type + // placeholder for actual locale type used by the + // traits class to localise *this. + typedef typename traits::locale_type locale_type; + +public: + explicit basic_regex(){} + explicit basic_regex(const charT* p, flag_type f = regex_constants::normal) + { + assign(p, f); + } + basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + { + assign(p1, p2, f); + } + basic_regex(const charT* p, size_type len, flag_type f) + { + assign(p, len, f); + } + basic_regex(const basic_regex& that) + : m_pimpl(that.m_pimpl) {} + ~basic_regex(){} + basic_regex& BOOST_REGEX_CALL operator=(const basic_regex& that) + { + return assign(that); + } + basic_regex& BOOST_REGEX_CALL operator=(const charT* ptr) + { + return assign(ptr); + } + + // + // assign: + basic_regex& assign(const basic_regex& that) + { + m_pimpl = that.m_pimpl; + return *this; + } + basic_regex& assign(const charT* p, flag_type f = regex_constants::normal) + { + return assign(p, p + traits::length(p), f); + } + basic_regex& assign(const charT* p, size_type len, flag_type f) + { + return assign(p, p + len, f); + } +private: + basic_regex& do_assign(const charT* p1, + const charT* p2, + flag_type f); +public: + basic_regex& assign(const charT* p1, + const charT* p2, + flag_type f = regex_constants::normal) + { + return do_assign(p1, p2, f); + } +#if !defined(BOOST_NO_MEMBER_TEMPLATES) + + template + unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + { + return set_expression(p.data(), p.data() + p.size(), f); + } + + template + explicit basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) + { + assign(p, f); + } + + template + basic_regex(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) + { + typedef typename traits::string_type seq_type; + seq_type a(arg_first, arg_last); + if(a.size()) + assign(&*a.begin(), &*a.begin() + a.size(), f); + else + assign(static_cast(0), static_cast(0), f); + } + + template + basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + return assign(p.data(), p.data() + p.size(), regex_constants::normal); + } + + template + basic_regex& BOOST_REGEX_CALL assign( + const std::basic_string& s, + flag_type f = regex_constants::normal) + { + return assign(s.data(), s.data() + s.size(), f); + } + + template + basic_regex& BOOST_REGEX_CALL assign(InputIterator arg_first, + InputIterator arg_last, + flag_type f = regex_constants::normal) + { + typedef typename traits::string_type seq_type; + seq_type a(arg_first, arg_last); + if(a.size()) + { + const charT* p1 = &*a.begin(); + const charT* p2 = &*a.begin() + a.size(); + return assign(p1, p2, f); + } + return assign(static_cast(0), static_cast(0), f); + } +#else + unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + { + return set_expression(p.data(), p.data() + p.size(), f); + } + + basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) + { + assign(p, f); + } + + basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + return assign(p.data(), p.data() + p.size(), regex_constants::normal); + } + + basic_regex& BOOST_REGEX_CALL assign( + const std::basic_string& s, + flag_type f = regex_constants::normal) + { + return assign(s.data(), s.data() + s.size(), f); + } + +#endif + + // + // locale: + locale_type BOOST_REGEX_CALL imbue(locale_type l); + locale_type BOOST_REGEX_CALL getloc()const + { + return m_pimpl.get() ? m_pimpl->getloc() : locale_type(); + } + // + // getflags: + // retained for backwards compatibility only, "flags" + // is now the preferred name: + flag_type BOOST_REGEX_CALL getflags()const + { + return flags(); + } + flag_type BOOST_REGEX_CALL flags()const + { + return m_pimpl.get() ? m_pimpl->flags() : 0; + } + // + // str: + std::basic_string BOOST_REGEX_CALL str()const + { + return m_pimpl.get() ? m_pimpl->str() : std::basic_string(); + } + // + // begin, end, subexpression: + std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const + { + if(!m_pimpl.get()) + throw std::logic_error("Can't access subexpressions in an invalid regex."); + return m_pimpl->subexpression(n); + } + const_iterator BOOST_REGEX_CALL begin()const + { + return (m_pimpl.get() ? m_pimpl->begin() : 0); + } + const_iterator BOOST_REGEX_CALL end()const + { + return (m_pimpl.get() ? m_pimpl->end() : 0); + } + // + // swap: + void BOOST_REGEX_CALL swap(basic_regex& that)throw() + { + m_pimpl.swap(that.m_pimpl); + } + // + // size: + size_type BOOST_REGEX_CALL size()const + { + return (m_pimpl.get() ? m_pimpl->size() : 0); + } + // + // max_size: + size_type BOOST_REGEX_CALL max_size()const + { + return UINT_MAX; + } + // + // empty: + bool BOOST_REGEX_CALL empty()const + { + return (m_pimpl.get() ? 0 != m_pimpl->status() : true); + } + + size_type BOOST_REGEX_CALL mark_count()const + { + return (m_pimpl.get() ? m_pimpl->mark_count() : 0); + } + + int status()const + { + return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty); + } + + int BOOST_REGEX_CALL compare(const basic_regex& that) const + { + if(m_pimpl.get() == that.m_pimpl.get()) + return 0; + if(!m_pimpl.get()) + return -1; + if(!that.m_pimpl.get()) + return 1; + if(status() != that.status()) + return status() - that.status(); + if(flags() != that.flags()) + return flags() - that.flags(); + return str().compare(that.str()); + } + bool BOOST_REGEX_CALL operator==(const basic_regex& e)const + { + return compare(e) == 0; + } + bool BOOST_REGEX_CALL operator != (const basic_regex& e)const + { + return compare(e) != 0; + } + bool BOOST_REGEX_CALL operator<(const basic_regex& e)const + { + return compare(e) < 0; + } + bool BOOST_REGEX_CALL operator>(const basic_regex& e)const + { + return compare(e) > 0; + } + bool BOOST_REGEX_CALL operator<=(const basic_regex& e)const + { + return compare(e) <= 0; + } + bool BOOST_REGEX_CALL operator>=(const basic_regex& e)const + { + return compare(e) >= 0; + } + + // + // The following are deprecated as public interfaces + // but are available for compatibility with earlier versions. + const charT* BOOST_REGEX_CALL expression()const + { + return (m_pimpl.get() && !m_pimpl->status() ? m_pimpl->expression() : 0); + } + unsigned int BOOST_REGEX_CALL set_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + { + assign(p1, p2, f | regex_constants::no_except); + return status(); + } + unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) + { + assign(p, f | regex_constants::no_except); + return status(); + } + unsigned int BOOST_REGEX_CALL error_code()const + { + return status(); + } + // + // private access methods: + // + const re_detail::re_syntax_base* get_first_state()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_first_state(); + } + unsigned get_restart_type()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_restart_type(); + } + const unsigned char* get_map()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_map(); + } + const ::boost::regex_traits_wrapper& get_traits()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_traits(); + } + bool can_be_null()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->can_be_null(); + } + const re_detail::regex_data& get_data()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_data(); + } + +private: + shared_ptr > m_pimpl; +}; + +// +// out of line members; +// these are the only members that mutate the basic_regex object, +// and are designed to provide the strong exception guarentee +// (in the event of a throw, the state of the object remains unchanged). +// +template +basic_regex& basic_regex::do_assign(const charT* p1, + const charT* p2, + flag_type f) +{ + shared_ptr > temp; + if(!m_pimpl.get()) + { + temp = shared_ptr >(new re_detail::basic_regex_implementation()); + } + else + { + temp = shared_ptr >(new re_detail::basic_regex_implementation(m_pimpl->m_ptraits)); + } + temp->assign(p1, p2, f); + temp.swap(m_pimpl); + return *this; +} + +template +typename basic_regex::locale_type BOOST_REGEX_CALL basic_regex::imbue(locale_type l) +{ + shared_ptr > temp(new re_detail::basic_regex_implementation()); + locale_type result = temp->imbue(l); + temp.swap(m_pimpl); + return result; +} + +// +// non-members: +// +template +void swap(basic_regex& e1, basic_regex& e2) +{ + e1.swap(e2); +} + +#ifndef BOOST_NO_STD_LOCALE +template +std::basic_ostream& + operator << (std::basic_ostream& os, + const basic_regex& e) +{ + return (os << e.str()); +} +#else +template +std::ostream& operator << (std::ostream& os, const basic_regex& e) +{ + return (os << e.str()); +} +#endif + +// +// class reg_expression: +// this is provided for backwards compatibility only, +// it is deprecated, no not use! +// +#ifdef BOOST_REGEX_NO_FWD +template > +#else +template +#endif +class reg_expression : public basic_regex +{ +public: + typedef typename basic_regex::flag_type flag_type; + typedef typename basic_regex::size_type size_type; + explicit reg_expression(){} + explicit reg_expression(const charT* p, flag_type f = regex_constants::normal) + : basic_regex(p, f){} + reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + : basic_regex(p1, p2, f){} + reg_expression(const charT* p, size_type len, flag_type f) + : basic_regex(p, len, f){} + reg_expression(const reg_expression& that) + : basic_regex(that) {} + ~reg_expression(){} + reg_expression& BOOST_REGEX_CALL operator=(const reg_expression& that) + { + return this->assign(that); + } + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) + template + explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + : basic_regex(p, f) + { + } + + template + reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) + : basic_regex(arg_first, arg_last, f) + { + } + + template + reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + this->assign(p); + return *this; + } +#else + explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + : basic_regex(p, f) + { + } + + reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + this->assign(p); + return *this; + } +#endif + +}; + +#ifdef BOOST_MSVC +#pragma warning (pop) +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_creator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_creator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,1332 @@ +/* + * + * 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 basic_regex_creator.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_creator which fills in + * the data members of a regex_data object. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ + +namespace re_detail{ + +template +struct digraph : public std::pair +{ + digraph() : std::pair(0, 0){} + digraph(charT c1) : std::pair(c1, 0){} + digraph(charT c1, charT c2) : std::pair(c1, c2) + {} +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + digraph(const digraph& d) : std::pair(d.first, d.second){} +#endif + template + digraph(const Seq& s) : std::pair() + { + BOOST_ASSERT(s.size() <= 2); + BOOST_ASSERT(s.size()); + this->first = s[0]; + this->second = (s.size() > 1) ? s[1] : 0; + } +}; + +template +class basic_char_set +{ +public: + typedef digraph digraph_type; + typedef typename traits::string_type string_type; + typedef typename traits::char_class_type mask_type; + + basic_char_set() + { + m_negate = false; + m_has_digraphs = false; + m_classes = 0; + m_negated_classes = 0; + m_empty = true; + } + + void add_single(const digraph_type& s) + { + m_singles.insert(m_singles.end(), s); + if(s.second) + m_has_digraphs = true; + m_empty = false; + } + void add_range(const digraph_type& first, const digraph_type& end) + { + m_ranges.insert(m_ranges.end(), first); + m_ranges.insert(m_ranges.end(), end); + if(first.second) + { + m_has_digraphs = true; + add_single(first); + } + if(end.second) + { + m_has_digraphs = true; + add_single(end); + } + m_empty = false; + } + void add_class(mask_type m) + { + m_classes |= m; + m_empty = false; + } + void add_negated_class(mask_type m) + { + m_negated_classes |= m; + m_empty = false; + } + void add_equivalent(const digraph_type& s) + { + m_equivalents.insert(m_equivalents.end(), s); + if(s.second) + { + m_has_digraphs = true; + add_single(s); + } + m_empty = false; + } + void negate() + { + m_negate = true; + //m_empty = false; + } + + // + // accessor functions: + // + bool has_digraphs()const + { + return m_has_digraphs; + } + bool is_negated()const + { + return m_negate; + } + typedef typename std::vector::const_iterator list_iterator; + list_iterator singles_begin()const + { + return m_singles.begin(); + } + list_iterator singles_end()const + { + return m_singles.end(); + } + list_iterator ranges_begin()const + { + return m_ranges.begin(); + } + list_iterator ranges_end()const + { + return m_ranges.end(); + } + list_iterator equivalents_begin()const + { + return m_equivalents.begin(); + } + list_iterator equivalents_end()const + { + return m_equivalents.end(); + } + mask_type classes()const + { + return m_classes; + } + mask_type negated_classes()const + { + return m_negated_classes; + } + bool empty()const + { + return m_empty; + } +private: + std::vector m_singles; // a list of single characters to match + std::vector m_ranges; // a list of end points of our ranges + bool m_negate; // true if the set is to be negated + bool m_has_digraphs; // true if we have digraphs present + mask_type m_classes; // character classes to match + mask_type m_negated_classes; // negated character classes to match + bool m_empty; // whether we've added anything yet + std::vector m_equivalents; // a list of equivalence classes +}; + +template +class basic_regex_creator +{ +public: + basic_regex_creator(regex_data* data); + std::ptrdiff_t getoffset(void* addr) + { + return getoffset(addr, m_pdata->m_data.data()); + } + std::ptrdiff_t getoffset(const void* addr, const void* base) + { + return static_cast(addr) - static_cast(base); + } + re_syntax_base* getaddress(std::ptrdiff_t off) + { + return getaddress(off, m_pdata->m_data.data()); + } + re_syntax_base* getaddress(std::ptrdiff_t off, void* base) + { + return static_cast(static_cast(static_cast(base) + off)); + } + void init(unsigned l_flags) + { + m_pdata->m_flags = l_flags; + m_icase = l_flags & regex_constants::icase; + } + regbase::flag_type flags() + { + return m_pdata->m_flags; + } + void flags(regbase::flag_type f) + { + m_pdata->m_flags = f; + if(m_icase != static_cast(f & regbase::icase)) + { + m_icase = static_cast(f & regbase::icase); + } + } + re_syntax_base* append_state(syntax_element_type t, std::size_t s = sizeof(re_syntax_base)); + re_syntax_base* insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s = sizeof(re_syntax_base)); + re_literal* append_literal(charT c); + re_syntax_base* append_set(const basic_char_set& char_set); + re_syntax_base* append_set(const basic_char_set& char_set, mpl::false_*); + re_syntax_base* append_set(const basic_char_set& char_set, mpl::true_*); + void finalize(const charT* p1, const charT* p2); +protected: + regex_data* m_pdata; // pointer to the basic_regex_data struct we are filling in + const ::boost::regex_traits_wrapper& + m_traits; // convenience reference to traits class + re_syntax_base* m_last_state; // the last state we added + bool m_icase; // true for case insensitive matches + unsigned m_repeater_id; // the state_id of the next repeater + bool m_has_backrefs; // true if there are actually any backrefs + unsigned m_backrefs; // bitmask of permitted backrefs + boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for; + typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character + typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character + typename traits::char_class_type m_lower_mask; // mask used to determine if a character is a lowercase character + typename traits::char_class_type m_upper_mask; // mask used to determine if a character is an uppercase character + typename traits::char_class_type m_alpha_mask; // mask used to determine if a character is an alphabetic character +private: + basic_regex_creator& operator=(const basic_regex_creator&); + basic_regex_creator(const basic_regex_creator&); + + void fixup_pointers(re_syntax_base* state); + void create_startmaps(re_syntax_base* state); + int calculate_backstep(re_syntax_base* state); + void create_startmap(re_syntax_base* state, unsigned char* l_map, unsigned int* pnull, unsigned char mask); + unsigned get_restart_type(re_syntax_base* state); + void set_all_masks(unsigned char* bits, unsigned char); + bool is_bad_repeat(re_syntax_base* pt); + void set_bad_repeat(re_syntax_base* pt); + syntax_element_type get_repeat_type(re_syntax_base* state); + void probe_leading_repeat(re_syntax_base* state); +}; + +template +basic_regex_creator::basic_regex_creator(regex_data* data) + : m_pdata(data), m_traits(*(data->m_ptraits)), m_last_state(0), m_repeater_id(0), m_has_backrefs(false), m_backrefs(0) +{ + m_pdata->m_data.clear(); + m_pdata->m_status = ::boost::regex_constants::error_ok; + static const charT w = 'w'; + static const charT s = 's'; + static const charT l[5] = { 'l', 'o', 'w', 'e', 'r', }; + static const charT u[5] = { 'u', 'p', 'p', 'e', 'r', }; + static const charT a[5] = { 'a', 'l', 'p', 'h', 'a', }; + m_word_mask = m_traits.lookup_classname(&w, &w +1); + m_mask_space = m_traits.lookup_classname(&s, &s +1); + m_lower_mask = m_traits.lookup_classname(l, l + 5); + m_upper_mask = m_traits.lookup_classname(u, u + 5); + m_alpha_mask = m_traits.lookup_classname(a, a + 5); + m_pdata->m_word_mask = m_word_mask; + BOOST_ASSERT(m_word_mask != 0); + BOOST_ASSERT(m_mask_space != 0); + BOOST_ASSERT(m_lower_mask != 0); + BOOST_ASSERT(m_upper_mask != 0); + BOOST_ASSERT(m_alpha_mask != 0); +} + +template +re_syntax_base* basic_regex_creator::append_state(syntax_element_type t, std::size_t s) +{ + // if the state is a backref then make a note of it: + if(t == syntax_element_backref) + this->m_has_backrefs = true; + // append a new state, start by aligning our last one: + m_pdata->m_data.align(); + // set the offset to the next state in our last one: + if(m_last_state) + m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state); + // now actually extent our data: + m_last_state = static_cast(m_pdata->m_data.extend(s)); + // fill in boilerplate options in the new state: + m_last_state->next.i = 0; + m_last_state->type = t; + return m_last_state; +} + +template +re_syntax_base* basic_regex_creator::insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s) +{ + // append a new state, start by aligning our last one: + m_pdata->m_data.align(); + // set the offset to the next state in our last one: + if(m_last_state) + m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state); + // remember the last state position: + std::ptrdiff_t off = getoffset(m_last_state) + s; + // now actually insert our data: + re_syntax_base* new_state = static_cast(m_pdata->m_data.insert(pos, s)); + // fill in boilerplate options in the new state: + new_state->next.i = s; + new_state->type = t; + m_last_state = getaddress(off); + return new_state; +} + +template +re_literal* basic_regex_creator::append_literal(charT c) +{ + re_literal* result; + // start by seeing if we have an existing re_literal we can extend: + if((0 == m_last_state) || (m_last_state->type != syntax_element_literal)) + { + // no existing re_literal, create a new one: + result = static_cast(append_state(syntax_element_literal, sizeof(re_literal) + sizeof(charT))); + result->length = 1; + *static_cast(static_cast(result+1)) = m_traits.translate(c, m_icase); + } + else + { + // we have an existing re_literal, extend it: + std::ptrdiff_t off = getoffset(m_last_state); + m_pdata->m_data.extend(sizeof(charT)); + m_last_state = result = static_cast(getaddress(off)); + charT* characters = static_cast(static_cast(result+1)); + characters[result->length] = m_traits.translate(c, m_icase); + ++(result->length); + } + return result; +} + +template +inline re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set) +{ + typedef mpl::bool_< (sizeof(charT) == 1) > truth_type; + return char_set.has_digraphs() + ? append_set(char_set, static_cast(0)) + : append_set(char_set, static_cast(0)); +} + +template +re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set, mpl::false_*) +{ + typedef typename traits::string_type string_type; + typedef typename basic_char_set::list_iterator item_iterator; + typedef typename traits::char_class_type mask_type; + + re_set_long* result = static_cast*>(append_state(syntax_element_long_set, sizeof(re_set_long))); + // + // fill in the basics: + // + result->csingles = static_cast(::boost::re_detail::distance(char_set.singles_begin(), char_set.singles_end())); + result->cranges = static_cast(::boost::re_detail::distance(char_set.ranges_begin(), char_set.ranges_end())) / 2; + result->cequivalents = static_cast(::boost::re_detail::distance(char_set.equivalents_begin(), char_set.equivalents_end())); + result->cclasses = char_set.classes(); + result->cnclasses = char_set.negated_classes(); + if(flags() & regbase::icase) + { + // adjust classes as needed: + if(((result->cclasses & m_lower_mask) == m_lower_mask) || ((result->cclasses & m_upper_mask) == m_upper_mask)) + result->cclasses |= m_alpha_mask; + if(((result->cnclasses & m_lower_mask) == m_lower_mask) || ((result->cnclasses & m_upper_mask) == m_upper_mask)) + result->cnclasses |= m_alpha_mask; + } + + result->isnot = char_set.is_negated(); + result->singleton = !char_set.has_digraphs(); + // + // remember where the state is for later: + // + std::ptrdiff_t offset = getoffset(result); + // + // now extend with all the singles: + // + item_iterator first, last; + first = char_set.singles_begin(); + last = char_set.singles_end(); + while(first != last) + { + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (first->second ? 3 : 2))); + p[0] = m_traits.translate(first->first, m_icase); + if(first->second) + { + p[1] = m_traits.translate(first->second, m_icase); + p[2] = 0; + } + else + p[1] = 0; + ++first; + } + // + // now extend with all the ranges: + // + first = char_set.ranges_begin(); + last = char_set.ranges_end(); + while(first != last) + { + // first grab the endpoints of the range: + digraph c1 = *first; + c1.first = this->m_traits.translate(c1.first, this->m_icase); + c1.second = this->m_traits.translate(c1.second, this->m_icase); + ++first; + digraph c2 = *first; + c2.first = this->m_traits.translate(c2.first, this->m_icase); + c2.second = this->m_traits.translate(c2.second, this->m_icase); + ++first; + string_type s1, s2; + // different actions now depending upon whether collation is turned on: + if(flags() & regex_constants::collate) + { + // we need to transform our range into sort keys: +#if BOOST_WORKAROUND(__GNUC__, < 3) + string_type in(3, charT(0)); + in[0] = c1.first; + in[1] = c1.second; + s1 = this->m_traits.transform(in.c_str(), (in[1] ? in.c_str()+2 : in.c_str()+1)); + in[0] = c2.first; + in[1] = c2.second; + s2 = this->m_traits.transform(in.c_str(), (in[1] ? in.c_str()+2 : in.c_str()+1)); +#else + charT a1[3] = { c1.first, c1.second, charT(0), }; + charT a2[3] = { c2.first, c2.second, charT(0), }; + s1 = this->m_traits.transform(a1, (a1[1] ? a1+2 : a1+1)); + s2 = this->m_traits.transform(a2, (a2[1] ? a2+2 : a2+1)); +#endif + if(s1.size() == 0) + s1 = string_type(1, charT(0)); + if(s2.size() == 0) + s2 = string_type(1, charT(0)); + } + else + { + if(c1.second) + { + s1.insert(s1.end(), c1.first); + s1.insert(s1.end(), c1.second); + } + else + s1 = string_type(1, c1.first); + if(c2.second) + { + s2.insert(s2.end(), c2.first); + s2.insert(s2.end(), c2.second); + } + else + s2.insert(s2.end(), c2.first); + } + if(s1 > s2) + { + // Oops error: + return 0; + } + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s1.size() + s2.size() + 2) ) ); + re_detail::copy(s1.begin(), s1.end(), p); + p[s1.size()] = charT(0); + p += s1.size() + 1; + re_detail::copy(s2.begin(), s2.end(), p); + p[s2.size()] = charT(0); + } + // + // now process the equivalence classes: + // + first = char_set.equivalents_begin(); + last = char_set.equivalents_end(); + while(first != last) + { + string_type s; + if(first->second) + { +#if BOOST_WORKAROUND(__GNUC__, < 3) + string_type in(3, charT(0)); + in[0] = first->first; + in[1] = first->second; + s = m_traits.transform_primary(in.c_str(), in.c_str()+2); +#else + charT cs[3] = { first->first, first->second, charT(0), }; + s = m_traits.transform_primary(cs, cs+2); +#endif + } + else + s = m_traits.transform_primary(&first->first, &first->first+1); + if(s.empty()) + return 0; // invalid or unsupported equivalence class + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s.size()+1) ) ); + re_detail::copy(s.begin(), s.end(), p); + p[s.size()] = charT(0); + ++first; + } + // + // finally reset the address of our last state: + // + m_last_state = result = static_cast*>(getaddress(offset)); + return result; +} + +namespace{ + +template +inline bool char_less(T t1, T t2) +{ + return t1 < t2; +} +template<> +inline bool char_less(char t1, char t2) +{ + return static_cast(t1) < static_cast(t2); +} +template<> +inline bool char_less(signed char t1, signed char t2) +{ + return static_cast(t1) < static_cast(t2); +} +} + +template +re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set, mpl::true_*) +{ + typedef typename traits::string_type string_type; + typedef typename basic_char_set::list_iterator item_iterator; + + re_set* result = static_cast(append_state(syntax_element_set, sizeof(re_set))); + bool negate = char_set.is_negated(); + std::memset(result->_map, 0, sizeof(result->_map)); + // + // handle singles first: + // + item_iterator first, last; + first = char_set.singles_begin(); + last = char_set.singles_end(); + while(first != last) + { + for(unsigned int i = 0; i < (1 << CHAR_BIT); ++i) + { + if(this->m_traits.translate(static_cast(i), this->m_icase) + == this->m_traits.translate(first->first, this->m_icase)) + result->_map[i] = true; + } + ++first; + } + // + // OK now handle ranges: + // + first = char_set.ranges_begin(); + last = char_set.ranges_end(); + while(first != last) + { + // first grab the endpoints of the range: + charT c1 = this->m_traits.translate(first->first, this->m_icase); + ++first; + charT c2 = this->m_traits.translate(first->first, this->m_icase); + ++first; + // different actions now depending upon whether collation is turned on: + if(flags() & regex_constants::collate) + { + // we need to transform our range into sort keys: + charT c3[2] = { c1, charT(0), }; + string_type s1 = this->m_traits.transform(c3, c3+1); + c3[0] = c2; + string_type s2 = this->m_traits.transform(c3, c3+1); + if(s1 > s2) + { + // Oops error: + return 0; + } + BOOST_ASSERT(c3[1] == charT(0)); + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + c3[0] = static_cast(i); + string_type s3 = this->m_traits.transform(c3, c3 +1); + if((s1 <= s3) && (s3 <= s2)) + result->_map[i] = true; + } + } + else + { + if(char_less(c2, c1)) + { + // Oops error: + return 0; + } + // everything in range matches: + std::memset(result->_map + static_cast(c1), true, 1 + static_cast(c2) - static_cast(c1)); + } + } + // + // and now the classes: + // + typedef typename traits::char_class_type mask_type; + mask_type m = char_set.classes(); + if(flags() & regbase::icase) + { + // adjust m as needed: + if(((m & m_lower_mask) == m_lower_mask) || ((m & m_upper_mask) == m_upper_mask)) + m |= m_alpha_mask; + } + if(m != 0) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + if(this->m_traits.isctype(static_cast(i), m)) + result->_map[i] = true; + } + } + // + // and now the negated classes: + // + m = char_set.negated_classes(); + if(flags() & regbase::icase) + { + // adjust m as needed: + if(((m & m_lower_mask) == m_lower_mask) || ((m & m_upper_mask) == m_upper_mask)) + m |= m_alpha_mask; + } + if(m != 0) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + if(0 == this->m_traits.isctype(static_cast(i), m)) + result->_map[i] = true; + } + } + // + // now process the equivalence classes: + // + first = char_set.equivalents_begin(); + last = char_set.equivalents_end(); + while(first != last) + { + string_type s; + BOOST_ASSERT(static_cast(0) == first->second); + s = m_traits.transform_primary(&first->first, &first->first+1); + if(s.empty()) + return 0; // invalid or unsupported equivalence class + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + charT c[2] = { (static_cast(i)), charT(0), }; + string_type s2 = this->m_traits.transform_primary(c, c+1); + if(s == s2) + result->_map[i] = true; + } + ++first; + } + if(negate) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + result->_map[i] = !(result->_map[i]); + } + } + return result; +} + +template +void basic_regex_creator::finalize(const charT* p1, const charT* p2) +{ + // we've added all the states we need, now finish things off. + // start by adding a terminating state: + append_state(syntax_element_match); + // extend storage to store original expression: + std::ptrdiff_t len = p2 - p1; + m_pdata->m_expression_len = len; + charT* ps = static_cast(m_pdata->m_data.extend(sizeof(charT) * (1 + (p2 - p1)))); + m_pdata->m_expression = ps; + re_detail::copy(p1, p2, ps); + ps[p2 - p1] = 0; + // fill in our other data... + // successful parsing implies a zero status: + m_pdata->m_status = 0; + // get the first state of the machine: + m_pdata->m_first_state = static_cast(m_pdata->m_data.data()); + // fixup pointers in the machine: + fixup_pointers(m_pdata->m_first_state); + // create nested startmaps: + create_startmaps(m_pdata->m_first_state); + // create main startmap: + std::memset(m_pdata->m_startmap, 0, sizeof(m_pdata->m_startmap)); + m_pdata->m_can_be_null = 0; + + m_bad_repeats = 0; + create_startmap(m_pdata->m_first_state, m_pdata->m_startmap, &(m_pdata->m_can_be_null), mask_all); + // get the restart type: + m_pdata->m_restart_type = get_restart_type(m_pdata->m_first_state); + // optimise a leading repeat if there is one: + probe_leading_repeat(m_pdata->m_first_state); +} + +template +void basic_regex_creator::fixup_pointers(re_syntax_base* state) +{ + while(state) + { + switch(state->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + // set the state_id of this repeat: + static_cast(state)->state_id = m_repeater_id++; + // fall through: + case syntax_element_alt: + std::memset(static_cast(state)->_map, 0, sizeof(static_cast(state)->_map)); + static_cast(state)->can_be_null = 0; + // fall through: + case syntax_element_jump: + static_cast(state)->alt.p = getaddress(static_cast(state)->alt.i, state); + // fall through again: + default: + if(state->next.i) + state->next.p = getaddress(state->next.i, state); + else + state->next.p = 0; + } + state = state->next.p; + } +} + +template +void basic_regex_creator::create_startmaps(re_syntax_base* state) +{ + // non-recursive implementation: + // create the last map in the machine first, so that earlier maps + // can make use of the result... + // + // This was originally a recursive implementation, but that caused stack + // overflows with complex expressions on small stacks (think COM+). + + // start by saving the case setting: + bool l_icase = m_icase; + std::vector > v; + + while(state) + { + switch(state->type) + { + case syntax_element_toggle_case: + // we need to track case changes here: + m_icase = static_cast(state)->icase; + state = state->next.p; + continue; + case syntax_element_alt: + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + // just push the state onto our stack for now: + v.push_back(std::pair(m_icase, state)); + state = state->next.p; + break; + case syntax_element_backstep: + // we need to calculate how big the backstep is: + static_cast(state)->index + = this->calculate_backstep(state->next.p); + if(static_cast(state)->index < 0) + { + // Oops error: + if(0 == this->m_pdata->m_status) // update the error code if not already set + this->m_pdata->m_status = boost::regex_constants::error_bad_pattern; + // + // clear the expression, we should be empty: + // + this->m_pdata->m_expression = 0; + this->m_pdata->m_expression_len = 0; + // + // and throw if required: + // + if(0 == (this->flags() & regex_constants::no_except)) + { + std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern); + boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0); + e.raise(); + } + } + // fall through: + default: + state = state->next.p; + } + } + // now work through our list, building all the maps as we go: + while(v.size()) + { + const std::pair& p = v.back(); + m_icase = p.first; + state = p.second; + v.pop_back(); + + // Build maps: + m_bad_repeats = 0; + create_startmap(state->next.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_take); + m_bad_repeats = 0; + create_startmap(static_cast(state)->alt.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_skip); + // adjust the type of the state to allow for faster matching: + state->type = this->get_repeat_type(state); + } + // restore case sensitivity: + m_icase = l_icase; +} + +template +int basic_regex_creator::calculate_backstep(re_syntax_base* state) +{ + typedef typename traits::char_class_type mask_type; + int result = 0; + while(state) + { + switch(state->type) + { + case syntax_element_startmark: + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + { + state = static_cast(state->next.p)->alt.p->next.p; + continue; + } + else if(static_cast(state)->index == -3) + { + state = state->next.p->next.p; + continue; + } + break; + case syntax_element_endmark: + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + return result; + break; + case syntax_element_literal: + result += static_cast(state)->length; + break; + case syntax_element_wild: + case syntax_element_set: + result += 1; + break; + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_backref: + case syntax_element_rep: + case syntax_element_combining: + case syntax_element_long_set_rep: + case syntax_element_backstep: + { + re_repeat* rep = static_cast(state); + // adjust the type of the state to allow for faster matching: + state->type = this->get_repeat_type(state); + if((state->type == syntax_element_dot_rep) + || (state->type == syntax_element_char_rep) + || (state->type == syntax_element_short_set_rep)) + { + if(rep->max != rep->min) + return -1; + result += static_cast(rep->min); + state = rep->alt.p; + continue; + } + else if((state->type == syntax_element_long_set_rep)) + { + BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + if(static_cast*>(rep->next.p)->singleton == 0) + return -1; + if(rep->max != rep->min) + return -1; + result += static_cast(rep->min); + state = rep->alt.p; + continue; + } + } + return -1; + case syntax_element_long_set: + if(static_cast*>(state)->singleton == 0) + return -1; + result += 1; + break; + case syntax_element_jump: + state = static_cast(state)->alt.p; + continue; + default: + break; + } + state = state->next.p; + } + return -1; +} + +template +void basic_regex_creator::create_startmap(re_syntax_base* state, unsigned char* l_map, unsigned int* pnull, unsigned char mask) +{ + int not_last_jump = 1; + + // track case sensitivity: + bool l_icase = m_icase; + + while(state) + { + switch(state->type) + { + case syntax_element_toggle_case: + l_icase = static_cast(state)->icase; + state = state->next.p; + break; + case syntax_element_literal: + { + // don't set anything in *pnull, set each element in l_map + // that could match the first character in the literal: + if(l_map) + { + l_map[0] |= mask_init; + charT first_char = *static_cast(static_cast(static_cast(state) + 1)); + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(m_traits.translate(static_cast(i), l_icase) == first_char) + l_map[i] |= mask; + } + } + return; + } + case syntax_element_end_line: + { + // next character must be a line separator (if there is one): + if(l_map) + { + l_map[0] |= mask_init; + l_map['\n'] |= mask; + l_map['\r'] |= mask; + l_map['\f'] |= mask; + l_map[0x85] |= mask; + } + // now figure out if we can match a NULL string at this point: + if(pnull) + create_startmap(state->next.p, 0, pnull, mask); + return; + } + case syntax_element_backref: + // can be null, and any character can match: + if(pnull) + *pnull |= mask; + // fall through: + case syntax_element_wild: + { + // can't be null, any character can match: + set_all_masks(l_map, mask); + return; + } + case syntax_element_match: + { + // must be null, any character can match: + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + case syntax_element_word_start: + { + // recurse, then AND with all the word characters: + create_startmap(state->next.p, l_map, pnull, mask); + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(!m_traits.isctype(static_cast(i), m_word_mask)) + l_map[i] &= static_cast(~mask); + } + } + return; + } + case syntax_element_word_end: + { + // recurse, then AND with all the word characters: + create_startmap(state->next.p, l_map, pnull, mask); + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(m_traits.isctype(static_cast(i), m_word_mask)) + l_map[i] &= static_cast(~mask); + } + } + return; + } + case syntax_element_buffer_end: + { + // we *must be null* : + if(pnull) + *pnull |= mask; + return; + } + case syntax_element_long_set: + if(l_map) + { + typedef typename traits::char_class_type mask_type; + if(static_cast*>(state)->singleton) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + charT c = static_cast(i); + if(&c != re_is_set_member(&c, &c + 1, static_cast*>(state), *m_pdata, m_icase)) + l_map[i] |= mask; + } + } + else + set_all_masks(l_map, mask); + } + return; + case syntax_element_set: + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(static_cast(state)->_map[ + static_cast(m_traits.translate(static_cast(i), l_icase))]) + l_map[i] |= mask; + } + } + return; + case syntax_element_jump: + // take the jump: + state = static_cast(state)->alt.p; + not_last_jump = -1; + break; + case syntax_element_alt: + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + re_alt* rep = static_cast(state); + if(rep->_map[0] & mask_init) + { + if(l_map) + { + // copy previous results: + l_map[0] |= mask_init; + for(unsigned int i = 0; i <= UCHAR_MAX; ++i) + { + if(rep->_map[i] & mask_any) + l_map[i] |= mask; + } + } + if(pnull) + { + if(rep->can_be_null & mask_any) + *pnull |= mask; + } + } + else + { + // we haven't created a startmap for this alternative yet + // so take the union of the two options: + if(is_bad_repeat(state)) + { + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + set_bad_repeat(state); + create_startmap(state->next.p, l_map, pnull, mask); + if((state->type == syntax_element_alt) + || (static_cast(state)->min == 0) + || (not_last_jump == 0)) + create_startmap(rep->alt.p, l_map, pnull, mask); + } + } + return; + case syntax_element_soft_buffer_end: + // match newline or null: + if(l_map) + { + l_map[0] |= mask_init; + l_map['\n'] |= mask; + l_map['\r'] |= mask; + } + if(pnull) + *pnull |= mask; + return; + case syntax_element_endmark: + // need to handle independent subs as a special case: + if(static_cast(state)->index < 0) + { + // can be null, any character can match: + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + else + { + state = state->next.p; + break; + } + + case syntax_element_startmark: + // need to handle independent subs as a special case: + if(static_cast(state)->index == -3) + { + state = state->next.p->next.p; + break; + } + // otherwise fall through: + default: + state = state->next.p; + } + ++not_last_jump; + } +} + +template +unsigned basic_regex_creator::get_restart_type(re_syntax_base* state) +{ + // + // find out how the machine starts, so we can optimise the search: + // + while(state) + { + switch(state->type) + { + case syntax_element_startmark: + case syntax_element_endmark: + state = state->next.p; + continue; + case syntax_element_start_line: + return regbase::restart_line; + case syntax_element_word_start: + return regbase::restart_word; + case syntax_element_buffer_start: + return regbase::restart_buf; + case syntax_element_restart_continue: + return regbase::restart_continue; + default: + state = 0; + continue; + } + } + return regbase::restart_any; +} + +template +void basic_regex_creator::set_all_masks(unsigned char* bits, unsigned char mask) +{ + // + // set mask in all of bits elements, + // if bits[0] has mask_init not set then we can + // optimise this to a call to memset: + // + if(bits) + { + if(bits[0] == 0) + (std::memset)(bits, mask, 1u << CHAR_BIT); + else + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + bits[i] |= mask; + } + bits[0] |= mask_init; + } +} + +template +bool basic_regex_creator::is_bad_repeat(re_syntax_base* pt) +{ + switch(pt->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + unsigned state_id = static_cast(pt)->state_id; + if(state_id > sizeof(m_bad_repeats) * CHAR_BIT) + return true; // run out of bits, assume we can't traverse this one. + static const boost::uintmax_t one = 1uL; + return m_bad_repeats & (one << state_id); + } + default: + return false; + } +} + +template +void basic_regex_creator::set_bad_repeat(re_syntax_base* pt) +{ + switch(pt->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + unsigned state_id = static_cast(pt)->state_id; + static const boost::uintmax_t one = 1uL; + if(state_id <= sizeof(m_bad_repeats) * CHAR_BIT) + m_bad_repeats |= (one << state_id); + } + default: + break; + } +} + +template +syntax_element_type basic_regex_creator::get_repeat_type(re_syntax_base* state) +{ + typedef typename traits::char_class_type mask_type; + if(state->type == syntax_element_rep) + { + // check to see if we are repeating a single state: + if(state->next.p->next.p->next.p == static_cast(state)->alt.p) + { + switch(state->next.p->type) + { + case re_detail::syntax_element_wild: + return re_detail::syntax_element_dot_rep; + case re_detail::syntax_element_literal: + return re_detail::syntax_element_char_rep; + case re_detail::syntax_element_set: + return re_detail::syntax_element_short_set_rep; + case re_detail::syntax_element_long_set: + if(static_cast*>(state->next.p)->singleton) + return re_detail::syntax_element_long_set_rep; + break; + default: + break; + } + } + } + return state->type; +} + +template +void basic_regex_creator::probe_leading_repeat(re_syntax_base* state) +{ + // enumerate our states, and see if we have a leading repeat + // for which failed search restarts can be optimised; + do + { + switch(state->type) + { + case syntax_element_startmark: + if(static_cast(state)->index >= 0) + { + state = state->next.p; + continue; + } + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + { + // skip past the zero width assertion: + state = static_cast(state->next.p)->alt.p->next.p; + continue; + } + if(static_cast(state)->index == -3) + { + // Have to skip the leading jump state: + state = state->next.p->next.p; + continue; + } + return; + case syntax_element_endmark: + case syntax_element_start_line: + case syntax_element_end_line: + case syntax_element_word_boundary: + case syntax_element_within_word: + case syntax_element_word_start: + case syntax_element_word_end: + case syntax_element_buffer_start: + case syntax_element_buffer_end: + case syntax_element_restart_continue: + state = state->next.p; + break; + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + if(this->m_has_backrefs == 0) + static_cast(state)->leading = true; + // fall through: + default: + return; + } + }while(state); +} + + +} // namespace re_detail + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_parser.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_parser.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,2140 @@ +/* + * + * 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 basic_regex_parser.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_parser. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4244 4800) +#endif + +template +class basic_regex_parser : public basic_regex_creator +{ +public: + basic_regex_parser(regex_data* data); + void parse(const charT* p1, const charT* p2, unsigned flags); + void fail(regex_constants::error_type error_code, std::ptrdiff_t position); + + bool parse_all(); + bool parse_basic(); + bool parse_extended(); + bool parse_literal(); + bool parse_open_paren(); + bool parse_basic_escape(); + bool parse_extended_escape(); + bool parse_match_any(); + bool parse_repeat(std::size_t low = 0, std::size_t high = (std::numeric_limits::max)()); + bool parse_repeat_range(bool isbasic); + bool parse_alt(); + bool parse_set(); + bool parse_backref(); + void parse_set_literal(basic_char_set& char_set); + bool parse_inner_set(basic_char_set& char_set); + bool parse_QE(); + bool parse_perl_extension(); + bool add_emacs_code(bool negate); + bool unwind_alts(std::ptrdiff_t last_paren_start); + digraph get_next_set_literal(basic_char_set& char_set); + charT unescape_character(); + regex_constants::syntax_option_type parse_options(); + +private: + typedef bool (basic_regex_parser::*parser_proc_type)(); + typedef typename traits::string_type string_type; + typedef typename traits::char_class_type char_class_type; + parser_proc_type m_parser_proc; // the main parser to use + const charT* m_base; // the start of the string being parsed + const charT* m_end; // the end of the string being parsed + const charT* m_position; // our current parser position + unsigned m_mark_count; // how many sub-expressions we have + std::ptrdiff_t m_paren_start; // where the last seen ')' began (where repeats are inserted). + std::ptrdiff_t m_alt_insert_point; // where to insert the next alternative + bool m_has_case_change; // true if somewhere in the current block the case has changed +#if defined(BOOST_MSVC) && defined(_M_IX86) + // This is an ugly warning suppression workaround (for warnings *inside* std::vector + // that can not otherwise be suppressed)... + BOOST_STATIC_ASSERT(sizeof(long) >= sizeof(void*)); + std::vector m_alt_jumps; // list of alternative in the current scope. +#else + std::vector m_alt_jumps; // list of alternative in the current scope. +#endif + + basic_regex_parser& operator=(const basic_regex_parser&); + basic_regex_parser(const basic_regex_parser&); +}; + +template +basic_regex_parser::basic_regex_parser(regex_data* data) + : basic_regex_creator(data), m_mark_count(0), m_paren_start(0), m_alt_insert_point(0), m_has_case_change(false) +{ +} + +template +void basic_regex_parser::parse(const charT* p1, const charT* p2, unsigned l_flags) +{ + // pass l_flags on to base class: + this->init(l_flags); + // set up pointers: + m_position = m_base = p1; + m_end = p2; + // empty strings are errors: + if((p1 == p2) && + ( + ((l_flags & regbase::main_option_type) != regbase::perl_syntax_group) + || (l_flags & regbase::no_empty_expressions) + ) + ) + { + fail(regex_constants::error_empty, 0); + return; + } + // select which parser to use: + switch(l_flags & regbase::main_option_type) + { + case regbase::perl_syntax_group: + m_parser_proc = &basic_regex_parser::parse_extended; + break; + case regbase::basic_syntax_group: + m_parser_proc = &basic_regex_parser::parse_basic; + break; + case regbase::literal: + m_parser_proc = &basic_regex_parser::parse_literal; + break; + } + + // parse all our characters: + bool result = parse_all(); + // + // Unwind our alternatives: + // + unwind_alts(-1); + // reset l_flags as a global scope (?imsx) may have altered them: + this->flags(l_flags); + // if we haven't gobbled up all the characters then we must + // have had an unexpected ')' : + if(!result) + { + fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_position)); + return; + } + // if an error has been set then give up now: + if(this->m_pdata->m_status) + return; + // fill in our sub-expression count: + this->m_pdata->m_mark_count = 1 + m_mark_count; + this->finalize(p1, p2); +} + +template +void basic_regex_parser::fail(regex_constants::error_type error_code, std::ptrdiff_t position) +{ + if(0 == this->m_pdata->m_status) // update the error code if not already set + this->m_pdata->m_status = error_code; + m_position = m_end; // don't bother parsing anything else + // get the error message: + std::string message = this->m_pdata->m_ptraits->error_string(error_code); + // and raise the exception, this will do nothing if exceptions are disabled: +#ifndef BOOST_NO_EXCEPTIONS + if(0 == (this->flags() & regex_constants::no_except)) + { + boost::regex_error e(message, error_code, position); + e.raise(); + } +#else + (void)position; // suppress warnings. +#endif +} + +template +bool basic_regex_parser::parse_all() +{ + bool result = true; + while(result && (m_position != m_end)) + { + result = (this->*m_parser_proc)(); + } + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4702) +#endif +template +bool basic_regex_parser::parse_basic() +{ + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_escape: + return parse_basic_escape(); + case regex_constants::syntax_dot: + return parse_match_any(); + case regex_constants::syntax_caret: + ++m_position; + this->append_state(syntax_element_start_line); + break; + case regex_constants::syntax_dollar: + ++m_position; + this->append_state(syntax_element_end_line); + break; + case regex_constants::syntax_star: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(); + } + case regex_constants::syntax_plus: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line) || !(this->flags() & regbase::emacs_ex)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(1); + } + case regex_constants::syntax_question: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line) || !(this->flags() & regbase::emacs_ex)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(0, 1); + } + case regex_constants::syntax_open_set: + return parse_set(); + case regex_constants::syntax_newline: + if(this->flags() & regbase::newline_alt) + return parse_alt(); + else + return parse_literal(); + default: + return parse_literal(); + } + return true; +} + +template +bool basic_regex_parser::parse_extended() +{ + bool result = true; + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_open_mark: + return parse_open_paren(); + case regex_constants::syntax_close_mark: + return false; + case regex_constants::syntax_escape: + return parse_extended_escape(); + case regex_constants::syntax_dot: + return parse_match_any(); + case regex_constants::syntax_caret: + ++m_position; + this->append_state( + (this->flags() & regex_constants::no_mod_m ? syntax_element_buffer_start : syntax_element_start_line)); + break; + case regex_constants::syntax_dollar: + ++m_position; + this->append_state( + (this->flags() & regex_constants::no_mod_m ? syntax_element_buffer_end : syntax_element_end_line)); + break; + case regex_constants::syntax_star: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(); + case regex_constants::syntax_question: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(0,1); + case regex_constants::syntax_plus: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(1); + case regex_constants::syntax_open_brace: + ++m_position; + return parse_repeat_range(false); + case regex_constants::syntax_close_brace: + fail(regex_constants::error_brace, this->m_position - this->m_end); + return false; + case regex_constants::syntax_or: + return parse_alt(); + case regex_constants::syntax_open_set: + return parse_set(); + case regex_constants::syntax_newline: + if(this->flags() & regbase::newline_alt) + return parse_alt(); + else + return parse_literal(); + case regex_constants::syntax_hash: + // + // If we have a mod_x flag set, then skip until + // we get to a newline character: + // + if((this->flags() + & (regbase::no_perl_ex|regbase::mod_x)) + == regbase::mod_x) + { + while((m_position != m_end) && !is_separator(*m_position++)){} + return true; + } + // Otherwise fall through: + default: + result = parse_literal(); + break; + } + return result; +} +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +bool basic_regex_parser::parse_literal() +{ + // append this as a literal provided it's not a space character + // or the perl option regbase::mod_x is not set: + if( + ((this->flags() + & (regbase::main_option_type|regbase::mod_x|regbase::no_perl_ex)) + != regbase::mod_x) + || !this->m_traits.isctype(*m_position, this->m_mask_space)) + this->append_literal(*m_position); + ++m_position; + return true; +} + +template +bool basic_regex_parser::parse_open_paren() +{ + // + // skip the '(' and error check: + // + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + // + // begin by checking for a perl-style (?...) extension: + // + if( + ((this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) == 0) + || ((this->flags() & (regbase::main_option_type | regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) + ) + { + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_question) + return parse_perl_extension(); + } + // + // update our mark count, and append the required state: + // + unsigned markid = 0; + if(0 == (this->flags() & regbase::nosubs)) + { + markid = ++m_mark_count; + if(this->flags() & regbase::save_subexpression_location) + this->m_pdata->m_subs.push_back(std::pair(std::distance(m_base, m_position) - 1, 0)); + } + re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); + pb->index = markid; + std::ptrdiff_t last_paren_start = this->getoffset(pb); + // back up insertion point for alternations, and set new point: + std::ptrdiff_t last_alt_point = m_alt_insert_point; + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + // + // back up the current flags in case we have a nested (?imsx) group: + // + regex_constants::syntax_option_type opts = this->flags(); + bool old_case_change = m_has_case_change; + m_has_case_change = false; // no changes to this scope as yet... + // + // now recursively add more states, this will terminate when we get to a + // matching ')' : + // + parse_all(); + // + // Unwind pushed alternatives: + // + if(0 == unwind_alts(last_paren_start)) + return false; + // + // restore flags: + // + if(m_has_case_change) + { + // the case has changed in one or more of the alternatives + // within the scoped (...) block: we have to add a state + // to reset the case sensitivity: + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = opts & regbase::icase; + } + this->flags(opts); + m_has_case_change = old_case_change; + // + // we either have a ')' or we have run out of characters prematurely: + // + if(m_position == m_end) + { + this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); + return false; + } + BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + if(markid && (this->flags() & regbase::save_subexpression_location)) + this->m_pdata->m_subs.at(markid - 1).second = std::distance(m_base, m_position); + ++m_position; + // + // append closing parenthesis state: + // + pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); + pb->index = markid; + this->m_paren_start = last_paren_start; + // + // restore the alternate insertion point: + // + this->m_alt_insert_point = last_alt_point; + // + // allow backrefs to this mark: + // + if((markid > 0) && (markid < sizeof(unsigned) * CHAR_BIT)) + this->m_backrefs |= 1u << (markid - 1); + + return true; +} + +template +bool basic_regex_parser::parse_basic_escape() +{ + ++m_position; + bool result = true; + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::syntax_open_mark: + return parse_open_paren(); + case regex_constants::syntax_close_mark: + return false; + case regex_constants::syntax_plus: + if(this->flags() & regex_constants::bk_plus_qm) + { + ++m_position; + return parse_repeat(1); + } + else + return parse_literal(); + case regex_constants::syntax_question: + if(this->flags() & regex_constants::bk_plus_qm) + { + ++m_position; + return parse_repeat(0, 1); + } + else + return parse_literal(); + case regex_constants::syntax_open_brace: + if(this->flags() & regbase::no_intervals) + return parse_literal(); + ++m_position; + return parse_repeat_range(true); + case regex_constants::syntax_close_brace: + if(this->flags() & regbase::no_intervals) + return parse_literal(); + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + case regex_constants::syntax_or: + if(this->flags() & regbase::bk_vbar) + return parse_alt(); + else + result = parse_literal(); + break; + case regex_constants::syntax_digit: + return parse_backref(); + case regex_constants::escape_type_start_buffer: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_buffer_start); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_end_buffer: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_buffer_end); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_word_assert: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_boundary); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_not_word_assert: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_within_word); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_left_word: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_start); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_right_word: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_end); + } + else + result = parse_literal(); + break; + default: + if(this->flags() & regbase::emacs_ex) + { + bool negate = true; + switch(*m_position) + { + case 'w': + negate = false; + // fall through: + case 'W': + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(this->m_word_mask); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; + } + case 's': + negate = false; + // fall through: + case 'S': + return add_emacs_code(negate); + case 'c': + case 'C': + // not supported yet: + fail(regex_constants::error_escape, m_position - m_base); + return false; + default: + break; + } + } + result = parse_literal(); + break; + } + return result; +} + +template +bool basic_regex_parser::parse_extended_escape() +{ + ++m_position; + bool negate = false; // in case this is a character class escape: \w \d etc + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::escape_type_not_class: + negate = true; + // fall through: + case regex_constants::escape_type_class: + { + typedef typename traits::char_class_type mask_type; + mask_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(m); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; + } + // + // not a class, just a regular unknown escape: + // + this->append_literal(unescape_character()); + break; + } + case regex_constants::syntax_digit: + return parse_backref(); + case regex_constants::escape_type_left_word: + ++m_position; + this->append_state(syntax_element_word_start); + break; + case regex_constants::escape_type_right_word: + ++m_position; + this->append_state(syntax_element_word_end); + break; + case regex_constants::escape_type_start_buffer: + ++m_position; + this->append_state(syntax_element_buffer_start); + break; + case regex_constants::escape_type_end_buffer: + ++m_position; + this->append_state(syntax_element_buffer_end); + break; + case regex_constants::escape_type_word_assert: + ++m_position; + this->append_state(syntax_element_word_boundary); + break; + case regex_constants::escape_type_not_word_assert: + ++m_position; + this->append_state(syntax_element_within_word); + break; + case regex_constants::escape_type_Z: + ++m_position; + this->append_state(syntax_element_soft_buffer_end); + break; + case regex_constants::escape_type_Q: + return parse_QE(); + case regex_constants::escape_type_C: + return parse_match_any(); + case regex_constants::escape_type_X: + ++m_position; + this->append_state(syntax_element_combining); + break; + case regex_constants::escape_type_G: + ++m_position; + this->append_state(syntax_element_restart_continue); + break; + case regex_constants::escape_type_not_property: + negate = true; + // fall through: + case regex_constants::escape_type_property: + { + ++m_position; + char_class_type m; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // maybe have \p{ddd} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + const charT* base = m_position; + // skip forward until we find enclosing brace: + while((m_position != m_end) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + m = this->m_traits.lookup_classname(++base, m_position++); + } + else + { + m = this->m_traits.lookup_classname(m_position, m_position+1); + ++m_position; + } + if(m != 0) + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(m); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + return true; + } + fail(regex_constants::error_ctype, m_position - m_base); + } + default: + this->append_literal(unescape_character()); + break; + } + return true; +} + +template +bool basic_regex_parser::parse_match_any() +{ + // + // we have a '.' that can match any character: + // + ++m_position; + static_cast( + this->append_state(syntax_element_wild, sizeof(re_dot)) + )->mask = static_cast(this->flags() & regbase::no_mod_s + ? re_detail::force_not_newline + : this->flags() & regbase::mod_s ? + re_detail::force_newline : re_detail::dont_care); + return true; +} + +template +bool basic_regex_parser::parse_repeat(std::size_t low, std::size_t high) +{ + bool greedy = true; + std::size_t insert_point; + // + // when we get to here we may have a non-greedy ? mark still to come: + // + if((m_position != m_end) + && ( + (0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex))) + || ((regbase::basic_syntax_group|regbase::emacs_ex) == (this->flags() & (regbase::main_option_type | regbase::emacs_ex))) + ) + ) + { + // OK we have a perl regex, check for a '?': + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_question) + { + greedy = false; + ++m_position; + } + } + if(0 == this->m_last_state) + { + fail(regex_constants::error_badrepeat, ::boost::re_detail::distance(m_base, m_position)); + return false; + } + if(this->m_last_state->type == syntax_element_endmark) + { + // insert a repeat before the '(' matching the last ')': + insert_point = this->m_paren_start; + } + else if((this->m_last_state->type == syntax_element_literal) && (static_cast(this->m_last_state)->length > 1)) + { + // the last state was a literal with more than one character, split it in two: + re_literal* lit = static_cast(this->m_last_state); + charT c = (static_cast(static_cast(lit+1)))[lit->length - 1]; + --(lit->length); + // now append new state: + lit = static_cast(this->append_state(syntax_element_literal, sizeof(re_literal) + sizeof(charT))); + lit->length = 1; + (static_cast(static_cast(lit+1)))[0] = c; + insert_point = this->getoffset(this->m_last_state); + } + else + { + // repeat the last state whatever it was, need to add some error checking here: + switch(this->m_last_state->type) + { + case syntax_element_start_line: + case syntax_element_end_line: + case syntax_element_word_boundary: + case syntax_element_within_word: + case syntax_element_word_start: + case syntax_element_word_end: + case syntax_element_buffer_start: + case syntax_element_buffer_end: + case syntax_element_alt: + case syntax_element_soft_buffer_end: + case syntax_element_restart_continue: + case syntax_element_jump: + case syntax_element_startmark: + case syntax_element_backstep: + // can't legally repeat any of the above: + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + default: + // do nothing... + break; + } + insert_point = this->getoffset(this->m_last_state); + } + // + // OK we now know what to repeat, so insert the repeat around it: + // + re_repeat* rep = static_cast(this->insert_state(insert_point, syntax_element_rep, re_repeater_size)); + rep->min = low; + rep->max = high; + rep->greedy = greedy; + rep->leading = false; + // store our repeater position for later: + std::ptrdiff_t rep_off = this->getoffset(rep); + // and append a back jump to the repeat: + re_jump* jmp = static_cast(this->append_state(syntax_element_jump, sizeof(re_jump))); + jmp->alt.i = rep_off - this->getoffset(jmp); + this->m_pdata->m_data.align(); + // now fill in the alt jump for the repeat: + rep = static_cast(this->getaddress(rep_off)); + rep->alt.i = this->m_pdata->m_data.size() - rep_off; + return true; +} + +template +bool basic_regex_parser::parse_repeat_range(bool isbasic) +{ + // + // parse a repeat-range: + // + std::size_t min, max; + int v; + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + // fail if at end: + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + // get min: + v = this->m_traits.toi(m_position, m_end, 10); + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + if(v < 0) + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + else if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + min = v; + // see if we have a comma: + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_comma) + { + // move on and error check: + ++m_position; + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + // get the value if any: + v = this->m_traits.toi(m_position, m_end, 10); + max = (v >= 0) ? v : (std::numeric_limits::max)(); + } + else + { + // no comma, max = min: + max = min; + } + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + // OK now check trailing }: + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + if(isbasic) + { + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_escape) + { + ++m_position; + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + } + else + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_brace) + ++m_position; + else + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + // + // finally go and add the repeat, unless error: + // + if(min > max) + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + return parse_repeat(min, max); +} + +template +bool basic_regex_parser::parse_alt() +{ + // + // error check: if there have been no previous states, + // or if the last state was a '(' then error: + // + if( + ((this->m_last_state == 0) || (this->m_last_state->type == syntax_element_startmark)) + && + !( + ((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) + && + ((this->flags() & regbase::no_empty_expressions) == 0) + ) + ) + { + fail(regex_constants::error_empty, this->m_position - this->m_base); + return false; + } + ++m_position; + // + // we need to append a trailing jump: + // + re_syntax_base* pj = this->append_state(re_detail::syntax_element_jump, sizeof(re_jump)); + std::ptrdiff_t jump_offset = this->getoffset(pj); + // + // now insert the alternative: + // + re_alt* palt = static_cast(this->insert_state(this->m_alt_insert_point, syntax_element_alt, re_alt_size)); + jump_offset += re_alt_size; + this->m_pdata->m_data.align(); + palt->alt.i = this->m_pdata->m_data.size() - this->getoffset(palt); + // + // update m_alt_insert_point so that the next alternate gets + // inserted at the start of the second of the two we've just created: + // + this->m_alt_insert_point = this->m_pdata->m_data.size(); + // + // the start of this alternative must have a case changes state + // if the current block has messed around with case changes: + // + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = this->m_icase; + } + // + // push the alternative onto our stack, a recursive + // implementation here is easier to understand (and faster + // as it happens), but causes all kinds of stack overflow problems + // on programs with small stacks (COM+). + // + m_alt_jumps.push_back(jump_offset); + return true; +} + +template +bool basic_regex_parser::parse_set() +{ + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + basic_char_set char_set; + + const charT* base = m_position; // where the '[' was + const charT* item_base = m_position; // where the '[' or '^' was + + while(m_position != m_end) + { + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_caret: + if(m_position == base) + { + char_set.negate(); + ++m_position; + item_base = m_position; + } + else + parse_set_literal(char_set); + break; + case regex_constants::syntax_close_set: + if(m_position == item_base) + { + parse_set_literal(char_set); + break; + } + else + { + ++m_position; + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_range, m_position - m_base); + return false; + } + } + return true; + case regex_constants::syntax_open_set: + if(parse_inner_set(char_set)) + break; + return true; + case regex_constants::syntax_escape: + { + // + // look ahead and see if this is a character class shortcut + // \d \w \s etc... + // + ++m_position; + if(this->m_traits.escape_syntax_type(*m_position) + == regex_constants::escape_type_class) + { + char_class_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + char_set.add_class(m); + ++m_position; + break; + } + } + else if(this->m_traits.escape_syntax_type(*m_position) + == regex_constants::escape_type_not_class) + { + // negated character class: + char_class_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + char_set.add_negated_class(m); + ++m_position; + break; + } + } + // not a character class, just a regular escape: + --m_position; + parse_set_literal(char_set); + break; + } + default: + parse_set_literal(char_set); + break; + } + } + return m_position != m_end; +} + +template +bool basic_regex_parser::parse_inner_set(basic_char_set& char_set) +{ + // + // we have either a character class [:name:] + // a collating element [.name.] + // or an equivalence class [=name=] + // + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_dot: + // + // a collating element is treated as a literal: + // + --m_position; + parse_set_literal(char_set); + return true; + case regex_constants::syntax_colon: + { + // check that character classes are actually enabled: + if((this->flags() & (regbase::main_option_type | regbase::no_char_classes)) + == (regbase::basic_syntax_group | regbase::no_char_classes)) + { + --m_position; + parse_set_literal(char_set); + return true; + } + // skip the ':' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching ':]' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_colon)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + // + // check for negated class: + // + bool negated = false; + if(this->m_traits.syntax_type(*name_first) == regex_constants::syntax_caret) + { + ++name_first; + negated = true; + } + typedef typename traits::char_class_type mask_type; + mask_type m = this->m_traits.lookup_classname(name_first, name_last); + if(m == 0) + { + if(char_set.empty() && (name_last - name_first == 1)) + { + // maybe a special case: + ++m_position; + if( (m_position != m_end) + && (this->m_traits.syntax_type(*m_position) + == regex_constants::syntax_close_set)) + { + if(this->m_traits.escape_syntax_type(*name_first) + == regex_constants::escape_type_left_word) + { + ++m_position; + this->append_state(syntax_element_word_start); + return false; + } + if(this->m_traits.escape_syntax_type(*name_first) + == regex_constants::escape_type_right_word) + { + ++m_position; + this->append_state(syntax_element_word_end); + return false; + } + } + } + fail(regex_constants::error_ctype, name_first - m_base); + return false; + } + if(negated == false) + char_set.add_class(m); + else + char_set.add_negated_class(m); + ++m_position; + break; + } + case regex_constants::syntax_equal: + { + // skip the '=' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching '=]' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + string_type m = this->m_traits.lookup_collatename(name_first, name_last); + if((0 == m.size()) || (m.size() > 2)) + { + fail(regex_constants::error_collate, name_first - m_base); + return false; + } + digraph d; + d.first = m[0]; + if(m.size() > 1) + d.second = m[1]; + else + d.second = 0; + char_set.add_equivalent(d); + ++m_position; + break; + } + default: + --m_position; + parse_set_literal(char_set); + break; + } + return true; +} + +template +void basic_regex_parser::parse_set_literal(basic_char_set& char_set) +{ + digraph start_range(get_next_set_literal(char_set)); + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash) + { + // we have a range: + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set) + { + digraph end_range = get_next_set_literal(char_set); + char_set.add_range(start_range, end_range); + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash) + { + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_set) + { + // trailing - : + --m_position; + return; + } + fail(regex_constants::error_range, m_position - m_base); + return; + } + return; + } + --m_position; + } + char_set.add_single(start_range); +} + +template +digraph basic_regex_parser::get_next_set_literal(basic_char_set& char_set) +{ + digraph result; + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_dash: + if(!char_set.empty()) + { + // see if we are at the end of the set: + if((++m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_range, m_position - m_base); + return result; + } + --m_position; + } + result.first = *m_position++; + return result; + case regex_constants::syntax_escape: + // check to see if escapes are supported first: + if(this->flags() & regex_constants::no_escape_in_lists) + { + result = *m_position++; + break; + } + ++m_position; + result = unescape_character(); + break; + case regex_constants::syntax_open_set: + { + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, m_position - m_base); + return result; + } + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_dot) + { + --m_position; + result.first = *m_position; + ++m_position; + return result; + } + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, m_position - m_base); + return result; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching ':]' + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_dot)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + ++m_position; + string_type s = this->m_traits.lookup_collatename(name_first, name_last); + if(s.empty() || (s.size() > 2)) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + result.first = s[0]; + if(s.size() > 1) + result.second = s[1]; + else + result.second = 0; + return result; + } + default: + result = *m_position++; + } + return result; +} + +// +// does a value fit in the specified charT type? +// +template +bool valid_value(charT, int v, const mpl::true_&) +{ + return (v >> (sizeof(charT) * CHAR_BIT)) == 0; +} +template +bool valid_value(charT, int, const mpl::false_&) +{ + return true; // v will alsways fit in a charT +} +template +bool valid_value(charT c, int v) +{ + return valid_value(c, v, mpl::bool_<(sizeof(charT) < sizeof(int))>()); +} + +template +charT basic_regex_parser::unescape_character() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + charT result(0); + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::escape_type_control_a: + result = charT('\a'); + break; + case regex_constants::escape_type_e: + result = charT(27); + break; + case regex_constants::escape_type_control_f: + result = charT('\f'); + break; + case regex_constants::escape_type_control_n: + result = charT('\n'); + break; + case regex_constants::escape_type_control_r: + result = charT('\r'); + break; + case regex_constants::escape_type_control_t: + result = charT('\t'); + break; + case regex_constants::escape_type_control_v: + result = charT('\v'); + break; + case regex_constants::escape_type_word_assert: + result = charT('\b'); + break; + case regex_constants::escape_type_ascii_control: + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + /* + if((*m_position < charT('@')) + || (*m_position > charT(125)) ) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + */ + result = static_cast(*m_position % 32); + break; + case regex_constants::escape_type_hex: + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + // maybe have \x{ddd} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + int i = this->m_traits.toi(m_position, m_end, 16); + if((m_position == m_end) + || (i < 0) + || ((std::numeric_limits::is_specialized) && (charT(i) > (std::numeric_limits::max)())) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + { + fail(regex_constants::error_badbrace, m_position - m_base); + return result; + } + ++m_position; + result = charT(i); + } + else + { + std::ptrdiff_t len = (std::min)(static_cast(2), m_end - m_position); + int i = this->m_traits.toi(m_position, m_position + len, 16); + if((i < 0) + || !valid_value(charT(0), i)) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + result = charT(i); + } + return result; + case regex_constants::syntax_digit: + { + // an octal escape sequence, the first character must be a zero + // followed by up to 3 octal digits: + std::ptrdiff_t len = (std::min)(::boost::re_detail::distance(m_position, m_end), static_cast(4)); + const charT* bp = m_position; + int val = this->m_traits.toi(bp, bp + 1, 8); + if(val != 0) + { + // Oops not an octal escape after all: + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + val = this->m_traits.toi(m_position, m_position + len, 8); + if(val < 0) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + return static_cast(val); + } + case regex_constants::escape_type_named_char: + { + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // maybe have \N{name} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + const charT* base = m_position; + // skip forward until we find enclosing brace: + while((m_position != m_end) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + string_type s = this->m_traits.lookup_collatename(++base, m_position++); + if(s.empty()) + { + fail(regex_constants::error_collate, m_position - m_base); + return false; + } + if(s.size() == 1) + { + return s[0]; + } + } + // fall through is a failure: + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + default: + result = *m_position; + break; + } + ++m_position; + return result; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool basic_regex_parser::parse_backref() +{ + BOOST_ASSERT(m_position != m_end); + const charT* pc = m_position; + int i = this->m_traits.toi(pc, pc + 1, 10); + if((i == 0) || (((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) && (this->flags() & regbase::no_bk_refs))) + { + // not a backref at all but an octal escape sequence: + charT c = unescape_character(); + this->append_literal(c); + } + else if((i > 0) && (this->m_backrefs & (1u << (i-1)))) + { + m_position = pc; + re_brace* pb = static_cast(this->append_state(syntax_element_backref, sizeof(re_brace))); + pb->index = i; + } + else + { + fail(regex_constants::error_backref, m_position - m_end); + return false; + } + return true; +} + +template +bool basic_regex_parser::parse_QE() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + // + // parse a \Q...\E sequence: + // + ++m_position; // skip the Q + const charT* start = m_position; + const charT* end; + do + { + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape)) + ++m_position; + if(m_position == m_end) + { + // a \Q...\E sequence may terminate with the end of the expression: + end = m_position; + break; + } + if(++m_position == m_end) // skip the escape + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // check to see if it's a \E: + if(this->m_traits.escape_syntax_type(*m_position) == regex_constants::escape_type_E) + { + ++m_position; + end = m_position - 2; + break; + } + // otherwise go round again: + }while(true); + // + // now add all the character between the two escapes as literals: + // + while(start != end) + { + this->append_literal(*start); + ++start; + } + return true; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool basic_regex_parser::parse_perl_extension() +{ + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + // + // treat comments as a special case, as these + // are the only ones that don't start with a leading + // startmark state: + // + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_hash) + { + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position++) != regex_constants::syntax_close_mark)) + {} + return true; + } + // + // backup some state, and prepare the way: + // + int markid = 0; + std::ptrdiff_t jump_offset = 0; + re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); + std::ptrdiff_t last_paren_start = this->getoffset(pb); + // back up insertion point for alternations, and set new point: + std::ptrdiff_t last_alt_point = m_alt_insert_point; + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + std::ptrdiff_t expected_alt_point = m_alt_insert_point; + bool restore_flags = true; + regex_constants::syntax_option_type old_flags = this->flags(); + bool old_case_change = m_has_case_change; + m_has_case_change = false; + // + // select the actual extension used: + // + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_colon: + // + // a non-capturing mark: + // + pb->index = markid = 0; + ++m_position; + break; + case regex_constants::syntax_equal: + pb->index = markid = -1; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::syntax_not: + pb->index = markid = -2; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::escape_type_left_word: + { + // a lookbehind assertion: + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + regex_constants::syntax_type t = this->m_traits.syntax_type(*m_position); + if(t == regex_constants::syntax_not) + pb->index = markid = -2; + else if(t == regex_constants::syntax_equal) + pb->index = markid = -1; + else + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->append_state(syntax_element_backstep, sizeof(re_brace)); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + } + case regex_constants::escape_type_right_word: + // + // an independent sub-expression: + // + pb->index = markid = -3; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::syntax_open_mark: + { + // a conditional expression: + pb->index = markid = -4; + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + int v = this->m_traits.toi(m_position, m_end, 10); + if(v > 0) + { + re_brace* br = static_cast(this->append_state(syntax_element_assert_backref, sizeof(re_brace))); + br->index = v; + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + } + else + { + // verify that we have a lookahead or lookbehind assert: + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_question) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::escape_type_left_word) + { + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + m_position -= 3; + } + else + { + if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + m_position -= 2; + } + } + break; + } + case regex_constants::syntax_close_mark: + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + default: + // + // lets assume that we have a (?imsx) group and try and parse it: + // + regex_constants::syntax_option_type opts = parse_options(); + if(m_position == m_end) + return false; + // make a note of whether we have a case change: + m_has_case_change = ((opts & regbase::icase) != (this->flags() & regbase::icase)); + pb->index = markid = 0; + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark) + { + // update flags and carry on as normal: + this->flags(opts); + restore_flags = false; + old_case_change |= m_has_case_change; // defer end of scope by one ')' + } + else if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_colon) + { + // update flags and carry on until the matching ')' is found: + this->flags(opts); + ++m_position; + } + else + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + + // finally append a case change state if we need it: + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = opts & regbase::icase; + } + + } + // + // now recursively add more states, this will terminate when we get to a + // matching ')' : + // + parse_all(); + // + // Unwind alternatives: + // + if(0 == unwind_alts(last_paren_start)) + return false; + // + // we either have a ')' or we have run out of characters prematurely: + // + if(m_position == m_end) + { + this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); + return false; + } + BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + ++m_position; + // + // restore the flags: + // + if(restore_flags) + { + // append a case change state if we need it: + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = old_flags & regbase::icase; + } + this->flags(old_flags); + } + // + // set up the jump pointer if we have one: + // + if(jump_offset) + { + this->m_pdata->m_data.align(); + re_jump* jmp = static_cast(this->getaddress(jump_offset)); + jmp->alt.i = this->m_pdata->m_data.size() - this->getoffset(jmp); + if(this->m_last_state == jmp) + { + // Oops... we didn't have anything inside the assertion: + fail(regex_constants::error_empty, m_position - m_base); + return false; + } + } + // + // verify that if this is conditional expression, that we do have + // an alternative, if not add one: + // + if(markid == -4) + { + re_syntax_base* b = this->getaddress(expected_alt_point); + // Make sure we have exactly one alternative following this state: + if(b->type != syntax_element_alt) + { + re_alt* alt = static_cast(this->insert_state(expected_alt_point, syntax_element_alt, sizeof(re_alt))); + alt->alt.i = this->m_pdata->m_data.size() - this->getoffset(alt); + } + else if(this->getaddress(static_cast(b)->alt.i, b)->type == syntax_element_alt) + { + fail(regex_constants::error_bad_pattern, m_position - m_base); + return false; + } + // check for invalid repetition of next state: + b = this->getaddress(expected_alt_point); + b = this->getaddress(static_cast(b)->next.i, b); + if((b->type != syntax_element_assert_backref) + && (b->type != syntax_element_startmark)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + } + // + // append closing parenthesis state: + // + pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); + pb->index = markid; + this->m_paren_start = last_paren_start; + // + // restore the alternate insertion point: + // + this->m_alt_insert_point = last_alt_point; + // + // and the case change data: + // + m_has_case_change = old_case_change; + return true; +} + +template +bool basic_regex_parser::add_emacs_code(bool negate) +{ + // + // parses an emacs style \sx or \Sx construct. + // + if(++m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + basic_char_set char_set; + if(negate) + char_set.negate(); + + static const charT s_punct[5] = { 'p', 'u', 'n', 'c', 't', }; + + switch(*m_position) + { + case 's': + case ' ': + char_set.add_class(this->m_mask_space); + break; + case 'w': + char_set.add_class(this->m_word_mask); + break; + case '_': + char_set.add_single(digraph(charT('$'))); + char_set.add_single(digraph(charT('&'))); + char_set.add_single(digraph(charT('*'))); + char_set.add_single(digraph(charT('+'))); + char_set.add_single(digraph(charT('-'))); + char_set.add_single(digraph(charT('_'))); + char_set.add_single(digraph(charT('<'))); + char_set.add_single(digraph(charT('>'))); + break; + case '.': + char_set.add_class(this->m_traits.lookup_classname(s_punct, s_punct+5)); + break; + case '(': + char_set.add_single(digraph(charT('('))); + char_set.add_single(digraph(charT('['))); + char_set.add_single(digraph(charT('{'))); + break; + case ')': + char_set.add_single(digraph(charT(')'))); + char_set.add_single(digraph(charT(']'))); + char_set.add_single(digraph(charT('}'))); + break; + case '"': + char_set.add_single(digraph(charT('"'))); + char_set.add_single(digraph(charT('\''))); + char_set.add_single(digraph(charT('`'))); + break; + case '\'': + char_set.add_single(digraph(charT('\''))); + char_set.add_single(digraph(charT(','))); + char_set.add_single(digraph(charT('#'))); + break; + case '<': + char_set.add_single(digraph(charT(';'))); + break; + case '>': + char_set.add_single(digraph(charT('\n'))); + char_set.add_single(digraph(charT('\f'))); + break; + default: + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; +} + +template +regex_constants::syntax_option_type basic_regex_parser::parse_options() +{ + // we have a (?imsx-imsx) group, convert it into a set of flags: + regex_constants::syntax_option_type f = this->flags(); + bool breakout = false; + do + { + switch(*m_position) + { + case 's': + f |= regex_constants::mod_s; + f &= ~regex_constants::no_mod_s; + break; + case 'm': + f &= ~regex_constants::no_mod_m; + break; + case 'i': + f |= regex_constants::icase; + break; + case 'x': + f |= regex_constants::mod_x; + break; + default: + breakout = true; + continue; + } + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + } + while(!breakout); + + if(*m_position == static_cast('-')) + { + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + do + { + switch(*m_position) + { + case 's': + f &= ~regex_constants::mod_s; + f |= regex_constants::no_mod_s; + break; + case 'm': + f |= regex_constants::no_mod_m; + break; + case 'i': + f &= ~regex_constants::icase; + break; + case 'x': + f &= ~regex_constants::mod_x; + break; + default: + breakout = true; + continue; + } + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + } + while(!breakout); + } + return f; +} + +template +bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_start) +{ + // + // If we didn't actually add any states after the last + // alternative then that's an error: + // + if((this->m_alt_insert_point == static_cast(this->m_pdata->m_data.size())) + && m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start) + && + !( + ((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) + && + ((this->flags() & regbase::no_empty_expressions) == 0) + ) + ) + { + fail(regex_constants::error_empty, this->m_position - this->m_base); + return false; + } + // + // Fix up our alternatives: + // + while(m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start)) + { + // + // fix up the jump to point to the end of the states + // that we've just added: + // + std::ptrdiff_t jump_offset = m_alt_jumps.back(); + m_alt_jumps.pop_back(); + this->m_pdata->m_data.align(); + re_jump* jmp = static_cast(this->getaddress(jump_offset)); + BOOST_ASSERT(jmp->type == syntax_element_jump); + jmp->alt.i = this->m_pdata->m_data.size() - jump_offset; + } + return true; +} + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/c_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/c_regex_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,211 @@ +/* + * + * 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.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class that wraps the global C locale. + */ + +#ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_C_REGEX_TRAITS_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif + +#include + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strlen; using ::tolower; +} +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +template +struct c_regex_traits; + +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef char char_type; + typedef std::size_t size_type; + typedef std::string string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::strlen)(p); + } + + char translate(char c) const + { + return c; + } + char translate_nocase(char c) const + { + return static_cast((std::tolower)(static_cast(c))); + } + + static string_type BOOST_REGEX_CALL transform(const char* p1, const char* p2); + static string_type BOOST_REGEX_CALL transform_primary(const char* p1, const char* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const char* p1, const char* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const char* p1, const char* p2); + + static bool BOOST_REGEX_CALL isctype(char, char_class_type); + static int BOOST_REGEX_CALL value(char, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#ifndef BOOST_NO_WREGEX +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef wchar_t char_type; + typedef std::size_t size_type; + typedef std::wstring string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::wcslen)(p); + } + + wchar_t translate(wchar_t c) const + { + return c; + } + wchar_t translate_nocase(wchar_t c) const + { + return (std::towlower)(c); + } + + static string_type BOOST_REGEX_CALL transform(const wchar_t* p1, const wchar_t* p2); + static string_type BOOST_REGEX_CALL transform_primary(const wchar_t* p1, const wchar_t* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const wchar_t* p1, const wchar_t* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const wchar_t* p1, const wchar_t* p2); + + static bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type); + static int BOOST_REGEX_CALL value(wchar_t, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +// +// Provide an unsigned short version as well, so the user can link to this +// no matter whether they build with /Zc:wchar_t or not (MSVC specific). +// +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef unsigned short char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::wcslen)((const wchar_t*)p); + } + + unsigned short translate(unsigned short c) const + { + return c; + } + unsigned short translate_nocase(unsigned short c) const + { + return (std::towlower)((wchar_t)c); + } + + static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2); + static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2); + + static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type); + static int BOOST_REGEX_CALL value(unsigned short, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#endif + +#endif // BOOST_NO_WREGEX + +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/char_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/char_regex_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,81 @@ +/* + * + * Copyright (c) 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 char_regex_traits.cpp + * VERSION see + * DESCRIPTION: Declares deprecated traits classes char_regex_traits<>. + */ + + +#ifndef BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP +#define BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +namespace deprecated{ +// +// class char_regex_traits_i +// provides case insensitive traits classes (deprecated): +template +class char_regex_traits_i : public regex_traits {}; + +template<> +class char_regex_traits_i : public regex_traits +{ +public: + typedef char char_type; + typedef unsigned char uchar_type; + typedef unsigned int size_type; + typedef regex_traits base_type; + +}; + +#ifndef BOOST_NO_WREGEX +template<> +class char_regex_traits_i : public regex_traits +{ +public: + typedef wchar_t char_type; + typedef unsigned short uchar_type; + typedef unsigned int size_type; + typedef regex_traits base_type; + +}; +#endif +} // namespace deprecated +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // include + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/cpp_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/cpp_regex_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,1062 @@ +/* + * + * 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.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class cpp_regex_traits. + */ + +#ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED + +#include + +#ifndef BOOST_NO_STD_LOCALE + +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifdef BOOST_HAS_THREADS +#include +#endif +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#include +#endif +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#include +#endif + +#include +#include +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4786) +#endif + +namespace boost{ + +// +// forward declaration is needed by some compilers: +// +template +class cpp_regex_traits; + +namespace re_detail{ + +// +// class parser_buf: +// acts as a stream buffer which wraps around a pair of pointers: +// +template > +class parser_buf : public ::std::basic_streambuf +{ + typedef ::std::basic_streambuf base_type; + typedef typename base_type::int_type int_type; + typedef typename base_type::char_type char_type; + typedef typename base_type::pos_type pos_type; + typedef ::std::streamsize streamsize; + typedef typename base_type::off_type off_type; +public: + parser_buf() : base_type() { setbuf(0, 0); } + const charT* getnext() { return this->gptr(); } +protected: + std::basic_streambuf* setbuf(char_type* s, streamsize n); + typename parser_buf::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which); + typename parser_buf::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which); +private: + parser_buf& operator=(const parser_buf&); + parser_buf(const parser_buf&); +}; + +template +std::basic_streambuf* +parser_buf::setbuf(char_type* s, streamsize n) +{ + this->setg(s, s, s + n); + return this; +} + +template +typename parser_buf::pos_type +parser_buf::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) +{ + if(which & ::std::ios_base::out) + return pos_type(off_type(-1)); + std::ptrdiff_t size = this->egptr() - this->eback(); + std::ptrdiff_t pos = this->gptr() - this->eback(); + charT* g = this->eback(); + switch(way) + { + case ::std::ios_base::beg: + if((off < 0) || (off > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + off, g + size); + break; + case ::std::ios_base::end: + if((off < 0) || (off > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + size - off, g + size); + break; + case ::std::ios_base::cur: + { + std::ptrdiff_t newpos = static_cast(pos + off); + if((newpos < 0) || (newpos > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + newpos, g + size); + break; + } + default: ; + } +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4244) +#endif + return static_cast(this->gptr() - this->eback()); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +typename parser_buf::pos_type +parser_buf::seekpos(pos_type sp, ::std::ios_base::openmode which) +{ + if(which & ::std::ios_base::out) + return pos_type(off_type(-1)); + off_type size = static_cast(this->egptr() - this->eback()); + charT* g = this->eback(); + if(off_type(sp) <= size) + { + this->setg(g, g + off_type(sp), g + size); + } + return pos_type(off_type(-1)); +} + +// +// class cpp_regex_traits_base: +// acts as a container for locale and the facets we are using. +// +template +struct cpp_regex_traits_base +{ + cpp_regex_traits_base(const std::locale& l) + { imbue(l); } + std::locale imbue(const std::locale& l); + + std::locale m_locale; + std::ctype const* m_pctype; +#ifndef BOOST_NO_STD_MESSAGES + std::messages const* m_pmessages; +#endif + std::collate const* m_pcollate; + + bool operator<(const cpp_regex_traits_base& b)const + { + if(m_pctype == b.m_pctype) + { +#ifndef BOOST_NO_STD_MESSAGES + if(m_pmessages == b.m_pmessages) + { + } + return m_pmessages < b.m_pmessages; +#else + return m_pcollate < b.m_pcollate; +#endif + } + return m_pctype < b.m_pctype; + } + bool operator==(const cpp_regex_traits_base& b)const + { + return (m_pctype == b.m_pctype) +#ifndef BOOST_NO_STD_MESSAGES + && (m_pmessages == b.m_pmessages) +#endif + && (m_pcollate == b.m_pcollate); + } +}; + +template +std::locale cpp_regex_traits_base::imbue(const std::locale& l) +{ + std::locale result(m_locale); + m_locale = l; + m_pctype = &BOOST_USE_FACET(std::ctype, l); +#ifndef BOOST_NO_STD_MESSAGES + m_pmessages = &BOOST_USE_FACET(std::messages, l); +#endif + m_pcollate = &BOOST_USE_FACET(std::collate, l); + return result; +} + +// +// class cpp_regex_traits_char_layer: +// implements methods that require specialisation for narrow characters: +// +template +class cpp_regex_traits_char_layer : public cpp_regex_traits_base +{ + typedef std::basic_string string_type; + typedef std::map map_type; + typedef typename map_type::const_iterator map_iterator_type; +public: + cpp_regex_traits_char_layer(const std::locale& l) + : cpp_regex_traits_base(l) + { + init(); + } + cpp_regex_traits_char_layer(const cpp_regex_traits_base& b) + : cpp_regex_traits_base(b) + { + init(); + } + void init(); + + regex_constants::syntax_type syntax_type(charT c)const + { + map_iterator_type i = m_char_map.find(c); + return ((i == m_char_map.end()) ? 0 : i->second); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + map_iterator_type i = m_char_map.find(c); + if(i == m_char_map.end()) + { + if(this->m_pctype->is(std::ctype_base::lower, c)) return regex_constants::escape_type_class; + if(this->m_pctype->is(std::ctype_base::upper, c)) return regex_constants::escape_type_not_class; + return 0; + } + return i->second; + } + +private: + string_type get_default_message(regex_constants::syntax_type); + // TODO: use a hash table when available! + map_type m_char_map; +}; + +template +void cpp_regex_traits_char_layer::init() +{ + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: +#ifndef BOOST_NO_STD_MESSAGES +#ifndef __IBMCPP__ + typename std::messages::catalog cat = static_cast::catalog>(-1); +#else + typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); +#endif + std::string cat_name(cpp_regex_traits::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_message(i)); + for(typename string_type::size_type j = 0; j < mss.size(); ++j) + { + m_char_map[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 i = 1; i < regex_constants::syntax_max; ++i) + { + const char* ptr = get_default_syntax(i); + while(ptr && *ptr) + { + m_char_map[this->m_pctype->widen(*ptr)] = i; + ++ptr; + } + } +#ifndef BOOST_NO_STD_MESSAGES + } +#endif +} + +template +typename cpp_regex_traits_char_layer::string_type + cpp_regex_traits_char_layer::get_default_message(regex_constants::syntax_type i) +{ + const char* ptr = get_default_syntax(i); + string_type result; + while(ptr && *ptr) + { + result.append(1, this->m_pctype->widen(*ptr)); + ++ptr; + } + return result; +} + +// +// specialised version for narrow characters: +// +template <> +class BOOST_REGEX_DECL cpp_regex_traits_char_layer : public cpp_regex_traits_base +{ + typedef std::string string_type; +public: + cpp_regex_traits_char_layer(const std::locale& l) + : cpp_regex_traits_base(l) + { + init(); + } + cpp_regex_traits_char_layer(const cpp_regex_traits_base& l) + : cpp_regex_traits_base(l) + { + init(); + } + + regex_constants::syntax_type syntax_type(char c)const + { + return m_char_map[static_cast(c)]; + } + regex_constants::escape_syntax_type escape_syntax_type(char c) const + { + return m_char_map[static_cast(c)]; + } + +private: + regex_constants::syntax_type m_char_map[1u << CHAR_BIT]; + void init(); +}; + +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +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 +}; + +#endif + +// +// class cpp_regex_traits_implementation: +// provides pimpl implementation for cpp_regex_traits. +// +template +class cpp_regex_traits_implementation : public cpp_regex_traits_char_layer +{ +public: + typedef typename cpp_regex_traits::char_class_type char_class_type; + typedef typename std::ctype::mask native_mask_type; +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + BOOST_STATIC_CONSTANT(char_class_type, mask_blank = 1u << 24); + BOOST_STATIC_CONSTANT(char_class_type, mask_word = 1u << 25); + BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 1u << 26); +#endif + + typedef std::basic_string string_type; + typedef charT char_type; + //cpp_regex_traits_implementation(); + cpp_regex_traits_implementation(const std::locale& l) + : cpp_regex_traits_char_layer(l) + { + init(); + } + cpp_regex_traits_implementation(const cpp_regex_traits_base& l) + : cpp_regex_traits_char_layer(l) + { + init(); + } + std::string error_string(regex_constants::error_type n) const + { + if(!m_error_strings.empty()) + { + std::map::const_iterator p = m_error_strings.find(n); + return (p == m_error_strings.end()) ? std::string(get_default_error_string(n)) : p->second; + } + return get_default_error_string(n); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + char_class_type result = lookup_classname_imp(p1, p2); + if(result == 0) + { + string_type temp(p1, p2); + this->m_pctype->tolower(&*temp.begin(), &*temp.begin() + temp.size()); + result = lookup_classname_imp(&*temp.begin(), &*temp.begin() + temp.size()); + } + return result; + } + string_type lookup_collatename(const charT* p1, const charT* p2) const; + string_type transform_primary(const charT* p1, const charT* p2) const; + string_type transform(const charT* p1, const charT* p2) const; +private: + std::map m_error_strings; // error messages indexed by numberic ID + std::map m_custom_class_names; // character class names + std::map m_custom_collate_names; // collating element names + unsigned m_collate_type; // the form of the collation string + charT m_collate_delim; // the collation group delimiter + // + // helpers: + // + char_class_type lookup_classname_imp(const charT* p1, const charT* p2) const; + void init(); +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +public: + bool isctype(charT c, char_class_type m)const; +#endif +}; + +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET +#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) + +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_blank; +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_word; +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_unicode; + +#endif +#endif + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform_primary(const charT* p1, const charT* p2) const +{ + // + // PRECONDITIONS: + // + // A bug in gcc 3.2 (and maybe other versions as well) treats + // p1 as a null terminated string, for efficiency reasons + // we work around this elsewhere, but just assert here that + // we adhere to gcc's (buggy) preconditions... + // + BOOST_ASSERT(*p2 == 0); + + string_type result; + // + // swallowing all exceptions here is a bad idea + // however at least one std lib will always throw + // std::bad_alloc for certain arguments... + // + try{ + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(m_collate_type) + { + case sort_C: + case sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: + { + result.assign(p1, p2); + this->m_pctype->tolower(&*result.begin(), &*result.begin() + result.size()); + result = this->m_pcollate->transform(&*result.begin(), &*result.begin() + result.size()); + break; + } + case sort_fixed: + { + // get a regular sort key, and then truncate it: + result.assign(this->m_pcollate->transform(p1, p2)); + result.erase(this->m_collate_delim); + break; + } + case sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result.assign(this->m_pcollate->transform(p1, p2)); + std::size_t i; + for(i = 0; i < result.size(); ++i) + { + if(result[i] == m_collate_delim) + break; + } + result.erase(i); + break; + } + }catch(...){} + while(result.size() && (charT(0) == *result.rbegin())) + result.erase(result.size() - 1); + if(result.empty()) + { + // character is ignorable at the primary level: + result = string_type(1, charT(0)); + } + return result; +} + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform(const charT* p1, const charT* p2) const +{ + // + // PRECONDITIONS: + // + // A bug in gcc 3.2 (and maybe other versions as well) treats + // p1 as a null terminated string, for efficiency reasons + // we work around this elsewhere, but just assert here that + // we adhere to gcc's (buggy) preconditions... + // + BOOST_ASSERT(*p2 == 0); + // + // swallowing all exceptions here is a bad idea + // however at least one std lib will always throw + // std::bad_alloc for certain arguments... + // + string_type result; + try{ + result = this->m_pcollate->transform(p1, p2); + // + // Borland's STLPort version returns a NULL-terminated + // string that has garbage at the end - each call to + // std::collate::transform returns a different string! + // So as a workaround, we'll truncate the string at the first NULL + // which _seems_ to work.... +#if BOOST_WORKAROUND(__BORLANDC__, < 0x580) + result.erase(result.find(charT(0))); +#else + // + // some implementations (Dinkumware) append unnecessary trailing \0's: + while(result.size() && (charT(0) == *result.rbegin())) + result.erase(result.size() - 1); +#endif + BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end()); + } + catch(...) + { + } + return result; +} + + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::lookup_collatename(const charT* p1, const charT* p2) const +{ + typedef typename std::map::const_iterator iter_type; + if(m_custom_collate_names.size()) + { + iter_type pos = m_custom_collate_names.find(string_type(p1, p2)); + if(pos != m_custom_collate_names.end()) + return pos->second; + } +#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 charT* p0 = p1; + while(p0 != p2) + name.append(1, char(*p0++)); +#endif + name = 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, charT(*b++)); + return result; + } +#endif + if(p2 - p1 == 1) + return string_type(1, *p1); + return string_type(); +} + +template +void cpp_regex_traits_implementation::init() +{ +#ifndef BOOST_NO_STD_MESSAGES +#ifndef __IBMCPP__ + typename std::messages::catalog cat = static_cast::catalog>(-1); +#else + typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); +#endif + std::string cat_name(cpp_regex_traits::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) + { + // + // Error messages: + // + for(boost::regex_constants::error_type i = static_cast(0); + i <= boost::regex_constants::error_unknown; + i = static_cast(i + 1)) + { + const char* p = get_default_error_string(i); + string_type default_message; + while(*p) + { + default_message.append(1, this->m_pctype->widen(*p)); + ++p; + } + string_type s = this->m_pmessages->get(cat, 0, i+200, default_message); + std::string result; + for(std::string::size_type j = 0; j < s.size(); ++j) + { + result.append(1, this->m_pctype->narrow(s[j], 0)); + } + m_error_strings[i] = result; + } + // + // Custom class names: + // +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + static const char_class_type masks[14] = + { + std::ctype::alnum, + std::ctype::alpha, + std::ctype::cntrl, + std::ctype::digit, + std::ctype::graph, + std::ctype::lower, + std::ctype::print, + std::ctype::punct, + std::ctype::space, + std::ctype::upper, + std::ctype::xdigit, + cpp_regex_traits_implementation::mask_blank, + cpp_regex_traits_implementation::mask_word, + cpp_regex_traits_implementation::mask_unicode, + }; +#else + static const char_class_type masks[14] = + { + ::boost::re_detail::char_class_alnum, + ::boost::re_detail::char_class_alpha, + ::boost::re_detail::char_class_cntrl, + ::boost::re_detail::char_class_digit, + ::boost::re_detail::char_class_graph, + ::boost::re_detail::char_class_lower, + ::boost::re_detail::char_class_print, + ::boost::re_detail::char_class_punct, + ::boost::re_detail::char_class_space, + ::boost::re_detail::char_class_upper, + ::boost::re_detail::char_class_xdigit, + ::boost::re_detail::char_class_blank, + ::boost::re_detail::char_class_word, + ::boost::re_detail::char_class_unicode, + }; +#endif + static const string_type null_string; + for(unsigned int j = 0; j <= 13; ++j) + { + string_type s(this->m_pmessages->get(cat, 0, j+300, null_string)); + if(s.size()) + this->m_custom_class_names[s] = masks[j]; + } + } +#endif + // + // get the collation format used by m_pcollate: + // + m_collate_type = re_detail::find_sort_syntax(this, &m_collate_delim); +} + +template +typename cpp_regex_traits_implementation::char_class_type + cpp_regex_traits_implementation::lookup_classname_imp(const charT* p1, const charT* p2) const +{ +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + static const char_class_type masks[20] = + { + 0, + std::ctype::alnum, + std::ctype::alpha, + cpp_regex_traits_implementation::mask_blank, + std::ctype::cntrl, + std::ctype::digit, + std::ctype::digit, + std::ctype::graph, + std::ctype::lower, + std::ctype::lower, + std::ctype::print, + std::ctype::punct, + std::ctype::space, + std::ctype::space, + std::ctype::upper, + cpp_regex_traits_implementation::mask_unicode, + std::ctype::upper, + std::ctype::alnum | cpp_regex_traits_implementation::mask_word, + std::ctype::alnum | cpp_regex_traits_implementation::mask_word, + std::ctype::xdigit, + }; +#else + static const char_class_type masks[20] = + { + 0, + ::boost::re_detail::char_class_alnum, + ::boost::re_detail::char_class_alpha, + ::boost::re_detail::char_class_blank, + ::boost::re_detail::char_class_cntrl, + ::boost::re_detail::char_class_digit, + ::boost::re_detail::char_class_digit, + ::boost::re_detail::char_class_graph, + ::boost::re_detail::char_class_lower, + ::boost::re_detail::char_class_lower, + ::boost::re_detail::char_class_print, + ::boost::re_detail::char_class_punct, + ::boost::re_detail::char_class_space, + ::boost::re_detail::char_class_space, + ::boost::re_detail::char_class_upper, + ::boost::re_detail::char_class_unicode, + ::boost::re_detail::char_class_upper, + ::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word, + ::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word, + ::boost::re_detail::char_class_xdigit, + }; +#endif + if(m_custom_class_names.size()) + { + typedef typename std::map, char_class_type>::const_iterator map_iter; + map_iter pos = m_custom_class_names.find(string_type(p1, p2)); + if(pos != m_custom_class_names.end()) + return pos->second; + } + std::size_t state_id = 1 + re_detail::get_default_class_id(p1, p2); + BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0])); + return masks[state_id]; +} + +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +template +bool cpp_regex_traits_implementation::isctype(const charT c, char_class_type mask) const +{ + return + ((mask & ::boost::re_detail::char_class_space) && (m_pctype->is(std::ctype::space, c))) + || ((mask & ::boost::re_detail::char_class_print) && (m_pctype->is(std::ctype::print, c))) + || ((mask & ::boost::re_detail::char_class_cntrl) && (m_pctype->is(std::ctype::cntrl, c))) + || ((mask & ::boost::re_detail::char_class_upper) && (m_pctype->is(std::ctype::upper, c))) + || ((mask & ::boost::re_detail::char_class_lower) && (m_pctype->is(std::ctype::lower, c))) + || ((mask & ::boost::re_detail::char_class_alpha) && (m_pctype->is(std::ctype::alpha, c))) + || ((mask & ::boost::re_detail::char_class_digit) && (m_pctype->is(std::ctype::digit, c))) + || ((mask & ::boost::re_detail::char_class_punct) && (m_pctype->is(std::ctype::punct, c))) + || ((mask & ::boost::re_detail::char_class_xdigit) && (m_pctype->is(std::ctype::xdigit, c))) + || ((mask & ::boost::re_detail::char_class_blank) && (m_pctype->is(std::ctype::space, c)) && !::boost::re_detail::is_separator(c)) + || ((mask & ::boost::re_detail::char_class_word) && (c == '_')) + || ((mask & ::boost::re_detail::char_class_unicode) && ::boost::re_detail::is_extended(c)); +} +#endif + + +template +inline boost::shared_ptr > create_cpp_regex_traits(const std::locale& l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT)) +{ + cpp_regex_traits_base key(l); + return ::boost::object_cache, cpp_regex_traits_implementation >::get(key, 5); +} + +} // re_detail + +template +class cpp_regex_traits +{ +private: + typedef std::ctype ctype_type; +public: + typedef charT char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + typedef std::locale locale_type; + typedef boost::uint_least32_t char_class_type; + + struct boost_extensions_tag{}; + + cpp_regex_traits() + : m_pimpl(re_detail::create_cpp_regex_traits(std::locale())) + { } + static size_type length(const char_type* p) + { + return std::char_traits::length(p); + } + regex_constants::syntax_type syntax_type(charT c)const + { + return m_pimpl->syntax_type(c); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + return m_pimpl->escape_syntax_type(c); + } + charT translate(charT c) const + { + return c; + } + charT translate_nocase(charT c) const + { + return m_pimpl->m_pctype->tolower(c); + } + charT translate(charT c, bool icase) const + { + return icase ? m_pimpl->m_pctype->tolower(c) : c; + } + charT tolower(charT c) const + { + return m_pimpl->m_pctype->tolower(c); + } + charT toupper(charT c) const + { + return m_pimpl->m_pctype->toupper(c); + } + string_type transform(const charT* p1, const charT* p2) const + { + return m_pimpl->transform(p1, p2); + } + string_type transform_primary(const charT* p1, const charT* p2) const + { + return m_pimpl->transform_primary(p1, p2); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_classname(p1, p2); + } + string_type lookup_collatename(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_collatename(p1, p2); + } + bool isctype(charT c, char_class_type f) const + { +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + typedef typename std::ctype::mask ctype_mask; + + static const ctype_mask mask_base = + static_cast( + std::ctype::alnum + | std::ctype::alpha + | std::ctype::cntrl + | std::ctype::digit + | std::ctype::graph + | std::ctype::lower + | std::ctype::print + | std::ctype::punct + | std::ctype::space + | std::ctype::upper + | std::ctype::xdigit); + + if((f & mask_base) + && (m_pimpl->m_pctype->is( + static_cast(f & mask_base), c))) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_unicode) && re_detail::is_extended(c)) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_word) && (c == '_')) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_blank) + && m_pimpl->m_pctype->is(std::ctype::space, c) + && !re_detail::is_separator(c)) + return true; + return false; +#else + return m_pimpl->isctype(c, f); +#endif + } + int toi(const charT*& p1, const charT* p2, int radix)const; + int value(charT c, int radix)const + { + const charT* pc = &c; + return toi(pc, pc + 1, radix); + } + locale_type imbue(locale_type l) + { + std::locale result(getloc()); + m_pimpl = re_detail::create_cpp_regex_traits(l); + return result; + } + locale_type getloc()const + { + return m_pimpl->m_locale; + } + std::string error_string(regex_constants::error_type n) const + { + return m_pimpl->error_string(n); + } + + // + // extension: + // set the name of the message catalog in use (defaults to "boost_regex"). + // + static std::string catalog_name(const std::string& name); + static std::string get_catalog_name(); + +private: + boost::shared_ptr > m_pimpl; + // + // catalog name handler: + // + static std::string& get_catalog_name_inst(); + +#ifdef BOOST_HAS_THREADS + static static_mutex& get_mutex_inst(); +#endif +}; + + +template +int cpp_regex_traits::toi(const charT*& first, const charT* last, int radix)const +{ + re_detail::parser_buf sbuf; // buffer for parsing numbers. + std::basic_istream is(&sbuf); // stream for parsing numbers. + + // we do NOT want to parse any thousands separators inside the stream: + last = std::find(first, last, BOOST_USE_FACET(std::numpunct, is.getloc()).thousands_sep()); + + sbuf.pubsetbuf(const_cast(static_cast(first)), static_cast(last-first)); + is.clear(); + if(std::abs(radix) == 16) is >> std::hex; + else if(std::abs(radix) == 8) is >> std::oct; + else is >> std::dec; + int val; + if(is >> val) + { + first = first + ((last - first) - sbuf.in_avail()); + return val; + } + else + return -1; +} + +template +std::string cpp_regex_traits::catalog_name(const std::string& name) +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + get_catalog_name_inst() = name; + return result; +} + +template +std::string& cpp_regex_traits::get_catalog_name_inst() +{ + static std::string s_name; + return s_name; +} + +template +std::string cpp_regex_traits::get_catalog_name() +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + return result; +} + +#ifdef BOOST_HAS_THREADS +template +static_mutex& cpp_regex_traits::get_mutex_inst() +{ + static static_mutex s_mutex = BOOST_STATIC_MUTEX_INIT; + return s_mutex; +} +#endif + + +} // boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/cregex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/cregex.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,329 @@ +/* + * + * 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 + * DESCRIPTION: Declares POSIX API functions + * + boost::RegEx high level wrapper. + */ + +#ifndef BOOST_RE_CREGEX_HPP_INCLUDED +#define BOOST_RE_CREGEX_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#include +#include + +#ifdef __cplusplus +#include +#else +#include +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +/* include these defs only for POSIX compatablity */ +#ifdef __cplusplus +namespace boost{ +extern "C" { +#endif + +#if defined(__cplusplus) && !defined(BOOST_NO_STDC_NAMESPACE) +typedef std::ptrdiff_t regoff_t; +typedef std::size_t regsize_t; +#else +typedef ptrdiff_t regoff_t; +typedef size_t regsize_t; +#endif + +typedef struct +{ + unsigned int re_magic; +#ifdef __cplusplus + std::size_t re_nsub; /* number of parenthesized subexpressions */ +#else + size_t re_nsub; +#endif + const char* re_endp; /* end pointer for REG_PEND */ + void* guts; /* none of your business :-) */ + match_flag_type eflags; /* none of your business :-) */ +} regex_tA; + +#ifndef BOOST_NO_WREGEX +typedef struct +{ + unsigned int re_magic; +#ifdef __cplusplus + std::size_t re_nsub; /* number of parenthesized subexpressions */ +#else + size_t re_nsub; +#endif + const wchar_t* re_endp; /* end pointer for REG_PEND */ + void* guts; /* none of your business :-) */ + match_flag_type eflags; /* none of your business :-) */ +} regex_tW; +#endif + +typedef struct +{ + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + +/* regcomp() flags */ +typedef enum{ + REG_BASIC = 0000, + REG_EXTENDED = 0001, + REG_ICASE = 0002, + REG_NOSUB = 0004, + REG_NEWLINE = 0010, + REG_NOSPEC = 0020, + REG_PEND = 0040, + REG_DUMP = 0200, + REG_NOCOLLATE = 0400, + REG_ESCAPE_IN_LISTS = 01000, + REG_NEWLINE_ALT = 02000, + REG_PERLEX = 04000, + + REG_PERL = REG_EXTENDED | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS | REG_PERLEX, + REG_AWK = REG_EXTENDED | REG_ESCAPE_IN_LISTS, + REG_GREP = REG_BASIC | REG_NEWLINE_ALT, + REG_EGREP = REG_EXTENDED | REG_NEWLINE_ALT, + + REG_ASSERT = 15, + REG_INVARG = 16, + REG_ATOI = 255, /* convert name to number (!) */ + REG_ITOA = 0400 /* convert number to name (!) */ +} reg_comp_flags; + +/* regexec() flags */ +typedef enum{ + REG_NOTBOL = 00001, + REG_NOTEOL = 00002, + REG_STARTEND = 00004 +} reg_exec_flags; + +// +// POSIX error codes: +// +typedef unsigned reg_error_t; +typedef reg_error_t reg_errcode_t; // backwards compatibility + +static const reg_error_t REG_NOERROR = 0; /* Success. */ +static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */ + + /* POSIX regcomp return error codes. (In the order listed in the + standard.) */ +static const reg_error_t REG_BADPAT = 2; /* Invalid pattern. */ +static const reg_error_t REG_ECOLLATE = 3; /* Undefined collating element. */ +static const reg_error_t REG_ECTYPE = 4; /* Invalid character class name. */ +static const reg_error_t REG_EESCAPE = 5; /* Trailing backslash. */ +static const reg_error_t REG_ESUBREG = 6; /* Invalid back reference. */ +static const reg_error_t REG_EBRACK = 7; /* Unmatched left bracket. */ +static const reg_error_t REG_EPAREN = 8; /* Parenthesis imbalance. */ +static const reg_error_t REG_EBRACE = 9; /* Unmatched \{. */ +static const reg_error_t REG_BADBR = 10; /* Invalid contents of \{\}. */ +static const reg_error_t REG_ERANGE = 11; /* Invalid range end. */ +static const reg_error_t REG_ESPACE = 12; /* Ran out of memory. */ +static const reg_error_t REG_BADRPT = 13; /* No preceding re for repetition op. */ +static const reg_error_t REG_EEND = 14; /* unexpected end of expression */ +static const reg_error_t REG_ESIZE = 15; /* expression too big */ +static const reg_error_t REG_ERPAREN = 8; /* = REG_EPAREN : unmatched right parenthesis */ +static const reg_error_t REG_EMPTY = 17; /* empty expression */ +static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */ +static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */ +static const reg_error_t REG_ESTACK = 19; /* out of stack space */ +static const reg_error_t REG_E_UNKNOWN = 20; /* unknown error */ +static const reg_error_t REG_ENOSYS = 20; /* = REG_E_UNKNOWN : Reserved. */ + +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int); +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t); +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int); +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA*); + +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW*, const wchar_t*, int); +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, regsize_t); +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, regsize_t, regmatch_t*, int); +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*); +#endif + +#ifdef UNICODE +#define regcomp regcompW +#define regerror regerrorW +#define regexec regexecW +#define regfree regfreeW +#define regex_t regex_tW +#else +#define regcomp regcompA +#define regerror regerrorA +#define regexec regexecA +#define regfree regfreeA +#define regex_t regex_tA +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef __cplusplus +} // extern "C" +} // namespace +#endif + +// +// C++ high level wrapper goes here: +// +#if defined(__cplusplus) +#include +#include +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +class RegEx; + +namespace re_detail{ + +class RegExData; +struct pred1; +struct pred2; +struct pred3; +struct pred4; + +} // namespace re_detail + +#if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_DISABLE_WIN32) +typedef bool (__cdecl *GrepCallback)(const RegEx& expression); +typedef bool (__cdecl *GrepFileCallback)(const char* file, const RegEx& expression); +typedef bool (__cdecl *FindFilesCallback)(const char* file); +#else +typedef bool (*GrepCallback)(const RegEx& expression); +typedef bool (*GrepFileCallback)(const char* file, const RegEx& expression); +typedef bool (*FindFilesCallback)(const char* file); +#endif + +class BOOST_REGEX_DECL RegEx +{ +private: + re_detail::RegExData* pdata; +public: + RegEx(); + RegEx(const RegEx& o); + ~RegEx(); + explicit RegEx(const char* c, bool icase = false); + explicit RegEx(const std::string& s, bool icase = false); + RegEx& operator=(const RegEx& o); + RegEx& operator=(const char* p); + RegEx& operator=(const std::string& s){ return this->operator=(s.c_str()); } + unsigned int SetExpression(const char* p, bool icase = false); + unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); } + std::string Expression()const; + unsigned int error_code()const; + // + // now matching operators: + // + bool Match(const char* p, match_flag_type flags = match_default); + bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); } + bool Search(const char* p, match_flag_type flags = match_default); + bool Search(const std::string& s, match_flag_type flags = match_default) { return Search(s.c_str(), flags); } + unsigned int Grep(GrepCallback cb, const char* p, match_flag_type flags = match_default); + unsigned int Grep(GrepCallback cb, const std::string& s, match_flag_type flags = match_default) { return Grep(cb, s.c_str(), flags); } + unsigned int Grep(std::vector& v, const char* p, match_flag_type flags = match_default); + unsigned int Grep(std::vector& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); } + unsigned int Grep(std::vector& v, const char* p, match_flag_type flags = match_default); + unsigned int Grep(std::vector& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); } +#ifndef BOOST_REGEX_NO_FILEITER + unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default); + unsigned int GrepFiles(GrepFileCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return GrepFiles(cb, files.c_str(), recurse, flags); } + unsigned int FindFiles(FindFilesCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default); + unsigned int FindFiles(FindFilesCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return FindFiles(cb, files.c_str(), recurse, flags); } +#endif + + std::string Merge(const std::string& in, const std::string& fmt, + bool copy = true, match_flag_type flags = match_default); + std::string Merge(const char* in, const char* fmt, + bool copy = true, match_flag_type flags = match_default); + + std::size_t Split(std::vector& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0); + // + // now operators for returning what matched in more detail: + // + std::size_t Position(int i = 0)const; + std::size_t Length(int i = 0)const; + bool Matched(int i = 0)const; + std::size_t Marks()const; + std::string What(int i = 0)const; + std::string operator[](int i)const { return What(i); } + + static const std::size_t npos; + + friend struct re_detail::pred1; + friend struct re_detail::pred2; + friend struct re_detail::pred3; + friend struct re_detail::pred4; +}; + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif + +#endif // include guard + + + + + + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/error_type.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/error_type.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,58 @@ +/* + * + * Copyright (c) 2003-2005 + * 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 error_type.hpp + * VERSION see + * DESCRIPTION: Declares regular expression error type enumerator. + */ + +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#define BOOST_REGEX_ERROR_TYPE_HPP + +#ifdef __cplusplus +namespace boost{ +#endif + +#ifdef __cplusplus +namespace regex_constants{ + +enum error_type{ + + error_ok = 0, // not used + error_no_match = 1, // not used + error_bad_pattern = 2, + error_collate = 3, + error_ctype = 4, + error_escape = 5, + error_backref = 6, + error_brack = 7, + error_paren = 8, + error_brace = 9, + error_badbrace = 10, + error_range = 11, + error_space = 12, + error_badrepeat = 13, + error_end = 14, // not used + error_size = 15, + error_right_paren = 16, // not used + error_empty = 17, + error_complexity = 18, + error_stack = 19, + error_unknown = 20 +}; + +} +} +#endif // __cplusplus + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/fileiter.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/fileiter.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,455 @@ +/* + * + * 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.hpp + * VERSION see + * DESCRIPTION: Declares various platform independent file and + * directory iterators, plus binary file input in + * the form of class map_file. + */ + +#ifndef BOOST_RE_FILEITER_HPP_INCLUDED +#define BOOST_RE_FILEITER_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#include + +#ifndef BOOST_REGEX_NO_FILEITER + +#if (defined(__CYGWIN__) || defined(__CYGWIN32__)) && !defined(BOOST_REGEX_NO_W32) +#error "Sorry, can't mix with STL code and gcc compiler: if you ran configure, try again with configure --disable-ms-windows" +#define BOOST_REGEX_FI_WIN32_MAP +#define BOOST_REGEX_FI_POSIX_DIR +#elif (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) && !defined(BOOST_REGEX_NO_W32) +#define BOOST_REGEX_FI_WIN32_MAP +#define BOOST_REGEX_FI_WIN32_DIR +#else +#define BOOST_REGEX_FI_POSIX_MAP +#define BOOST_REGEX_FI_POSIX_DIR +#endif + +#if defined(BOOST_REGEX_FI_WIN32_MAP)||defined(BOOST_REGEX_FI_WIN32_DIR) +#include +#endif + +#if defined(BOOST_REGEX_FI_WIN32_DIR) + +#include + +namespace boost{ + namespace re_detail{ + +#ifndef BOOST_NO_ANSI_APIS +typedef WIN32_FIND_DATAA _fi_find_data; +#else +typedef WIN32_FIND_DATAW _fi_find_data; +#endif +typedef HANDLE _fi_find_handle; + + } // namespace re_detail + +} // namespace boost + +#define _fi_invalid_handle INVALID_HANDLE_VALUE +#define _fi_dir FILE_ATTRIBUTE_DIRECTORY + +#elif defined(BOOST_REGEX_FI_POSIX_DIR) + +#include +#include +#include +#include +#include +#include +#include + +#if defined(__SUNPRO_CC) +using std::list; +#endif + +#ifndef MAX_PATH +#define MAX_PATH 256 +#endif + +namespace boost{ + namespace re_detail{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +struct _fi_find_data +{ + unsigned dwFileAttributes; + char cFileName[MAX_PATH]; +}; + +struct _fi_priv_data; + +typedef _fi_priv_data* _fi_find_handle; +#define _fi_invalid_handle 0 +#define _fi_dir 1 + +_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData); +bool _fi_FindNextFile(_fi_find_handle hFindFile, _fi_find_data* lpFindFileData); +bool _fi_FindClose(_fi_find_handle hFindFile); + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + + } // namespace re_detail +} // namespace boost + +#ifdef FindFirstFile + #undef FindFirstFile +#endif +#ifdef FindNextFile + #undef FindNextFile +#endif +#ifdef FindClose + #undef FindClose +#endif + +#define FindFirstFileA _fi_FindFirstFile +#define FindNextFileA _fi_FindNextFile +#define FindClose _fi_FindClose + +#endif + +namespace boost{ + namespace re_detail{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +#ifdef BOOST_REGEX_FI_WIN32_MAP // win32 mapfile + +class BOOST_REGEX_DECL mapfile +{ + HANDLE hfile; + HANDLE hmap; + const char* _first; + const char* _last; +public: + + typedef const char* iterator; + + mapfile(){ hfile = hmap = 0; _first = _last = 0; } + mapfile(const char* file){ hfile = hmap = 0; _first = _last = 0; open(file); } + ~mapfile(){ close(); } + void open(const char* file); + void close(); + const char* begin(){ return _first; } + const char* end(){ return _last; } + size_t size(){ return _last - _first; } + bool valid(){ return (hfile != 0) && (hfile != INVALID_HANDLE_VALUE); } +}; + + +#else + +class BOOST_REGEX_DECL mapfile_iterator; + +class BOOST_REGEX_DECL mapfile +{ + typedef char* pointer; + std::FILE* hfile; + long int _size; + pointer* _first; + pointer* _last; + mutable std::list condemed; + enum sizes + { + buf_size = 4096 + }; + void lock(pointer* node)const; + void unlock(pointer* node)const; +public: + + typedef mapfile_iterator iterator; + + mapfile(){ hfile = 0; _size = 0; _first = _last = 0; } + mapfile(const char* file){ hfile = 0; _size = 0; _first = _last = 0; open(file); } + ~mapfile(){ close(); } + void open(const char* file); + void close(); + iterator begin()const; + iterator end()const; + unsigned long size()const{ return _size; } + bool valid()const{ return hfile != 0; } + friend class mapfile_iterator; +}; + +class BOOST_REGEX_DECL mapfile_iterator +#if !defined(BOOST_NO_STD_ITERATOR) || defined(BOOST_MSVC_STD_ITERATOR) +: public std::iterator +#endif +{ + typedef mapfile::pointer internal_pointer; + internal_pointer* node; + const mapfile* file; + unsigned long offset; + long position()const + { + return file ? ((node - file->_first) * mapfile::buf_size + offset) : 0; + } + void position(long pos) + { + if(file) + { + node = file->_first + (pos / mapfile::buf_size); + offset = pos % mapfile::buf_size; + } + } +public: + typedef std::ptrdiff_t difference_type; + typedef char value_type; + typedef const char* pointer; + typedef const char& reference; + typedef std::random_access_iterator_tag iterator_category; + + mapfile_iterator() { node = 0; file = 0; offset = 0; } + mapfile_iterator(const mapfile* f, long arg_position) + { + file = f; + node = f->_first + arg_position / mapfile::buf_size; + offset = arg_position % mapfile::buf_size; + if(file) + file->lock(node); + } + mapfile_iterator(const mapfile_iterator& i) + { + file = i.file; + node = i.node; + offset = i.offset; + if(file) + file->lock(node); + } + ~mapfile_iterator() + { + if(file && node) + file->unlock(node); + } + mapfile_iterator& operator = (const mapfile_iterator& i); + char operator* ()const + { + BOOST_ASSERT(node >= file->_first); + BOOST_ASSERT(node < file->_last); + return file ? *(*node + sizeof(int) + offset) : char(0); + } + char operator[] (long off)const + { + mapfile_iterator tmp(*this); + tmp += off; + return *tmp; + } + mapfile_iterator& operator++ (); + mapfile_iterator operator++ (int); + mapfile_iterator& operator-- (); + mapfile_iterator operator-- (int); + + mapfile_iterator& operator += (long off) + { + position(position() + off); + return *this; + } + mapfile_iterator& operator -= (long off) + { + position(position() - off); + return *this; + } + + friend inline bool operator==(const mapfile_iterator& i, const mapfile_iterator& j) + { + return (i.file == j.file) && (i.node == j.node) && (i.offset == j.offset); + } + + friend inline bool operator!=(const mapfile_iterator& i, const mapfile_iterator& j) + { + return !(i == j); + } + + friend inline bool operator<(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() < j.position(); + } + friend inline bool operator>(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() > j.position(); + } + friend inline bool operator<=(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() <= j.position(); + } + friend inline bool operator>=(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() >= j.position(); + } + + friend mapfile_iterator operator + (const mapfile_iterator& i, long off); + friend mapfile_iterator operator + (long off, const mapfile_iterator& i) + { + mapfile_iterator tmp(i); + return tmp += off; + } + friend mapfile_iterator operator - (const mapfile_iterator& i, long off); + friend inline long operator - (const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() - j.position(); + } +}; + +#endif + +// _fi_sep determines the directory separator, either '\\' or '/' +BOOST_REGEX_DECL extern const char* _fi_sep; + +struct file_iterator_ref +{ + _fi_find_handle hf; + _fi_find_data _data; + long count; +}; + + +class BOOST_REGEX_DECL file_iterator +{ + char* _root; + char* _path; + char* ptr; + file_iterator_ref* ref; + +public: + typedef std::ptrdiff_t difference_type; + typedef const char* value_type; + typedef const char** pointer; + typedef const char*& reference; + typedef std::input_iterator_tag iterator_category; + + file_iterator(); + file_iterator(const char* wild); + ~file_iterator(); + file_iterator(const file_iterator&); + file_iterator& operator=(const file_iterator&); + const char* root()const { return _root; } + const char* path()const { return _path; } + const char* name()const { return ptr; } + _fi_find_data* data() { return &(ref->_data); } + void next(); + file_iterator& operator++() { next(); return *this; } + file_iterator operator++(int); + const char* operator*() { return path(); } + + friend inline bool operator == (const file_iterator& f1, const file_iterator& f2) + { + return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle)); + } + + friend inline bool operator != (const file_iterator& f1, const file_iterator& f2) + { + return !(f1 == f2); + } + +}; + +// dwa 9/13/00 - suppress unused parameter warning +inline bool operator < (const file_iterator&, const file_iterator&) +{ + return false; +} + + +class BOOST_REGEX_DECL directory_iterator +{ + char* _root; + char* _path; + char* ptr; + file_iterator_ref* ref; + +public: + typedef std::ptrdiff_t difference_type; + typedef const char* value_type; + typedef const char** pointer; + typedef const char*& reference; + typedef std::input_iterator_tag iterator_category; + + directory_iterator(); + directory_iterator(const char* wild); + ~directory_iterator(); + directory_iterator(const directory_iterator& other); + directory_iterator& operator=(const directory_iterator& other); + + const char* root()const { return _root; } + const char* path()const { return _path; } + const char* name()const { return ptr; } + _fi_find_data* data() { return &(ref->_data); } + void next(); + directory_iterator& operator++() { next(); return *this; } + directory_iterator operator++(int); + const char* operator*() { return path(); } + + static const char* separator() { return _fi_sep; } + + friend inline bool operator == (const directory_iterator& f1, const directory_iterator& f2) + { + return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle)); + } + + + friend inline bool operator != (const directory_iterator& f1, const directory_iterator& f2) + { + return !(f1 == f2); + } + + }; + +inline bool operator < (const directory_iterator&, const directory_iterator&) +{ + return false; +} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + + +} // namespace re_detail +using boost::re_detail::directory_iterator; +using boost::re_detail::file_iterator; +using boost::re_detail::mapfile; +} // namespace boost + +#endif // BOOST_REGEX_NO_FILEITER +#endif // BOOST_RE_FILEITER_HPP + + + + + + + + + + + + + + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/instances.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/instances.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,215 @@ +/* + * + * 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 + * DESCRIPTION: Defines those template instances that are placed in the + * library rather than in the users object files. + */ + +// +// note no include guard, we may include this multiple times: +// +#ifndef BOOST_REGEX_NO_EXTERNAL_TEMPLATES + +namespace boost{ + +// +// this header can be included multiple times, each time with +// a different character type, BOOST_REGEX_CHAR_T must be defined +// first: +// +#ifndef BOOST_REGEX_CHAR_T +# error "BOOST_REGEX_CHAR_T not defined" +#endif + +#ifndef BOOST_REGEX_TRAITS_T +# define BOOST_REGEX_TRAITS_T , boost::regex_traits +#endif + +// +// what follows is compiler specific: +// + +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x600) + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +# ifndef BOOST_REGEX_INSTANTIATE +# pragma option push -Jgx +# endif + +template class BOOST_REGEX_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >; +template class BOOST_REGEX_DECL match_results< const BOOST_REGEX_CHAR_T* >; +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_DECL ::boost::re_detail::perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >; +#endif + +# ifndef BOOST_REGEX_INSTANTIATE +# pragma option pop +# endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#elif defined(BOOST_MSVC) || defined(__ICL) + +# ifndef BOOST_REGEX_INSTANTIATE +# ifdef __GNUC__ +# define template __extension__ extern template +# else +# if BOOST_MSVC > 1310 +# define BOOST_REGEX_TEMPLATE_DECL +# endif +# define template extern template +# endif +# endif + +#ifndef BOOST_REGEX_TEMPLATE_DECL +# define BOOST_REGEX_TEMPLATE_DECL BOOST_REGEX_DECL +#endif + +# ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4251 4231 4660) +# endif + +template class BOOST_REGEX_TEMPLATE_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >; + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template class BOOST_REGEX_TEMPLATE_DECL match_results< const BOOST_REGEX_CHAR_T* >; +#endif +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >; +#endif +#if !(defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB <= 1))\ + && !(defined(BOOST_INTEL_CXX_VERSION) && (BOOST_INTEL_CXX_VERSION <= 800))\ + && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))\ + && !defined(BOOST_REGEX_ICU_INSTANCES) +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template class BOOST_REGEX_TEMPLATE_DECL match_results< std::basic_string::const_iterator >; +#endif +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher< std::basic_string::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >; +#endif +#endif + + +# ifdef BOOST_MSVC +# pragma warning(pop) +# endif + +# ifdef template +# undef template +# endif + +#undef BOOST_REGEX_TEMPLATE_DECL + +#elif (defined(__GNUC__) && (__GNUC__ >= 3)) + +# ifndef BOOST_REGEX_INSTANTIATE +# define template __extension__ extern template +# endif + +#if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_REGEX_ICU_INSTANCES) +namespace re_detail{ +template BOOST_REGEX_DECL +std::locale cpp_regex_traits_base::imbue(const std::locale& l); + +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform_primary(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::lookup_collatename(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +void cpp_regex_traits_implementation::init(); +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::char_class_type + cpp_regex_traits_implementation::lookup_classname_imp(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +template BOOST_REGEX_DECL +bool cpp_regex_traits_implementation::isctype(const BOOST_REGEX_CHAR_T c, char_class_type mask) const; +#endif +} // namespace +template BOOST_REGEX_DECL +int cpp_regex_traits::toi(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last, int radix)const; +template BOOST_REGEX_DECL +std::string cpp_regex_traits::catalog_name(const std::string& name); +template BOOST_REGEX_DECL +std::string& cpp_regex_traits::get_catalog_name_inst(); +template BOOST_REGEX_DECL +std::string cpp_regex_traits::get_catalog_name(); +#ifdef BOOST_HAS_THREADS +template BOOST_REGEX_DECL +static_mutex& cpp_regex_traits::get_mutex_inst(); +#endif +#endif + +template BOOST_REGEX_DECL basic_regex& + basic_regex::do_assign( + const BOOST_REGEX_CHAR_T* p1, + const BOOST_REGEX_CHAR_T* p2, + flag_type f); +template BOOST_REGEX_DECL basic_regex::locale_type BOOST_REGEX_CALL + basic_regex::imbue(locale_type l); + +template BOOST_REGEX_DECL void BOOST_REGEX_CALL + match_results::maybe_assign( + const match_results& m); + +namespace re_detail{ +template BOOST_REGEX_DECL void perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::construct_init( + const basic_regex& e, match_flag_type f); +template BOOST_REGEX_DECL bool perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::match(); +template BOOST_REGEX_DECL bool perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::find(); +} // namespace + +#if (defined(__GLIBCPP__) || defined(__GLIBCXX__)) \ + && !defined(BOOST_REGEX_ICU_INSTANCES)\ + && !defined(__SGI_STL_PORT)\ + && !defined(_STLPORT_VERSION) +// std:basic_string<>::const_iterator instances as well: +template BOOST_REGEX_DECL void BOOST_REGEX_CALL + match_results::const_iterator>::maybe_assign( + const match_results::const_iterator>& m); + +namespace re_detail{ +template BOOST_REGEX_DECL void perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::construct_init( + const basic_regex& e, match_flag_type f); +template BOOST_REGEX_DECL bool perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::match(); +template BOOST_REGEX_DECL bool perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::find(); +} // namespace +#endif + +# ifdef template +# undef template +# endif + + +#endif + +} // namespace boost + +#endif // BOOST_REGEX_NO_EXTERNAL_TEMPLATES + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/iterator_category.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/iterator_category.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 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 regex_match.hpp + * VERSION see + * DESCRIPTION: Iterator traits for selecting an iterator type as + * an integral constant expression. + */ + + +#ifndef BOOST_REGEX_ITERATOR_CATEGORY_HPP +#define BOOST_REGEX_ITERATOR_CATEGORY_HPP + +#include +#include +#include + +namespace boost{ +namespace detail{ + +template +struct is_random_imp +{ +private: + typedef typename std::iterator_traits::iterator_category cat; +public: + BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible::value)); +}; + +template +struct is_random_pointer_imp +{ + BOOST_STATIC_CONSTANT(bool, value = true); +}; + +template +struct is_random_imp_selector +{ + template + struct rebind + { + typedef is_random_imp type; + }; +}; + +template <> +struct is_random_imp_selector +{ + template + struct rebind + { + typedef is_random_pointer_imp type; + }; +}; + +} + +template +struct is_random_access_iterator +{ +private: + typedef detail::is_random_imp_selector< ::boost::is_pointer::value> selector; + typedef typename selector::template rebind bound_type; + typedef typename bound_type::type answer; +public: + BOOST_STATIC_CONSTANT(bool, value = answer::value); +}; + +#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION +template +const bool is_random_access_iterator::value; +#endif + +} + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/iterator_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/iterator_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,135 @@ +/* + * + * 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 iterator_traits.cpp + * VERSION see + * DESCRIPTION: Declares iterator traits workarounds. + */ + +#ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP +#define BOOST_REGEX_V4_ITERATOR_TRAITS_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + +template +struct regex_iterator_traits +{ + typedef typename T::iterator_category iterator_category; + typedef typename T::value_type value_type; +#if !defined(BOOST_NO_STD_ITERATOR) + typedef typename T::difference_type difference_type; + typedef typename T::pointer pointer; + typedef typename T::reference reference; +#else + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type& reference; +#endif +}; + +template +struct pointer_iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; +template +struct const_pointer_iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef const T* pointer; + typedef const T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; + +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +// +// the follwoing are needed for ICU support: +// +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; + +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +#endif + +#if defined(__SGI_STL_PORT) && defined(__STL_DEBUG) +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +#ifndef BOOST_NO_STD_WSTRING +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +#endif // BOOST_NO_WSTRING +#endif // stport + +#else + +template +struct regex_iterator_traits : public std::iterator_traits {}; + +#endif + +} // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/match_flags.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/match_flags.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,138 @@ +/* + * + * 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 match_flags.hpp + * VERSION see + * DESCRIPTION: Declares match_flags type. + */ + +#ifndef BOOST_REGEX_V4_MATCH_FLAGS +#define BOOST_REGEX_V4_MATCH_FLAGS + +#ifdef __cplusplus +# include +#endif + +#ifdef __cplusplus +namespace boost{ + namespace regex_constants{ +#endif + +typedef enum _match_flags +{ + match_default = 0, + match_not_bol = 1, // first is not start of line + match_not_eol = match_not_bol << 1, // last is not end of line + match_not_bob = match_not_eol << 1, // first is not start of buffer + match_not_eob = match_not_bob << 1, // last is not end of buffer + match_not_bow = match_not_eob << 1, // first is not start of word + match_not_eow = match_not_bow << 1, // last is not end of word + match_not_dot_newline = match_not_eow << 1, // \n is not matched by '.' + match_not_dot_null = match_not_dot_newline << 1, // '\0' is not matched by '.' + match_prev_avail = match_not_dot_null << 1, // *--first is a valid expression + match_init = match_prev_avail << 1, // internal use + match_any = match_init << 1, // don't care what we match + match_not_null = match_any << 1, // string can't be null + match_continuous = match_not_null << 1, // each grep match must continue from + // uninterupted from the previous one + match_partial = match_continuous << 1, // find partial matches + + match_stop = match_partial << 1, // stop after first match (grep) V3 only + match_not_initial_null = match_stop, // don't match initial null, V4 only + match_all = match_stop << 1, // must find the whole of input even if match_any is set + match_perl = match_all << 1, // Use perl matching rules + match_posix = match_perl << 1, // Use POSIX matching rules + match_nosubs = match_posix << 1, // don't trap marked subs + match_extra = match_nosubs << 1, // include full capture information for repeated captures + match_single_line = match_extra << 1, // treat text as single line and ignor any \n's when matching ^ and $. + match_unused1 = match_single_line << 1, // unused + match_unused2 = match_unused1 << 1, // unused + match_unused3 = match_unused2 << 1, // unused + match_max = match_unused3, + + format_perl = 0, // perl style replacement + format_default = 0, // ditto. + format_sed = match_max << 1, // sed style replacement. + format_all = format_sed << 1, // enable all extentions to sytax. + format_no_copy = format_all << 1, // don't copy non-matching segments. + format_first_only = format_no_copy << 1, // Only replace first occurance. + format_is_if = format_first_only << 1, // internal use only. + format_literal = format_is_if << 1 // treat string as a literal + +} match_flags; + +#if (defined(_MSC_VER) && (_MSC_VER < 1300)) || defined(__BORLANDC__) +typedef unsigned long match_flag_type; +#else +typedef match_flags match_flag_type; + + +#ifdef __cplusplus +inline match_flags operator&(match_flags m1, match_flags m2) +{ return static_cast(static_cast(m1) & static_cast(m2)); } +inline match_flags operator|(match_flags m1, match_flags m2) +{ return static_cast(static_cast(m1) | static_cast(m2)); } +inline match_flags operator^(match_flags m1, match_flags m2) +{ return static_cast(static_cast(m1) ^ static_cast(m2)); } +inline match_flags operator~(match_flags m1) +{ return static_cast(~static_cast(m1)); } +inline match_flags& operator&=(match_flags& m1, match_flags m2) +{ m1 = m1&m2; return m1; } +inline match_flags& operator|=(match_flags& m1, match_flags m2) +{ m1 = m1|m2; return m1; } +inline match_flags& operator^=(match_flags& m1, match_flags m2) +{ m1 = m1^m2; return m1; } +#endif +#endif + +#ifdef __cplusplus +} // namespace regex_constants +// +// import names into boost for backwards compatiblity: +// +using regex_constants::match_flag_type; +using regex_constants::match_default; +using regex_constants::match_not_bol; +using regex_constants::match_not_eol; +using regex_constants::match_not_bob; +using regex_constants::match_not_eob; +using regex_constants::match_not_bow; +using regex_constants::match_not_eow; +using regex_constants::match_not_dot_newline; +using regex_constants::match_not_dot_null; +using regex_constants::match_prev_avail; +//using regex_constants::match_init; +using regex_constants::match_any; +using regex_constants::match_not_null; +using regex_constants::match_continuous; +using regex_constants::match_partial; +//using regex_constants::match_stop; +using regex_constants::match_all; +using regex_constants::match_perl; +using regex_constants::match_posix; +using regex_constants::match_nosubs; +using regex_constants::match_extra; +using regex_constants::match_single_line; +//using regex_constants::match_max; +using regex_constants::format_all; +using regex_constants::format_sed; +using regex_constants::format_perl; +using regex_constants::format_default; +using regex_constants::format_no_copy; +using regex_constants::format_first_only; +//using regex_constants::format_is_if; + +} // namespace boost +#endif // __cplusplus +#endif // include guard + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/match_results.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/match_results.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,427 @@ +/* + * + * 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 match_results.cpp + * VERSION see + * DESCRIPTION: Declares template class match_results. + */ + +#ifndef BOOST_REGEX_V4_MATCH_RESULTS_HPP +#define BOOST_REGEX_V4_MATCH_RESULTS_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif + +template +class match_results +{ +private: +#ifndef BOOST_NO_STD_ALLOCATOR + typedef std::vector, Allocator> vector_type; +#else + typedef std::vector > vector_type; +#endif +public: + typedef sub_match value_type; +#if !defined(BOOST_NO_STD_ALLOCATOR) && !(defined(BOOST_MSVC) && defined(_STLPORT_VERSION)) + typedef typename Allocator::const_reference const_reference; +#else + typedef const value_type& const_reference; +#endif + typedef const_reference reference; + typedef typename vector_type::const_iterator const_iterator; + typedef const_iterator iterator; + typedef typename re_detail::regex_iterator_traits< + BidiIterator>::difference_type difference_type; + typedef typename Allocator::size_type size_type; + typedef Allocator allocator_type; + typedef typename re_detail::regex_iterator_traits< + BidiIterator>::value_type char_type; + typedef std::basic_string string_type; + + // construct/copy/destroy: + explicit match_results(const Allocator& a = Allocator()) +#ifndef BOOST_NO_STD_ALLOCATOR + : m_subs(a), m_base() {} +#else + : m_subs(), m_base() { (void)a; } +#endif + match_results(const match_results& m) + : m_subs(m.m_subs), m_base(m.m_base) {} + match_results& operator=(const match_results& m) + { + m_subs = m.m_subs; + m_base = m.m_base; + return *this; + } + ~match_results(){} + + // size: + size_type size() const + { return empty() ? 0 : m_subs.size() - 2; } + size_type max_size() const + { return m_subs.max_size(); } + bool empty() const + { return m_subs.size() < 2; } + // element access: + difference_type length(int sub = 0) const + { + sub += 2; + if((sub < (int)m_subs.size()) && (sub > 0)) + return m_subs[sub].length(); + return 0; + } + difference_type position(size_type sub = 0) const + { + sub += 2; + if(sub < m_subs.size()) + { + const sub_match& s = m_subs[sub]; + if(s.matched || (sub == 2)) + { + return ::boost::re_detail::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); + } + } + return ~static_cast(0); + } + string_type str(int sub = 0) const + { + sub += 2; + string_type result; + if(sub < (int)m_subs.size() && (sub > 0)) + { + const sub_match& s = m_subs[sub]; + if(s.matched) + { + result = s.str(); + } + } + return result; + } + const_reference operator[](int sub) const + { + sub += 2; + if(sub < (int)m_subs.size() && (sub >= 0)) + { + return m_subs[sub]; + } + return m_null; + } + + const_reference prefix() const + { + return (*this)[-1]; + } + + const_reference suffix() const + { + return (*this)[-2]; + } + const_iterator begin() const + { + return (m_subs.size() > 2) ? (m_subs.begin() + 2) : m_subs.end(); + } + const_iterator end() const + { + return m_subs.end(); + } + // format: + template + OutputIterator format(OutputIterator out, + const string_type& fmt, + match_flag_type flags = format_default) const + { + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, *this, fmt.data(), fmt.data() + fmt.size(), flags, traits); + } + string_type format(const string_type& fmt, + match_flag_type flags = format_default) const + { + string_type result; + re_detail::string_out_iterator i(result); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, *this, fmt.data(), fmt.data() + fmt.size(), flags, traits); + return result; + } + // format with locale: + template + OutputIterator format(OutputIterator out, + const string_type& fmt, + match_flag_type flags, + const RegexT& re) const + { + return ::boost::re_detail::regex_format_imp(out, *this, fmt.data(), fmt.data() + fmt.size(), flags, re.get_traits()); + } + template + string_type format(const string_type& fmt, + match_flag_type flags, + const RegexT& re) const + { + string_type result; + re_detail::string_out_iterator i(result); + ::boost::re_detail::regex_format_imp(i, *this, fmt.data(), fmt.data() + fmt.size(), flags, re.get_traits()); + return result; + } + + allocator_type get_allocator() const + { +#ifndef BOOST_NO_STD_ALLOCATOR + return m_subs.get_allocator(); +#else + return allocator_type(); +#endif + } + void swap(match_results& that) + { + std::swap(m_subs, that.m_subs); + std::swap(m_base, that.m_base); + } + bool operator==(const match_results& that)const + { + return (m_subs == that.m_subs) && (m_base == that.m_base); + } + bool operator!=(const match_results& that)const + { return !(*this == that); } + +#ifdef BOOST_REGEX_MATCH_EXTRA + typedef typename sub_match::capture_sequence_type capture_sequence_type; + + const capture_sequence_type& captures(int i)const + { + return (*this)[i].captures(); + } +#endif + + // + // private access functions: + void BOOST_REGEX_CALL set_second(BidiIterator i) + { + BOOST_ASSERT(m_subs.size() > 2); + m_subs[2].second = i; + m_subs[2].matched = true; + m_subs[0].first = i; + m_subs[0].matched = (m_subs[0].first != m_subs[0].second); + m_null.first = i; + m_null.second = i; + m_null.matched = false; + } + + void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true) + { + pos += 2; + BOOST_ASSERT(m_subs.size() > pos); + m_subs[pos].second = i; + m_subs[pos].matched = m; + if(pos == 2) + { + m_subs[0].first = i; + m_subs[0].matched = (m_subs[0].first != m_subs[0].second); + m_null.first = i; + m_null.second = i; + m_null.matched = false; + } + } + void BOOST_REGEX_CALL set_size(size_type n, BidiIterator i, BidiIterator j) + { + value_type v(j); + size_type len = m_subs.size(); + if(len > n + 2) + { + m_subs.erase(m_subs.begin()+n+2, m_subs.end()); + std::fill(m_subs.begin(), m_subs.end(), v); + } + else + { + std::fill(m_subs.begin(), m_subs.end(), v); + if(n+2 != len) + m_subs.insert(m_subs.end(), n+2-len, v); + } + m_subs[1].first = i; + } + void BOOST_REGEX_CALL set_base(BidiIterator pos) + { + m_base = pos; + } + BidiIterator base()const + { + return m_base; + } + void BOOST_REGEX_CALL set_first(BidiIterator i) + { + // set up prefix: + m_subs[1].second = i; + m_subs[1].matched = (m_subs[1].first != i); + // set up $0: + m_subs[2].first = i; + // zero out everything else: + for(size_type n = 3; n < m_subs.size(); ++n) + { + m_subs[n].first = m_subs[n].second = m_subs[0].second; + m_subs[n].matched = false; + } + } + void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos) + { + BOOST_ASSERT(pos+2 < m_subs.size()); + if(pos) + m_subs[pos+2].first = i; + else + set_first(i); + } + void BOOST_REGEX_CALL maybe_assign(const match_results& m); + + +private: + vector_type m_subs; // subexpressions + BidiIterator m_base; // where the search started from + sub_match m_null; // a null match +}; + +template +void BOOST_REGEX_CALL match_results::maybe_assign(const match_results& m) +{ + const_iterator p1, p2; + p1 = begin(); + p2 = m.begin(); + // + // Distances are measured from the start of *this* match, unless this isn't + // a valid match in which case we use the start of the whole sequence. Note that + // no subsequent match-candidate can ever be to the left of the first match found. + // This ensures that when we are using bidirectional iterators, that distances + // measured are as short as possible, and therefore as efficient as possible + // to compute. Finally note that we don't use the "matched" data member to test + // whether a sub-expression is a valid match, because partial matches set this + // to false for sub-expression 0. + // + BidiIterator l_end = this->suffix().second; + BidiIterator l_base = (p1->first == l_end) ? this->prefix().first : (*this)[0].first; + difference_type len1 = 0; + difference_type len2 = 0; + difference_type base1 = 0; + difference_type base2 = 0; + std::size_t i; + for(i = 0; i < size(); ++i, ++p1, ++p2) + { + // + // Leftmost takes priority over longest; handle special cases + // where distances need not be computed first (an optimisation + // for bidirectional iterators: ensure that we don't accidently + // compute the length of the whole sequence, as this can be really + // expensive). + // + if(p1->first == l_end) + { + if(p2->first != l_end) + { + // p2 must be better than p1, and no need to calculate + // actual distances: + base1 = 1; + base2 = 0; + break; + } + else + { + // *p1 and *p2 are either unmatched or match end-of sequence, + // either way no need to calculate distances: + if((p1->matched == false) && (p2->matched == true)) + break; + if((p1->matched == true) && (p2->matched == false)) + return; + continue; + } + } + else if(p2->first == l_end) + { + // p1 better than p2, and no need to calculate distances: + return; + } + base1 = ::boost::re_detail::distance(l_base, p1->first); + base2 = ::boost::re_detail::distance(l_base, p2->first); + BOOST_ASSERT(base1 >= 0); + BOOST_ASSERT(base2 >= 0); + if(base1 < base2) return; + if(base2 < base1) break; + + len1 = ::boost::re_detail::distance((BidiIterator)p1->first, (BidiIterator)p1->second); + len2 = ::boost::re_detail::distance((BidiIterator)p2->first, (BidiIterator)p2->second); + BOOST_ASSERT(len1 >= 0); + BOOST_ASSERT(len2 >= 0); + if((len1 != len2) || ((p1->matched == false) && (p2->matched == true))) + break; + if((p1->matched == true) && (p2->matched == false)) + return; + } + if(i == size()) + return; + if(base2 < base1) + *this = m; + else if((len2 > len1) || ((p1->matched == false) && (p2->matched == true)) ) + *this = m; +} + +template +void swap(match_results& a, match_results& b) +{ + a.swap(b); +} + +#ifndef BOOST_NO_STD_LOCALE +template +std::basic_ostream& + operator << (std::basic_ostream& os, + const match_results& s) +{ + return (os << s.str()); +} +#else +template +std::ostream& operator << (std::ostream& os, + const match_results& s) +{ + return (os << s.str()); +} +#endif + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/mem_block_cache.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/mem_block_cache.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,99 @@ + /* + * Copyright (c) 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 mem_block_cache.hpp + * VERSION see + * DESCRIPTION: memory block cache used by the non-recursive matcher. + */ + +#ifndef BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP +#define BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP + +#include +#ifdef BOOST_HAS_THREADS +#include +#endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost{ +namespace re_detail{ + +struct mem_block_node +{ + mem_block_node* next; +}; + +struct mem_block_cache +{ + // this member has to be statically initialsed: + mem_block_node* next; + unsigned cached_blocks; +#ifdef BOOST_HAS_THREADS + boost::static_mutex mut; +#endif + + ~mem_block_cache() + { + while(next) + { + mem_block_node* old = next; + next = next->next; + ::operator delete(old); + } + } + void* get() + { +#ifdef BOOST_HAS_THREADS + boost::static_mutex::scoped_lock g(mut); +#endif + if(next) + { + mem_block_node* result = next; + next = next->next; + --cached_blocks; + return result; + } + return ::operator new(BOOST_REGEX_BLOCKSIZE); + } + void put(void* p) + { +#ifdef BOOST_HAS_THREADS + boost::static_mutex::scoped_lock g(mut); +#endif + if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS) + { + ::operator delete(p); + } + else + { + mem_block_node* old = static_cast(p); + old->next = next; + next = old; + ++cached_blocks; + } + } +}; + +extern mem_block_cache block_cache; + +} +} // namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,556 @@ +/* + * + * Copyright (c) 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) + * + */ + +#ifndef BOOST_REGEX_MATCHER_HPP +#define BOOST_REGEX_MATCHER_HPP + +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +// +// error checking API: +// +BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex_constants::syntax_option_type ef, match_flag_type mf); +// +// function can_start: +// +template +inline bool can_start(charT c, const unsigned char* map, unsigned char mask) +{ + return ((c < static_cast(0)) ? true : ((c >= static_cast(1 << CHAR_BIT)) ? true : map[c] & mask)); +} +inline bool can_start(char c, const unsigned char* map, unsigned char mask) +{ + return map[(unsigned char)c] & mask; +} +inline bool can_start(signed char c, const unsigned char* map, unsigned char mask) +{ + return map[(unsigned char)c] & mask; +} +inline bool can_start(unsigned char c, const unsigned char* map, unsigned char mask) +{ + return map[c] & mask; +} +inline bool can_start(unsigned short c, const unsigned char* map, unsigned char mask) +{ + return ((c >= (1 << CHAR_BIT)) ? true : map[c] & mask); +} +#if !defined(__hpux) // WCHAR_MIN not usable in pp-directives. +#if defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +inline bool can_start(wchar_t c, const unsigned char* map, unsigned char mask) +{ + return ((c >= static_cast(1u << CHAR_BIT)) ? true : map[c] & mask); +} +#endif +#endif +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) +inline bool can_start(unsigned int c, const unsigned char* map, unsigned char mask) +{ + return (((c >= static_cast(1u << CHAR_BIT)) ? true : map[c] & mask)); +} +#endif + + +// +// Unfortunately Rogue Waves standard library appears to have a bug +// in std::basic_string::compare that results in eroneous answers +// in some cases (tested with Borland C++ 5.1, Rogue Wave lib version +// 0x020101) the test case was: +// {39135,0} < {0xff,0} +// which succeeds when it should not. +// +#ifndef _RWSTD_VER +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) +template +inline int string_compare(const std::basic_string& s, const C* p) +{ + if(0 == *p) + { + if(s.empty() || ((s.size() == 1) && (s[0] == 0))) + return 0; + } + return s.compare(p); +} +#endif +#else +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) +template +inline int string_compare(const std::basic_string& s, const C* p) +{ + if(0 == *p) + { + if(s.empty() || ((s.size() == 1) && (s[0] == 0))) + return 0; + } + return s.compare(p); +} +#endif +inline int string_compare(const std::string& s, const char* p) +{ return std::strcmp(s.c_str(), p); } +# ifndef BOOST_NO_WREGEX +inline int string_compare(const std::wstring& s, const wchar_t* p) +{ return std::wcscmp(s.c_str(), p); } +#endif +#endif +template +inline int string_compare(const Seq& s, const C* p) +{ + std::size_t i = 0; + while((i < s.size()) && (p[i] == s[i])) + { + ++i; + } + return (i == s.size()) ? -p[i] : s[i] - p[i]; +} +# define STR_COMP(s,p) string_compare(s,p) + +template +inline const charT* re_skip_past_null(const charT* p) +{ + while (*p != static_cast(0)) ++p; + return ++p; +} + +template +iterator BOOST_REGEX_CALL re_is_set_member(iterator next, + iterator last, + const re_set_long* set_, + const regex_data& e, bool icase) +{ + const charT* p = reinterpret_cast(set_+1); + iterator ptr; + unsigned int i; + //bool icase = e.m_flags & regex_constants::icase; + + if(next == last) return next; + + typedef typename traits_type::string_type traits_string_type; + const ::boost::regex_traits_wrapper& traits_inst = *(e.m_ptraits); + + // dwa 9/13/00 suppress incorrect MSVC warning - it claims this is never + // referenced + (void)traits_inst; + + // try and match a single character, could be a multi-character + // collating element... + for(i = 0; i < set_->csingles; ++i) + { + ptr = next; + if(*p == static_cast(0)) + { + // treat null string as special case: + if(traits_inst.translate(*ptr, icase) != *p) + { + while(*p == static_cast(0))++p; + continue; + } + return set_->isnot ? next : (ptr == next) ? ++next : ptr; + } + else + { + while(*p && (ptr != last)) + { + if(traits_inst.translate(*ptr, icase) != *p) + break; + ++p; + ++ptr; + } + + if(*p == static_cast(0)) // if null we've matched + return set_->isnot ? next : (ptr == next) ? ++next : ptr; + + p = re_skip_past_null(p); // skip null + } + } + + charT col = traits_inst.translate(*next, icase); + + + if(set_->cranges || set_->cequivalents) + { + traits_string_type s1; + // + // try and match a range, NB only a single character can match + if(set_->cranges) + { + if((e.m_flags & regex_constants::collate) == 0) + s1.assign(1, col); + else + { + charT a[2] = { col, charT(0), }; + s1 = traits_inst.transform(a, a + 1); + } + for(i = 0; i < set_->cranges; ++i) + { + if(STR_COMP(s1, p) >= 0) + { + do{ ++p; }while(*p); + ++p; + if(STR_COMP(s1, p) <= 0) + return set_->isnot ? next : ++next; + } + else + { + // skip first string + do{ ++p; }while(*p); + ++p; + } + // skip second string + do{ ++p; }while(*p); + ++p; + } + } + // + // try and match an equivalence class, NB only a single character can match + if(set_->cequivalents) + { + charT a[2] = { col, charT(0), }; + s1 = traits_inst.transform_primary(a, a +1); + for(i = 0; i < set_->cequivalents; ++i) + { + if(STR_COMP(s1, p) == 0) + return set_->isnot ? next : ++next; + // skip string + do{ ++p; }while(*p); + ++p; + } + } + } + if(traits_inst.isctype(col, set_->cclasses) == true) + return set_->isnot ? next : ++next; + if((set_->cnclasses != 0) && (traits_inst.isctype(col, set_->cnclasses) == false)) + return set_->isnot ? next : ++next; + return set_->isnot ? ++next : next; +} + +template +class repeater_count +{ + repeater_count** stack; + repeater_count* next; + int state_id; + std::size_t count; // the number of iterations so far + BidiIterator start_pos; // where the last repeat started +public: + repeater_count(repeater_count** s) + { + stack = s; + next = 0; + state_id = -1; + count = 0; + } + repeater_count(int i, repeater_count** s, BidiIterator start) + : start_pos(start) + { + state_id = i; + stack = s; + next = *stack; + *stack = this; + if(state_id > next->state_id) + count = 0; + else + { + repeater_count* p = next; + while(p->state_id != state_id) + p = p->next; + count = p->count; + start_pos = p->start_pos; + } + } + ~repeater_count() + { + *stack = next; + } + std::size_t get_count() { return count; } + int get_id() { return state_id; } + std::size_t operator++() { return ++count; } + bool check_null_repeat(const BidiIterator& pos, std::size_t max) + { + // this is called when we are about to start a new repeat, + // if the last one was NULL move our count to max, + // otherwise save the current position. + bool result = (count == 0) ? false : (pos == start_pos); + if(result) + count = max; + else + start_pos = pos; + return result; + } +}; + +struct saved_state; + +enum saved_state_type +{ + saved_type_end = 0, + saved_type_paren = 1, + saved_type_recurse = 2, + saved_type_assertion = 3, + saved_state_alt = 4, + saved_state_repeater_count = 5, + saved_state_extra_block = 6, + saved_state_greedy_single_repeat = 7, + saved_state_rep_slow_dot = 8, + saved_state_rep_fast_dot = 9, + saved_state_rep_char = 10, + saved_state_rep_short_set = 11, + saved_state_rep_long_set = 12, + saved_state_non_greedy_long_repeat = 13, + saved_state_count = 14 +}; + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif + +template +class perl_matcher +{ +public: + typedef typename traits::char_type char_type; + typedef perl_matcher self_type; + typedef bool (self_type::*matcher_proc_type)(void); + typedef std::size_t traits_size_type; + typedef typename is_byte::width_type width_type; + typedef typename regex_iterator_traits::difference_type difference_type; + + perl_matcher(BidiIterator first, BidiIterator end, + match_results& what, + const basic_regex& e, + match_flag_type f, + BidiIterator l_base) + : m_result(what), base(first), last(end), + position(first), backstop(l_base), re(e), traits_inst(e.get_traits()), + m_independent(false), next_count(&rep_obj), rep_obj(&next_count) + { + construct_init(e, f); + } + + bool match(); + bool find(); + + void setf(match_flag_type f) + { m_match_flags |= f; } + void unsetf(match_flag_type f) + { m_match_flags &= ~f; } + +private: + void construct_init(const basic_regex& e, match_flag_type f); + + bool find_imp(); + bool match_imp(); +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + typedef bool (perl_matcher::*protected_proc_type)(); + bool protected_call(protected_proc_type); +#endif + void estimate_max_state_count(std::random_access_iterator_tag*); + void estimate_max_state_count(void*); + bool match_prefix(); + bool match_all_states(); + + // match procs, stored in s_match_vtable: + bool match_startmark(); + bool match_endmark(); + bool match_literal(); + bool match_start_line(); + bool match_end_line(); + bool match_wild(); + bool match_match(); + bool match_word_boundary(); + bool match_within_word(); + bool match_word_start(); + bool match_word_end(); + bool match_buffer_start(); + bool match_buffer_end(); + bool match_backref(); + bool match_long_set(); + bool match_set(); + bool match_jump(); + bool match_alt(); + bool match_rep(); + bool match_combining(); + bool match_soft_buffer_end(); + bool match_restart_continue(); + bool match_long_set_repeat(); + bool match_set_repeat(); + bool match_char_repeat(); + bool match_dot_repeat_fast(); + bool match_dot_repeat_slow(); + bool match_backstep(); + bool match_assert_backref(); + bool match_toggle_case(); +#ifdef BOOST_REGEX_RECURSIVE + bool backtrack_till_match(std::size_t count); +#endif + + // find procs stored in s_find_vtable: + bool find_restart_any(); + bool find_restart_word(); + bool find_restart_line(); + bool find_restart_buf(); + bool find_restart_lit(); + +private: + // final result structure to be filled in: + match_results& m_result; + // temporary result for POSIX matches: + scoped_ptr > m_temp_match; + // pointer to actual result structure to fill in: + match_results* m_presult; + // start of sequence being searched: + BidiIterator base; + // end of sequence being searched: + BidiIterator last; + // current character being examined: + BidiIterator position; + // where to restart next search after failed match attempt: + BidiIterator restart; + // where the current search started from, acts as base for $` during grep: + BidiIterator search_base; + // how far we can go back when matching lookbehind: + BidiIterator backstop; + // the expression being examined: + const basic_regex& re; + // the expression's traits class: + const ::boost::regex_traits_wrapper& traits_inst; + // the next state in the machine being matched: + const re_syntax_base* pstate; + // matching flags in use: + match_flag_type m_match_flags; + // how many states we have examined so far: + boost::uintmax_t state_count; + // max number of states to examine before giving up: + boost::uintmax_t max_state_count; + // whether we should ignore case or not: + bool icase; + // set to true when (position == last), indicates that we may have a partial match: + bool m_has_partial_match; + // set to true whenever we get a match: + bool m_has_found_match; + // set to true whenever we're inside an independent sub-expression: + bool m_independent; + // the current repeat being examined: + repeater_count* next_count; + // the first repeat being examined (top of linked list): + repeater_count rep_obj; + // the mask to pass when matching word boundaries: + typename traits::char_class_type m_word_mask; + // the bitmask to use when determining whether a match_any matches a newline or not: + unsigned char match_any_mask; + +#ifdef BOOST_REGEX_NON_RECURSIVE + // + // additional members for non-recursive version: + // + typedef bool (self_type::*unwind_proc_type)(bool); + + void extend_stack(); + bool unwind(bool); + bool unwind_end(bool); + bool unwind_paren(bool); + bool unwind_recursion_stopper(bool); + bool unwind_assertion(bool); + bool unwind_alt(bool); + bool unwind_repeater_counter(bool); + bool unwind_extra_block(bool); + bool unwind_greedy_single_repeat(bool); + bool unwind_slow_dot_repeat(bool); + bool unwind_fast_dot_repeat(bool); + bool unwind_char_repeat(bool); + bool unwind_short_set_repeat(bool); + bool unwind_long_set_repeat(bool); + bool unwind_non_greedy_repeat(bool); + void destroy_single_repeat(); + void push_matched_paren(int index, const sub_match& sub); + void push_recursion_stopper(); + void push_assertion(const re_syntax_base* ps, bool positive); + void push_alt(const re_syntax_base* ps); + void push_repeater_count(int i, repeater_count** s); + void push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id); + void push_non_greedy_repeat(const re_syntax_base* ps); + + + // pointer to base of stack: + saved_state* m_stack_base; + // pointer to current stack position: + saved_state* m_backup_state; + // determines what value to return when unwinding from recursion, + // allows for mixed recursive/non-recursive algorithm: + bool m_recursive_result; + // how many memory blocks have we used up?: + unsigned used_block_count; +#endif + + // these operations aren't allowed, so are declared private, + // bodies are provided to keep explicit-instantiation requests happy: + perl_matcher& operator=(const perl_matcher&) + { + return *this; + } + perl_matcher(const perl_matcher& that) + : m_result(that.m_result), re(that.re), traits_inst(that.traits_inst), rep_obj(0) {} +}; + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace re_detail + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +// +// include the implementation of perl_matcher: +// +#ifdef BOOST_REGEX_RECURSIVE +#include +#else +#include +#endif +// this one has to be last: +#include + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_common.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_common.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,971 @@ +/* + * + * Copyright (c) 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 perl_matcher_common.cpp + * VERSION see + * DESCRIPTION: Definitions of perl_matcher member functions that are + * common to both the recursive and non-recursive versions. + */ + +#ifndef BOOST_REGEX_V4_PERL_MATCHER_COMMON_HPP +#define BOOST_REGEX_V4_PERL_MATCHER_COMMON_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef __BORLANDC__ +# pragma option push -w-8008 -w-8066 +#endif +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +template +void perl_matcher::construct_init(const basic_regex& e, match_flag_type f) +{ + typedef typename regex_iterator_traits::iterator_category category; + typedef typename basic_regex::flag_type expression_flag_type; + + if(e.empty()) + { + // precondition failure: e is not a valid regex. + std::invalid_argument ex("Invalid regular expression object"); + boost::throw_exception(ex); + } + pstate = 0; + m_match_flags = f; + estimate_max_state_count(static_cast(0)); + expression_flag_type re_f = re.flags(); + icase = re_f & regex_constants::icase; + if(!(m_match_flags & (match_perl|match_posix))) + { + if((re_f & (regbase::main_option_type|regbase::no_perl_ex)) == 0) + m_match_flags |= match_perl; + else if((re_f & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) + m_match_flags |= match_perl; + else + m_match_flags |= match_posix; + } + if(m_match_flags & match_posix) + { + m_temp_match.reset(new match_results()); + m_presult = m_temp_match.get(); + } + else + m_presult = &m_result; +#ifdef BOOST_REGEX_NON_RECURSIVE + m_stack_base = 0; + m_backup_state = 0; +#endif + // find the value to use for matching word boundaries: + m_word_mask = re.get_data().m_word_mask; + // find bitmask to use for matching '.': + match_any_mask = static_cast((f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline); +} + +template +void perl_matcher::estimate_max_state_count(std::random_access_iterator_tag*) +{ + // + // How many states should we allow our machine to visit before giving up? + // This is a heuristic: it takes the greater of O(N^2) and O(NS^2) + // where N is the length of the string, and S is the number of states + // in the machine. It's tempting to up this to O(N^2S) or even O(N^2S^2) + // but these take unreasonably amounts of time to bale out in pathological + // cases. + // + // Calculate NS^2 first: + // + static const boost::uintmax_t k = 100000; + boost::uintmax_t dist = boost::re_detail::distance(base, last); + if(dist == 0) + dist = 1; + boost::uintmax_t states = re.size(); + if(states == 0) + states = 1; + states *= states; + if((std::numeric_limits::max)() / dist < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states *= dist; + if((std::numeric_limits::max)() - k < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states += k; + + max_state_count = states; + + // + // Now calculate N^2: + // + states = dist; + if((std::numeric_limits::max)() / dist < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states *= dist; + if((std::numeric_limits::max)() - k < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states += k; + // + // N^2 can be a very large number indeed, to prevent things getting out + // of control, cap the max states: + // + if(states > BOOST_REGEX_MAX_STATE_COUNT) + states = BOOST_REGEX_MAX_STATE_COUNT; + // + // If (the possibly capped) N^2 is larger than our first estimate, + // use this instead: + // + if(states > max_state_count) + max_state_count = states; +} + +template +inline void perl_matcher::estimate_max_state_count(void*) +{ + // we don't know how long the sequence is: + max_state_count = BOOST_REGEX_MAX_STATE_COUNT; +} + +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD +template +inline bool perl_matcher::protected_call( + protected_proc_type proc) +{ + ::boost::re_detail::concrete_protected_call + > + obj(this, proc); + return obj.execute(); + +} +#endif + +template +inline bool perl_matcher::match() +{ +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + return protected_call(&perl_matcher::match_imp); +#else + return match_imp(); +#endif +} + +template +bool perl_matcher::match_imp() +{ + // initialise our stack if we are non-recursive: +#ifdef BOOST_REGEX_NON_RECURSIVE + save_state_init init(&m_stack_base, &m_backup_state); + used_block_count = BOOST_REGEX_MAX_BLOCKS; +#if !defined(BOOST_NO_EXCEPTIONS) + try{ +#endif +#endif + + // reset our state machine: + position = base; + search_base = base; + state_count = 0; + m_match_flags |= regex_constants::match_all; + m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last); + m_presult->set_base(base); + if(m_match_flags & match_posix) + m_result = *m_presult; + verify_options(re.flags(), m_match_flags); + if(0 == match_prefix()) + return false; + return m_result[0].second == last; + +#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_NO_EXCEPTIONS) + } + catch(...) + { + // unwind all pushed states, apart from anything else this + // ensures that all the states are correctly destructed + // not just the memory freed. + while(unwind(true)){} + throw; + } +#endif +} + +template +inline bool perl_matcher::find() +{ +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + return protected_call(&perl_matcher::find_imp); +#else + return find_imp(); +#endif +} + +template +bool perl_matcher::find_imp() +{ + static matcher_proc_type const s_find_vtable[7] = + { + &perl_matcher::find_restart_any, + &perl_matcher::find_restart_word, + &perl_matcher::find_restart_line, + &perl_matcher::find_restart_buf, + &perl_matcher::match_prefix, + &perl_matcher::find_restart_lit, + &perl_matcher::find_restart_lit, + }; + + // initialise our stack if we are non-recursive: +#ifdef BOOST_REGEX_NON_RECURSIVE + save_state_init init(&m_stack_base, &m_backup_state); + used_block_count = BOOST_REGEX_MAX_BLOCKS; +#if !defined(BOOST_NO_EXCEPTIONS) + try{ +#endif +#endif + + state_count = 0; + if((m_match_flags & regex_constants::match_init) == 0) + { + // reset our state machine: + search_base = position = base; + pstate = re.get_first_state(); + m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last); + m_presult->set_base(base); + m_match_flags |= regex_constants::match_init; + } + else + { + // start again: + search_base = position = m_result[0].second; + // If last match was null and match_not_null was not set then increment + // our start position, otherwise we go into an infinite loop: + if(((m_match_flags & match_not_null) == 0) && (m_result.length() == 0)) + { + if(position == last) + return false; + else + ++position; + } + // reset $` start: + m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last); + //if((base != search_base) && (base == backstop)) + // m_match_flags |= match_prev_avail; + } + if(m_match_flags & match_posix) + { + m_result.set_size(re.mark_count(), base, last); + m_result.set_base(base); + } + + verify_options(re.flags(), m_match_flags); + // find out what kind of expression we have: + unsigned type = (m_match_flags & match_continuous) ? + static_cast(regbase::restart_continue) + : static_cast(re.get_restart_type()); + + // call the appropriate search routine: + matcher_proc_type proc = s_find_vtable[type]; + return (this->*proc)(); + +#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_NO_EXCEPTIONS) + } + catch(...) + { + // unwind all pushed states, apart from anything else this + // ensures that all the states are correctly destructed + // not just the memory freed. + while(unwind(true)){} + throw; + } +#endif +} + +template +bool perl_matcher::match_prefix() +{ + m_has_partial_match = false; + m_has_found_match = false; + pstate = re.get_first_state(); + m_presult->set_first(position); + restart = position; + match_all_states(); + if(!m_has_found_match && m_has_partial_match && (m_match_flags & match_partial)) + { + m_has_found_match = true; + m_presult->set_second(last, 0, false); + position = last; + } +#ifdef BOOST_REGEX_MATCH_EXTRA + if(m_has_found_match && (match_extra & m_match_flags)) + { + // + // we have a match, reverse the capture information: + // + for(unsigned i = 0; i < m_presult->size(); ++i) + { + typename sub_match::capture_sequence_type & seq = ((*m_presult)[i]).get_captures(); + std::reverse(seq.begin(), seq.end()); + } + } +#endif + if(!m_has_found_match) + position = restart; // reset search postion + return m_has_found_match; +} + +template +bool perl_matcher::match_endmark() +{ + int index = static_cast(pstate)->index; + if(index > 0) + { + if((m_match_flags & match_nosubs) == 0) + m_presult->set_second(position, index); + } + else if((index < 0) && (index != -4)) + { + // matched forward lookahead: + pstate = 0; + return true; + } + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_literal() +{ + unsigned int len = static_cast(pstate)->length; + const char_type* what = reinterpret_cast(static_cast(pstate) + 1); + // + // compare string with what we stored in + // our records: + for(unsigned int i = 0; i < len; ++i, ++position) + { + if((position == last) || (traits_inst.translate(*position, icase) != what[i])) + return false; + } + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_start_line() +{ + if(position == backstop) + { + if((m_match_flags & match_prev_avail) == 0) + { + if((m_match_flags & match_not_bol) == 0) + { + pstate = pstate->next.p; + return true; + } + return false; + } + } + else if(m_match_flags & match_single_line) + return false; + + // check the previous value character: + BidiIterator t(position); + --t; + if(position != last) + { + if(is_separator(*t) && !((*t == static_cast('\r')) && (*position == static_cast('\n'))) ) + { + pstate = pstate->next.p; + return true; + } + } + else if(is_separator(*t)) + { + pstate = pstate->next.p; + return true; + } + return false; +} + +template +bool perl_matcher::match_end_line() +{ + if(position != last) + { + if(m_match_flags & match_single_line) + return false; + // we're not yet at the end so *first is always valid: + if(is_separator(*position)) + { + if((position != backstop) || (m_match_flags & match_prev_avail)) + { + // check that we're not in the middle of \r\n sequence + BidiIterator t(position); + --t; + if((*t == static_cast('\r')) && (*position == static_cast('\n'))) + { + return false; + } + } + pstate = pstate->next.p; + return true; + } + } + else if((m_match_flags & match_not_eol) == 0) + { + pstate = pstate->next.p; + return true; + } + return false; +} + +template +bool perl_matcher::match_wild() +{ + if(position == last) + return false; + if(is_separator(*position) && ((match_any_mask & static_cast(pstate)->mask) == 0)) + return false; + if((*position == char_type(0)) && (m_match_flags & match_not_dot_null)) + return false; + pstate = pstate->next.p; + ++position; + return true; +} + +template +bool perl_matcher::match_match() +{ + if((m_match_flags & match_not_null) && (position == (*m_presult)[0].first)) + return false; + if((m_match_flags & match_all) && (position != last)) + return false; + if((m_match_flags & regex_constants::match_not_initial_null) && (position == search_base)) + return false; + m_presult->set_second(position); + pstate = 0; + m_has_found_match = true; + if((m_match_flags & match_posix) == match_posix) + { + m_result.maybe_assign(*m_presult); + if((m_match_flags & match_any) == 0) + return false; + } +#ifdef BOOST_REGEX_MATCH_EXTRA + if(match_extra & m_match_flags) + { + for(unsigned i = 0; i < m_presult->size(); ++i) + if((*m_presult)[i].matched) + ((*m_presult)[i]).get_captures().push_back((*m_presult)[i]); + } +#endif + return true; +} + +template +bool perl_matcher::match_word_boundary() +{ + bool b; // indcates whether next character is a word character + if(position != last) + { + // prev and this character must be opposites: + #if defined(BOOST_REGEX_USE_C_LOCALE) && defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) + b = traits::isctype(*position, m_word_mask); + #else + b = traits_inst.isctype(*position, m_word_mask); + #endif + } + else + { + b = (m_match_flags & match_not_eow) ? true : false; + } + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + { + if(m_match_flags & match_not_bow) + b ^= true; + else + b ^= false; + } + else + { + --position; + b ^= traits_inst.isctype(*position, m_word_mask); + ++position; + } + if(b) + { + pstate = pstate->next.p; + return true; + } + return false; // no match if we get to here... +} + +template +bool perl_matcher::match_within_word() +{ + if(position == last) + return false; + // both prev and this character must be m_word_mask: + bool prev = traits_inst.isctype(*position, m_word_mask); + { + bool b; + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + return false; + else + { + --position; + b = traits_inst.isctype(*position, m_word_mask); + ++position; + } + if(b == prev) + { + pstate = pstate->next.p; + return true; + } + } + return false; +} + +template +bool perl_matcher::match_word_start() +{ + if(position == last) + return false; // can't be starting a word if we're already at the end of input + if(!traits_inst.isctype(*position, m_word_mask)) + return false; // next character isn't a word character + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + { + if(m_match_flags & match_not_bow) + return false; // no previous input + } + else + { + // otherwise inside buffer: + BidiIterator t(position); + --t; + if(traits_inst.isctype(*t, m_word_mask)) + return false; // previous character not non-word + } + // OK we have a match: + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_word_end() +{ + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + return false; // start of buffer can't be end of word + BidiIterator t(position); + --t; + if(traits_inst.isctype(*t, m_word_mask) == false) + return false; // previous character wasn't a word character + + if(position == last) + { + if(m_match_flags & match_not_eow) + return false; // end of buffer but not end of word + } + else + { + // otherwise inside buffer: + if(traits_inst.isctype(*position, m_word_mask)) + return false; // next character is a word character + } + pstate = pstate->next.p; + return true; // if we fall through to here then we've succeeded +} + +template +bool perl_matcher::match_buffer_start() +{ + if((position != backstop) || (m_match_flags & match_not_bob)) + return false; + // OK match: + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_buffer_end() +{ + if((position != last) || (m_match_flags & match_not_eob)) + return false; + // OK match: + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_backref() +{ + // + // Compare with what we previously matched. + // Note that this succeeds if the backref did not partisipate + // in the match, this is in line with ECMAScript, but not Perl + // or PCRE. + // + BidiIterator i = (*m_presult)[static_cast(pstate)->index].first; + BidiIterator j = (*m_presult)[static_cast(pstate)->index].second; + while(i != j) + { + if((position == last) || (traits_inst.translate(*position, icase) != traits_inst.translate(*i, icase))) + return false; + ++i; + ++position; + } + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_long_set() +{ + typedef typename traits::char_class_type char_class_type; + // let the traits class do the work: + if(position == last) + return false; + BidiIterator t = re_is_set_member(position, last, static_cast*>(pstate), re.get_data(), icase); + if(t != position) + { + pstate = pstate->next.p; + position = t; + return true; + } + return false; +} + +template +bool perl_matcher::match_set() +{ + if(position == last) + return false; + if(static_cast(pstate)->_map[static_cast(traits_inst.translate(*position, icase))]) + { + pstate = pstate->next.p; + ++position; + return true; + } + return false; +} + +template +bool perl_matcher::match_jump() +{ + pstate = static_cast(pstate)->alt.p; + return true; +} + +template +bool perl_matcher::match_combining() +{ + if(position == last) + return false; + if(is_combining(traits_inst.translate(*position, icase))) + return false; + ++position; + while((position != last) && is_combining(traits_inst.translate(*position, icase))) + ++position; + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_soft_buffer_end() +{ + if(m_match_flags & match_not_eob) + return false; + BidiIterator p(position); + while((p != last) && is_separator(traits_inst.translate(*p, icase)))++p; + if(p != last) + return false; + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_restart_continue() +{ + if(position == search_base) + { + pstate = pstate->next.p; + return true; + } + return false; +} + +template +bool perl_matcher::match_backstep() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + if( ::boost::is_random_access_iterator::value) + { + std::ptrdiff_t maxlen = ::boost::re_detail::distance(backstop, position); + if(maxlen < static_cast(pstate)->index) + return false; + std::advance(position, -static_cast(pstate)->index); + } + else + { + int c = static_cast(pstate)->index; + while(c--) + { + if(position == backstop) + return false; + --position; + } + } + pstate = pstate->next.p; + return true; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +inline bool perl_matcher::match_assert_backref() +{ + // return true if marked sub-expression N has been matched: + bool result = (*m_presult)[static_cast(pstate)->index].matched; + pstate = pstate->next.p; + return result; +} + +template +bool perl_matcher::match_toggle_case() +{ + // change our case sensitivity: + this->icase = static_cast(pstate)->icase; + pstate = pstate->next.p; + return true; +} + + +template +bool perl_matcher::find_restart_any() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + const unsigned char* _map = re.get_map(); + while(true) + { + // skip everything we can't match: + while((position != last) && !can_start(*position, _map, (unsigned char)mask_any) ) + ++position; + if(position == last) + { + // run out of characters, try a null match if possible: + if(re.can_be_null()) + return match_prefix(); + break; + } + // now try and obtain a match: + if(match_prefix()) + return true; + if(position == last) + return false; + ++position; + } + return false; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::find_restart_word() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + // do search optimised for word starts: + const unsigned char* _map = re.get_map(); + if((m_match_flags & match_prev_avail) || (position != base)) + --position; + else if(match_prefix()) + return true; + do + { + while((position != last) && traits_inst.isctype(*position, m_word_mask)) + ++position; + while((position != last) && !traits_inst.isctype(*position, m_word_mask)) + ++position; + if(position == last) + break; + + if(can_start(*position, _map, (unsigned char)mask_any) ) + { + if(match_prefix()) + return true; + } + if(position == last) + break; + } while(true); + return false; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::find_restart_line() +{ + // do search optimised for line starts: + const unsigned char* _map = re.get_map(); + if(match_prefix()) + return true; + while(position != last) + { + while((position != last) && !is_separator(*position)) + ++position; + if(position == last) + return false; + ++position; + if(position == last) + { + if(re.can_be_null() && match_prefix()) + return true; + return false; + } + + if( can_start(*position, _map, (unsigned char)mask_any) ) + { + if(match_prefix()) + return true; + } + if(position == last) + return false; + //++position; + } + return false; +} + +template +bool perl_matcher::find_restart_buf() +{ + if((position == base) && ((m_match_flags & match_not_bob) == 0)) + return match_prefix(); + return false; +} + +template +bool perl_matcher::find_restart_lit() +{ +#if 0 + if(position == last) + return false; // can't possibly match if we're at the end already + + unsigned type = (m_match_flags & match_continuous) ? + static_cast(regbase::restart_continue) + : static_cast(re.get_restart_type()); + + const kmp_info* info = access::get_kmp(re); + int len = info->len; + const char_type* x = info->pstr; + int j = 0; + while (position != last) + { + while((j > -1) && (x[j] != traits_inst.translate(*position, icase))) + j = info->kmp_next[j]; + ++position; + ++j; + if(j >= len) + { + if(type == regbase::restart_fixed_lit) + { + std::advance(position, -j); + restart = position; + std::advance(restart, len); + m_result.set_first(position); + m_result.set_second(restart); + position = restart; + return true; + } + else + { + restart = position; + std::advance(position, -j); + if(match_prefix()) + return true; + else + { + for(int k = 0; (restart != position) && (k < j); ++k, --restart) + {} // dwa 10/20/2000 - warning suppression for MWCW + if(restart != last) + ++restart; + position = restart; + j = 0; //we could do better than this... + } + } + } + } + if((m_match_flags & match_partial) && (position == last) && j) + { + // we need to check for a partial match: + restart = position; + std::advance(position, -j); + return match_prefix(); + } +#endif + return false; +} + +} // namespace re_detail + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef __BORLANDC__ +# pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_non_recursive.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_non_recursive.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,1400 @@ +/* + * + * Copyright (c) 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 perl_matcher_common.cpp + * VERSION see + * DESCRIPTION: Definitions of perl_matcher member functions that are + * specific to the non-recursive implementation. + */ + +#ifndef BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP +#define BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP + +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +template +inline void inplace_destroy(T* p) +{ + (void)p; // warning suppression + p->~T(); +} + +struct saved_state +{ + union{ + unsigned int state_id; + // this padding ensures correct alignment on 64-bit platforms: + std::size_t padding1; + std::ptrdiff_t padding2; + void* padding3; + }; + saved_state(unsigned i) : state_id(i) {} +}; + +template +struct saved_matched_paren : public saved_state +{ + int index; + sub_match sub; + saved_matched_paren(int i, const sub_match& s) : saved_state(1), index(i), sub(s){}; +}; + +template +struct saved_position : public saved_state +{ + const re_syntax_base* pstate; + BidiIterator position; + saved_position(const re_syntax_base* ps, BidiIterator pos, int i) : saved_state(i), pstate(ps), position(pos){}; +}; + +template +struct saved_assertion : public saved_position +{ + bool positive; + saved_assertion(bool p, const re_syntax_base* ps, BidiIterator pos) + : saved_position(ps, pos, saved_type_assertion), positive(p){}; +}; + +template +struct saved_repeater : public saved_state +{ + repeater_count count; + saved_repeater(int i, repeater_count** s, BidiIterator start) + : saved_state(saved_state_repeater_count), count(i,s,start){} +}; + +struct saved_extra_block : public saved_state +{ + saved_state *base, *end; + saved_extra_block(saved_state* b, saved_state* e) + : saved_state(saved_state_extra_block), base(b), end(e) {} +}; + +struct save_state_init +{ + saved_state** stack; + save_state_init(saved_state** base, saved_state** end) + : stack(base) + { + *base = static_cast(get_mem_block()); + *end = reinterpret_cast(reinterpret_cast(*base)+BOOST_REGEX_BLOCKSIZE); + --(*end); + (void) new (*end)saved_state(0); + BOOST_ASSERT(*end > *base); + } + ~save_state_init() + { + put_mem_block(*stack); + *stack = 0; + } +}; + +template +struct saved_single_repeat : public saved_state +{ + std::size_t count; + const re_repeat* rep; + BidiIterator last_position; + saved_single_repeat(std::size_t c, const re_repeat* r, BidiIterator lp, int arg_id) + : saved_state(arg_id), count(c), rep(r), last_position(lp){} +}; + +template +bool perl_matcher::match_all_states() +{ + static matcher_proc_type const s_match_vtable[29] = + { + (&perl_matcher::match_startmark), + &perl_matcher::match_endmark, + &perl_matcher::match_literal, + &perl_matcher::match_start_line, + &perl_matcher::match_end_line, + &perl_matcher::match_wild, + &perl_matcher::match_match, + &perl_matcher::match_word_boundary, + &perl_matcher::match_within_word, + &perl_matcher::match_word_start, + &perl_matcher::match_word_end, + &perl_matcher::match_buffer_start, + &perl_matcher::match_buffer_end, + &perl_matcher::match_backref, + &perl_matcher::match_long_set, + &perl_matcher::match_set, + &perl_matcher::match_jump, + &perl_matcher::match_alt, + &perl_matcher::match_rep, + &perl_matcher::match_combining, + &perl_matcher::match_soft_buffer_end, + &perl_matcher::match_restart_continue, + (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), + &perl_matcher::match_char_repeat, + &perl_matcher::match_set_repeat, + &perl_matcher::match_long_set_repeat, + &perl_matcher::match_backstep, + &perl_matcher::match_assert_backref, + &perl_matcher::match_toggle_case, + }; + + push_recursion_stopper(); + do{ + while(pstate) + { + matcher_proc_type proc = s_match_vtable[pstate->type]; + ++state_count; + if(!(this->*proc)()) + { + if(state_count > max_state_count) + raise_error(traits_inst, regex_constants::error_space); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + bool successful_unwind = unwind(false); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(false == successful_unwind) + return m_recursive_result; + } + } + }while(unwind(true)); + return m_recursive_result; +} + +template +void perl_matcher::extend_stack() +{ + if(used_block_count) + { + --used_block_count; + saved_state* stack_base; + saved_state* backup_state; + stack_base = static_cast(get_mem_block()); + backup_state = reinterpret_cast(reinterpret_cast(stack_base)+BOOST_REGEX_BLOCKSIZE); + saved_extra_block* block = static_cast(backup_state); + --block; + (void) new (block) saved_extra_block(m_stack_base, m_backup_state); + m_stack_base = stack_base; + m_backup_state = block; + } + else + raise_error(traits_inst, regex_constants::error_size); +} + +template +inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) +{ + BOOST_ASSERT(index); + saved_matched_paren* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_matched_paren(index, sub); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_recursion_stopper() +{ + saved_state* pmp = m_backup_state; + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = m_backup_state; + --pmp; + } + (void) new (pmp)saved_state(saved_type_recurse); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_assertion(const re_syntax_base* ps, bool positive) +{ + saved_assertion* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_assertion(positive, ps, position); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_alt(const re_syntax_base* ps) +{ + saved_position* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_position(ps, position, saved_state_alt); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_non_greedy_repeat(const re_syntax_base* ps) +{ + saved_position* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_position(ps, position, saved_state_non_greedy_long_repeat); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_repeater_count(int i, repeater_count** s) +{ + saved_repeater* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_repeater(i, s, position); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_single_repeat(c, r, last_position, state_id); + m_backup_state = pmp; +} + +template +bool perl_matcher::match_startmark() +{ + int index = static_cast(pstate)->index; + switch(index) + { + case 0: + pstate = pstate->next.p; + break; + case -1: + case -2: + { + // forward lookahead assert: + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + push_assertion(next_pstate, index == -1); + break; + } + case -3: + { + // independent sub-expression, currently this is always recursive: + bool old_independent = m_independent; + m_independent = true; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + pstate = next_pstate; + m_independent = old_independent; +#ifdef BOOST_REGEX_MATCH_EXTRA + if(r && (m_match_flags & match_extra)) + { + // + // our captures have been stored in *m_presult + // we need to unpack them, and insert them + // back in the right order when we unwind the stack: + // + match_results temp_match(*m_presult); + unsigned i; + for(i = 0; i < temp_match.size(); ++i) + (*m_presult)[i].get_captures().clear(); + // match everything else: + r = match_all_states(); + // now place the stored captures back: + for(i = 0; i < temp_match.size(); ++i) + { + typedef typename sub_match::capture_sequence_type seq; + seq& s1 = (*m_presult)[i].get_captures(); + const seq& s2 = temp_match[i].captures(); + s1.insert( + s1.end(), + s2.begin(), + s2.end()); + } + } +#endif + return r; + } + case -4: + { + // conditional expression: + const re_alt* alt = static_cast(pstate->next.p); + BOOST_ASSERT(alt->type == syntax_element_alt); + pstate = alt->next.p; + if(pstate->type == syntax_element_assert_backref) + { + if(!match_assert_backref()) + pstate = alt->alt.p; + break; + } + else + { + // zero width assertion, have to match this recursively: + BOOST_ASSERT(pstate->type == syntax_element_startmark); + bool negated = static_cast(pstate)->index == -2; + BidiIterator saved_position = position; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + position = saved_position; + if(negated) + r = !r; + if(r) + pstate = next_pstate; + else + pstate = alt->alt.p; + break; + } + } + default: + { + BOOST_ASSERT(index > 0); + if((m_match_flags & match_nosubs) == 0) + { + push_matched_paren(index, (*m_presult)[index]); + m_presult->set_first(position, index); + } + pstate = pstate->next.p; + break; + } + } + return true; +} + +template +bool perl_matcher::match_alt() +{ + bool take_first, take_second; + const re_alt* jmp = static_cast(pstate); + + // find out which of these two alternatives we need to take: + if(position == last) + { + take_first = jmp->can_be_null & mask_take; + take_second = jmp->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, jmp->_map, (unsigned char)mask_take); + take_second = can_start(*position, jmp->_map, (unsigned char)mask_skip); + } + + if(take_first) + { + // we can take the first alternative, + // see if we need to push next alternative: + if(take_second) + { + push_alt(jmp->alt.p); + } + pstate = pstate->next.p; + return true; + } + if(take_second) + { + pstate = jmp->alt.p; + return true; + } + return false; // neither option is possible +} + +template +bool perl_matcher::match_rep() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127 4244) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + + // find out which of these two alternatives we need to take: + bool take_first, take_second; + if(position == last) + { + take_first = rep->can_be_null & mask_take; + take_second = rep->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, rep->_map, (unsigned char)mask_take); + take_second = can_start(*position, rep->_map, (unsigned char)mask_skip); + } + + if((m_backup_state->state_id != saved_state_repeater_count) + || (static_cast*>(m_backup_state)->count.get_id() != rep->state_id) + || (next_count->get_id() != rep->state_id)) + { + // we're moving to a different repeat from the last + // one, so set up a counter object: + push_repeater_count(rep->state_id, &next_count); + } + // + // If we've had at least one repeat already, and the last one + // matched the NULL string then set the repeat count to + // maximum: + // + next_count->check_null_repeat(position, rep->max); + + if(next_count->get_count() < rep->min) + { + // we must take the repeat: + if(take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return true; + } + return false; + } + + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // try and take the repeat if we can: + if((next_count->get_count() < rep->max) && take_first) + { + if(take_second) + { + // store position in case we fail: + push_alt(rep->alt.p); + } + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return true; + } + else if(take_second) + { + pstate = rep->alt.p; + return true; + } + return false; // can't take anything, fail... + } + else // non-greedy + { + // try and skip the repeat if we can: + if(take_second) + { + if((next_count->get_count() < rep->max) && take_first) + { + // store position in case we fail: + push_non_greedy_repeat(rep->next.p); + } + pstate = rep->alt.p; + return true; + } + if((next_count->get_count() < rep->max) && take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return true; + } + } + return false; +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_dot_repeat_slow() +{ + unsigned count = 0; + const re_repeat* rep = static_cast(pstate); + re_syntax_base* psingle = rep->next.p; + // match compulsary repeats first: + while(count < rep->min) + { + pstate = psingle; + if(!match_wild()) + return false; + ++count; + } + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // repeat for as long as we can: + while(count < rep->max) + { + pstate = psingle; + if(!match_wild()) + break; + ++count; + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_slow_dot); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +} + +template +bool perl_matcher::match_dot_repeat_fast() +{ + if(m_match_flags & match_not_dot_null) + return match_dot_repeat_slow(); + if((static_cast(pstate->next.p)->mask & match_any_mask) == 0) + return match_dot_repeat_slow(); + + const re_repeat* rep = static_cast(pstate); + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + unsigned count = static_cast((std::min)(static_cast(::boost::re_detail::distance(position, last)), static_cast(greedy ? rep->max : rep->min))); + if(rep->min > count) + { + position = last; + return false; // not enough text left to match + } + std::advance(position, count); + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_fast_dot); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +} + +template +bool perl_matcher::match_char_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); + const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); + std::size_t count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && (traits_inst.translate(*position, icase) == what)) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && (traits_inst.translate(*position, icase) == what)) + { + ++position; + ++count; + } + } + + if(count < rep->min) + return false; + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_char); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + const unsigned char* map = static_cast(rep->next.p)->_map; + std::size_t count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + } + + if(count < rep->min) + return false; + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_short_set); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_long_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + typedef typename traits::char_class_type mask_type; + const re_repeat* rep = static_cast(pstate); + const re_set_long* set = static_cast*>(pstate->next.p); + std::size_t count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + ++count; + } + } + + if(count < rep->min) + return false; + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_long_set); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +/**************************************************************************** + +Unwind and associated proceedures follow, these perform what normal stack +unwinding does in the recursive implementation. + +****************************************************************************/ + +template +bool perl_matcher::unwind(bool have_match) +{ + static unwind_proc_type const s_unwind_table[14] = + { + &perl_matcher::unwind_end, + &perl_matcher::unwind_paren, + &perl_matcher::unwind_recursion_stopper, + &perl_matcher::unwind_assertion, + &perl_matcher::unwind_alt, + &perl_matcher::unwind_repeater_counter, + &perl_matcher::unwind_extra_block, + &perl_matcher::unwind_greedy_single_repeat, + &perl_matcher::unwind_slow_dot_repeat, + &perl_matcher::unwind_fast_dot_repeat, + &perl_matcher::unwind_char_repeat, + &perl_matcher::unwind_short_set_repeat, + &perl_matcher::unwind_long_set_repeat, + &perl_matcher::unwind_non_greedy_repeat, + }; + + m_recursive_result = have_match; + unwind_proc_type unwinder; + bool cont; + // + // keep unwinding our stack until we have something to do: + // + do + { + unwinder = s_unwind_table[m_backup_state->state_id]; + cont = (this->*unwinder)(m_recursive_result); + }while(cont); + // + // return true if we have more states to try: + // + return pstate ? true : false; +} + +template +bool perl_matcher::unwind_end(bool) +{ + pstate = 0; // nothing left to search + return false; // end of stack nothing more to search +} + +template +bool perl_matcher::unwind_paren(bool have_match) +{ + saved_matched_paren* pmp = static_cast*>(m_backup_state); + // restore previous values if no match was found: + if(have_match == false) + { + m_presult->set_first(pmp->sub.first, pmp->index); + m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched); + } +#ifdef BOOST_REGEX_MATCH_EXTRA + // + // we have a match, push the capture information onto the stack: + // + else if(pmp->sub.matched && (match_extra & m_match_flags)) + ((*m_presult)[pmp->index]).get_captures().push_back(pmp->sub); +#endif + // unwind stack: + m_backup_state = pmp+1; + boost::re_detail::inplace_destroy(pmp); + return true; // keep looking +} + +template +bool perl_matcher::unwind_recursion_stopper(bool) +{ + boost::re_detail::inplace_destroy(m_backup_state++); + pstate = 0; // nothing left to search + return false; // end of stack nothing more to search +} + +template +bool perl_matcher::unwind_assertion(bool r) +{ + saved_assertion* pmp = static_cast*>(m_backup_state); + pstate = pmp->pstate; + position = pmp->position; + bool result = (r == pmp->positive); + m_recursive_result = pmp->positive ? r : !r; + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return !result; // return false if the assertion was matched to stop search. +} + +template +bool perl_matcher::unwind_alt(bool r) +{ + saved_position* pmp = static_cast*>(m_backup_state); + if(!r) + { + pstate = pmp->pstate; + position = pmp->position; + } + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return r; +} + +template +bool perl_matcher::unwind_repeater_counter(bool) +{ + saved_repeater* pmp = static_cast*>(m_backup_state); + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return true; // keep looking +} + +template +bool perl_matcher::unwind_extra_block(bool) +{ + saved_extra_block* pmp = static_cast(m_backup_state); + void* condemmed = m_stack_base; + m_stack_base = pmp->base; + m_backup_state = pmp->end; + boost::re_detail::inplace_destroy(pmp); + put_mem_block(condemmed); + return true; // keep looking +} + +template +inline void perl_matcher::destroy_single_repeat() +{ + saved_single_repeat* p = static_cast*>(m_backup_state); + boost::re_detail::inplace_destroy(p++); + m_backup_state = p; +} + +template +bool perl_matcher::unwind_greedy_single_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + + count -= rep->min; + + if((m_match_flags & match_partial) && (position == last)) + m_has_partial_match = true; + + BOOST_ASSERT(count); + position = pmp->last_position; + + // backtrack till we can skip out: + do + { + --position; + --count; + ++state_count; + }while(count && !can_start(*position, rep->_map, mask_skip)); + + // if we've hit base, destroy this state: + if(count == 0) + { + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count + rep->min; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_slow_dot_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + BOOST_ASSERT(rep->type == syntax_element_dot_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_wild); + + BOOST_ASSERT(count < rep->max); + pstate = rep->next.p; + position = pmp->last_position; + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(!match_wild()) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++count; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_fast_dot_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + + BOOST_ASSERT(count < rep->max); + position = pmp->last_position; + if(position != last) + { + + // wind forward until we can skip out of the repeat: + do + { + ++position; + ++count; + ++state_count; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_char_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + pstate = rep->next.p; + const char_type what = *reinterpret_cast(static_cast(pstate) + 1); + position = pmp->last_position; + + BOOST_ASSERT(rep->type == syntax_element_char_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_literal); + BOOST_ASSERT(count < rep->max); + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(traits_inst.translate(*position, icase) != what) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++count; + ++ position; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_short_set_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + pstate = rep->next.p; + const unsigned char* map = static_cast(rep->next.p)->_map; + position = pmp->last_position; + + BOOST_ASSERT(rep->type == syntax_element_short_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_set); + BOOST_ASSERT(count < rep->max); + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(!map[static_cast(traits_inst.translate(*position, icase))]) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++count; + ++ position; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_long_set_repeat(bool r) +{ + typedef typename traits::char_class_type mask_type; + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + pstate = rep->next.p; + const re_set_long* set = static_cast*>(pstate); + position = pmp->last_position; + + BOOST_ASSERT(rep->type == syntax_element_long_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_ASSERT(count < rep->max); + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(position == re_is_set_member(position, last, set, re.get_data(), icase)) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++position; + ++count; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_non_greedy_repeat(bool r) +{ + saved_position* pmp = static_cast*>(m_backup_state); + if(!r) + { + position = pmp->position; + pstate = pmp->pstate; + ++(*next_count); + } + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return r; +} + +} // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_recursive.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_recursive.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,854 @@ +/* + * + * Copyright (c) 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 perl_matcher_common.cpp + * VERSION see + * DESCRIPTION: Definitions of perl_matcher member functions that are + * specific to the recursive implementation. + */ + +#ifndef BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP +#define BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +template +class backup_subex +{ + int index; + sub_match sub; +public: + template + backup_subex(const match_results& w, int i) + : index(i), sub(w[i], false) {} + template + void restore(match_results& w) + { + w.set_first(sub.first, index); + w.set_second(sub.second, index, sub.matched); + } + const sub_match& get() { return sub; } +}; + +template +bool perl_matcher::match_all_states() +{ + static matcher_proc_type const s_match_vtable[29] = + { + (&perl_matcher::match_startmark), + &perl_matcher::match_endmark, + &perl_matcher::match_literal, + &perl_matcher::match_start_line, + &perl_matcher::match_end_line, + &perl_matcher::match_wild, + &perl_matcher::match_match, + &perl_matcher::match_word_boundary, + &perl_matcher::match_within_word, + &perl_matcher::match_word_start, + &perl_matcher::match_word_end, + &perl_matcher::match_buffer_start, + &perl_matcher::match_buffer_end, + &perl_matcher::match_backref, + &perl_matcher::match_long_set, + &perl_matcher::match_set, + &perl_matcher::match_jump, + &perl_matcher::match_alt, + &perl_matcher::match_rep, + &perl_matcher::match_combining, + &perl_matcher::match_soft_buffer_end, + &perl_matcher::match_restart_continue, + (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), + &perl_matcher::match_char_repeat, + &perl_matcher::match_set_repeat, + &perl_matcher::match_long_set_repeat, + &perl_matcher::match_backstep, + &perl_matcher::match_assert_backref, + &perl_matcher::match_toggle_case, + }; + + if(state_count > max_state_count) + raise_error(traits_inst, regex_constants::error_space); + while(pstate) + { + matcher_proc_type proc = s_match_vtable[pstate->type]; + ++state_count; + if(!(this->*proc)()) + { + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + return 0; + } + } + return true; +} + +template +bool perl_matcher::match_startmark() +{ + int index = static_cast(pstate)->index; + bool r = true; + switch(index) + { + case 0: + pstate = pstate->next.p; + break; + case -1: + case -2: + { + // forward lookahead assert: + BidiIterator old_position(position); + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + r = match_all_states(); + pstate = next_pstate; + position = old_position; + if((r && (index != -1)) || (!r && (index != -2))) + r = false; + else + r = true; + break; + } + case -3: + { + // independent sub-expression: + bool old_independent = m_independent; + m_independent = true; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + r = match_all_states(); + pstate = next_pstate; + m_independent = old_independent; +#ifdef BOOST_REGEX_MATCH_EXTRA + if(r && (m_match_flags & match_extra)) + { + // + // our captures have been stored in *m_presult + // we need to unpack them, and insert them + // back in the right order when we unwind the stack: + // + unsigned i; + match_results tm(*m_presult); + for(i = 0; i < tm.size(); ++i) + (*m_presult)[i].get_captures().clear(); + // match everything else: + r = match_all_states(); + // now place the stored captures back: + for(i = 0; i < tm.size(); ++i) + { + typedef typename sub_match::capture_sequence_type seq; + seq& s1 = (*m_presult)[i].get_captures(); + const seq& s2 = tm[i].captures(); + s1.insert( + s1.end(), + s2.begin(), + s2.end()); + } + } +#endif + break; + } + case -4: + { + // conditional expression: + const re_alt* alt = static_cast(pstate->next.p); + BOOST_ASSERT(alt->type == syntax_element_alt); + pstate = alt->next.p; + if(pstate->type == syntax_element_assert_backref) + { + if(!match_assert_backref()) + pstate = alt->alt.p; + break; + } + else + { + // zero width assertion, have to match this recursively: + BOOST_ASSERT(pstate->type == syntax_element_startmark); + bool negated = static_cast(pstate)->index == -2; + BidiIterator saved_position = position; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + position = saved_position; + if(negated) + r = !r; + if(r) + pstate = next_pstate; + else + pstate = alt->alt.p; + break; + } + } + default: + { + BOOST_ASSERT(index > 0); + if((m_match_flags & match_nosubs) == 0) + { + backup_subex sub(*m_presult, index); + m_presult->set_first(position, index); + pstate = pstate->next.p; + r = match_all_states(); + if(r == false) + sub.restore(*m_presult); +#ifdef BOOST_REGEX_MATCH_EXTRA + // + // we have a match, push the capture information onto the stack: + // + else if(sub.get().matched && (match_extra & m_match_flags)) + ((*m_presult)[index]).get_captures().push_back(sub.get()); +#endif + } + else + { + pstate = pstate->next.p; + } + break; + } + } + return r; +} + +template +bool perl_matcher::match_alt() +{ + bool take_first, take_second; + const re_alt* jmp = static_cast(pstate); + + // find out which of these two alternatives we need to take: + if(position == last) + { + take_first = jmp->can_be_null & mask_take; + take_second = jmp->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, jmp->_map, (unsigned char)mask_take); + take_second = can_start(*position, jmp->_map, (unsigned char)mask_skip); + } + + if(take_first) + { + // we can take the first alternative, + // see if we need to push next alternative: + if(take_second) + { + BidiIterator oldposition(position); + const re_syntax_base* old_pstate = jmp->alt.p; + pstate = pstate->next.p; + if(!match_all_states()) + { + pstate = old_pstate; + position = oldposition; + } + return true; + } + pstate = pstate->next.p; + return true; + } + if(take_second) + { + pstate = jmp->alt.p; + return true; + } + return false; // neither option is possible +} + +template +bool perl_matcher::match_rep() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127 4244) +#endif + const re_repeat* rep = static_cast(pstate); + // + // Always copy the repeat count, so that the state is restored + // when we exit this scope: + // + repeater_count r(rep->state_id, &next_count, position); + // + // If we've had at least one repeat already, and the last one + // matched the NULL string then set the repeat count to + // maximum: + // + next_count->check_null_repeat(position, rep->max); + + // find out which of these two alternatives we need to take: + bool take_first, take_second; + if(position == last) + { + take_first = rep->can_be_null & mask_take; + take_second = rep->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, rep->_map, (unsigned char)mask_take); + take_second = can_start(*position, rep->_map, (unsigned char)mask_skip); + } + + if(next_count->get_count() < rep->min) + { + // we must take the repeat: + if(take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return match_all_states(); + } + return false; + } + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // try and take the repeat if we can: + if((next_count->get_count() < rep->max) && take_first) + { + // store position in case we fail: + BidiIterator pos = position; + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + if(match_all_states()) + return true; + // failed repeat, reset posistion and fall through for alternative: + position = pos; + } + if(take_second) + { + pstate = rep->alt.p; + return true; + } + return false; // can't take anything, fail... + } + else // non-greedy + { + // try and skip the repeat if we can: + if(take_second) + { + // store position in case we fail: + BidiIterator pos = position; + pstate = rep->alt.p; + if(match_all_states()) + return true; + // failed alternative, reset posistion and fall through for repeat: + position = pos; + } + if((next_count->get_count() < rep->max) && take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return match_all_states(); + } + } + return false; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_dot_repeat_slow() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + unsigned count = 0; + const re_repeat* rep = static_cast(pstate); + re_syntax_base* psingle = rep->next.p; + // match compulsary repeats first: + while(count < rep->min) + { + pstate = psingle; + if(!match_wild()) + return false; + ++count; + } + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // normal repeat: + while(count < rep->max) + { + pstate = psingle; + if(!match_wild()) + break; + ++count; + } + if((rep->leading) && (count < rep->max)) + restart = position; + pstate = rep; + return backtrack_till_match(count - rep->min); + } + else + { + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + ++count; + pstate = psingle; + position = save_pos; + if(!match_wild()) + return false; + }while(true); + } +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_dot_repeat_fast() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + if(m_match_flags & match_not_dot_null) + return match_dot_repeat_slow(); + if((static_cast(pstate->next.p)->mask & match_any_mask) == 0) + return match_dot_repeat_slow(); + // + // start by working out how much we can skip: + // + const re_repeat* rep = static_cast(pstate); +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4267) +#endif + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t count = (std::min)(static_cast(::boost::re_detail::distance(position, last)), static_cast(greedy ? rep->max : rep->min)); + if(rep->min > count) + { + position = last; + return false; // not enough text left to match + } + std::advance(position, count); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + ++position; + ++count; + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + if(save_pos == last) + return false; + position = ++save_pos; + ++count; + }while(true); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_char_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#pragma warning(disable:4267) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); + const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t count, desired; + if(::boost::is_random_access_iterator::value) + { + desired = + (std::min)( + (std::size_t)(greedy ? rep->max : rep->min), + (std::size_t)::boost::re_detail::distance(position, last)); + count = desired; + ++desired; + if(icase) + { + while(--desired && (traits_inst.translate_nocase(*position) == what)) + { + ++position; + } + } + else + { + while(--desired && (traits_inst.translate(*position) == what)) + { + ++position; + } + } + count = count - desired; + } + else + { + count = 0; + desired = greedy ? rep->max : rep->min; + while((count < desired) && (position != last) && (traits_inst.translate(*position, icase) == what)) + { + ++position; + ++count; + } + } + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(count < rep->min) + return false; + + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + if((traits_inst.translate(*position, icase) == what)) + { + ++position; + ++count; + } + else + return false; // counldn't repeat even though it was the only option + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + position = save_pos; + if(position == last) + return false; + if(traits_inst.translate(*position, icase) == what) + { + ++position; + ++count; + } + else + { + return false; + } + }while(true); +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + const unsigned char* map = static_cast(rep->next.p)->_map; + unsigned count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + } + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(count < rep->min) + return false; + + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + if(map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + else + return false; // counldn't repeat even though it was the only option + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + position = save_pos; + if(position == last) + return false; + if(map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + else + { + return false; + } + }while(true); +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_long_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + typedef typename traits::char_class_type char_class_type; + const re_repeat* rep = static_cast(pstate); + const re_set_long* set = static_cast*>(pstate->next.p); + unsigned count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + ++count; + } + } + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(count < rep->min) + return false; + + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + if(position != re_is_set_member(position, last, set, re.get_data(), icase)) + { + ++position; + ++count; + } + else + return false; // counldn't repeat even though it was the only option + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + position = save_pos; + if(position == last) + return false; + if(position != re_is_set_member(position, last, set, re.get_data(), icase)) + { + ++position; + ++count; + } + else + { + return false; + } + }while(true); +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::backtrack_till_match(std::size_t count) +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + if((m_match_flags & match_partial) && (position == last)) + m_has_partial_match = true; + + const re_repeat* rep = static_cast(pstate); + BidiIterator backtrack = position; + if(position == last) + { + if(rep->can_be_null & mask_skip) + { + pstate = rep->alt.p; + if(match_all_states()) + return true; + } + if(count) + { + position = --backtrack; + --count; + } + else + return false; + } + do + { + while(count && !can_start(*position, rep->_map, mask_skip)) + { + --position; + --count; + ++state_count; + } + pstate = rep->alt.p; + backtrack = position; + if(match_all_states()) + return true; + if(count == 0) + return false; + position = --backtrack; + ++state_count; + --count; + }while(true); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +} // namespace re_detail +} // namespace boost +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/primary_transform.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/primary_transform.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,146 @@ +/* + * + * 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: primary_transform.hpp + * VERSION: see + * DESCRIPTION: Heuristically determines the sort string format in use + * by the current locale. + */ + +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#define BOOST_REGEX_PRIMARY_TRANSFORM + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + namespace re_detail{ + + +enum{ + sort_C, + sort_fixed, + sort_delim, + sort_unknown +}; + +template +unsigned count_chars(const S& s, charT c) +{ + // + // Count how many occurances of character c occur + // in string s: if c is a delimeter between collation + // fields, then this should be the same value for all + // sort keys: + // + unsigned int count = 0; + for(unsigned pos = 0; pos < s.size(); ++pos) + { + if(s[pos] == c) ++count; + } + return count; +} + + +template +unsigned find_sort_syntax(const traits* pt, charT* delim) +{ + // + // compare 'a' with 'A' to see how similar they are, + // should really use a-accute but we can't portably do that, + // + typedef typename traits::string_type string_type; + typedef typename traits::char_type char_type; + + // Suppress incorrect warning for MSVC + (void)pt; + + char_type a[2] = {'a', '\0', }; + string_type sa(pt->transform(a, a+1)); + if(sa == a) + { + *delim = 0; + return sort_C; + } + char_type A[2] = { 'A', '\0', }; + string_type sA(pt->transform(A, A+1)); + char_type c[2] = { ';', '\0', }; + string_type sc(pt->transform(c, c+1)); + + int pos = 0; + while((pos <= static_cast(sa.size())) && (pos <= static_cast(sA.size())) && (sa[pos] == sA[pos])) ++pos; + --pos; + if(pos < 0) + { + *delim = 0; + return sort_unknown; + } + // + // at this point sa[pos] is either the end of a fixed width field + // or the character that acts as a delimiter: + // + charT maybe_delim = sa[pos]; + if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim))) + { + *delim = maybe_delim; + return sort_delim; + } + // + // OK doen't look like a delimiter, try for fixed width field: + // + if((sa.size() == sA.size()) && (sa.size() == sc.size())) + { + // note assumes that the fixed width field is less than + // (numeric_limits::max)(), should be true for all types + // I can't imagine 127 character fields... + *delim = static_cast(++pos); + return sort_fixed; + } + // + // don't know what it is: + // + *delim = 0; + return sort_unknown; +} + + + } // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/protected_call.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/protected_call.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,81 @@ +/* + * + * 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 basic_regex_creator.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_creator which fills in + * the data members of a regex_data object. + */ + +#ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP +#define BOOST_REGEX_V4_PROTECTED_CALL_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +class BOOST_REGEX_DECL abstract_protected_call +{ +public: + bool BOOST_REGEX_CALL execute()const; + // this stops gcc-4 from complaining: + virtual ~abstract_protected_call(){} +private: + virtual bool call()const = 0; +}; + +template +class concrete_protected_call + : public abstract_protected_call +{ +public: + typedef bool (T::*proc_type)(); + concrete_protected_call(T* o, proc_type p) + : obj(o), proc(p) {} +private: + virtual bool call()const; + T* obj; + proc_type proc; +}; + +template +bool concrete_protected_call::call()const +{ + return (obj->*proc)(); +} + +} +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regbase.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regbase.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,180 @@ +/* + * + * 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 regbase.cpp + * VERSION see + * DESCRIPTION: Declares class regbase. + */ + +#ifndef BOOST_REGEX_V4_REGBASE_HPP +#define BOOST_REGEX_V4_REGBASE_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +// +// class regbase +// handles error codes and flags +// +class BOOST_REGEX_DECL regbase +{ +public: + enum flag_type_ + { + // + // Divide the flags up into logical groups: + // bits 0-7 indicate main synatx type. + // bits 8-15 indicate syntax subtype. + // bits 16-31 indicate options that are common to all + // regex syntaxes. + // In all cases the default is 0. + // + // Main synatx group: + // + perl_syntax_group = 0, // default + basic_syntax_group = 1, // POSIX basic + literal = 2, // all characters are literals + main_option_type = literal | basic_syntax_group | perl_syntax_group, // everything! + // + // options specific to perl group: + // + no_bk_refs = 1 << 8, // \d not allowed + no_perl_ex = 1 << 9, // disable perl extensions + no_mod_m = 1 << 10, // disable Perl m modifier + mod_x = 1 << 11, // Perl x modifier + mod_s = 1 << 12, // force s modifier on (overrides match_not_dot_newline) + no_mod_s = 1 << 13, // force s modifier off (overrides match_not_dot_newline) + + // + // options specific to basic group: + // + no_char_classes = 1 << 8, // [[:CLASS:]] not allowed + no_intervals = 1 << 9, // {x,y} not allowed + bk_plus_qm = 1 << 10, // uses \+ and \? + bk_vbar = 1 << 11, // use \| for alternatives + emacs_ex = 1 << 12, // enables emacs extensions + + // + // options common to all groups: + // + no_escape_in_lists = 1 << 16, // '\' not special inside [...] + newline_alt = 1 << 17, // \n is the same as | + no_except = 1 << 18, // no exception on error + failbit = 1 << 19, // error flag + icase = 1 << 20, // characters are matched regardless of case + nocollate = 0, // don't use locale specific collation (deprecated) + collate = 1 << 21, // use locale specific collation + nosubs = 1 << 22, // don't mark sub-expressions + save_subexpression_location = 1 << 23, // save subexpression locations + no_empty_expressions = 1 << 24, // no empty expressions allowed + optimize = 0, // not really supported + + + + basic = basic_syntax_group | collate | no_escape_in_lists, + extended = no_bk_refs | collate | no_perl_ex | no_escape_in_lists, + normal = 0, + emacs = basic_syntax_group | collate | emacs_ex | bk_vbar, + awk = no_bk_refs | collate | no_perl_ex, + grep = basic | newline_alt, + egrep = extended | newline_alt, + sed = basic, + perl = normal, + ECMAScript = normal, + JavaScript = normal, + JScript = normal + }; + typedef unsigned int flag_type; + + enum restart_info + { + restart_any = 0, + restart_word = 1, + restart_line = 2, + restart_buf = 3, + restart_continue = 4, + restart_lit = 5, + restart_fixed_lit = 6, + restart_count = 7 + }; +}; + +// +// provide std lib proposal compatible constants: +// +namespace regex_constants{ + + enum flag_type_ + { + + no_except = ::boost::regbase::no_except, + failbit = ::boost::regbase::failbit, + literal = ::boost::regbase::literal, + icase = ::boost::regbase::icase, + nocollate = ::boost::regbase::nocollate, + collate = ::boost::regbase::collate, + nosubs = ::boost::regbase::nosubs, + optimize = ::boost::regbase::optimize, + bk_plus_qm = ::boost::regbase::bk_plus_qm, + bk_vbar = ::boost::regbase::bk_vbar, + no_intervals = ::boost::regbase::no_intervals, + no_char_classes = ::boost::regbase::no_char_classes, + no_escape_in_lists = ::boost::regbase::no_escape_in_lists, + no_mod_m = ::boost::regbase::no_mod_m, + mod_x = ::boost::regbase::mod_x, + mod_s = ::boost::regbase::mod_s, + no_mod_s = ::boost::regbase::no_mod_s, + save_subexpression_location = ::boost::regbase::save_subexpression_location, + no_empty_expressions = ::boost::regbase::no_empty_expressions, + + basic = ::boost::regbase::basic, + extended = ::boost::regbase::extended, + normal = ::boost::regbase::normal, + emacs = ::boost::regbase::emacs, + awk = ::boost::regbase::awk, + grep = ::boost::regbase::grep, + egrep = ::boost::regbase::egrep, + sed = basic, + perl = normal, + ECMAScript = normal, + JavaScript = normal, + JScript = normal + }; + typedef ::boost::regbase::flag_type syntax_option_type; + +} // namespace regex_constants + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,202 @@ +/* + * + * 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 regex.cpp + * VERSION see + * DESCRIPTION: Declares boost::basic_regex<> and associated + * functions and classes. This header is the main + * entry point for the template regex code. + */ + +#ifndef BOOST_RE_REGEX_HPP_INCLUDED +#define BOOST_RE_REGEX_HPP_INCLUDED + +#ifdef __cplusplus + +// what follows is all C++ don't include in C builds!! + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif + +#ifndef BOOST_REGEX_FWD_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_HPP +#include +#endif +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_MATCH_FLAGS +#include +#endif +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#include +#endif +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif + +#ifndef BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_STATES_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGBASE_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_SUB_MATCH_HPP +#include +#endif +#ifndef BOOST_REGEX_FORMAT_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_MATCH_RESULTS_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP +#include +#endif +#ifndef BOOST_REGEX_MATCHER_HPP +#include +#endif +// +// template instances: +// +#define BOOST_REGEX_CHAR_T char +#ifdef BOOST_REGEX_NARROW_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif + +#ifndef BOOST_NO_WREGEX +#define BOOST_REGEX_CHAR_T wchar_t +#ifdef BOOST_REGEX_WIDE_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif +#endif + +#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) +#define BOOST_REGEX_CHAR_T unsigned short +#ifdef BOOST_REGEX_US_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif +#endif + + +namespace boost{ +#ifdef BOOST_REGEX_NO_FWD +typedef basic_regex > regex; +#ifndef BOOST_NO_WREGEX +typedef basic_regex > wregex; +#endif +#endif + +typedef match_results cmatch; +typedef match_results smatch; +#ifndef BOOST_NO_WREGEX +typedef match_results wcmatch; +typedef match_results wsmatch; +#endif + +} // namespace boost +#ifndef BOOST_REGEX_MATCH_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP +#include +#endif +#ifndef BOOST_REGEX_ITERATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_TOKEN_ITERATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_GREP_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP +#include +#endif +#ifndef BOOST_REGEX_SPLIT_HPP +#include +#endif + +#endif // __cplusplus + +#endif // include + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_format.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_format.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,662 @@ +/* + * + * 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 regex_format.hpp + * VERSION see + * DESCRIPTION: Provides formatting output routines for search and replace + * operations. Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_FORMAT_HPP +#define BOOST_REGEX_FORMAT_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// +// Forward declaration: +// + template >::allocator_type > +class match_results; + +namespace re_detail{ + +// +// struct trivial_format_traits: +// defines minimum localisation support for formatting +// in the case that the actual regex traits is unavailable. +// +template +struct trivial_format_traits +{ + typedef charT char_type; + + static std::ptrdiff_t length(const charT* p) + { + return global_length(p); + } + static charT tolower(charT c) + { + return ::boost::re_detail::global_lower(c); + } + static charT toupper(charT c) + { + return ::boost::re_detail::global_upper(c); + } + static int value(const charT c, int radix) + { + int result = global_value(c); + return result >= radix ? -1 : result; + } + int toi(const charT*& p1, const charT* p2, int radix)const + { + return global_toi(p1, p2, radix, *this); + } +}; + +template +class basic_regex_formatter +{ +public: + typedef typename traits::char_type char_type; + basic_regex_formatter(OutputIterator o, const Results& r, const traits& t) + : m_traits(t), m_results(r), m_out(o), m_state(output_copy), m_restore_state(output_copy), m_have_conditional(false) {} + OutputIterator format(const char_type* p1, const char_type* p2, match_flag_type f); + OutputIterator format(const char_type* p1, match_flag_type f) + { + return format(p1, p1 + m_traits.length(p1), f); + } +private: + typedef typename Results::value_type sub_match_type; + enum output_state + { + output_copy, + output_next_lower, + output_next_upper, + output_lower, + output_upper, + output_none + }; + + void put(char_type c); + void put(const sub_match_type& sub); + void format_all(); + void format_perl(); + void format_escape(); + void format_conditional(); + void format_until_scope_end(); + + const traits& m_traits; // the traits class for localised formatting operations + const Results& m_results; // the match_results being used. + OutputIterator m_out; // where to send output. + const char_type* m_position; // format string, current position + const char_type* m_end; // format string end + match_flag_type m_flags; // format flags to use + output_state m_state; // what to do with the next character + output_state m_restore_state; // what state to restore to. + bool m_have_conditional; // we are parsing a conditional +private: + basic_regex_formatter(const basic_regex_formatter&); + basic_regex_formatter& operator=(const basic_regex_formatter&); +}; + +template +OutputIterator basic_regex_formatter::format(const char_type* p1, const char_type* p2, match_flag_type f) +{ + m_position = p1; + m_end = p2; + m_flags = f; + format_all(); + return m_out; +} + +template +void basic_regex_formatter::format_all() +{ + // over and over: + while(m_position != m_end) + { + switch(*m_position) + { + case '&': + if(m_flags & ::boost::regex_constants::format_sed) + { + ++m_position; + put(m_results[0]); + break; + } + put(*m_position++); + break; + case '\\': + format_escape(); + break; + case '(': + if(m_flags & boost::regex_constants::format_all) + { + ++m_position; + bool have_conditional = m_have_conditional; + m_have_conditional = false; + format_until_scope_end(); + m_have_conditional = have_conditional; + if(m_position == m_end) + return; + BOOST_ASSERT(*m_position == static_cast(')')); + ++m_position; // skip the closing ')' + break; + } + put(*m_position); + ++m_position; + break; + case ')': + if(m_flags & boost::regex_constants::format_all) + { + return; + } + put(*m_position); + ++m_position; + break; + case ':': + if((m_flags & boost::regex_constants::format_all) && m_have_conditional) + { + return; + } + put(*m_position); + ++m_position; + break; + case '?': + if(m_flags & boost::regex_constants::format_all) + { + ++m_position; + format_conditional(); + break; + } + put(*m_position); + ++m_position; + break; + case '$': + if((m_flags & format_sed) == 0) + { + format_perl(); + break; + } + // fall through, not a special character: + default: + put(*m_position); + ++m_position; + break; + } + } +} + +template +void basic_regex_formatter::format_perl() +{ + // + // On entry *m_position points to a '$' character + // output the information that goes with it: + // + BOOST_ASSERT(*m_position == '$'); + // + // see if this is a trailing '$': + // + if(++m_position == m_end) + { + --m_position; + put(*m_position); + ++m_position; + return; + } + // + // OK find out what kind it is: + // + bool have_brace = false; + const char_type* save_position = m_position; + switch(*m_position) + { + case '&': + ++m_position; + put(this->m_results[0]); + break; + case '`': + ++m_position; + put(this->m_results.prefix()); + break; + case '\'': + ++m_position; + put(this->m_results.suffix()); + break; + case '$': + put(*m_position++); + break; + case '{': + have_brace = true; + ++m_position; + // fall through.... + default: + // see if we have a number: + { + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(2), len); + int v = m_traits.toi(m_position, m_position + len, 10); + if((v < 0) || (have_brace && ((m_position == m_end) || (*m_position != '}')))) + { + // leave the $ as is, and carry on: + m_position = --save_position; + put(*m_position); + ++m_position; + break; + } + // otherwise output sub v: + put(this->m_results[v]); + if(have_brace) + ++m_position; + } + } +} + +template +void basic_regex_formatter::format_escape() +{ + // skip the escape and check for trailing escape: + if(++m_position == m_end) + { + put(static_cast('\\')); + return; + } + // now switch on the escape type: + switch(*m_position) + { + case 'a': + put(static_cast('\a')); + ++m_position; + break; + case 'f': + put(static_cast('\f')); + ++m_position; + break; + case 'n': + put(static_cast('\n')); + ++m_position; + break; + case 'r': + put(static_cast('\r')); + ++m_position; + break; + case 't': + put(static_cast('\t')); + ++m_position; + break; + case 'v': + put(static_cast('\v')); + ++m_position; + break; + case 'x': + if(++m_position == m_end) + { + put(static_cast('x')); + return; + } + // maybe have \x{ddd} + if(*m_position == static_cast('{')) + { + ++m_position; + int val = m_traits.toi(m_position, m_end, 16); + if(val < 0) + { + // invalid value treat everything as literals: + put(static_cast('x')); + put(static_cast('{')); + return; + } + if(*m_position != static_cast('}')) + { + while(*m_position != static_cast('\\')) + --m_position; + ++m_position; + put(*m_position++); + return; + } + ++m_position; + put(static_cast(val)); + return; + } + else + { + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(2), len); + int val = m_traits.toi(m_position, m_position + len, 16); + if(val < 0) + { + --m_position; + put(*m_position++); + return; + } + put(static_cast(val)); + } + break; + case 'c': + if(++m_position == m_end) + { + --m_position; + put(*m_position++); + return; + } + put(static_cast(*m_position++ % 32)); + break; + case 'e': + put(static_cast(27)); + ++m_position; + break; + default: + // see if we have a perl specific escape: + if((m_flags & boost::regex_constants::format_sed) == 0) + { + bool breakout = false; + switch(*m_position) + { + case 'l': + ++m_position; + m_restore_state = m_state; + m_state = output_next_lower; + breakout = true; + break; + case 'L': + ++m_position; + m_state = output_lower; + breakout = true; + break; + case 'u': + ++m_position; + m_restore_state = m_state; + m_state = output_next_upper; + breakout = true; + break; + case 'U': + ++m_position; + m_state = output_upper; + breakout = true; + break; + case 'E': + ++m_position; + m_state = output_copy; + breakout = true; + break; + } + if(breakout) + break; + } + // see if we have a \n sed style backreference: + int v = m_traits.toi(m_position, m_position+1, 10); + if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed))) + { + put(m_results[v]); + break; + } + else if(v == 0) + { + // octal ecape sequence: + --m_position; + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(4), len); + v = m_traits.toi(m_position, m_position + len, 8); + BOOST_ASSERT(v >= 0); + put(static_cast(v)); + break; + } + // Otherwise output the character "as is": + put(*m_position++); + break; + } +} + +template +void basic_regex_formatter::format_conditional() +{ + if(m_position == m_end) + { + // oops trailing '?': + put(static_cast('?')); + return; + } + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(2), len); + int v = m_traits.toi(m_position, m_position + len, 10); + if(v < 0) + { + // oops not a number: + put(static_cast('?')); + return; + } + + // output varies depending upon whether sub-expression v matched or not: + if(m_results[v].matched) + { + m_have_conditional = true; + format_all(); + m_have_conditional = false; + if((m_position != m_end) && (*m_position == static_cast(':'))) + { + // skip the ':': + ++m_position; + // save output state, then turn it off: + output_state saved_state = m_state; + m_state = output_none; + // format the rest of this scope: + format_until_scope_end(); + // restore output state: + m_state = saved_state; + } + } + else + { + // save output state, then turn it off: + output_state saved_state = m_state; + m_state = output_none; + // format until ':' or ')': + m_have_conditional = true; + format_all(); + m_have_conditional = false; + // restore state: + m_state = saved_state; + if((m_position != m_end) && (*m_position == static_cast(':'))) + { + // skip the ':': + ++m_position; + // format the rest of this scope: + format_until_scope_end(); + } + } +} + +template +void basic_regex_formatter::format_until_scope_end() +{ + do + { + format_all(); + if((m_position == m_end) || (*m_position == static_cast(')'))) + return; + put(*m_position++); + }while(m_position != m_end); +} + +template +void basic_regex_formatter::put(char_type c) +{ + // write a single character to output + // according to which case translation mode we are in: + switch(this->m_state) + { + case output_none: + return; + case output_next_lower: + c = m_traits.tolower(c); + this->m_state = m_restore_state; + break; + case output_next_upper: + c = m_traits.toupper(c); + this->m_state = m_restore_state; + break; + case output_lower: + c = m_traits.tolower(c); + break; + case output_upper: + c = m_traits.toupper(c); + break; + default: + break; + } + *m_out = c; + ++m_out; +} + +template +void basic_regex_formatter::put(const sub_match_type& sub) +{ + typedef typename sub_match_type::iterator iterator_type; + iterator_type i = sub.first; + while(i != sub.second) + { + put(*i); + ++i; + } +} + +template +class string_out_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator +#endif +{ + S* out; +public: + string_out_iterator(S& s) : out(&s) {} + string_out_iterator& operator++() { return *this; } + string_out_iterator& operator++(int) { return *this; } + string_out_iterator& operator*() { return *this; } + string_out_iterator& operator=(typename S::value_type v) + { + out->append(1, v); + return *this; + } + +#ifdef BOOST_NO_STD_ITERATOR + typedef std::ptrdiff_t difference_type; + typedef typename S::value_type value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::output_iterator_tag iterator_category; +#endif +}; + +template +OutputIterator regex_format_imp(OutputIterator out, + const match_results& m, + const charT* p1, const charT* p2, + match_flag_type flags, + const traits& t + ) +{ + if(flags & regex_constants::format_literal) + { + return re_detail::copy(p1, p2, out); + } + + re_detail::basic_regex_formatter< + OutputIterator, + match_results, + traits > f(out, m, t); + return f.format(p1, p2, flags); +} + + +} // namespace re_detail + +template +OutputIterator regex_format(OutputIterator out, + const match_results& m, + const charT* fmt, + match_flag_type flags = format_all + ) +{ + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, m, fmt, fmt + traits.length(fmt), flags, traits); +} + +template +OutputIterator regex_format(OutputIterator out, + const match_results& m, + const std::basic_string& fmt, + match_flag_type flags = format_all + ) +{ + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); +} + +template +std::basic_string regex_format(const match_results& m, + const charT* fmt, + match_flag_type flags = format_all) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, m, fmt, fmt + traits.length(fmt), flags, traits); + return result; +} + +template +std::basic_string regex_format(const match_results& m, + const std::basic_string& fmt, + match_flag_type flags = format_all) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_FORMAT_HPP + + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_fwd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_fwd.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,73 @@ +/* + * + * 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 regex_fwd.cpp + * VERSION see + * DESCRIPTION: Forward declares boost::basic_regex<> and + * associated typedefs. + */ + +#ifndef BOOST_REGEX_FWD_HPP_INCLUDED +#define BOOST_REGEX_FWD_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +// +// define BOOST_REGEX_NO_FWD if this +// header doesn't work! +// +#ifdef BOOST_REGEX_NO_FWD +# ifndef BOOST_RE_REGEX_HPP +# include +# endif +#else + +namespace boost{ + +template +class cpp_regex_traits; +template +struct c_regex_traits; +template +class w32_regex_traits; + +#ifdef BOOST_REGEX_USE_WIN32_LOCALE +template > +struct regex_traits; +#elif defined(BOOST_REGEX_USE_CPP_LOCALE) +template > +struct regex_traits; +#else +template > +struct regex_traits; +#endif + +template > +class basic_regex; + +typedef basic_regex > regex; +#ifndef BOOST_NO_WREGEX +typedef basic_regex > wregex; +#endif + +} // namespace boost + +#endif // BOOST_REGEX_NO_FWD + +#endif + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_grep.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_grep.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,155 @@ +/* + * + * 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 regex_grep.hpp + * VERSION see + * DESCRIPTION: Provides regex_grep implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_GREP_HPP +#define BOOST_REGEX_V4_REGEX_GREP_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// +// regex_grep: +// find all non-overlapping matches within the sequence first last: +// +template +inline unsigned int regex_grep(Predicate foo, + BidiIterator first, + BidiIterator last, + const basic_regex& e, + match_flag_type flags = match_default) +{ + if(e.flags() & regex_constants::failbit) + return false; + + typedef typename match_results::allocator_type match_allocator_type; + + match_results m; + re_detail::perl_matcher matcher(first, last, m, e, flags, first); + unsigned int count = 0; + while(matcher.find()) + { + ++count; + if(0 == foo(m)) + return count; // caller doesn't want to go on + if(m[0].second == last) + return count; // we've reached the end, don't try and find an extra null match. + if(m.length() == 0) + { + if(m[0].second == last) + return count; + // we found a NULL-match, now try to find + // a non-NULL one at the same position: + match_results m2(m); + matcher.setf(match_not_null | match_continuous); + if(matcher.find()) + { + ++count; + if(0 == foo(m)) + return count; + } + else + { + // reset match back to where it was: + m = m2; + } + matcher.unsetf((match_not_null | match_continuous) & ~flags); + } + } + return count; +} + +// +// regex_grep convenience interfaces: +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +// +// this isn't really a partial specialisation, but template function +// overloading - if the compiler doesn't support partial specialisation +// then it really won't support this either: +template +inline unsigned int regex_grep(Predicate foo, const charT* str, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, str, str + traits::length(str), e, flags); +} + +template +inline unsigned int regex_grep(Predicate foo, const std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, s.begin(), s.end(), e, flags); +} +#else // partial specialisation +inline unsigned int regex_grep(bool (*foo)(const cmatch&), const char* str, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, str, str + regex::traits_type::length(str), e, flags); +} +#ifndef BOOST_NO_WREGEX +inline unsigned int regex_grep(bool (*foo)(const wcmatch&), const wchar_t* str, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, str, str + wregex::traits_type::length(str), e, flags); +} +#endif +inline unsigned int regex_grep(bool (*foo)(const match_results&), const std::string& s, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, s.begin(), s.end(), e, flags); +} +#if !defined(BOOST_NO_WREGEX) +inline unsigned int regex_grep(bool (*foo)(const match_results::const_iterator>&), + const std::basic_string& s, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, s.begin(), s.end(), e, flags); +} +#endif +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_GREP_HPP + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_iterator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,201 @@ +/* + * + * Copyright (c) 2003 + * 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_iterator.hpp + * VERSION see + * DESCRIPTION: Provides regex_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_ITERATOR_HPP +#define BOOST_REGEX_V4_REGEX_ITERATOR_HPP + +#include + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +class regex_iterator_implementation +{ + typedef basic_regex regex_type; + + match_results what; // current match + BidirectionalIterator base; // start of sequence + BidirectionalIterator end; // end of sequence + const regex_type re; // the expression + match_flag_type flags; // flags for matching + +public: + regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f) + : base(), end(last), re(*p), flags(f){} + bool init(BidirectionalIterator first) + { + base = first; + return regex_search(first, end, what, re, flags); + } + bool compare(const regex_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); + } + const match_results& get() + { return what; } + bool next() + { + //if(what.prefix().first != what[0].second) + // flags |= match_prev_avail; + BidirectionalIterator next_start = what[0].second; + match_flag_type f(flags); + if(!what.length()) + f |= regex_constants::match_not_initial_null; + //if(base != next_start) + // f |= regex_constants::match_not_bob; + bool result = regex_search(next_start, end, what, re, f, base); + if(result) + what.set_base(base); + return result; + } +private: + regex_iterator_implementation& operator=(const regex_iterator_implementation&); +}; + +template ::value_type, + class traits = regex_traits > +class regex_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + match_results, + typename re_detail::regex_iterator_traits::difference_type, + const match_results*, + const match_results& > +#endif +{ +private: + typedef regex_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef basic_regex regex_type; + typedef match_results value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + regex_iterator(){} + regex_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + match_flag_type m = match_default) + : pdata(new impl(&re, b, m)) + { + if(!pdata->init(a)) + { + pdata.reset(); + } + } + regex_iterator(const regex_iterator& that) + : pdata(that.pdata) {} + regex_iterator& operator=(const regex_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const regex_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const regex_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + regex_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + regex_iterator operator++(int) + { + regex_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef regex_iterator cregex_iterator; +typedef regex_iterator sregex_iterator; +#ifndef BOOST_NO_WREGEX +typedef regex_iterator wcregex_iterator; +typedef regex_iterator wsregex_iterator; +#endif + +// make_regex_iterator: +template +inline regex_iterator make_regex_iterator(const charT* p, const basic_regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_iterator(p, p+traits::length(p), e, m); +} +template +inline regex_iterator::const_iterator, charT, traits> make_regex_iterator(const std::basic_string& p, const basic_regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, m); +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_ITERATOR_HPP + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_match.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_match.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,382 @@ +/* + * + * 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 regex_match.hpp + * VERSION see + * DESCRIPTION: Regular expression matching algorithms. + * Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + + +#ifndef BOOST_REGEX_MATCH_HPP +#define BOOST_REGEX_MATCH_HPP + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// +// proc regex_match +// returns true if the specified regular expression matches +// the whole of the input. Fills in what matched in m. +// +template +bool regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + re_detail::perl_matcher matcher(first, last, m, e, flags, first); + return matcher.match(); +} +template +bool regex_match(iterator first, iterator last, + const basic_regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(first, last, m, e, flags | regex_constants::match_any); +} +// +// query_match convenience interfaces: +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +// +// this isn't really a partial specialisation, but template function +// overloading - if the compiler doesn't support partial specialisation +// then it really won't support this either: +template +inline bool regex_match(const charT* str, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + traits::length(str), m, e, flags); +} + +template +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator, Allocator>& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +template +inline bool regex_match(const charT* str, + const basic_regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any); +} + +template +inline bool regex_match(const std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + typedef typename std::basic_string::const_iterator iterator; + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#else // partial ordering +inline bool regex_match(const char* str, + cmatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +#ifndef BOOST_NO_WREGEX +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const wregex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +#endif +inline bool regex_match(const std::string& s, + smatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +#if !defined(BOOST_NO_WREGEX) +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const wregex& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +#endif + +#endif + + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_MATCH_HPP + + + + + + + + + + + + + + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_merge.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_merge.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,93 @@ +/* + * + * 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 regex_format.hpp + * VERSION see + * DESCRIPTION: Provides formatting output routines for search and replace + * operations. Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP +#define BOOST_REGEX_V4_REGEX_MERGE_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +inline OutputIterator regex_merge(OutputIterator out, + Iterator first, + Iterator last, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + return regex_replace(out, first, last, e, fmt, flags); +} + +template +inline OutputIterator regex_merge(OutputIterator out, + Iterator first, + Iterator last, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return regex_merge(out, first, last, e, fmt.c_str(), flags); +} + +template +inline std::basic_string regex_merge(const std::basic_string& s, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + return regex_replace(s, e, fmt, flags); +} + +template +inline std::basic_string regex_merge(const std::basic_string& s, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return regex_replace(s, e, fmt, flags); +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_MERGE_HPP + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_raw_buffer.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_raw_buffer.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,210 @@ +/* + * + * 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 regex_raw_buffer.hpp + * VERSION see + * DESCRIPTION: Raw character buffer for regex code. + * Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#define BOOST_REGEX_RAW_BUFFER_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include +#include + +namespace boost{ + namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +struct empty_padding{}; + +union padding +{ + void* p; + unsigned int i; +}; + +template +struct padding3 +{ + enum{ + padding_size = 8, + padding_mask = 7 + }; +}; + +template<> +struct padding3<2> +{ + enum{ + padding_size = 2, + padding_mask = 1 + }; +}; + +template<> +struct padding3<4> +{ + enum{ + padding_size = 4, + padding_mask = 3 + }; +}; + +template<> +struct padding3<8> +{ + enum{ + padding_size = 8, + padding_mask = 7 + }; +}; + +template<> +struct padding3<16> +{ + enum{ + padding_size = 16, + padding_mask = 15 + }; +}; + +enum{ + padding_size = padding3::padding_size, + padding_mask = padding3::padding_mask +}; + +// +// class raw_storage +// basically this is a simplified vector +// this is used by basic_regex for expression storage +// + +class BOOST_REGEX_DECL raw_storage +{ +public: + typedef std::size_t size_type; + typedef unsigned char* pointer; +private: + pointer last, start, end; +public: + + raw_storage(); + raw_storage(size_type n); + + ~raw_storage() + { + ::operator delete(start); + } + + void BOOST_REGEX_CALL resize(size_type n); + + void* BOOST_REGEX_CALL extend(size_type n) + { + if(size_type(last - end) < n) + resize(n + (end - start)); + register pointer result = end; + end += n; + return result; + } + + void* BOOST_REGEX_CALL insert(size_type pos, size_type n); + + size_type BOOST_REGEX_CALL size() + { + return end - start; + } + + size_type BOOST_REGEX_CALL capacity() + { + return last - start; + } + + void* BOOST_REGEX_CALL data()const + { + return start; + } + + size_type BOOST_REGEX_CALL index(void* ptr) + { + return static_cast(ptr) - static_cast(data()); + } + + void BOOST_REGEX_CALL clear() + { + end = start; + } + + void BOOST_REGEX_CALL align() + { + // move end up to a boundary: + end = start + (((end - start) + padding_mask) & ~padding_mask); + } + void swap(raw_storage& that) + { + std::swap(start, that.start); + std::swap(end, that.end); + std::swap(last, that.last); + } +}; + +inline raw_storage::raw_storage() +{ + last = start = end = 0; +} + +inline raw_storage::raw_storage(size_type n) +{ + start = end = static_cast(::operator new(n)); + BOOST_REGEX_NOEH_ASSERT(start) + last = start + n; +} + + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace re_detail +} // namespace boost + +#endif + + + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_replace.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_replace.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,122 @@ +/* + * + * 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 regex_format.hpp + * VERSION see + * DESCRIPTION: Provides formatting output routines for search and replace + * operations. Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP +#define BOOST_REGEX_V4_REGEX_REPLACE_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +OutputIterator regex_replace(OutputIterator out, + BidirectionalIterator first, + BidirectionalIterator last, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + regex_iterator i(first, last, e, flags); + regex_iterator j; + if(i == j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(first, last, out); + } + else + { + BidirectionalIterator last_m(first); + while(i != j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(i->prefix().first, i->prefix().second, out); + out = i->format(out, fmt, flags, e); + last_m = (*i)[0].second; + if(flags & regex_constants::format_first_only) + break; + ++i; + } + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(last_m, last, out); + } + return out; +} + +template +inline OutputIterator regex_replace(OutputIterator out, + Iterator first, + Iterator last, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return regex_replace(out, first, last, e, fmt.c_str(), flags); +} + +template +std::basic_string regex_replace(const std::basic_string& s, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + regex_replace(i, s.begin(), s.end(), e, fmt, flags); + return result; +} + +template +std::basic_string regex_replace(const std::basic_string& s, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_REPLACE_HPP + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_search.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_search.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,217 @@ +/* + * + * 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 regex_search.hpp + * VERSION see + * DESCRIPTION: Provides regex_search implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP +#define BOOST_REGEX_V4_REGEX_SEARCH_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +bool regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(first, last, m, e, flags, first); +} + +template +bool regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const basic_regex& e, + match_flag_type flags, + BidiIterator base) +{ + if(e.flags() & regex_constants::failbit) + return false; + + re_detail::perl_matcher matcher(first, last, m, e, flags, base); + return matcher.find(); +} + +// +// regex_search convenience interfaces: +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +// +// this isn't really a partial specialisation, but template function +// overloading - if the compiler doesn't support partial specialisation +// then it really won't support this either: +template +inline bool regex_search(const charT* str, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + traits::length(str), m, e, flags); +} + +template +inline bool regex_search(const std::basic_string& s, + match_results::const_iterator, Allocator>& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), m, e, flags); +} +#else // partial overloads: +inline bool regex_search(const char* str, + cmatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_search(const char* first, const char* last, + const regex& e, + match_flag_type flags = match_default) +{ + cmatch m; + return regex_search(first, last, m, e, flags | regex_constants::match_any); +} + +#ifndef BOOST_NO_WREGEX +inline bool regex_search(const wchar_t* str, + wcmatch& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_search(const wchar_t* first, const wchar_t* last, + const wregex& e, + match_flag_type flags = match_default) +{ + wcmatch m; + return regex_search(first, last, m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_search(const std::string& s, + smatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), m, e, flags); +} +#if !defined(BOOST_NO_WREGEX) +inline bool regex_search(const std::basic_string& s, + wsmatch& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), m, e, flags); +} +#endif + +#endif + +template +bool regex_search(BidiIterator first, BidiIterator last, + const basic_regex& e, + match_flag_type flags = match_default) +{ + if(e.flags() & regex_constants::failbit) + return false; + + match_results m; + typedef typename match_results::allocator_type match_alloc_type; + re_detail::perl_matcher matcher(first, last, m, e, flags | regex_constants::match_any, first); + return matcher.find(); +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template +inline bool regex_search(const charT* str, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + traits::length(str), e, flags); +} + +template +inline bool regex_search(const std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), e, flags); +} +#else // non-template function overloads +inline bool regex_search(const char* str, + const regex& e, + match_flag_type flags = match_default) +{ + cmatch m; + return regex_search(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_WREGEX +inline bool regex_search(const wchar_t* str, + const wregex& e, + match_flag_type flags = match_default) +{ + wcmatch m; + return regex_search(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_search(const std::string& s, + const regex& e, + match_flag_type flags = match_default) +{ + smatch m; + return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if !defined(BOOST_NO_WREGEX) +inline bool regex_search(const std::basic_string& s, + const wregex& e, + match_flag_type flags = match_default) +{ + wsmatch m; + return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} + +#endif // BOOST_NO_WREGEX + +#endif // partial overload + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_SEARCH_HPP + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_split.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_split.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,172 @@ +/* + * + * 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 regex_split.hpp + * VERSION see + * DESCRIPTION: Implements regex_split and associated functions. + * Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_SPLIT_HPP +#define BOOST_REGEX_SPLIT_HPP + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace re_detail{ + +template +const basic_regex& get_default_expression(charT) +{ + static const charT expression_text[4] = { '\\', 's', '+', '\00', }; + static const basic_regex e(expression_text); + return e; +} + +template +class split_pred +{ + typedef std::basic_string string_type; + typedef typename string_type::const_iterator iterator_type; + iterator_type* p_last; + OutputIterator* p_out; + std::size_t* p_max; + std::size_t initial_max; +public: + split_pred(iterator_type* a, OutputIterator* b, std::size_t* c) + : p_last(a), p_out(b), p_max(c), initial_max(*c) {} + + bool operator()(const match_results& what); +}; + +template +bool split_pred::operator() + (const match_results& what) +{ + *p_last = what[0].second; + if(what.size() > 1) + { + // output sub-expressions only: + for(unsigned i = 1; i < what.size(); ++i) + { + *(*p_out) = what.str(i); + ++(*p_out); + if(0 == --*p_max) return false; + } + return *p_max != 0; + } + else + { + // output $` only if it's not-null or not at the start of the input: + const sub_match& sub = what[-1]; + if((sub.first != sub.second) || (*p_max != initial_max)) + { + *(*p_out) = sub.str(); + ++(*p_out); + return --*p_max; + } + } + // + // initial null, do nothing: + return true; +} + +} // namespace re_detail + +template +std::size_t regex_split(OutputIterator out, + std::basic_string& s, + const basic_regex& e, + match_flag_type flags, + std::size_t max_split) +{ + typedef typename std::basic_string::const_iterator ci_t; + typedef typename match_results::allocator_type match_allocator; + ci_t last = s.begin(); + std::size_t init_size = max_split; + re_detail::split_pred pred(&last, &out, &max_split); + ci_t i, j; + i = s.begin(); + j = s.end(); + regex_grep(pred, i, j, e, flags); + // + // if there is still input left, do a final push as long as max_split + // is not exhausted, and we're not splitting sub-expressions rather + // than whitespace: + if(max_split && (last != s.end()) && (e.mark_count() == 1)) + { + *out = std::basic_string((ci_t)last, (ci_t)s.end()); + ++out; + last = s.end(); + --max_split; + } + // + // delete from the string everything that has been processed so far: + s.erase(0, last - s.begin()); + // + // return the number of new records pushed: + return init_size - max_split; +} + +template +inline std::size_t regex_split(OutputIterator out, + std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_split(out, s, e, flags, UINT_MAX); +} + +template +inline std::size_t regex_split(OutputIterator out, + std::basic_string& s) +{ + return regex_split(out, s, re_detail::get_default_expression(charT(0)), match_default, UINT_MAX); +} + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_token_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_token_iterator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,342 @@ +/* + * + * Copyright (c) 2003 + * 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_token_iterator.hpp + * VERSION see + * DESCRIPTION: Provides regex_token_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP +#define BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP + +#include +#include +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +// +// Borland C++ Builder 6, and Visual C++ 6, +// can't cope with the array template constructor +// so we have a template member that will accept any type as +// argument, and then assert that is really is an array: +// +#include +#include +#endif + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) +# pragma warning(push) +# pragma warning(disable:4700) +#endif + +template +class regex_token_iterator_implementation +{ + typedef basic_regex regex_type; + typedef sub_match value_type; + + match_results what; // current match + BidirectionalIterator base; // start of search area + BidirectionalIterator end; // end of search area + const regex_type re; // the expression + match_flag_type flags; // match flags + value_type result; // the current string result + int N; // the current sub-expression being enumerated + std::vector subs; // the sub-expressions to enumerate + +public: + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f) + : end(last), re(*p), flags(f){ subs.push_back(sub); } + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector& v, match_flag_type f) + : end(last), re(*p), flags(f), subs(v){} +#if !BOOST_WORKAROUND(__HP_aCC, < 60700) +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const T& submatches, match_flag_type f) + : end(last), re(*p), flags(f) + { + // assert that T really is an array: + BOOST_STATIC_ASSERT(::boost::is_array::value); + const std::size_t array_size = sizeof(T) / sizeof(submatches[0]); + for(std::size_t i = 0; i < array_size; ++i) + { + subs.push_back(submatches[i]); + } + } +#else + template + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f) + : end(last), re(*p), flags(f) + { + for(std::size_t i = 0; i < CN; ++i) + { + subs.push_back(submatches[i]); + } + } +#endif +#endif + bool init(BidirectionalIterator first) + { + N = 0; + base = first; + if(regex_search(first, end, what, re, flags, base) == true) + { + N = 0; + result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]); + return true; + } + else if((subs[N] == -1) && (first != end)) + { + result.first = first; + result.second = end; + result.matched = (first != end); + N = -1; + return true; + } + return false; + } + bool compare(const regex_token_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) + && (end == that.end) + && (flags == that.flags) + && (N == that.N) + && (what[0].first == that.what[0].first) + && (what[0].second == that.what[0].second); + } + const value_type& get() + { return result; } + bool next() + { + if(N == -1) + return false; + if(N+1 < (int)subs.size()) + { + ++N; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + //if(what.prefix().first != what[0].second) + // flags |= /*match_prev_avail |*/ regex_constants::match_not_bob; + BidirectionalIterator last_end(what[0].second); + if(regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base)) + { + N =0; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + else if((last_end != end) && (subs[0] == -1)) + { + N =-1; + result.first = last_end; + result.second = end; + result.matched = (last_end != end); + return true; + } + return false; + } +private: + regex_token_iterator_implementation& operator=(const regex_token_iterator_implementation&); +}; + +template ::value_type, + class traits = regex_traits > +class regex_token_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + sub_match, + typename re_detail::regex_iterator_traits::difference_type, + const sub_match*, + const sub_match& > +#endif +{ +private: + typedef regex_token_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef basic_regex regex_type; + typedef sub_match value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + regex_token_iterator(){} + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + int submatch = 0, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatch, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const std::vector& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#if !BOOST_WORKAROUND(__HP_aCC, < 60700) +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const T& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#else + template + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const int (&submatches)[N], match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#endif +#endif + regex_token_iterator(const regex_token_iterator& that) + : pdata(that.pdata) {} + regex_token_iterator& operator=(const regex_token_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const regex_token_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const regex_token_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + regex_token_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + regex_token_iterator operator++(int) + { + regex_token_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef regex_token_iterator cregex_token_iterator; +typedef regex_token_iterator sregex_token_iterator; +#ifndef BOOST_NO_WREGEX +typedef regex_token_iterator wcregex_token_iterator; +typedef regex_token_iterator wsregex_token_iterator; +#endif + +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} +#endif +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} + +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) +# pragma warning(pop) +#endif +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,189 @@ +/* + * + * Copyright (c) 2003 + * 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.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits classes. + */ + +#ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_REGEX_TRAITS_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifndef BOOST_NO_STD_LOCALE +# ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) +# ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +# ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#ifndef BOOST_REGEX_FWD_HPP_INCLUDED +#include +#endif + +#include "boost/mpl/has_xxx.hpp" +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +template +struct regex_traits : public implementationT +{ + regex_traits() : implementationT() {} +}; + +// +// class regex_traits_wrapper. +// this is what our implementation will actually store; +// it provides default implementations of the "optional" +// interfaces that we support, in addition to the +// required "standard" ones: +// +namespace re_detail{ +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__HP_aCC, < 60000) +BOOST_MPL_HAS_XXX_TRAIT_DEF(boost_extensions_tag) +#else +template +struct has_boost_extensions_tag +{ + BOOST_STATIC_CONSTANT(bool, value = false); +}; +#endif + +template +struct default_wrapper : public BaseT +{ + typedef typename BaseT::char_type char_type; + std::string error_string(::boost::regex_constants::error_type e)const + { + return ::boost::re_detail::get_default_error_string(e); + } + ::boost::regex_constants::syntax_type syntax_type(char_type c)const + { + return ((c & 0x7f) == c) ? get_default_syntax_type(static_cast(c)) : ::boost::regex_constants::syntax_char; + } + ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const + { + return ((c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast(c)) : ::boost::regex_constants::escape_type_identity; + } + int toi(const char_type*& p1, const char_type* p2, int radix)const + { + return ::boost::re_detail::global_toi(p1, p2, radix, *this); + } + char_type translate(char_type c, bool icase)const + { + return (icase ? this->translate_nocase(c) : this->translate(c)); + } + char_type translate(char_type c)const + { + return BaseT::translate(c); + } + char_type tolower(char_type c)const + { + return ::boost::re_detail::global_lower(c); + } + char_type toupper(char_type c)const + { + return ::boost::re_detail::global_upper(c); + } +}; + +template +struct compute_wrapper_base +{ + typedef BaseT type; +}; +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__HP_aCC, < 60000) +template +struct compute_wrapper_base +{ + typedef default_wrapper type; +}; +#else +template <> +struct compute_wrapper_base, false> +{ + typedef default_wrapper > type; +}; +#ifndef BOOST_NO_WREGEX +template <> +struct compute_wrapper_base, false> +{ + typedef default_wrapper > type; +}; +#endif +#endif + +} // namespace re_detail + +template +struct regex_traits_wrapper + : public ::boost::re_detail::compute_wrapper_base< + BaseT, + ::boost::re_detail::has_boost_extensions_tag::value + >::type +{ + regex_traits_wrapper(){} +private: + regex_traits_wrapper(const regex_traits_wrapper&); + regex_traits_wrapper& operator=(const regex_traits_wrapper&); +}; + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // include + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits_defaults.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits_defaults.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,331 @@ +/* + * + * 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.hpp + * VERSION see + * DESCRIPTION: Declares API's for access to regex_traits default properties. + */ + +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#define BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#include +#endif + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strlen; +} +#endif + +namespace boost{ namespace re_detail{ + + +// +// helpers to suppress warnings: +// +template +inline bool is_extended(charT c) +{ return c > 256; } +inline bool is_extended(char) +{ return false; } + + +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n); +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n); +BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c); +BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c); + +// is charT c a combining character? +BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(uint_least16_t s); + +template +inline bool is_combining(charT c) +{ + return (c <= static_cast(0)) ? false : ((c >= static_cast((std::numeric_limits::max)())) ? false : is_combining_implementation(static_cast(c))); +} +template <> +inline bool is_combining(char) +{ + return false; +} +template <> +inline bool is_combining(signed char) +{ + return false; +} +template <> +inline bool is_combining(unsigned char) +{ + return false; +} +#ifndef __hpux // can't use WCHAR_MAX/MIN in pp-directives +#ifdef _MSC_VER +template<> +inline bool is_combining(wchar_t c) +{ + return is_combining_implementation(static_cast(c)); +} +#elif !defined(__DECCXX) && !defined(__osf__) && !defined(__OSF__) && defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if defined(WCHAR_MAX) && (WCHAR_MAX <= USHRT_MAX) +template<> +inline bool is_combining(wchar_t c) +{ + return is_combining_implementation(static_cast(c)); +} +#else +template<> +inline bool is_combining(wchar_t c) +{ + return (c >= (std::numeric_limits::max)()) ? false : is_combining_implementation(static_cast(c)); +} +#endif +#endif +#endif + +// +// is a charT c a line separator? +// +template +inline bool is_separator(charT c) +{ + return BOOST_REGEX_MAKE_BOOL( + (c == static_cast('\n')) + || (c == static_cast('\r')) + || (c == static_cast('\f')) + || (static_cast(c) == 0x2028u) + || (static_cast(c) == 0x2029u) + || (static_cast(c) == 0x85u)); +} +template <> +inline bool is_separator(char c) +{ + return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r') || (c == '\f')); +} + +// +// get a default collating element: +// +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name); + +// +// get the state_id of a character clasification, the individual +// traits classes then transform that state_id into a bitmask: +// +template +struct character_pointer_range +{ + const charT* p1; + const charT* p2; + + bool operator < (const character_pointer_range& r)const + { + return std::lexicographical_compare(p1, p2, r.p1, r.p2); + } + bool operator == (const character_pointer_range& r)const + { + // Not only do we check that the ranges are of equal size before + // calling std::equal, but there is no other algorithm available: + // not even a non-standard MS one. So forward to unchecked_equal + // in the MS case. + return ((p2 - p1) == (r.p2 - r.p1)) && re_detail::equal(p1, p2, r.p1); + } +}; +template +int get_default_class_id(const charT* p1, const charT* p2) +{ + static const charT data[72] = { + 'a', 'l', 'n', 'u', 'm', + 'a', 'l', 'p', 'h', 'a', + 'b', 'l', 'a', 'n', 'k', + 'c', 'n', 't', 'r', 'l', + 'd', 'i', 'g', 'i', 't', + 'g', 'r', 'a', 'p', 'h', + 'l', 'o', 'w', 'e', 'r', + 'p', 'r', 'i', 'n', 't', + 'p', 'u', 'n', 'c', 't', + 's', 'p', 'a', 'c', 'e', + 'u', 'n', 'i', 'c', 'o', 'd', 'e', + 'u', 'p', 'p', 'e', 'r', + 'w', 'o', 'r', 'd', + 'x', 'd', 'i', 'g', 'i', 't', + }; + + static const character_pointer_range ranges[19] = + { + {data+0, data+5,}, // alnum + {data+5, data+10,}, // alpha + {data+10, data+15,}, // blank + {data+15, data+20,}, // cntrl + {data+20, data+21,}, // d + {data+20, data+25,}, // digit + {data+25, data+30,}, // graph + {data+30, data+31,}, // l + {data+30, data+35,}, // lower + {data+35, data+40,}, // print + {data+40, data+45,}, // punct + {data+45, data+46,}, // s + {data+45, data+50,}, // space + {data+57, data+58,}, // u + {data+50, data+57,}, // unicode + {data+57, data+62,}, // upper + {data+62, data+63,}, // w + {data+62, data+66,}, // word + {data+66, data+72,}, // xdigit + }; + static const character_pointer_range* ranges_begin = ranges; + static const character_pointer_range* ranges_end = ranges + (sizeof(ranges)/sizeof(ranges[0])); + + character_pointer_range t = { p1, p2, }; + const character_pointer_range* p = std::lower_bound(ranges_begin, ranges_end, t); + if((p != ranges_end) && (t == *p)) + return static_cast(p - ranges); + return -1; +} + +// +// helper functions: +// +template +std::ptrdiff_t global_length(const charT* p) +{ + std::ptrdiff_t n = 0; + while(*p) + { + ++p; + ++n; + } + return n; +} +template<> +inline std::ptrdiff_t global_length(const char* p) +{ + return (std::strlen)(p); +} +#ifndef BOOST_NO_WREGEX +template<> +inline std::ptrdiff_t global_length(const wchar_t* p) +{ + return (std::wcslen)(p); +} +#endif +template +inline charT BOOST_REGEX_CALL global_lower(charT c) +{ + return c; +} +template +inline charT BOOST_REGEX_CALL global_upper(charT c) +{ + return c; +} + +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_lower(char c); +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_upper(char c); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c); +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c); +#endif +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_lower(unsigned short c); +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short c); +#endif +// +// This sucks: declare template specialisations of global_lower/global_upper +// that just forward to the non-template implementation functions. We do +// this because there is one compiler (Compaq Tru64 C++) that doesn't seem +// to differentiate between templates and non-template overloads.... +// what's more, the primary template, plus all overloads have to be +// defined in the same translation unit (if one is inline they all must be) +// otherwise the "local template instantiation" compiler option can pick +// the wrong instantiation when linking: +// +template<> inline char BOOST_REGEX_CALL global_lower(char c){ return do_global_lower(c); } +template<> inline char BOOST_REGEX_CALL global_upper(char c){ return do_global_upper(c); } +#ifndef BOOST_NO_WREGEX +template<> inline wchar_t BOOST_REGEX_CALL global_lower(wchar_t c){ return do_global_lower(c); } +template<> inline wchar_t BOOST_REGEX_CALL global_upper(wchar_t c){ return do_global_upper(c); } +#endif +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +template<> inline unsigned short BOOST_REGEX_CALL global_lower(unsigned short c){ return do_global_lower(c); } +template<> inline unsigned short BOOST_REGEX_CALL global_upper(unsigned short c){ return do_global_upper(c); } +#endif + +template +int global_value(charT c) +{ + static const charT zero = '0'; + static const charT nine = '9'; + static const charT a = 'a'; + static const charT f = 'f'; + static const charT A = 'A'; + static const charT F = 'F'; + + if(c > f) return -1; + if(c >= a) return 10 + (c - a); + if(c > F) return -1; + if(c >= A) return 10 + (c - A); + if(c > nine) return -1; + if(c >= zero) return c - zero; + return -1; +} +template +int global_toi(const charT*& p1, const charT* p2, int radix, const traits& t) +{ + (void)t; // warning suppression + int next_value = t.value(*p1, radix); + if((p1 == p2) || (next_value < 0) || (next_value >= radix)) + return -1; + int result = 0; + while(p1 != p2) + { + next_value = t.value(*p1, radix); + if((next_value < 0) || (next_value >= radix)) + break; + result *= radix; + result += next_value; + ++p1; + } + return result; +} + +} // re_detail +} // boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/regex_workaround.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_workaround.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,202 @@ +/* + * + * Copyright (c) 1998-2005 + * 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_workarounds.cpp + * VERSION see + * DESCRIPTION: Declares Misc workarounds. + */ + +#ifndef BOOST_REGEX_WORKAROUND_HPP +#define BOOST_REGEX_WORKAROUND_HPP + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef BOOST_NO_STD_LOCALE +# include +#endif + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::sprintf; using ::strcpy; using ::strcat; using ::strlen; +} +#endif + +namespace boost{ namespace re_detail{ +#ifdef BOOST_NO_STD_DISTANCE +template +std::ptrdiff_t distance(const T& x, const T& y) +{ return y - x; } +#else +using std::distance; +#endif +}} + + +#ifdef BOOST_REGEX_NO_BOOL +# define BOOST_REGEX_MAKE_BOOL(x) static_cast((x) ? true : false) +#else +# define BOOST_REGEX_MAKE_BOOL(x) static_cast(x) +#endif + +/***************************************************************************** + * + * Fix broken broken namespace support: + * + ****************************************************************************/ + +#if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus) + +namespace std{ + using ::ptrdiff_t; + using ::size_t; + using ::abs; + using ::memset; + using ::memcpy; +} + +#endif + +/***************************************************************************** + * + * helper functions pointer_construct/pointer_destroy: + * + ****************************************************************************/ + +#ifdef __cplusplus +namespace boost{ namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning (push) +#pragma warning (disable : 4100) +#endif + +template +inline void pointer_destroy(T* p) +{ p->~T(); (void)p; } + +#ifdef BOOST_MSVC +#pragma warning (pop) +#endif + +template +inline void pointer_construct(T* p, const T& t) +{ new (p) T(t); } + +}} // namespaces +#endif + +/***************************************************************************** + * + * helper function copy: + * + ****************************************************************************/ + +#ifdef __cplusplus +namespace boost{ namespace re_detail{ +#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(_CPPLIB_VER) && defined(BOOST_DINKUMWARE_STDLIB) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) + // + // MSVC 8 will either emit warnings or else refuse to compile + // code that makes perfectly legitimate use of std::copy, when + // the OutputIterator type is a user-defined class (apparently all user + // defined iterators are "unsafe"). This code works around that: + // + template + inline OutputIterator copy( + InputIterator first, + InputIterator last, + OutputIterator dest + ) + { + return stdext::unchecked_copy(first, last, dest); + } + template + inline bool equal( + InputIterator1 first, + InputIterator1 last, + InputIterator2 with + ) + { + return stdext::unchecked_equal(first, last, with); + } + +#else + using std::copy; + using std::equal; +#endif +#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__ + + // use safe versions of strcpy etc: + using ::strcpy_s; + using ::strcat_s; +#else + inline std::size_t strcpy_s( + char *strDestination, + std::size_t sizeInBytes, + const char *strSource + ) + { + if(std::strlen(strSource)+1 > sizeInBytes) + return 1; + std::strcpy(strDestination, strSource); + return 0; + } + inline std::size_t strcat_s( + char *strDestination, + std::size_t sizeInBytes, + const char *strSource + ) + { + if(std::strlen(strSource) + std::strlen(strDestination) + 1 > sizeInBytes) + return 1; + std::strcat(strDestination, strSource); + return 0; + } + +#endif + + inline void overflow_error_if_not_zero(std::size_t i) + { + if(i) + { + std::overflow_error e("String buffer too small"); + boost::throw_exception(e); + } + } + +}} // namespaces + +#endif // __cplusplus + +#endif // include guard + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/states.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/states.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,290 @@ +/* + * + * 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 states.cpp + * VERSION see + * DESCRIPTION: Declares internal state machine structures. + */ + +#ifndef BOOST_REGEX_V4_STATES_HPP +#define BOOST_REGEX_V4_STATES_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +/*** mask_type ******************************************************* +Whenever we have a choice of two alternatives, we use an array of bytes +to indicate which of the two alternatives it is possible to take for any +given input character. If mask_take is set, then we can take the next +state, and if mask_skip is set then we can take the alternative. +***********************************************************************/ +enum mask_type +{ + mask_take = 1, + mask_skip = 2, + mask_init = 4, + mask_any = mask_skip | mask_take, + mask_all = mask_any +}; + +/*** helpers ********************************************************** +These helpers let us use function overload resolution to detect whether +we have narrow or wide character strings: +***********************************************************************/ +struct _narrow_type{}; +struct _wide_type{}; +template struct is_byte; +template<> struct is_byte { typedef _narrow_type width_type; }; +template<> struct is_byte{ typedef _narrow_type width_type; }; +template<> struct is_byte { typedef _narrow_type width_type; }; +template struct is_byte { typedef _wide_type width_type; }; + +/*** enum syntax_element_type ****************************************** +Every record in the state machine falls into one of the following types: +***********************************************************************/ +enum syntax_element_type +{ + // start of a marked sub-expression, or perl-style (?...) extension + syntax_element_startmark = 0, + // end of a marked sub-expression, or perl-style (?...) extension + syntax_element_endmark = syntax_element_startmark + 1, + // any sequence of literal characters + syntax_element_literal = syntax_element_endmark + 1, + // start of line assertion: ^ + syntax_element_start_line = syntax_element_literal + 1, + // end of line assertion $ + syntax_element_end_line = syntax_element_start_line + 1, + // match any character: . + syntax_element_wild = syntax_element_end_line + 1, + // end of expression: we have a match when we get here + syntax_element_match = syntax_element_wild + 1, + // perl style word boundary: \b + syntax_element_word_boundary = syntax_element_match + 1, + // perl style within word boundary: \B + syntax_element_within_word = syntax_element_word_boundary + 1, + // start of word assertion: \< + syntax_element_word_start = syntax_element_within_word + 1, + // end of word assertion: \> + syntax_element_word_end = syntax_element_word_start + 1, + // start of buffer assertion: \` + syntax_element_buffer_start = syntax_element_word_end + 1, + // end of buffer assertion: \' + syntax_element_buffer_end = syntax_element_buffer_start + 1, + // backreference to previously matched sub-expression + syntax_element_backref = syntax_element_buffer_end + 1, + // either a wide character set [..] or one with multicharacter collating elements: + syntax_element_long_set = syntax_element_backref + 1, + // narrow character set: [...] + syntax_element_set = syntax_element_long_set + 1, + // jump to a new state in the machine: + syntax_element_jump = syntax_element_set + 1, + // choose between two production states: + syntax_element_alt = syntax_element_jump + 1, + // a repeat + syntax_element_rep = syntax_element_alt + 1, + // match a combining character sequence + syntax_element_combining = syntax_element_rep + 1, + // perl style soft buffer end: \z + syntax_element_soft_buffer_end = syntax_element_combining + 1, + // perl style continuation: \G + syntax_element_restart_continue = syntax_element_soft_buffer_end + 1, + // single character repeats: + syntax_element_dot_rep = syntax_element_restart_continue + 1, + syntax_element_char_rep = syntax_element_dot_rep + 1, + syntax_element_short_set_rep = syntax_element_char_rep + 1, + syntax_element_long_set_rep = syntax_element_short_set_rep + 1, + // a backstep for lookbehind repeats: + syntax_element_backstep = syntax_element_long_set_rep + 1, + // an assertion that a mark was matched: + syntax_element_assert_backref = syntax_element_backstep + 1, + syntax_element_toggle_case = syntax_element_assert_backref + 1 +}; + +#ifdef BOOST_REGEX_DEBUG +// dwa 09/26/00 - This is needed to suppress warnings about an ambiguous conversion +std::ostream& operator<<(std::ostream&, syntax_element_type); +#endif + +struct re_syntax_base; + +/*** union offset_type ************************************************ +Points to another state in the machine. During machine construction +we use integral offsets, but these are converted to pointers before +execution of the machine. +***********************************************************************/ +union offset_type +{ + re_syntax_base* p; + std::ptrdiff_t i; +}; + +/*** struct re_syntax_base ******************************************** +Base class for all states in the machine. +***********************************************************************/ +struct re_syntax_base +{ + syntax_element_type type; // what kind of state this is + offset_type next; // next state in the machine +}; + +/*** struct re_brace ************************************************** +A marked parenthesis. +***********************************************************************/ +struct re_brace : public re_syntax_base +{ + // The index to match, can be zero (don't mark the sub-expression) + // or negative (for perl style (?...) extentions): + int index; +}; + +/*** struct re_dot ************************************************** +Match anything. +***********************************************************************/ +enum +{ + dont_care = 1, + force_not_newline = 0, + force_newline = 2, + + test_not_newline = 2, + test_newline = 3 +}; +struct re_dot : public re_syntax_base +{ + unsigned char mask; +}; + +/*** struct re_literal ************************************************ +A string of literals, following this structure will be an +array of characters: charT[length] +***********************************************************************/ +struct re_literal : public re_syntax_base +{ + unsigned int length; +}; + +/*** struct re_case ************************************************ +Indicates whether we are moving to a case insensive block or not +***********************************************************************/ +struct re_case : public re_syntax_base +{ + bool icase; +}; + +/*** struct re_set_long *********************************************** +A wide character set of characters, following this structure will be +an array of type charT: +First csingles null-terminated strings +Then 2 * cranges NULL terminated strings +Then cequivalents NULL terminated strings +***********************************************************************/ +template +struct re_set_long : public re_syntax_base +{ + unsigned int csingles, cranges, cequivalents; + mask_type cclasses; + mask_type cnclasses; + bool isnot; + bool singleton; +}; + +/*** struct re_set **************************************************** +A set of narrow-characters, matches any of _map which is none-zero +***********************************************************************/ +struct re_set : public re_syntax_base +{ + unsigned char _map[1 << CHAR_BIT]; +}; + +/*** struct re_jump *************************************************** +Jump to a new location in the machine (not next). +***********************************************************************/ +struct re_jump : public re_syntax_base +{ + offset_type alt; // location to jump to +}; + +/*** struct re_alt *************************************************** +Jump to a new location in the machine (possibly next). +***********************************************************************/ +struct re_alt : public re_jump +{ + unsigned char _map[1 << CHAR_BIT]; // which characters can take the jump + unsigned int can_be_null; // true if we match a NULL string +}; + +/*** struct re_repeat ************************************************* +Repeat a section of the machine +***********************************************************************/ +struct re_repeat : public re_alt +{ + std::size_t min, max; // min and max allowable repeats + int state_id; // Unique identifier for this repeat + bool leading; // True if this repeat is at the start of the machine (lets us optimize some searches) + bool greedy; // True if this is a greedy repeat +}; + +/*** enum re_jump_size_type ******************************************* +Provides compiled size of re_jump structure (allowing for trailing alignment). +We provide this so we know how manybytes to insert when constructing the machine +(The value of padding_mask is defined in regex_raw_buffer.hpp). +***********************************************************************/ +enum re_jump_size_type +{ + re_jump_size = (sizeof(re_jump) + padding_mask) & ~(padding_mask), + re_repeater_size = (sizeof(re_repeat) + padding_mask) & ~(padding_mask), + re_alt_size = (sizeof(re_alt) + padding_mask) & ~(padding_mask) +}; + +/*** proc re_is_set_member ********************************************* +Forward declaration: we'll need this one later... +***********************************************************************/ + +template +struct regex_data; + +template +iterator BOOST_REGEX_CALL re_is_set_member(iterator next, + iterator last, + const re_set_long* set_, + const regex_data& e, bool icase); + +} // namespace re_detail + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/sub_match.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/sub_match.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,509 @@ +/* + * + * 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 sub_match.cpp + * VERSION see + * DESCRIPTION: Declares template class sub_match. + */ + +#ifndef BOOST_REGEX_V4_SUB_MATCH_HPP +#define BOOST_REGEX_V4_SUB_MATCH_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +template +struct sub_match : public std::pair +{ + typedef typename re_detail::regex_iterator_traits::value_type value_type; +#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef std::ptrdiff_t difference_type; +#else + typedef typename re_detail::regex_iterator_traits::difference_type difference_type; +#endif + typedef BidiIterator iterator_type; + typedef BidiIterator iterator; + typedef BidiIterator const_iterator; + + bool matched; + + sub_match() : std::pair(), matched(false) {} + sub_match(BidiIterator i) : std::pair(i, i), matched(false) {} +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1310)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)\ + && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) + template + operator std::basic_string ()const + { + return std::basic_string(this->first, this->second); + } +#else + operator std::basic_string ()const + { + return str(); + } +#endif + difference_type BOOST_REGEX_CALL length()const + { + difference_type n = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); + return n; + } + std::basic_string str()const + { + std::basic_string result; + std::size_t len = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); + result.reserve(len); + BidiIterator i = this->first; + while(i != this->second) + { + result.append(1, *i); + ++i; + } + return result; + } + int compare(const sub_match& s)const + { + if(matched != s.matched) + return static_cast(matched) - static_cast(s.matched); + return str().compare(s.str()); + } + int compare(const std::basic_string& s)const + { + return str().compare(s); + } + int compare(const value_type* p)const + { + return str().compare(p); + } + + bool operator==(const sub_match& that)const + { return compare(that) == 0; } + bool BOOST_REGEX_CALL operator !=(const sub_match& that)const + { return compare(that) != 0; } + bool operator<(const sub_match& that)const + { return compare(that) < 0; } + bool operator>(const sub_match& that)const + { return compare(that) > 0; } + bool operator<=(const sub_match& that)const + { return compare(that) <= 0; } + bool operator>=(const sub_match& that)const + { return compare(that) >= 0; } + +#ifdef BOOST_REGEX_MATCH_EXTRA + typedef std::vector > capture_sequence_type; + + const capture_sequence_type& captures()const + { + if(!m_captures) + m_captures.reset(new capture_sequence_type()); + return *m_captures; + } + // + // Private implementation API: DO NOT USE! + // + capture_sequence_type& get_captures()const + { + if(!m_captures) + m_captures.reset(new capture_sequence_type()); + return *m_captures; + } + +private: + mutable boost::scoped_ptr m_captures; +public: + +#endif + sub_match(const sub_match& that, bool +#ifdef BOOST_REGEX_MATCH_EXTRA + deep_copy +#endif + = true + ) + : std::pair(that), + matched(that.matched) + { +#ifdef BOOST_REGEX_MATCH_EXTRA + if(that.m_captures) + if(deep_copy) + m_captures.reset(new capture_sequence_type(*(that.m_captures))); +#endif + } + sub_match& operator=(const sub_match& that) + { + this->first = that.first; + this->second = that.second; + matched = that.matched; +#ifdef BOOST_REGEX_MATCH_EXTRA + if(that.m_captures) + get_captures() = *(that.m_captures); +#endif + return *this; + } + + +#ifdef BOOST_OLD_REGEX_H + // + // the following are deprecated, do not use!! + // + operator int()const; + operator unsigned int()const; + operator short()const + { + return (short)(int)(*this); + } + operator unsigned short()const + { + return (unsigned short)(unsigned int)(*this); + } +#endif +}; + +typedef sub_match csub_match; +typedef sub_match ssub_match; +#ifndef BOOST_NO_WREGEX +typedef sub_match wcsub_match; +typedef sub_match wssub_match; +#endif + +// comparison to std::basic_string<> part 1: +template +inline bool operator == (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) == 0; } +template +inline bool operator != (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) != 0; } +template +inline bool operator < (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) < 0; } +template +inline bool operator <= (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) <= 0; } +template +inline bool operator >= (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) >= 0; } +template +inline bool operator > (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) > 0; } +// comparison to std::basic_string<> part 2: +template +inline bool operator == (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) == 0; } +template +inline bool operator != (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) != 0; } +template +inline bool operator < (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) < 0; } +template +inline bool operator > (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) > 0; } +template +inline bool operator <= (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) <= 0; } +template +inline bool operator >= (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) >= 0; } +// comparison to const charT* part 1: +template +inline bool operator == (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) == 0; } +template +inline bool operator != (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) != 0; } +template +inline bool operator > (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) > 0; } +template +inline bool operator < (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) < 0; } +template +inline bool operator >= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) >= 0; } +template +inline bool operator <= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) <= 0; } +// comparison to const charT* part 2: +template +inline bool operator == (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) == 0; } +template +inline bool operator != (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) != 0; } +template +inline bool operator < (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) > 0; } +template +inline bool operator > (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) < 0; } +template +inline bool operator <= (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) >= 0; } +template +inline bool operator >= (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) <= 0; } + +// comparison to const charT& part 1: +template +inline bool operator == (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) == 0; } +template +inline bool operator != (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) != 0; } +template +inline bool operator > (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) > 0; } +template +inline bool operator < (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) < 0; } +template +inline bool operator >= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) >= 0; } +template +inline bool operator <= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) <= 0; } +// comparison to const charT* part 2: +template +inline bool operator == (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) == 0; } +template +inline bool operator != (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) != 0; } +template +inline bool operator < (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) > 0; } +template +inline bool operator > (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) < 0; } +template +inline bool operator <= (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) >= 0; } +template +inline bool operator >= (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) <= 0; } + +// addition operators: +template +inline std::basic_string::value_type, traits, Allocator> +operator + (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ + std::basic_string::value_type, traits, Allocator> result; + result.reserve(s.size() + m.length() + 1); + return result.append(s).append(m.first, m.second); +} +template +inline std::basic_string::value_type, traits, Allocator> +operator + (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ + std::basic_string::value_type, traits, Allocator> result; + result.reserve(s.size() + m.length() + 1); + return result.append(m.first, m.second).append(s); +} +#if !(defined(__GNUC__) && defined(BOOST_NO_STD_LOCALE)) +template +inline std::basic_string::value_type> +operator + (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ + std::basic_string::value_type> result; + result.reserve(std::char_traits::value_type>::length(s) + m.length() + 1); + return result.append(s).append(m.first, m.second); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const * s) +{ + std::basic_string::value_type> result; + result.reserve(std::char_traits::value_type>::length(s) + m.length() + 1); + return result.append(m.first, m.second).append(s); +} +#else +// worwaround versions: +template +inline std::basic_string::value_type> +operator + (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ + return s + m.str(); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const * s) +{ + return m.str() + s; +} +#endif +template +inline std::basic_string::value_type> +operator + (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ + std::basic_string::value_type> result; + result.reserve(m.length() + 2); + return result.append(1, s).append(m.first, m.second); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ + std::basic_string::value_type> result; + result.reserve(m.length() + 2); + return result.append(m.first, m.second).append(1, s); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m1, + const sub_match& m2) +{ + std::basic_string::value_type> result; + result.reserve(m1.length() + m2.length() + 1); + return result.append(m1.first, m1.second).append(m2.first, m2.second); +} +#ifndef BOOST_NO_STD_LOCALE +template +std::basic_ostream& + operator << (std::basic_ostream& os, + const sub_match& s) +{ + return (os << s.str()); +} +#else +template +std::ostream& operator << (std::ostream& os, + const sub_match& s) +{ + return (os << s.str()); +} +#endif + +#ifdef BOOST_OLD_REGEX_H +namespace re_detail{ +template +int do_toi(BidiIterator i, BidiIterator j, char c, int radix) +{ + std::string s(i, j); + char* p; + int result = std::strtol(s.c_str(), &p, radix); + if(*p)raise_regex_exception("Bad sub-expression"); + return result; +} + +// +// helper: +template +int do_toi(I& i, I j, charT c) +{ + int result = 0; + while((i != j) && (isdigit(*i))) + { + result = result*10 + (*i - '0'); + ++i; + } + return result; +} +} + + +template +sub_match::operator int()const +{ + BidiIterator i = first; + BidiIterator j = second; + if(i == j)raise_regex_exception("Bad sub-expression"); + int neg = 1; + if((i != j) && (*i == '-')) + { + neg = -1; + ++i; + } + neg *= re_detail::do_toi(i, j, *i); + if(i != j)raise_regex_exception("Bad sub-expression"); + return neg; +} +template +sub_match::operator unsigned int()const +{ + BidiIterator i = first; + BidiIterator j = second; + if(i == j) + raise_regex_exception("Bad sub-expression"); + return re_detail::do_toi(i, j, *first); +} +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/syntax_type.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/syntax_type.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2003 + * 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 syntax_type.hpp + * VERSION see + * DESCRIPTION: Declares regular expression synatx type enumerator. + */ + +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#define BOOST_REGEX_SYNTAX_TYPE_HPP + +namespace boost{ +namespace regex_constants{ + +typedef unsigned char syntax_type; + +// +// values chosen are binary compatible with previous version: +// +static const syntax_type syntax_char = 0; +static const syntax_type syntax_open_mark = 1; +static const syntax_type syntax_close_mark = 2; +static const syntax_type syntax_dollar = 3; +static const syntax_type syntax_caret = 4; +static const syntax_type syntax_dot = 5; +static const syntax_type syntax_star = 6; +static const syntax_type syntax_plus = 7; +static const syntax_type syntax_question = 8; +static const syntax_type syntax_open_set = 9; +static const syntax_type syntax_close_set = 10; +static const syntax_type syntax_or = 11; +static const syntax_type syntax_escape = 12; +static const syntax_type syntax_dash = 14; +static const syntax_type syntax_open_brace = 15; +static const syntax_type syntax_close_brace = 16; +static const syntax_type syntax_digit = 17; +static const syntax_type syntax_comma = 27; +static const syntax_type syntax_equal = 37; +static const syntax_type syntax_colon = 36; +static const syntax_type syntax_not = 53; + +// extensions: + +static const syntax_type syntax_hash = 13; +static const syntax_type syntax_newline = 26; + +// escapes: + +typedef syntax_type escape_syntax_type; + +static const escape_syntax_type escape_type_word_assert = 18; +static const escape_syntax_type escape_type_not_word_assert = 19; +static const escape_syntax_type escape_type_control_f = 29; +static const escape_syntax_type escape_type_control_n = 30; +static const escape_syntax_type escape_type_control_r = 31; +static const escape_syntax_type escape_type_control_t = 32; +static const escape_syntax_type escape_type_control_v = 33; +static const escape_syntax_type escape_type_ascii_control = 35; +static const escape_syntax_type escape_type_hex = 34; +static const escape_syntax_type escape_type_unicode = 0; // not used +static const escape_syntax_type escape_type_identity = 0; // not used +static const escape_syntax_type escape_type_backref = syntax_digit; +static const escape_syntax_type escape_type_decimal = syntax_digit; // not used +static const escape_syntax_type escape_type_class = 22; +static const escape_syntax_type escape_type_not_class = 23; + +// extensions: + +static const escape_syntax_type escape_type_left_word = 20; +static const escape_syntax_type escape_type_right_word = 21; +static const escape_syntax_type escape_type_start_buffer = 24; // for \` +static const escape_syntax_type escape_type_end_buffer = 25; // for \' +static const escape_syntax_type escape_type_control_a = 28; // for \a +static const escape_syntax_type escape_type_e = 38; // for \e +static const escape_syntax_type escape_type_E = 47; // for \Q\E +static const escape_syntax_type escape_type_Q = 48; // for \Q\E +static const escape_syntax_type escape_type_X = 49; // for \X +static const escape_syntax_type escape_type_C = 50; // for \C +static const escape_syntax_type escape_type_Z = 51; // for \Z +static const escape_syntax_type escape_type_G = 52; // for \G + +static const escape_syntax_type escape_type_property = 54; // for \p +static const escape_syntax_type escape_type_not_property = 55; // for \P +static const escape_syntax_type escape_type_named_char = 56; // for \N + +static const escape_syntax_type syntax_max = 57; + +} +} + + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_iterator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,193 @@ +/* + * + * Copyright (c) 2003 + * 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 u32regex_iterator.hpp + * VERSION see + * DESCRIPTION: Provides u32regex_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP +#define BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP + +namespace boost{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +template +class u32regex_iterator_implementation +{ + typedef u32regex regex_type; + + match_results what; // current match + BidirectionalIterator base; // start of sequence + BidirectionalIterator end; // end of sequence + const regex_type re; // the expression + match_flag_type flags; // flags for matching + +public: + u32regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f) + : base(), end(last), re(*p), flags(f){} + bool init(BidirectionalIterator first) + { + base = first; + return u32regex_search(first, end, what, re, flags, base); + } + bool compare(const u32regex_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); + } + const match_results& get() + { return what; } + bool next() + { + //if(what.prefix().first != what[0].second) + // flags |= match_prev_avail; + BidirectionalIterator next_start = what[0].second; + match_flag_type f(flags); + if(!what.length()) + f |= regex_constants::match_not_initial_null; + //if(base != next_start) + // f |= regex_constants::match_not_bob; + bool result = u32regex_search(next_start, end, what, re, f, base); + if(result) + what.set_base(base); + return result; + } +private: + u32regex_iterator_implementation& operator=(const u32regex_iterator_implementation&); +}; + +template +class u32regex_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + match_results, + typename re_detail::regex_iterator_traits::difference_type, + const match_results*, + const match_results& > +#endif +{ +private: + typedef u32regex_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef u32regex regex_type; + typedef match_results value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + u32regex_iterator(){} + u32regex_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + match_flag_type m = match_default) + : pdata(new impl(&re, b, m)) + { + if(!pdata->init(a)) + { + pdata.reset(); + } + } + u32regex_iterator(const u32regex_iterator& that) + : pdata(that.pdata) {} + u32regex_iterator& operator=(const u32regex_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const u32regex_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const u32regex_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + u32regex_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + u32regex_iterator operator++(int) + { + u32regex_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef u32regex_iterator utf8regex_iterator; +typedef u32regex_iterator utf16regex_iterator; +typedef u32regex_iterator utf32regex_iterator; + +inline u32regex_iterator make_u32regex_iterator(const char* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(p, p+std::strlen(p), e, m); +} +#ifndef BOOST_NO_WREGEX +inline u32regex_iterator make_u32regex_iterator(const wchar_t* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(p, p+std::wcslen(p), e, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex_iterator make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(p, p+u_strlen(p), e, m); +} +#endif +template +inline u32regex_iterator::const_iterator> make_u32regex_iterator(const std::basic_string& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_iterator(p.begin(), p.end(), e, m); +} +inline u32regex_iterator make_u32regex_iterator(const UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, m); +} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_ITERATOR_HPP + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_token_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_token_iterator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,377 @@ +/* + * + * Copyright (c) 2003 + * 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 u32regex_token_iterator.hpp + * VERSION see + * DESCRIPTION: Provides u32regex_token_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_U32REGEX_TOKEN_ITERATOR_HPP +#define BOOST_REGEX_V4_U32REGEX_TOKEN_ITERATOR_HPP + +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +// +// Borland C++ Builder 6, and Visual C++ 6, +// can't cope with the array template constructor +// so we have a template member that will accept any type as +// argument, and then assert that is really is an array: +// +#include +#include +#endif + +namespace boost{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) +# pragma warning(push) +# pragma warning(disable:4700) +#endif + +template +class u32regex_token_iterator_implementation +{ + typedef u32regex regex_type; + typedef sub_match value_type; + + match_results what; // current match + BidirectionalIterator end; // end of search area + BidirectionalIterator base; // start of search area + const regex_type re; // the expression + match_flag_type flags; // match flags + value_type result; // the current string result + int N; // the current sub-expression being enumerated + std::vector subs; // the sub-expressions to enumerate + +public: + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f) + : end(last), re(*p), flags(f){ subs.push_back(sub); } + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector& v, match_flag_type f) + : end(last), re(*p), flags(f), subs(v){} +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + // can't reliably get this to work.... +#elif (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const T& submatches, match_flag_type f) + : end(last), re(*p), flags(f) + { + // assert that T really is an array: + BOOST_STATIC_ASSERT(::boost::is_array::value); + const std::size_t array_size = sizeof(T) / sizeof(submatches[0]); + for(std::size_t i = 0; i < array_size; ++i) + { + subs.push_back(submatches[i]); + } + } +#else + template + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f) + : end(last), re(*p), flags(f) + { + for(std::size_t i = 0; i < CN; ++i) + { + subs.push_back(submatches[i]); + } + } +#endif + + bool init(BidirectionalIterator first) + { + base = first; + N = 0; + if(u32regex_search(first, end, what, re, flags, base) == true) + { + N = 0; + result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]); + return true; + } + else if((subs[N] == -1) && (first != end)) + { + result.first = first; + result.second = end; + result.matched = (first != end); + N = -1; + return true; + } + return false; + } + bool compare(const u32regex_token_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) + && (end == that.end) + && (flags == that.flags) + && (N == that.N) + && (what[0].first == that.what[0].first) + && (what[0].second == that.what[0].second); + } + const value_type& get() + { return result; } + bool next() + { + if(N == -1) + return false; + if(N+1 < (int)subs.size()) + { + ++N; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + //if(what.prefix().first != what[0].second) + // flags |= match_prev_avail | regex_constants::match_not_bob; + BidirectionalIterator last_end(what[0].second); + if(u32regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base)) + { + N =0; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + else if((last_end != end) && (subs[0] == -1)) + { + N =-1; + result.first = last_end; + result.second = end; + result.matched = (last_end != end); + return true; + } + return false; + } +private: + u32regex_token_iterator_implementation& operator=(const u32regex_token_iterator_implementation&); +}; + +template +class u32regex_token_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + sub_match, + typename re_detail::regex_iterator_traits::difference_type, + const sub_match*, + const sub_match& > +#endif +{ +private: + typedef u32regex_token_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef u32regex regex_type; + typedef sub_match value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + u32regex_token_iterator(){} + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + int submatch = 0, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatch, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const std::vector& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + // can't reliably get this to work.... +#elif (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const T& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#else + template + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const int (&submatches)[N], match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#endif + u32regex_token_iterator(const u32regex_token_iterator& that) + : pdata(that.pdata) {} + u32regex_token_iterator& operator=(const u32regex_token_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const u32regex_token_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const u32regex_token_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + u32regex_token_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + u32regex_token_iterator operator++(int) + { + u32regex_token_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef u32regex_token_iterator utf8regex_token_iterator; +typedef u32regex_token_iterator utf16regex_token_iterator; +typedef u32regex_token_iterator utf32regex_token_iterator; + +// construction from an integral sub_match state_id: +inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::strlen(p), e, submatch, m); +} +#ifndef BOOST_NO_WREGEX +inline u32regex_token_iterator make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+u_strlen(p), e, submatch, m); +} +#endif +template +inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_token_iterator(p.begin(), p.end(), e, m); +} +inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); +} + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +// construction from a reference to an array: +template +inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::strlen(p), e, submatch, m); +} +#ifndef BOOST_NO_WREGEX +template +inline u32regex_token_iterator make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +template +inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+u_strlen(p), e, m); +} +#endif +template +inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_token_iterator(p.begin(), p.end(), e, m); +} +template +inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); +} +#endif // BOOST_MSVC < 1300 + +// construction from a vector of sub_match state_id's: +inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::strlen(p), e, submatch, m); +} +#ifndef BOOST_NO_WREGEX +inline u32regex_token_iterator make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+u_strlen(p), e, submatch, m); +} +#endif +template +inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_token_iterator(p.begin(), p.end(), e, m); +} +inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); +} + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) +# pragma warning(pop) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex/v4/w32_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/w32_regex_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,731 @@ +/* + * + * 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.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class w32_regex_traits. + */ + +#ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_W32_REGEX_TRAITS_HPP_INCLUDED + +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifdef BOOST_HAS_THREADS +#include +#endif +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#include +#endif +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#include +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4786) +#pragma warning(disable:4800) +#endif + +namespace boost{ + +// +// forward declaration is needed by some compilers: +// +template +class w32_regex_traits; + +namespace re_detail{ + +// +// start by typedeffing the types we'll need: +// +typedef ::boost::uint32_t lcid_type; // placeholder for LCID. +typedef ::boost::shared_ptr cat_type; // placeholder for dll HANDLE. + +// +// then add wrappers around the actual Win32 API's (ie implementation hiding): +// +BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale(); +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t, lcid_type); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type state_id); +#endif +#endif +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t, lcid_type); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type state_id); +#endif +#endif +BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name); +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::string& def); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::wstring& def); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string& def); +#endif +#endif +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type state_id, const char* p1, const char* p2); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type state_id, const wchar_t* p1, const wchar_t* p2); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transform(lcid_type state_id, const unsigned short* p1, const unsigned short* p2); +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type state_id); +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type); +#endif +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, char c); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, wchar_t c); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type state_id, boost::uint32_t m, unsigned short c); +#endif +#endif +// +// class w32_regex_traits_base: +// acts as a container for locale and the facets we are using. +// +template +struct w32_regex_traits_base +{ + w32_regex_traits_base(lcid_type l) + { imbue(l); } + lcid_type imbue(lcid_type l); + + lcid_type m_locale; +}; + +template +inline lcid_type w32_regex_traits_base::imbue(lcid_type l) +{ + lcid_type result(m_locale); + m_locale = l; + return result; +} + +// +// class w32_regex_traits_char_layer: +// implements methods that require specialisation for narrow characters: +// +template +class w32_regex_traits_char_layer : public w32_regex_traits_base +{ + typedef std::basic_string string_type; + typedef std::map map_type; + typedef typename map_type::const_iterator map_iterator_type; +public: + w32_regex_traits_char_layer(const lcid_type l); + + regex_constants::syntax_type syntax_type(charT c)const + { + map_iterator_type i = m_char_map.find(c); + return ((i == m_char_map.end()) ? 0 : i->second); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + map_iterator_type i = m_char_map.find(c); + if(i == m_char_map.end()) + { + if(::boost::re_detail::w32_is_lower(c, this->m_locale)) return regex_constants::escape_type_class; + if(::boost::re_detail::w32_is_upper(c, this->m_locale)) return regex_constants::escape_type_not_class; + return 0; + } + return i->second; + } + charT tolower(charT c)const + { + return ::boost::re_detail::w32_tolower(c, this->m_locale); + } + bool isctype(boost::uint32_t mask, charT c)const + { + return ::boost::re_detail::w32_is(this->m_locale, mask, c); + } + +private: + string_type get_default_message(regex_constants::syntax_type); + // TODO: use a hash table when available! + map_type m_char_map; +}; + +template +w32_regex_traits_char_layer::w32_regex_traits_char_layer(::boost::re_detail::lcid_type l) + : w32_regex_traits_base(l) +{ + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: + cat_type cat; + std::string cat_name(w32_regex_traits::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_message(i)); + for(typename string_type::size_type j = 0; j < mss.size(); ++j) + { + this->m_char_map[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) + { + this->m_char_map[static_cast(*ptr)] = i; + ++ptr; + } + } + } +} + +template +typename w32_regex_traits_char_layer::string_type + w32_regex_traits_char_layer::get_default_message(regex_constants::syntax_type i) +{ + const char* ptr = get_default_syntax(i); + string_type result; + while(ptr && *ptr) + { + result.append(1, static_cast(*ptr)); + ++ptr; + } + return result; +} + +// +// specialised version for narrow characters: +// +template <> +class BOOST_REGEX_DECL w32_regex_traits_char_layer : public w32_regex_traits_base +{ + typedef std::string string_type; +public: + w32_regex_traits_char_layer(::boost::re_detail::lcid_type l) + : w32_regex_traits_base(l) + { + init(); + } + + regex_constants::syntax_type syntax_type(char c)const + { + return m_char_map[static_cast(c)]; + } + regex_constants::escape_syntax_type escape_syntax_type(char c) const + { + return m_char_map[static_cast(c)]; + } + char tolower(char c)const + { + return m_lower_map[static_cast(c)]; + } + bool isctype(boost::uint32_t mask, char c)const + { + return m_type_map[static_cast(c)] & mask; + } + +private: + regex_constants::syntax_type m_char_map[1u << CHAR_BIT]; + char m_lower_map[1u << CHAR_BIT]; + boost::uint16_t m_type_map[1u << CHAR_BIT]; + void init(); +}; + +// +// class w32_regex_traits_implementation: +// provides pimpl implementation for w32_regex_traits. +// +template +class w32_regex_traits_implementation : public w32_regex_traits_char_layer +{ +public: + typedef typename w32_regex_traits::char_class_type char_class_type; + BOOST_STATIC_CONSTANT(char_class_type, mask_word = 0x0400); // must be C1_DEFINED << 1 + BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 0x0800); // must be C1_DEFINED << 2 + BOOST_STATIC_CONSTANT(char_class_type, mask_base = 0x3ff); // all the masks used by the CT_CTYPE1 group + + typedef std::basic_string string_type; + typedef charT char_type; + w32_regex_traits_implementation(::boost::re_detail::lcid_type l); + std::string error_string(regex_constants::error_type n) const + { + if(!m_error_strings.empty()) + { + std::map::const_iterator p = m_error_strings.find(n); + return (p == m_error_strings.end()) ? std::string(get_default_error_string(n)) : p->second; + } + return get_default_error_string(n); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + char_class_type result = lookup_classname_imp(p1, p2); + if(result == 0) + { + typedef typename string_type::size_type size_type; + string_type temp(p1, p2); + for(size_type i = 0; i < temp.size(); ++i) + temp[i] = this->tolower(temp[i]); + result = lookup_classname_imp(&*temp.begin(), &*temp.begin() + temp.size()); + } + return result; + } + string_type lookup_collatename(const charT* p1, const charT* p2) const; + string_type transform_primary(const charT* p1, const charT* p2) const; + string_type transform(const charT* p1, const charT* p2) const + { + return ::boost::re_detail::w32_transform(this->m_locale, p1, p2); + } +private: + std::map m_error_strings; // error messages indexed by numberic ID + std::map m_custom_class_names; // character class names + std::map m_custom_collate_names; // collating element names + unsigned m_collate_type; // the form of the collation string + charT m_collate_delim; // the collation group delimiter + // + // helpers: + // + char_class_type lookup_classname_imp(const charT* p1, const charT* p2) const; +}; + +template +typename w32_regex_traits_implementation::string_type + w32_regex_traits_implementation::transform_primary(const charT* p1, const charT* p2) const +{ + string_type result; + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(m_collate_type) + { + case sort_C: + case sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: + { + result.assign(p1, p2); + typedef typename string_type::size_type size_type; + for(size_type i = 0; i < result.size(); ++i) + result[i] = this->tolower(result[i]); + result = this->transform(&*result.begin(), &*result.begin() + result.size()); + break; + } + case sort_fixed: + { + // get a regular sort key, and then truncate it: + result.assign(this->transform(p1, p2)); + result.erase(this->m_collate_delim); + break; + } + case sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result.assign(this->transform(p1, p2)); + std::size_t i; + for(i = 0; i < result.size(); ++i) + { + if(result[i] == m_collate_delim) + break; + } + result.erase(i); + break; + } + if(result.empty()) + result = string_type(1, charT(0)); + return result; +} + +template +typename w32_regex_traits_implementation::string_type + w32_regex_traits_implementation::lookup_collatename(const charT* p1, const charT* p2) const +{ + typedef typename std::map::const_iterator iter_type; + if(m_custom_collate_names.size()) + { + iter_type pos = m_custom_collate_names.find(string_type(p1, p2)); + if(pos != m_custom_collate_names.end()) + return pos->second; + } +#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 charT* p0 = p1; + while(p0 != p2) + name.append(1, char(*p0++)); +#endif + name = 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, charT(*b++)); + return result; + } +#endif + if(p2 - p1 == 1) + return string_type(1, *p1); + return string_type(); +} + +template +w32_regex_traits_implementation::w32_regex_traits_implementation(::boost::re_detail::lcid_type l) +: w32_regex_traits_char_layer(l) +{ + cat_type cat; + std::string cat_name(w32_regex_traits::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) + { + // + // Error messages: + // + for(boost::regex_constants::error_type i = static_cast(0); + i <= boost::regex_constants::error_unknown; + i = static_cast(i + 1)) + { + const char* p = get_default_error_string(i); + string_type default_message; + while(*p) + { + default_message.append(1, static_cast(*p)); + ++p; + } + string_type s = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i+200, default_message); + std::string result; + for(std::string::size_type j = 0; j < s.size(); ++j) + { + result.append(1, static_cast(s[j])); + } + m_error_strings[i] = result; + } + // + // Custom class names: + // + static const char_class_type masks[14] = + { + 0x0104u, // C1_ALPHA | C1_DIGIT + 0x0100u, // C1_ALPHA + 0x0020u, // C1_CNTRL + 0x0004u, // C1_DIGIT + (~(0x0020u|0x0008u) & 0x01ffu) | 0x0400u, // not C1_CNTRL or C1_SPACE + 0x0002u, // C1_LOWER + (~0x0020u & 0x01ffu) | 0x0400, // not C1_CNTRL + 0x0010u, // C1_PUNCT + 0x0008u, // C1_SPACE + 0x0001u, // C1_UPPER + 0x0080u, // C1_XDIGIT + 0x0040u, // C1_BLANK + w32_regex_traits_implementation::mask_word, + w32_regex_traits_implementation::mask_unicode, + }; + static const string_type null_string; + for(unsigned int j = 0; j <= 13; ++j) + { + string_type s(::boost::re_detail::w32_cat_get(cat, this->m_locale, j+300, null_string)); + if(s.size()) + this->m_custom_class_names[s] = masks[j]; + } + } + // + // get the collation format used by m_pcollate: + // + m_collate_type = re_detail::find_sort_syntax(this, &m_collate_delim); +} + +template +typename w32_regex_traits_implementation::char_class_type + w32_regex_traits_implementation::lookup_classname_imp(const charT* p1, const charT* p2) const +{ + static const char_class_type masks[20] = + { + 0, + 0x0104u, // C1_ALPHA | C1_DIGIT + 0x0100u, // C1_ALPHA + 0x0040u, // C1_BLANK + 0x0020u, // C1_CNTRL + 0x0004u, // C1_DIGIT + 0x0004u, // C1_DIGIT + (~(0x0020u|0x0008u|0x0040) & 0x01ffu) | 0x0400u, // not C1_CNTRL or C1_SPACE or C1_BLANK + 0x0002u, // C1_LOWER + 0x0002u, // C1_LOWER + (~0x0020u & 0x01ffu) | 0x0400, // not C1_CNTRL + 0x0010u, // C1_PUNCT + 0x0008u, // C1_SPACE + 0x0008u, // C1_SPACE + 0x0001u, // C1_UPPER + w32_regex_traits_implementation::mask_unicode, + 0x0001u, // C1_UPPER + 0x0104u | w32_regex_traits_implementation::mask_word, + 0x0104u | w32_regex_traits_implementation::mask_word, + 0x0080u, // C1_XDIGIT + }; + if(m_custom_class_names.size()) + { + typedef typename std::map, char_class_type>::const_iterator map_iter; + map_iter pos = m_custom_class_names.find(string_type(p1, p2)); + if(pos != m_custom_class_names.end()) + return pos->second; + } + std::size_t state_id = 1 + re_detail::get_default_class_id(p1, p2); + if(state_id < sizeof(masks) / sizeof(masks[0])) + return masks[state_id]; + return masks[0]; +} + + +template +boost::shared_ptr > create_w32_regex_traits(::boost::re_detail::lcid_type l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT)) +{ + // TODO: create a cache for previously constructed objects. + return boost::object_cache< ::boost::re_detail::lcid_type, w32_regex_traits_implementation >::get(l, 5); +} + +} // re_detail + +template +class w32_regex_traits +{ +public: + typedef charT char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + typedef ::boost::re_detail::lcid_type locale_type; + typedef boost::uint_least32_t char_class_type; + + struct boost_extensions_tag{}; + + w32_regex_traits() + : m_pimpl(re_detail::create_w32_regex_traits(::boost::re_detail::w32_get_default_locale())) + { } + static size_type length(const char_type* p) + { + return std::char_traits::length(p); + } + regex_constants::syntax_type syntax_type(charT c)const + { + return m_pimpl->syntax_type(c); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + return m_pimpl->escape_syntax_type(c); + } + charT translate(charT c) const + { + return c; + } + charT translate_nocase(charT c) const + { + return this->m_pimpl->tolower(c); + } + charT translate(charT c, bool icase) const + { + return icase ? this->m_pimpl->tolower(c) : c; + } + charT tolower(charT c) const + { + return this->m_pimpl->tolower(c); + } + charT toupper(charT c) const + { + return ::boost::re_detail::w32_toupper(c, this->m_pimpl->m_locale); + } + string_type transform(const charT* p1, const charT* p2) const + { + return ::boost::re_detail::w32_transform(this->m_pimpl->m_locale, p1, p2); + } + string_type transform_primary(const charT* p1, const charT* p2) const + { + return m_pimpl->transform_primary(p1, p2); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_classname(p1, p2); + } + string_type lookup_collatename(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_collatename(p1, p2); + } + bool isctype(charT c, char_class_type f) const + { + if((f & re_detail::w32_regex_traits_implementation::mask_base) + && (this->m_pimpl->isctype(f & re_detail::w32_regex_traits_implementation::mask_base, c))) + return true; + else if((f & re_detail::w32_regex_traits_implementation::mask_unicode) && re_detail::is_extended(c)) + return true; + else if((f & re_detail::w32_regex_traits_implementation::mask_word) && (c == '_')) + return true; + return false; + } + int toi(const charT*& p1, const charT* p2, int radix)const + { + return ::boost::re_detail::global_toi(p1, p2, radix, *this); + } + int value(charT c, int radix)const + { + int result = ::boost::re_detail::global_value(c); + return result < radix ? result : -1; + } + locale_type imbue(locale_type l) + { + ::boost::re_detail::lcid_type result(getloc()); + m_pimpl = re_detail::create_w32_regex_traits(l); + return result; + } + locale_type getloc()const + { + return m_pimpl->m_locale; + } + std::string error_string(regex_constants::error_type n) const + { + return m_pimpl->error_string(n); + } + + // + // extension: + // set the name of the message catalog in use (defaults to "boost_regex"). + // + static std::string catalog_name(const std::string& name); + static std::string get_catalog_name(); + +private: + boost::shared_ptr > m_pimpl; + // + // catalog name handler: + // + static std::string& get_catalog_name_inst(); + +#ifdef BOOST_HAS_THREADS + static static_mutex& get_mutex_inst(); +#endif +}; + +template +std::string w32_regex_traits::catalog_name(const std::string& name) +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + get_catalog_name_inst() = name; + return result; +} + +template +std::string& w32_regex_traits::get_catalog_name_inst() +{ + static std::string s_name; + return s_name; +} + +template +std::string w32_regex_traits::get_catalog_name() +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + return result; +} + +#ifdef BOOST_HAS_THREADS +template +static_mutex& w32_regex_traits::get_mutex_inst() +{ + static static_mutex s_mutex = BOOST_STATIC_MUTEX_INIT; + return s_mutex; +} +#endif + + +} // boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/regex_fwd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex_fwd.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,33 @@ +/* + * + * 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/libs/regex for documentation. + * FILE regex_fwd.cpp + * VERSION see + * DESCRIPTION: Forward declares boost::basic_regex<> and + * associated typedefs. + */ + +#ifndef BOOST_REGEX_FWD_HPP +#define BOOST_REGEX_FWD_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include + +#endif + + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/scoped_array.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/scoped_array.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,16 @@ +#ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED +#define BOOST_SCOPED_ARRAY_HPP_INCLUDED + +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002 Peter Dimov +// +// Distributed under 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) +// +// http://www.boost.org/libs/smart_ptr/scoped_array.htm +// + +#include + +#endif // #ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/scoped_ptr.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/scoped_ptr.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,16 @@ +#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED +#define BOOST_SCOPED_PTR_HPP_INCLUDED + +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002 Peter Dimov +// +// Distributed under 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) +// +// http://www.boost.org/libs/smart_ptr/scoped_ptr.htm +// + +#include + +#endif // #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/system/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/config.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,75 @@ +// boost/system/config.hpp -------------------------------------------------// + +// Copyright Beman Dawes 2003, 2006 + +// Distributed under 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) + +// See http://www.boost.org/libs/system for documentation. + +#ifndef BOOST_SYSTEM_CONFIG_HPP +#define BOOST_SYSTEM_CONFIG_HPP + +#include + +// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use. +// If not specified, a sensible default will be applied. + +# if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API ) +# error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined +# elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API ) +# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) +# define BOOST_WINDOWS_API +# else +# define BOOST_POSIX_API +# endif +# endif + +// enable dynamic linking on Windows ---------------------------------------// + +//# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK)) && defined(__BORLANDC__) && defined(__WIN32__) +//# error Dynamic linking Boost.System does not work for Borland; use static linking instead +//# endif + +#ifdef BOOST_HAS_DECLSPEC // defined in config system +// we need to import/export our code only if the user has specifically +// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost +// libraries to be dynamically linked, or BOOST_SYSTEM_DYN_LINK +// if they want just this one to be dynamically liked: +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) +// export if this is our own source, otherwise import: +#ifdef BOOST_SYSTEM_SOURCE +# define BOOST_SYSTEM_DECL __declspec(dllexport) +#else +# define BOOST_SYSTEM_DECL __declspec(dllimport) +#endif // BOOST_SYSTEM_SOURCE +#endif // DYN_LINK +#endif // BOOST_HAS_DECLSPEC +// +// if BOOST_SYSTEM_DECL isn't defined yet define it now: +#ifndef BOOST_SYSTEM_DECL +#define BOOST_SYSTEM_DECL +#endif + +// enable automatic library variant selection ------------------------------// + +#if !defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SYSTEM_NO_LIB) +// +// Set the name of our library, this will get undef'ed by auto_link.hpp +// once it's done with it: +// +#define BOOST_LIB_NAME boost_system +// +// If we're importing code from a dll, then tell auto_link.hpp about it: +// +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) +# define BOOST_DYN_LINK +#endif +// +// And include the header that does the work: +// +#include +#endif // auto-linking disabled + +#endif // BOOST_SYSTEM_CONFIG_HPP + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/system/cygwin_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/cygwin_error.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,56 @@ +// boost/system/cygwin_error.hpp -------------------------------------------// + +// Copyright Beman Dawes 2007 + +// Distributed under 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) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_CYGWIN_ERROR_HPP +#define BOOST_CYGWIN_ERROR_HPP + +// This header is effectively empty for compiles on operating systems where +// it is not applicable. + +# ifdef __CYGWIN__ + +#include + +namespace boost +{ + namespace system + { + // To construct an error_code after a API error: + // + // error_code( errno, system_category ) + + // User code should use the portable "posix" enums for POSIX errors; this + // allows such code to be portable to non-POSIX systems. For the non-POSIX + // errno values that POSIX-based systems typically provide in addition to + // POSIX values, use the system specific enums below. + + namespace cygwin_error + { + enum cygwin_errno + { + no_net = ENONET, + no_package = ENOPKG, + no_share = ENOSHARE + }; + } // namespace cygwin_error + + template<> struct is_error_code_enum + { static const bool value = true; }; + + namespace cygwin_error + { + inline error_code make_error_code( cygwin_errno e ) + { return error_code( e, get_system_category() ); } + } + } +} + +#endif // __CYGWIN__ + +#endif // BOOST_CYGWIN_ERROR_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/system/error_code.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/error_code.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,501 @@ +// boost/system/error_code.hpp ---------------------------------------------// + +// Copyright Beman Dawes 2006, 2007 +// Copyright Christoper Kohlhoff 2007 + +// Distributed under 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) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_ERROR_CODE_HPP +#define BOOST_ERROR_CODE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: undef these macros if not already defined +#include + +#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) +# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined +#endif + +#include // must be the last #include + +namespace boost +{ + namespace system + { + + class error_code; + class error_condition; + + // "Concept" helpers ---------------------------------------------------// + + template< class T > + struct is_error_code_enum { static const bool value = false; }; + + template< class T > + struct is_error_condition_enum { static const bool value = false; }; + + // generic error_conditions --------------------------------------------// + + namespace errc + { + enum errc_t + { + success = 0, + address_family_not_supported = EAFNOSUPPORT, + address_in_use = EADDRINUSE, + address_not_available = EADDRNOTAVAIL, + already_connected = EISCONN, + argument_list_too_long = E2BIG, + argument_out_of_domain = EDOM, + bad_address = EFAULT, + bad_file_descriptor = EBADF, + bad_message = EBADMSG, + broken_pipe = EPIPE, + connection_aborted = ECONNABORTED, + connection_already_in_progress = EALREADY, + connection_refused = ECONNREFUSED, + connection_reset = ECONNRESET, + cross_device_link = EXDEV, + destination_address_required = EDESTADDRREQ, + device_or_resource_busy = EBUSY, + directory_not_empty = ENOTEMPTY, + executable_format_error = ENOEXEC, + file_exists = EEXIST, + file_too_large = EFBIG, + filename_too_long = ENAMETOOLONG, + function_not_supported = ENOSYS, + host_unreachable = EHOSTUNREACH, + identifier_removed = EIDRM, + illegal_byte_sequence = EILSEQ, + inappropriate_io_control_operation = ENOTTY, + interrupted = EINTR, + invalid_argument = EINVAL, + invalid_seek = ESPIPE, + io_error = EIO, + is_a_directory = EISDIR, + message_size = EMSGSIZE, + network_down = ENETDOWN, + network_reset = ENETRESET, + network_unreachable = ENETUNREACH, + no_buffer_space = ENOBUFS, + no_child_process = ECHILD, + no_link = ENOLINK, + no_lock_available = ENOLCK, + no_message_available = ENODATA, + no_message = ENOMSG, + no_protocol_option = ENOPROTOOPT, + no_space_on_device = ENOSPC, + no_stream_resources = ENOSR, + no_such_device_or_address = ENXIO, + no_such_device = ENODEV, + no_such_file_or_directory = ENOENT, + no_such_process = ESRCH, + not_a_directory = ENOTDIR, + not_a_socket = ENOTSOCK, + not_a_stream = ENOSTR, + not_connected = ENOTCONN, + not_enough_memory = ENOMEM, + not_supported = ENOTSUP, + operation_canceled = ECANCELED, + operation_in_progress = EINPROGRESS, + operation_not_permitted = EPERM, + operation_not_supported = EOPNOTSUPP, + operation_would_block = EWOULDBLOCK, + owner_dead = EOWNERDEAD, + permission_denied = EACCES, + protocol_error = EPROTO, + protocol_not_supported = EPROTONOSUPPORT, + read_only_file_system = EROFS, + resource_deadlock_would_occur = EDEADLK, + resource_unavailable_try_again = EAGAIN, + result_out_of_range = ERANGE, + state_not_recoverable = ENOTRECOVERABLE, + stream_timeout = ETIME, + text_file_busy = ETXTBSY, + timed_out = ETIMEDOUT, + too_many_files_open_in_system = ENFILE, + too_many_files_open = EMFILE, + too_many_links = EMLINK, + too_many_synbolic_link_levels = ELOOP, + value_too_large = EOVERFLOW, + wrong_protocol_type = EPROTOTYPE + }; + + } // namespace errc + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + namespace posix = errc; + namespace posix_error = errc; +# endif + + template<> struct is_error_condition_enum + { static const bool value = true; }; + + + // ----------------------------------------------------------------------// + + // Operating system specific interfaces --------------------------------// + + + // The interface is divided into general and system-specific portions to + // meet these requirements: + // + // * Code calling an operating system API can create an error_code with + // a single category (system_category), even for POSIX-like operating + // systems that return some POSIX errno values and some native errno + // values. This code should not have to pay the cost of distinguishing + // between categories, since it is not yet known if that is needed. + // + // * Users wishing to write system-specific code should be given enums for + // at least the common error cases. + // + // * System specific code should fail at compile time if moved to another + // operating system. + + // The system specific portions of the interface are located in headers + // with names reflecting the operating system. For example, + // + // + // + // + // + // These headers are effectively empty for compiles on operating systems + // where they are not applicable. + + // ----------------------------------------------------------------------// + + // class error_category ------------------------------------------------// + + class error_category : public noncopyable + { + public: + virtual ~error_category(){} + virtual inline const char * name() const; // see implementation note below + virtual inline std::string message( int ev ) const; // see implementation note below + virtual inline error_condition default_error_condition( int ev ) const; + virtual inline bool equivalent( int code, const error_condition & condition ) const; + virtual inline bool equivalent( const error_code & code, int condition ) const; + + bool operator==(const error_category & rhs) const { return this == &rhs; } + bool operator!=(const error_category & rhs) const { return this != &rhs; } + bool operator<( const error_category & rhs ) const + { + return std::less()( this, &rhs ); + } + }; + + // predefined error categories -----------------------------------------// + + BOOST_SYSTEM_DECL const error_category & get_system_category(); + BOOST_SYSTEM_DECL const error_category & get_generic_category(); + + static const error_category & system_category = get_system_category(); + static const error_category & generic_category = get_generic_category(); + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + // deprecated synonyms + inline const error_category & get_posix_category() { return get_generic_category(); } + static const error_category & posix_category = get_generic_category(); + static const error_category & errno_ecat = get_generic_category(); + static const error_category & native_ecat = get_system_category(); +# endif + + // class error_condition -----------------------------------------------// + + // error_conditions are portable, error_codes are system or library specific + + class error_condition + { + public: + + // constructors: + error_condition() : m_val(0), m_cat(&get_generic_category()) {} + error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + + template + error_condition(ErrorConditionEnum e, + typename boost::enable_if >::type* = 0) + { + *this = make_error_condition(e); + } + + // modifiers: + + void assign( int val, const error_category & cat ) + { + m_val = val; + m_cat = &cat; + } + + template + typename boost::enable_if, error_condition>::type & + operator=( ErrorConditionEnum val ) + { + *this = make_error_condition(val); + return *this; + } + + void clear() + { + m_val = 0; + m_cat = &get_generic_category(); + } + + // observers: + int value() const { return m_val; } + const error_category & category() const { return *m_cat; } + std::string message() const { return m_cat->message(value()); } + + typedef void (*unspecified_bool_type)(); + static void unspecified_bool_true() {} + + operator unspecified_bool_type() const // true if error + { + return m_val == 0 ? 0 : unspecified_bool_true; + } + + bool operator!() const // true if no error + { + return m_val == 0; + } + + // relationals: + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + inline friend bool operator==( const error_condition & lhs, + const error_condition & rhs ) + { + return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; + } + + inline friend bool operator<( const error_condition & lhs, + const error_condition & rhs ) + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + { + return lhs.m_cat < rhs.m_cat + || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); + } + + private: + int m_val; + const error_category * m_cat; + + }; + + // class error_code ----------------------------------------------------// + + // We want error_code to be a value type that can be copied without slicing + // and without requiring heap allocation, but we also want it to have + // polymorphic behavior based on the error category. This is achieved by + // abstract base class error_category supplying the polymorphic behavior, + // and error_code containing a pointer to an object of a type derived + // from error_category. + class error_code + { + public: + + // constructors: + error_code() : m_val(0), m_cat(&get_system_category()) {} + error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + + template + error_code(ErrorCodeEnum e, + typename boost::enable_if >::type* = 0) + { + *this = make_error_code(e); + } + + // modifiers: + void assign( int val, const error_category & cat ) + { + m_val = val; + m_cat = &cat; + } + + template + typename boost::enable_if, error_code>::type & + operator=( ErrorCodeEnum val ) + { + *this = make_error_code(val); + return *this; + } + + void clear() + { + m_val = 0; + m_cat = &get_system_category(); + } + + // observers: + int value() const { return m_val; } + const error_category & category() const { return *m_cat; } + error_condition default_error_condition() const { return m_cat->default_error_condition(value()); } + std::string message() const { return m_cat->message(value()); } + + typedef void (*unspecified_bool_type)(); + static void unspecified_bool_true() {} + + operator unspecified_bool_type() const // true if error + { + return m_val == 0 ? 0 : unspecified_bool_true; + } + + bool operator!() const // true if no error + { + return m_val == 0; + } + + // relationals: + inline friend bool operator==( const error_code & lhs, + const error_code & rhs ) + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + { + return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; + } + + inline friend bool operator<( const error_code & lhs, + const error_code & rhs ) + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + { + return lhs.m_cat < rhs.m_cat + || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); + } + + private: + int m_val; + const error_category * m_cat; + + }; + + // predefined error_code object used as "throw on error" tag + BOOST_SYSTEM_DECL extern error_code throws; + + // non-member functions ------------------------------------------------// + + inline bool operator!=( const error_code & lhs, + const error_code & rhs ) + { + return !(lhs == rhs); + } + + inline bool operator!=( const error_condition & lhs, + const error_condition & rhs ) + { + return !(lhs == rhs); + } + + inline bool operator==( const error_code & code, + const error_condition & condition ) + { + return code.category().equivalent( code.value(), condition ) + || condition.category().equivalent( code, condition.value() ); + } + + inline bool operator!=( const error_code & lhs, + const error_condition & rhs ) + { + return !(lhs == rhs); + } + + inline bool operator==( const error_condition & condition, + const error_code & code ) + { + return condition.category().equivalent( code, condition.value() ) + || code.category().equivalent( code.value(), condition ); + } + + inline bool operator!=( const error_condition & lhs, + const error_code & rhs ) + { + return !(lhs == rhs); + } + + // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. + + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, error_code ec) + { + os << ec.category().name() << ':' << ec.value(); + return os; + } + + inline std::size_t hash_value( const error_code & ec ) + { + return static_cast(ec.value()) + + reinterpret_cast(&ec.category()); + } + + // make_* functions for errc::errc_t -----------------------------// + + namespace errc + { + // explicit conversion: + inline error_code make_error_code( errc_t e ) + { return error_code( e, get_generic_category() ); } + + // implicit conversion: + inline error_condition make_error_condition( errc_t e ) + { return error_condition( e, get_generic_category() ); } + } + + // error_category default implementation -------------------------------// + + inline error_condition error_category::default_error_condition( int ev ) const + { + return error_condition( ev, *this ); + } + + inline bool error_category::equivalent( int code, + const error_condition & condition ) const + { + return default_error_condition( code ) == condition; + } + + inline bool error_category::equivalent( const error_code & code, + int condition ) const + { + return *this == code.category() && code.value() == condition; + } + + // error_category implementation note: VC++ 8.0 objects to name() and + // message() being pure virtual functions. Thus these implementations. + inline const char * error_category::name() const + { + return "error: should never be called"; + } + + inline std::string error_category::message( int ) const + { + static std::string s("error: should never be called"); + return s; + } + + } // namespace system +} // namespace boost + +#include // pops abi_prefix.hpp pragmas + +# ifdef BOOST_ERROR_CODE_HEADER_ONLY +# include +# endif + +#endif // BOOST_ERROR_CODE_HPP + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/system/linux_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/linux_error.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,110 @@ +// boost/system/linux_error.hpp -------------------------------------------// + +// Copyright Beman Dawes 2007 + +// Distributed under 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) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_LINUX_ERROR_HPP +#define BOOST_LINUX_ERROR_HPP + +// This header is effectively empty for compiles on operating systems where +// it is not applicable. + +#if defined(linux) || defined(__linux) || defined(__linux__) + +#include + +namespace boost +{ + namespace system + { + // To construct an error_code after a API error: + // + // error_code( errno, system_category ) + + // User code should use the portable "posix" enums for POSIX errors; this + // allows such code to be portable to non-POSIX systems. For the non-POSIX + // errno values that POSIX-based systems typically provide in addition to + // POSIX values, use the system specific enums below. + + namespace linux_error + { + enum linux_errno + { + advertise_error = EADV, + bad_exchange = EBADE, + bad_file_number = EBADFD, + bad_font_format = EBFONT, + bad_request_code = EBADRQC, + bad_request_descriptor = EBADR, + bad_slot = EBADSLT, + channel_range = ECHRNG, + communication_error = ECOMM, + dot_dot_error = EDOTDOT, + exchange_full = EXFULL, + host_down = EHOSTDOWN, + is_named_file_type= EISNAM, + key_expired = EKEYEXPIRED, + key_rejected = EKEYREJECTED, + key_revoked = EKEYREVOKED, + level2_halt= EL2HLT, + level2_no_syncronized= EL2NSYNC, + level3_halt = EL3HLT, + level3_reset = EL3RST, + link_range = ELNRNG, + medium_type = EMEDIUMTYPE, + no_anode= ENOANO, + no_block_device = ENOTBLK, + no_csi = ENOCSI, + no_key = ENOKEY, + no_medium = ENOMEDIUM, + no_network = ENONET, + no_package = ENOPKG, + not_avail = ENAVAIL, + not_named_file_type= ENOTNAM, + not_recoverable = ENOTRECOVERABLE, + not_unique = ENOTUNIQ, + owner_dead = EOWNERDEAD, + protocol_no_supported = EPFNOSUPPORT, + remote_address_changed = EREMCHG, + remote_io_error = EREMOTEIO, + remote_object = EREMOTE, + restart_needed = ERESTART, + shared_library_access = ELIBACC, + shared_library_bad = ELIBBAD, + shared_library_execute = ELIBEXEC, + shared_library_max_ = ELIBMAX, + shared_library_section= ELIBSCN, + shutdown = ESHUTDOWN, + socket_type_not_supported = ESOCKTNOSUPPORT, + srmount_error = ESRMNT, + stream_pipe_error = ESTRPIPE, + too_many_references = ETOOMANYREFS, + too_many_users = EUSERS, + unattached = EUNATCH, + unclean = EUCLEAN + }; + } // namespace linux_error + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + namespace Linux = linux_error; +# endif + + template<> struct is_error_code_enum + { static const bool value = true; }; + + namespace linux_error + { + inline error_code make_error_code( linux_errno e ) + { return error_code( e, get_system_category() ); } + } + + } // namespace system +} // namespace boost + +#endif // Linux + +#endif // BOOST_LINUX_ERROR_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/system/system_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/system_error.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,81 @@ +// Boost system_error.hpp --------------------------------------------------// + +// Copyright Beman Dawes 2006 + +// Distributed under 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) + +#ifndef BOOST_SYSTEM_ERROR_HPP +#define BOOST_SYSTEM_ERROR_HPP + +#include +#include +#include +#include + +namespace boost +{ + namespace system + { + // class system_error --------------------------------------------------// + + class system_error : public std::runtime_error + { + public: + system_error( error_code ec ) + : std::runtime_error(""), m_error_code(ec) {} + + system_error( error_code ec, const std::string & what_arg ) + : std::runtime_error(what_arg), m_error_code(ec) {} + + system_error( error_code ec, const char* what_arg ) + : std::runtime_error(what_arg), m_error_code(ec) {} + + system_error( int ev, const error_category & ecat ) + : std::runtime_error(""), m_error_code(ev,ecat) {} + + system_error( int ev, const error_category & ecat, + const std::string & what_arg ) + : std::runtime_error(what_arg), m_error_code(ev,ecat) {} + + system_error( int ev, const error_category & ecat, + const char * what_arg ) + : std::runtime_error(what_arg), m_error_code(ev,ecat) {} + + virtual ~system_error() throw() {} + + const error_code & code() const throw() { return m_error_code; } + const char * what() const throw(); + + private: + error_code m_error_code; + mutable std::string m_what; + }; + + // implementation ------------------------------------------------------// + + inline const char * system_error::what() const throw() + // see http://www.boost.org/more/error_handling.html for lazy build rationale + { + if ( m_what.empty() ) + { + try + { + m_what = this->std::runtime_error::what(); + if ( m_error_code ) + { + if ( !m_what.empty() ) m_what += ": "; + m_what += m_error_code.message(); + } + } + catch (...) { return std::runtime_error::what(); } + } + return m_what.c_str(); + } + + } // namespace system +} // namespace boost + +#endif // BOOST_SYSTEM_ERROR_HPP + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/system/windows_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/windows_error.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,118 @@ +// boost/system/windows_error.hpp ------------------------------------------// + +// Copyright Beman Dawes 2007 + +// Distributed under 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) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_WINDOWS_ERROR_HPP +#define BOOST_WINDOWS_ERROR_HPP + +// This header is effectively empty for compiles on operating systems where +// it is not applicable. + +#include + +#ifdef BOOST_WINDOWS_API + +#include +#include + +namespace boost +{ + namespace system + { + + // Microsoft Windows ---------------------------------------------------// + + // To construct an error_code after a API error: + // + // error_code( ::GetLastError(), system_category ) + + namespace windows_error + { + enum windows_error_code + { + success = 0, + // These names and values are based on Windows winerror.h + invalid_function = ERROR_INVALID_FUNCTION, + file_not_found = ERROR_FILE_NOT_FOUND, + path_not_found = ERROR_PATH_NOT_FOUND, + too_many_open_files = ERROR_TOO_MANY_OPEN_FILES, + access_denied = ERROR_ACCESS_DENIED, + invalid_handle = ERROR_INVALID_HANDLE, + arena_trashed = ERROR_ARENA_TRASHED, + not_enough_memory = ERROR_NOT_ENOUGH_MEMORY, + invalid_block = ERROR_INVALID_BLOCK, + bad_environment = ERROR_BAD_ENVIRONMENT, + bad_format = ERROR_BAD_FORMAT, + invalid_access = ERROR_INVALID_ACCESS, + outofmemory = ERROR_OUTOFMEMORY, + invalid_drive = ERROR_INVALID_DRIVE, + current_directory = ERROR_CURRENT_DIRECTORY, + not_same_device = ERROR_NOT_SAME_DEVICE, + no_more_files = ERROR_NO_MORE_FILES, + write_protect = ERROR_WRITE_PROTECT, + bad_unit = ERROR_BAD_UNIT, + not_ready = ERROR_NOT_READY, + bad_command = ERROR_BAD_COMMAND, + crc = ERROR_CRC, + bad_length = ERROR_BAD_LENGTH, + seek = ERROR_SEEK, + not_dos_disk = ERROR_NOT_DOS_DISK, + sector_not_found = ERROR_SECTOR_NOT_FOUND, + out_of_paper = ERROR_OUT_OF_PAPER, + write_fault = ERROR_WRITE_FAULT, + read_fault = ERROR_READ_FAULT, + gen_failure = ERROR_GEN_FAILURE, + sharing_violation = ERROR_SHARING_VIOLATION, + lock_violation = ERROR_LOCK_VIOLATION, + wrong_disk = ERROR_WRONG_DISK, + sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED, + handle_eof = ERROR_HANDLE_EOF, + handle_disk_full= ERROR_HANDLE_DISK_FULL, + rem_not_list = ERROR_REM_NOT_LIST, + dup_name = ERROR_DUP_NAME, + bad_net_path = ERROR_BAD_NETPATH, + network_busy = ERROR_NETWORK_BUSY, + // ... + file_exists = ERROR_FILE_EXISTS, + cannot_make = ERROR_CANNOT_MAKE, + // ... + broken_pipe = ERROR_BROKEN_PIPE, + open_failed = ERROR_OPEN_FAILED, + buffer_overflow = ERROR_BUFFER_OVERFLOW, + disk_full= ERROR_DISK_FULL, + // ... + lock_failed = ERROR_LOCK_FAILED, + busy = ERROR_BUSY, + cancel_violation = ERROR_CANCEL_VIOLATION, + already_exists = ERROR_ALREADY_EXISTS + // ... + + // TODO: add more Windows errors + }; + + } // namespace windows + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + namespace windows = windows_error; +# endif + + template<> struct is_error_code_enum + { static const bool value = true; }; + + namespace windows_error + { + inline error_code make_error_code( windows_error_code e ) + { return error_code( e, get_system_category() ); } + } + + } // namespace system +} // namespace boost + +#endif // BOOST_WINDOWS_API + +#endif // BOOST_WINDOWS_ERROR_HPP diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/array.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/array.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,88 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_ARRAY_HPP_INCLUDED +# define BOOST_TR1_ARRAY_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_ARRAY + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(array) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(array)) +# endif + +#else + +#include +#include +#include +#include + +namespace std{ namespace tr1{ + +using ::boost::array; + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) +// [6.1.3.2] Tuple creation functions +using ::boost::swap; +#endif + +#if !defined(BOOST_TR1_USE_OLD_TUPLE) +}} namespace boost{ namespace fusion{ +#endif + +// [6.2.2.5] Tuple interface to class template array +template struct tuple_size; // forward declaration +template struct tuple_element; // forward declaration +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +struct tuple_size< ::boost::array > + : public ::boost::integral_constant< ::std::size_t, N>{}; + + +template +struct tuple_element > +{ +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) + BOOST_STATIC_ASSERT(I < (int)N); + BOOST_STATIC_ASSERT(I >= 0); +#endif + typedef T type; +}; +#endif +template +T& get( ::boost::array& a) +{ + BOOST_STATIC_ASSERT(I < N); + BOOST_STATIC_ASSERT(I >= 0); + return a[I]; +} + +template +const T& get(const array& a) +{ + BOOST_STATIC_ASSERT(I < N); + BOOST_STATIC_ASSERT(I >= 0); + return a[I]; +} + +#if !defined(BOOST_TR1_USE_OLD_TUPLE) +}} namespace std{ namespace tr1{ + + using ::boost::fusion::tuple_size; + using ::boost::fusion::tuple_element; + using ::boost::fusion::get; + +#endif + + +} } // namespaces + +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/cmath.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/cmath.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,267 @@ +// (C) Copyright John Maddock 2008. +// 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) + +#ifndef BOOST_TR1_CMATH_HPP_INCLUDED +# define BOOST_TR1_CMATH_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_CMATH + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(cmath) +# else +# include +# include BOOST_TR1_HEADER(cmath) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + +using boost::math::tr1::assoc_laguerre; +using boost::math::tr1::assoc_laguerref; +using boost::math::tr1::assoc_laguerrel; +// [5.2.1.2] associated Legendre functions: +using boost::math::tr1::assoc_legendre; +using boost::math::tr1::assoc_legendref; +using boost::math::tr1::assoc_legendrel; +// [5.2.1.3] beta function: +using boost::math::tr1::beta; +using boost::math::tr1::betaf; +using boost::math::tr1::betal; +// [5.2.1.4] (complete) elliptic integral of the first kind: +using boost::math::tr1::comp_ellint_1; +using boost::math::tr1::comp_ellint_1f; +using boost::math::tr1::comp_ellint_1l; +// [5.2.1.5] (complete) elliptic integral of the second kind: +using boost::math::tr1::comp_ellint_2; +using boost::math::tr1::comp_ellint_2f; +using boost::math::tr1::comp_ellint_2l; +// [5.2.1.6] (complete) elliptic integral of the third kind: +using boost::math::tr1::comp_ellint_3; +using boost::math::tr1::comp_ellint_3f; +using boost::math::tr1::comp_ellint_3l; +#if 0 +// [5.2.1.7] confluent hypergeometric functions: +using boost::math::tr1::conf_hyperg; +using boost::math::tr1::conf_hypergf; +using boost::math::tr1::conf_hypergl; +#endif +// [5.2.1.8] regular modified cylindrical Bessel functions: +using boost::math::tr1::cyl_bessel_i; +using boost::math::tr1::cyl_bessel_if; +using boost::math::tr1::cyl_bessel_il; +// [5.2.1.9] cylindrical Bessel functions (of the first kind): +using boost::math::tr1::cyl_bessel_j; +using boost::math::tr1::cyl_bessel_jf; +using boost::math::tr1::cyl_bessel_jl; +// [5.2.1.10] irregular modified cylindrical Bessel functions: +using boost::math::tr1::cyl_bessel_k; +using boost::math::tr1::cyl_bessel_kf; +using boost::math::tr1::cyl_bessel_kl; +// [5.2.1.11] cylindrical Neumann functions; +// cylindrical Bessel functions (of the second kind): +using boost::math::tr1::cyl_neumann; +using boost::math::tr1::cyl_neumannf; +using boost::math::tr1::cyl_neumannl; +// [5.2.1.12] (incomplete) elliptic integral of the first kind: +using boost::math::tr1::ellint_1; +using boost::math::tr1::ellint_1f; +using boost::math::tr1::ellint_1l; +// [5.2.1.13] (incomplete) elliptic integral of the second kind: +using boost::math::tr1::ellint_2; +using boost::math::tr1::ellint_2f; +using boost::math::tr1::ellint_2l; +// [5.2.1.14] (incomplete) elliptic integral of the third kind: +using boost::math::tr1::ellint_3; +using boost::math::tr1::ellint_3f; +using boost::math::tr1::ellint_3l; +// [5.2.1.15] exponential integral: +using boost::math::tr1::expint; +using boost::math::tr1::expintf; +using boost::math::tr1::expintl; +// [5.2.1.16] Hermite polynomials: +using boost::math::tr1::hermite; +using boost::math::tr1::hermitef; +using boost::math::tr1::hermitel; +#if 0 +// [5.2.1.17] hypergeometric functions: +using boost::math::tr1::hyperg; +using boost::math::tr1::hypergf; +using boost::math::tr1::hypergl; +#endif +// [5.2.1.18] Laguerre polynomials: +using boost::math::tr1::laguerre; +using boost::math::tr1::laguerref; +using boost::math::tr1::laguerrel; +// [5.2.1.19] Legendre polynomials: +using boost::math::tr1::legendre; +using boost::math::tr1::legendref; +using boost::math::tr1::legendrel; +// [5.2.1.20] Riemann zeta function: +using boost::math::tr1::riemann_zeta; +using boost::math::tr1::riemann_zetaf; +using boost::math::tr1::riemann_zetal; +// [5.2.1.21] spherical Bessel functions (of the first kind): +using boost::math::tr1::sph_bessel; +using boost::math::tr1::sph_besself; +using boost::math::tr1::sph_bessell; +// [5.2.1.22] spherical associated Legendre functions: +using boost::math::tr1::sph_legendre; +using boost::math::tr1::sph_legendref; +using boost::math::tr1::sph_legendrel; +// [5.2.1.23] spherical Neumann functions; +// spherical Bessel functions (of the second kind): +using boost::math::tr1::sph_neumann; +using boost::math::tr1::sph_neumannf; +using boost::math::tr1::sph_neumannl; + +// types +using boost::math::tr1::double_t; +using boost::math::tr1::float_t; +// functions +using boost::math::tr1::acosh; +using boost::math::tr1::acoshf; +using boost::math::tr1::acoshl; +using boost::math::tr1::asinh; +using boost::math::tr1::asinhf; +using boost::math::tr1::asinhl; +using boost::math::tr1::atanh; +using boost::math::tr1::atanhf; +using boost::math::tr1::atanhl; +using boost::math::tr1::cbrt; +using boost::math::tr1::cbrtf; +using boost::math::tr1::cbrtl; +using boost::math::tr1::copysign; +using boost::math::tr1::copysignf; +using boost::math::tr1::copysignl; +using boost::math::tr1::erf; +using boost::math::tr1::erff; +using boost::math::tr1::erfl; +using boost::math::tr1::erfc; +using boost::math::tr1::erfcf; +using boost::math::tr1::erfcl; +#if 0 +using boost::math::tr1::exp2; +using boost::math::tr1::exp2f; +using boost::math::tr1::exp2l; +#endif +using boost::math::tr1::expm1; +using boost::math::tr1::expm1f; +using boost::math::tr1::expm1l; +#if 0 +using boost::math::tr1::fdim; +using boost::math::tr1::fdimf; +using boost::math::tr1::fdiml; +using boost::math::tr1::fma; +using boost::math::tr1::fmaf; +using boost::math::tr1::fmal; +#endif +using boost::math::tr1::fmax; +using boost::math::tr1::fmaxf; +using boost::math::tr1::fmaxl; +using boost::math::tr1::fmin; +using boost::math::tr1::fminf; +using boost::math::tr1::fminl; +using boost::math::tr1::hypot; +using boost::math::tr1::hypotf; +using boost::math::tr1::hypotl; +#if 0 +using boost::math::tr1::ilogb; +using boost::math::tr1::ilogbf; +using boost::math::tr1::ilogbl; +#endif +using boost::math::tr1::lgamma; +using boost::math::tr1::lgammaf; +using boost::math::tr1::lgammal; +#if 0 +using boost::math::tr1::llrint; +using boost::math::tr1::llrintf; +using boost::math::tr1::llrintl; +#endif +using boost::math::tr1::llround; +using boost::math::tr1::llroundf; +using boost::math::tr1::llroundl; +using boost::math::tr1::log1p; +using boost::math::tr1::log1pf; +using boost::math::tr1::log1pl; +#if 0 +using boost::math::tr1::log2; +using boost::math::tr1::log2f; +using boost::math::tr1::log2l; +using boost::math::tr1::logb; +using boost::math::tr1::logbf; +using boost::math::tr1::logbl; +using boost::math::tr1::lrint; +using boost::math::tr1::lrintf; +using boost::math::tr1::lrintl; +#endif +using boost::math::tr1::lround; +using boost::math::tr1::lroundf; +using boost::math::tr1::lroundl; +#if 0 +using boost::math::tr1::nan; +using boost::math::tr1::nanf; +using boost::math::tr1::nanl; +using boost::math::tr1::nearbyint; +using boost::math::tr1::nearbyintf; +using boost::math::tr1::nearbyintl; +#endif +using boost::math::tr1::nextafter; +using boost::math::tr1::nextafterf; +using boost::math::tr1::nextafterl; +using boost::math::tr1::nexttoward; +using boost::math::tr1::nexttowardf; +using boost::math::tr1::nexttowardl; +#if 0 +using boost::math::tr1::remainder; +using boost::math::tr1::remainderf; +using boost::math::tr1::remainderl; +using boost::math::tr1::remquo; +using boost::math::tr1::remquof; +using boost::math::tr1::remquol; +using boost::math::tr1::rint; +using boost::math::tr1::rintf; +using boost::math::tr1::rintl; +#endif +using boost::math::tr1::round; +using boost::math::tr1::roundf; +using boost::math::tr1::roundl; +#if 0 +using boost::math::tr1::scalbln; +using boost::math::tr1::scalblnf; +using boost::math::tr1::scalblnl; +using boost::math::tr1::scalbn; +using boost::math::tr1::scalbnf; +using boost::math::tr1::scalbnl; +#endif +using boost::math::tr1::tgamma; +using boost::math::tr1::tgammaf; +using boost::math::tr1::tgammal; +using boost::math::tr1::trunc; +using boost::math::tr1::truncf; +using boost::math::tr1::truncl; +// C99 macros defined as C++ templates +using boost::math::tr1::signbit; +using boost::math::tr1::fpclassify; +using boost::math::tr1::isfinite; +using boost::math::tr1::isinf; +using boost::math::tr1::isnan; +using boost::math::tr1::isnormal; +#if 0 +using boost::math::tr1::isgreater; +using boost::math::tr1::isgreaterequal; +using boost::math::tr1::isless; +using boost::math::tr1::islessequal; +using boost::math::tr1::islessgreater; +using boost::math::tr1::isunordered; +#endif +} } // namespaces + +#endif // BOOST_HAS_TR1_CMATH + +#endif // BOOST_TR1_CMATH_HPP_INCLUDED diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/complex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/complex.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,244 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_COMPLEX_HPP_INCLUDED +# define BOOST_TR1_COMPLEX_HPP_INCLUDED +# include +# include + +#ifndef BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG + +#include + +namespace std { +namespace tr1 { + +using boost::math::acos; +using boost::math::asin; +using boost::math::atan; +using boost::math::acosh; +using boost::math::asinh; +using boost::math::atanh; +using boost::math::fabs; + +} } + +#else + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(complex) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(complex)) +# endif + +#endif + +#ifndef BOOST_HAS_TR1_COMPLEX_OVERLOADS + +#include +#include +#include +#include + +namespace std{ + +#ifdef BOOST_NO_STDC_NAMESPACE + using :: atan2; +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) arg(const T& t) +{ + return ::std::atan2(0.0, static_cast(t)); +} +#else +inline double arg(const double& t) +{ + return ::std::atan2(0.0, t); +} +#endif +inline long double arg(const long double& t) +{ + return ::std::atan2(0.0L, static_cast(t)); +} +inline float arg(const float& t) +{ + return ::std::atan2(0.0F, static_cast(t)); +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) norm(const T& t) +{ + double r = static_cast(t); + return r*r; +} +#else +inline double norm(const double& t) +{ + return t*t; +} +#endif +inline long double norm(const long double& t) +{ + long double l = t; + return l*l; +} +inline float norm(const float& t) +{ + float f = t; + return f*f; +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(std::complex) conj(const T& t) +{ + return ::std::conj(std::complex(static_cast(t))); +} +#else +inline std::complex conj(const double& t) +{ + return ::std::conj(std::complex(t)); +} +#endif +inline std::complex conj(const long double& t) +{ + return ::std::conj(std::complex(t)); +} +inline std::complex conj(const float& t) +{ + std::complex ct(t); + ct = ::std::conj(ct); + return ct; +} + +#if !BOOST_WORKAROUND(__BORLANDC__, <=0x570) && !BOOST_WORKAROUND(BOOST_MSVC, < 1310) +inline complex polar(const char& rho, const char& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned char& rho, const unsigned char& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const signed char& rho, const signed char& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const short& rho, const short& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned short& rho, const unsigned short& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const int& rho, const int& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned int& rho, const unsigned int& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const long& rho, const long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned long& rho, const unsigned long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +#ifdef BOOST_HAS_LONG_LONG +inline complex polar(const long long& rho, const long long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned long long& rho, const unsigned long long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +#elif defined(BOOST_HAS_MS_INT64) +inline complex polar(const __int64& rho, const __int64& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned __int64& rho, const unsigned __int64& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +#endif + +template +inline complex::type> + polar(const T& rho, const U& theta) +{ + typedef typename boost::tr1_detail::promote_to_real::type real_type; + return std::polar(static_cast(rho), static_cast(theta)); +} +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) imag(const T& ) +{ + return 0; +} +#else +inline double imag(const double& ) +{ + return 0; +} +#endif +inline long double imag(const long double& ) +{ + return 0; +} +inline float imag(const float& ) +{ + return 0; +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) real(const T& t) +{ + return static_cast(t); +} +#else +inline double real(const double& t) +{ + return t; +} +#endif +inline long double real(const long double& t) +{ + return t; +} +inline float real(const float& t) +{ + return t; +} + +template +inline complex::type> + pow(const complex& x, const complex& y) +{ + typedef complex::type> result_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast1_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast2_type; + cast1_type x1(x); + cast2_type y1(y); + return std::pow(x1, y1); +} +template +inline complex::type> + pow (const complex& x, const U& y) +{ + typedef typename boost::tr1_detail::promote_to_real::type real_type; + typedef complex::type> result_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast1_type; + real_type r = y; + cast1_type x1(x); + std::complex y1(r); + return std::pow(x1, y1); +} + +template +inline complex::type> + pow (const T& x, const complex& y) +{ + typedef typename boost::tr1_detail::promote_to_real::type real_type; + typedef complex::type> result_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast_type; + real_type r = x; + std::complex x1(r); + cast_type y1(y); + return std::pow(x1, y1); +} + +} + +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/detail/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/config.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,163 @@ +// (C) Copyright John Maddock 2005-7. +// 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) + +#ifndef BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED +# define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED + +#include + +#if defined(__GNUC__) || (!defined(_AIX) && defined(__IBMCPP__) && (__IBMCPP__ >= 800)) +#if !defined(BOOST_HAS_INCLUDE_NEXT) +# define BOOST_HAS_INCLUDE_NEXT +#endif +// Need to find out if we're using GLIBC: +#ifdef BOOST_TR1_UTILITY_INCLUDED +// Oops we're in a recursive include path!! +// Need to include utility, or some std lib header, +// but *not* via or +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_CONFIG_RECURSION +# endif +# if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT) +# include_next +# else +# include BOOST_TR1_STD_HEADER(utility) +# endif +# ifdef BOOST_TR1_NO_CONFIG_RECURSION +# undef BOOST_TR1_NO_CONFIG_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#else +#include +#endif +#endif + +#if defined(__GLIBCXX__) && !defined(BOOST_TR1_PATH) +# define BOOST_TR1_PATH(name) tr1/name +#endif +#if !defined(BOOST_TR1_PATH) +# define BOOST_TR1_PATH(name) name +#endif + +#define BOOST_TR1_HEADER(name) + +// Can't use BOOST_WORKAROUND here, it leads to recursive includes: +#if (defined(__BORLANDC__) && (__BORLANDC__ <= 0x600)) || (defined(_MSC_VER) && (_MSC_VER < 1310)) +# define BOOST_TR1_USE_OLD_TUPLE +#endif + +#ifdef __IBMCPP_TR1__ + // turn on support for everything: +# define BOOST_HAS_TR1 +#endif + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define BOOST_HAS_TR1_COMPLEX_OVERLOADS +# define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG +#endif + +#ifdef BOOST_HAS_TR1 + // turn on support for everything: +# define BOOST_HAS_TR1_ARRAY +# define BOOST_HAS_TR1_COMPLEX_OVERLOADS +# define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_RESULT_OF +# define BOOST_HAS_TR1_MEM_FN +# define BOOST_HAS_TR1_BIND +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_HASH +# define BOOST_HAS_TR1_SHARED_PTR +# define BOOST_HAS_TR1_RANDOM +# define BOOST_HAS_TR1_REGEX +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_TYPE_TRAITS +# define BOOST_HAS_TR1_UTILITY +# define BOOST_HAS_TR1_UNORDERED_MAP +# define BOOST_HAS_TR1_UNORDERED_SET +# define BOOST_HAS_TR1_CMATH + +#endif + +#if defined(__MWERKS__) && (__MWERKS__ >= 0x3205) +// +// Very preliminary MWCW support, may not be right: +// +# define BOOST_HAS_TR1_SHARED_PTR +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_RESULT_OF +#endif + +#ifdef BOOST_HAS_GCC_TR1 + // turn on support for everything in gcc 4.0.x: +# define BOOST_HAS_TR1_ARRAY +#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 +//# define BOOST_HAS_TR1_COMPLEX_OVERLOADS +# define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG +#endif +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_RESULT_OF +# define BOOST_HAS_TR1_MEM_FN +# define BOOST_HAS_TR1_BIND +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_HASH +# define BOOST_HAS_TR1_SHARED_PTR +#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 +# define BOOST_HAS_TR1_RANDOM +//# define BOOST_HAS_TR1_REGEX +#ifdef _GLIBCXX_USE_C99_MATH_TR1 +# define BOOST_HAS_TR1_CMATH +#endif +#endif +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_TYPE_TRAITS +# define BOOST_HAS_TR1_UTILITY +# define BOOST_HAS_TR1_UNORDERED_MAP +# define BOOST_HAS_TR1_UNORDERED_SET + +#endif + +#if defined(_MSC_VER) && (_MSC_VER >= 1500) \ + && defined(_MSC_FULL_VER) && \ + !defined(__SGI_STL_PORT) && \ + !defined(_STLPORT_VERSION) && \ + !defined(_RWSTD_VER_STR) && \ + !defined(_RWSTD_VER) +// +// MSVC-9.0 defines a not-quite TR1 conforming hash +// function object in , so we must define +// this here, in addition the feature pack for VC9 +// provides a more or less full TR1 implementation: +// +#if defined(_HAS_TR1) && (_HAS_TR1 + 0) +# define BOOST_HAS_TR1_ARRAY +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_RESULT_OF +# define BOOST_HAS_TR1_MEM_FN +# define BOOST_HAS_TR1_BIND +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_HASH +# define BOOST_HAS_TR1_SHARED_PTR +# define BOOST_HAS_TR1_RANDOM +# define BOOST_HAS_TR1_REGEX +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_TYPE_TRAITS +# define BOOST_HAS_TR1_UTILITY +# define BOOST_HAS_TR1_UNORDERED_MAP +# define BOOST_HAS_TR1_UNORDERED_SET +#else +# define BOOST_HAS_TR1_HASH +#endif +#endif + +#include + +#endif + + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/detail/config_all.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/config_all.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,158 @@ +// (C) Copyright John Maddock 2005. +// 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) + +/* + * The gcc include path logic is derived from STLport: + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999-2003 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef BOOST_TR1_DETAIL_CONFIG_ALL_HPP_INCLUDED +# define BOOST_TR1_DETAIL_CONFIG_ALL_HPP_INCLUDED + +// +// IMPORTANT: we must figure out the basics, such as how to +// forward to the real std lib headers *without* including +// boost/config.hpp or any of the std lib headers. A classic +// chicken and the egg problem.... +// +// Including at least lets us detect STLport: +// +#include + +// Including allows us to use __GLIBCXX__ to +// determine the version of the stdc++ library in use +// under Darwin. +#include + +# if defined(_RWSTD_VER) && _RWSTD_VER >= 0x04010200 +# if !defined (__SUNPRO_CC) && !defined (__DECCXX) +# define BOOST_TR1_STD_CHEADER(name) <../include/ansi/name> +# endif +# endif + + +# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && !defined(__BORLANDC__) +# ifdef __SUNPRO_CC + // can't use <../stlport/name> since some compilers put stlport in a different directory: +# define BOOST_TR1_STD_HEADER(name) <../stlport4/name> +# elif defined(__PGI) +# define BOOST_TR1_STD_HEADER(name) <../CC/name> +# else +# define BOOST_TR1_STD_HEADER(name) <../stlport/name> +# endif + +# elif defined(__HP_aCC) + // HP aCC include path: +# define BOOST_TR1_STD_HEADER(name) <../include_std/name> + +# elif defined(__DECCXX) +# define BOOST_TR1_STD_HEADER(name) <../cxx/name> + +# elif defined(__BORLANDC__) && __BORLANDC__ >= 0x570 +# define BOOST_TR1_STD_HEADER(name) <../include/dinkumware/name> + +# elif defined(__GNUC__) && __GNUC__ >= 3 +# if defined(BOOST_TR1_GCC_INCLUDE_PATH) +# define BOOST_TR1_STD_HEADER(name) <../BOOST_TR1_GCC_INCLUDE_PATH/name> +# elif ( (__GNUC__ == 3 ) && ((__GNUC_MINOR__ == 0) || ((__GNUC_MINOR__ < 3) && defined(__APPLE_CC__)))) +# define BOOST_TR1_STD_HEADER(name) <../g++-v3/name> +# else +# if ( ((__GNUC__ == 3 ) && (__GNUC_MINOR__ >= 3)) && (defined(__APPLE_CC__) || defined(__CYGWIN__))) +# define BOOST_TR1_STD_HEADER(name) <../c++/name> +# elif ((__GLIBCXX__ == 20050421) && defined(__APPLE_CC__)) + // Some Darwin tools fix libstdc++ at 4.0.0 irrespective of the actual + // compiler version: +# define BOOST_TR1_STD_HEADER(name) <../4.0.0/name> + /* + * Before version 3.4.0 the 0 patch level was not part of the include path: + */ +# elif defined (__GNUC_PATCHLEVEL__) && ((__GNUC_PATCHLEVEL__ > 0) || \ + (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ > 3)) +# define BOOST_TR1_STD_HEADER(name) <../__GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__/name> +# else +# define BOOST_TR1_STD_HEADER(name) <../__GNUC__.__GNUC_MINOR__/name> +# endif +# endif + +# if !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT) && !defined(__ICC) \ + && (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) + // Disable use of #include_next on Linux as typically we are installed in a directory that is searched + // *after* the std lib include path: +# define BOOST_TR1_DISABLE_INCLUDE_NEXT +# endif + +# else +# define BOOST_TR1_STD_HEADER(name) <../include/name> +# endif + +#if !defined(BOOST_TR1_STD_CHEADER) +# define BOOST_TR1_STD_CHEADER(name) BOOST_TR1_STD_HEADER(name) +#endif + +#if defined(__GNUC__) && !defined(BOOST_HAS_INCLUDE_NEXT) +# define BOOST_HAS_INCLUDE_NEXT +#endif +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define BOOST_HAS_CPP_0X +#endif + +// +// We may be in the middle of parsing boost/config.hpp +// when this header is included, so don't rely on config +// stuff in the rest of this header... +// +// Find our actual std lib: +// +#if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT) +// +// We don't take this branch if BOOST_TR1_DISABLE_INCLUDE_NEXT +// is defined as we may be installed in +// /usr/include, in which case #include_next won't work as our +// include path will occur AFTER the regular std lib one :-( +// +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_CONFIG_ALL_RECURSION +# endif +# include_next +# if (__GNUC__ < 3) +# include_next +# include_next +# endif +# ifdef BOOST_TR1_NO_CONFIG_ALL_RECURSION +# undef BOOST_TR1_NO_CONFIG_ALL_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#else +# include BOOST_TR1_STD_HEADER(utility) +#endif + +#include + +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/detail/functor2iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/functor2iterator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_FUNCTOR_IT_HPP_INCLUDED +# define BOOST_TR1_FUNCTOR_IT_HPP_INCLUDED + +# include + +namespace boost{ namespace tr1_details{ + +template +struct functor2iterator : boost::iterator_facade, const R, std::input_iterator_tag> +{ + functor2iterator() : m_func(0){} + functor2iterator(Func& f) + : m_func(&f) + { + m_val = (*m_func)(); + } + const R& dereference()const + { return m_val; } + void increment(){ m_val = (*m_func)(); } + bool equal(const functor2iterator&)const + { return false; } +private: + Func* m_func; + R m_val; +}; + +} } + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/detail/math_overloads.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/math_overloads.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,58 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_MATH_OVERLOADS_HPP_INCLUDED +# define BOOST_TR1_MATH_OVERLOADS_HPP_INCLUDED +# include + +# ifndef BOOST_NO_SFINAE +# include +# include +# define BOOST_TR1_MATH_RETURN(RET) typename ::boost::enable_if< ::boost::is_convertible, RET >::type +# else +# define BOOST_TR1_MATH_RETURN(RET) RET +# endif + +# include +# include +# include + +namespace boost{ namespace tr1_detail{ + +template +struct largest_real +{ + typedef typename boost::mpl::if_< + boost::is_same, + long double, + typename boost::mpl::if_< + boost::is_same, + long double, + typename boost::mpl::if_< + boost::is_same, + double, + typename boost::mpl::if_< + boost::is_same, + double, + float + >::type + >::type + >::type + >::type type; +}; + +template +struct promote_to_real +{ + typedef typename largest_real< + typename boost::mpl::if_< boost::is_floating_point, T, double>::type, + typename boost::mpl::if_< boost::is_floating_point, U, double>::type + >::type type; +}; + +} } + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/functional.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/functional.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,137 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_FUNCTIONAL_HPP_INCLUDED +# define BOOST_TR1_FUNCTIONAL_HPP_INCLUDED +# include +# include + +#if defined(BOOST_HAS_TR1_REFERENCE_WRAPPER) \ + || defined(BOOST_HAS_TR1_RESULT_OF)\ + || defined(BOOST_HAS_TR1_MEM_FN)\ + || defined(BOOST_HAS_TR1_BIND)\ + || defined(BOOST_HAS_TR1_FUNCTION)\ + || defined(BOOST_HAS_TR1_HASH) +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(functional) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(functional)) +# endif +#endif + +#ifndef BOOST_HAS_TR1_REFERENCE_WRAPPER + +#include + +namespace std{ namespace tr1{ + + using ::boost::reference_wrapper; + using ::boost::ref; + using ::boost::cref; + +} } + +#endif // BOOST_HAS_TR1_REFERENCE_WRAPPER + +#if !defined(BOOST_HAS_TR1_RESULT_OF)\ + && !defined(BOOST_NO_SFINAE) && \ + !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + +// +// we can only actually include result_of.hpp if the compiler +// really does support it, otherwise we just get endless errors... +// +#include + +namespace std{ namespace tr1{ + + using ::boost::result_of; + +} } + +#endif // BOOST_HAS_TR1_RESULT_OF + +#ifndef BOOST_HAS_TR1_MEM_FN +// mem_fn: +#include + +namespace std{ namespace tr1{ + +using boost::mem_fn; + +} } + +#endif // BOOST_HAS_TR1_MEM_FN + + +#ifndef BOOST_HAS_TR1_BIND +// Bind: +#include + +namespace std{ namespace tr1{ + + using ::boost::is_bind_expression; + using ::boost::is_placeholder; + using ::boost::bind; + namespace placeholders { +#ifndef BOOST_BIND_NO_PLACEHOLDERS + using ::_1; + using ::_2; + using ::_3; + using ::_4; + using ::_5; + using ::_6; + using ::_7; + using ::_8; + using ::_9; +#endif + } // placeholders + +} } + +#endif + +#ifndef BOOST_HAS_TR1_FUNCTION +// polymorphic function object wrappers: +#include +#include + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x582) \ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1310) \ + && !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX) +namespace std{ namespace tr1{ + + using ::boost::bad_function_call; + using ::boost::function; + using ::boost::swap; + +}} +#endif + +#endif // BOOST_HAS_TR1_FUNCTION + +#ifndef BOOST_HAS_TR1_HASH +// +// This header can get included by boost/hash.hpp +// leading to cyclic dependencies. As a workaround +// we forward declare boost::hash and include +// the actual header later. +// +namespace boost{ +template struct hash; +} + +namespace std{ namespace tr1{ + using ::boost::hash; + +}} + +#include + +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/memory.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/memory.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,72 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_MEMORY_HPP_INCLUDED +# define BOOST_TR1_MEMORY_HPP_INCLUDED +# include +# include +# include + +#ifndef BOOST_HAS_TR1_SHARED_PTR + +// +// This header can get included by boost/shared_ptr.hpp which leads +// to cyclic dependencies, the workaround is to forward declare all +// the boost components, and then include the actual headers afterwards. +// This is fragile, but seems to work, and doesn't require modification +// of boost/shared_ptr.hpp. +// +namespace boost{ + +class bad_weak_ptr; +template class weak_ptr; +template class shared_ptr; +template void swap(weak_ptr & a, weak_ptr & b); +template void swap(shared_ptr & a, shared_ptr & b); +template shared_ptr static_pointer_cast(shared_ptr const & r); +template shared_ptr dynamic_pointer_cast(shared_ptr const & r); +template shared_ptr const_pointer_cast(shared_ptr const & r); +template D * get_deleter(shared_ptr const & p); +template class enable_shared_from_this; + +namespace detail{ +class shared_count; +class weak_count; +} + +} + +namespace std{ namespace tr1{ + + using ::boost::bad_weak_ptr; + using ::boost::shared_ptr; +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) + using ::boost::swap; +#endif + using ::boost::static_pointer_cast; + using ::boost::dynamic_pointer_cast; + using ::boost::const_pointer_cast; + using ::boost::get_deleter; + using ::boost::weak_ptr; + using ::boost::enable_shared_from_this; + +} } +#include +#include +#include + +#else + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(memory) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(memory)) +# endif + +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/random.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/random.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,586 @@ +// (C) Copyright John Maddock 2005. +// (C) Copyright Henry S. Warren 2005. +// 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) + +#ifndef BOOST_TR1_RANDOM_HPP_INCLUDED +# define BOOST_TR1_RANDOM_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_RANDOM +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(random) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(random)) +# endif +#else +// Boost.Random: +#include +#ifndef __SUNPRO_CC + // Sunpros linker complains if we so much as include this... +# include +#endif +#include +#include +#include + +namespace std { namespace tr1{ + +using ::boost::variate_generator; + +template +class linear_congruential +{ +private: + typedef ::boost::random::linear_congruential impl_type; +public: + // types + typedef UIntType result_type; + // parameter values + BOOST_STATIC_CONSTANT(UIntType, multiplier = a); + BOOST_STATIC_CONSTANT(UIntType, increment = c); + BOOST_STATIC_CONSTANT(UIntType, modulus = m); + // constructors and member function + explicit linear_congruential(unsigned long x0 = 1) + : m_gen(x0){} + linear_congruential(const linear_congruential& that) + : m_gen(that.m_gen){} + template linear_congruential(Gen& g) + { + init1(g, ::boost::is_same()); + } + void seed(unsigned long x0 = 1) + { m_gen.seed(x0); } + template void seed(Gen& g) + { + init2(g, ::boost::is_fundamental()); + } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { + return m_gen(); + } + bool operator==(const linear_congruential& that)const + { return m_gen == that.m_gen; } + bool operator!=(const linear_congruential& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const linear_congruential& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + linear_congruential& lcg) + { + return is >> lcg.m_gen; + } +#endif + +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + //typedef typename Gen::result_type gen_rt; + boost::tr1_details::functor2iterator f1(g), f2; + m_gen.seed(f1, f2); + } + impl_type m_gen; +}; + +template +class mersenne_twister +{ + typedef ::boost::random::mersenne_twister + imp_type; +public: + // types + typedef UIntType result_type; + // parameter values + BOOST_STATIC_CONSTANT(int, word_size = w); + BOOST_STATIC_CONSTANT(int, state_size = n); + BOOST_STATIC_CONSTANT(int, shift_size = m); + BOOST_STATIC_CONSTANT(int, mask_bits = r); + BOOST_STATIC_CONSTANT(UIntType, parameter_a = a); + BOOST_STATIC_CONSTANT(int, output_u = u); + BOOST_STATIC_CONSTANT(int, output_s = s); + BOOST_STATIC_CONSTANT(UIntType, output_b = b); + BOOST_STATIC_CONSTANT(int, output_t = t); + BOOST_STATIC_CONSTANT(UIntType, output_c = c); + BOOST_STATIC_CONSTANT(int, output_l = l); + // constructors and member function + mersenne_twister(){} + explicit mersenne_twister(unsigned long value) + : m_gen(value == 0 ? 5489UL : value){} + template mersenne_twister(Gen& g) + { + init1(g, ::boost::is_same()); + } + void seed() + { m_gen.seed(); } + void seed(unsigned long value) + { m_gen.seed(value == 0 ? 5489UL : value); } + template void seed(Gen& g) + { init2(g, ::boost::is_fundamental()); } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { return m_gen(); } + bool operator==(const mersenne_twister& that)const + { return m_gen == that.m_gen; } + bool operator!=(const mersenne_twister& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const mersenne_twister& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + mersenne_twister& lcg) + { + return is >> lcg.m_gen; + } +#endif +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g == 0 ? 4357UL : g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + m_gen.seed(g); + } + imp_type m_gen; +}; + +template +class subtract_with_carry +{ +public: + // types + typedef IntType result_type; + // parameter values + BOOST_STATIC_CONSTANT(IntType, modulus = m); + BOOST_STATIC_CONSTANT(int, long_lag = r); + BOOST_STATIC_CONSTANT(int, short_lag = s); + + // constructors and member function + subtract_with_carry(){} + explicit subtract_with_carry(unsigned long value) + : m_gen(value == 0 ? 19780503UL : value){} + template subtract_with_carry(Gen& g) + { init1(g, ::boost::is_same >()); } + void seed(unsigned long value = 19780503ul) + { m_gen.seed(value == 0 ? 19780503UL : value); } + template void seed(Gen& g) + { init2(g, ::boost::is_fundamental()); } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { return m_gen(); } + bool operator==(const subtract_with_carry& that)const + { return m_gen == that.m_gen; } + bool operator!=(const subtract_with_carry& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const subtract_with_carry& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + subtract_with_carry& lcg) + { + return is >> lcg.m_gen; + } +#endif +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g == 0 ? 19780503UL : g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + m_gen.seed(g); + } + ::boost::random::subtract_with_carry m_gen; +}; + +template +class subtract_with_carry_01 +{ +public: + // types + typedef RealType result_type; + // parameter values + BOOST_STATIC_CONSTANT(int, word_size = w); + BOOST_STATIC_CONSTANT(int, long_lag = r); + BOOST_STATIC_CONSTANT(int, short_lag = s); + + // constructors and member function + subtract_with_carry_01(){} + explicit subtract_with_carry_01(unsigned long value) + : m_gen(value == 0 ? 19780503UL : value){} + template subtract_with_carry_01(Gen& g) + { init1(g, ::boost::is_same >()); } + void seed(unsigned long value = 19780503UL) + { m_gen.seed(value == 0 ? 19780503UL : value); } + template void seed(Gen& g) + { init2(g, ::boost::is_fundamental()); } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { return m_gen(); } + bool operator==(const subtract_with_carry_01& that)const + { return m_gen == that.m_gen; } + bool operator!=(const subtract_with_carry_01& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const subtract_with_carry_01& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + subtract_with_carry_01& lcg) + { + return is >> lcg.m_gen; + } +#endif +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g == 0 ? 19780503UL : g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + //typedef typename Gen::result_type gen_rt; + boost::tr1_details::functor2iterator f1(g), f2; + m_gen.seed(f1, f2); + } + ::boost::random::subtract_with_carry_01 m_gen; +}; + +using ::boost::random::discard_block; + +template +class xor_combine +{ +public: + // types + typedef UniformRandomNumberGenerator1 base1_type; + typedef UniformRandomNumberGenerator2 base2_type; + typedef unsigned long result_type; + // parameter values + BOOST_STATIC_CONSTANT(int, shift1 = s1); + BOOST_STATIC_CONSTANT(int, shift2 = s2); + // constructors and member function + xor_combine(){ init_minmax(); } + xor_combine(const base1_type & rng1, const base2_type & rng2) + : m_b1(rng1), m_b2(rng2) { init_minmax(); } + xor_combine(unsigned long s) + : m_b1(s), m_b2(s+1) { init_minmax(); } + template xor_combine(Gen& g) + { + init_minmax(); + init1(g, ::boost::is_same >()); + } + void seed() + { + m_b1.seed(); + m_b2.seed(); + } + void seed(unsigned long s) + { + m_b1.seed(s); + m_b2.seed(s+1); + } + template void seed(Gen& g) + { + init2(g, ::boost::is_fundamental()); + } + + const base1_type& base1() const + { return m_b1; } + const base2_type& base2() const + { return m_b2; } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return m_min; } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return m_max; } + result_type operator()() + { return (m_b1() << s1) ^ (m_b2() << s2); } + + bool operator == (const xor_combine& that)const + { return (m_b1 == that.m_b1) && (m_b2 == that.m_b2); } + bool operator != (const xor_combine& that)const + { return !(*this == that); } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const xor_combine& lcg) + { + return os << lcg.m_b1 << " " << lcg.m_b2; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + xor_combine& lcg) + { + return is >> lcg.m_b1 >> lcg.m_b2; + } +#endif + +private: + void init_minmax(); + base1_type m_b1; + base2_type m_b2; + result_type m_min; + result_type m_max; + + template + void init1(Gen& g, const ::boost::true_type&) + { + m_b1 = g.m_b1; + m_b2 = g.m_b2; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_b1.seed(static_cast(g)); + m_b2.seed(static_cast(g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + m_b1.seed(g); + m_b2.seed(g); + } +}; + +template +void xor_combine::init_minmax() +{ + // + // The following code is based on that given in "Hacker's Delight" + // by Henry S. Warren, (Addison-Wesley, 2003), and at + // http://www.hackersdelight.org/index.htm. + // Used here by permission. + // + // calculation of minimum value: + // + result_type a = (m_b1.min)() << s1; + result_type b = (m_b1.max)() << s1; + result_type c = (m_b2.min)() << s2; + result_type d = (m_b2.max)() << s2; + result_type m, temp; + + m = 0x1uL << ((sizeof(result_type) * CHAR_BIT) - 1); + while (m != 0) { + if (~a & c & m) { + temp = (a | m) & (static_cast(0u) - m); + if (temp <= b) a = temp; + } + else if (a & ~c & m) { + temp = (c | m) & (static_cast(0u) - m); + if (temp <= d) c = temp; + } + m >>= 1; + } + m_min = a ^ c; + + // + // calculation of maximum value: + // + if((((std::numeric_limits::max)() >> s1) < (m_b1.max)()) + || ((((std::numeric_limits::max)()) >> s2) < (m_b2.max)())) + { + m_max = (std::numeric_limits::max)(); + return; + } + a = (m_b1.min)() << s1; + b = (m_b1.max)() << s1; + c = (m_b2.min)() << s2; + d = (m_b2.max)() << s2; + + m = 0x1uL << ((sizeof(result_type) * CHAR_BIT) - 1); + + while (m != 0) { + if (b & d & m) { + temp = (b - m) | (m - 1); + if (temp >= a) b = temp; + else { + temp = (d - m) | (m - 1); + if (temp >= c) d = temp; + } + } + m = m >> 1; + } + m_max = b ^ d; +} + +typedef linear_congruential< ::boost::int32_t, 16807, 0, 2147483647> minstd_rand0; +typedef linear_congruential< ::boost::int32_t, 48271, 0, 2147483647> minstd_rand; +typedef mersenne_twister< ::boost::uint32_t, 32,624,397,31,0x9908b0df,11,7,0x9d2c5680,15,0xefc60000,18> mt19937; +typedef subtract_with_carry_01 ranlux_base_01; +typedef subtract_with_carry_01 ranlux64_base_01; +typedef discard_block, 223, 24> ranlux3; +typedef discard_block, 389, 24> ranlux4; +typedef discard_block, 223, 24> ranlux3_01; +typedef discard_block, 389, 24> ranlux4_01; + +#ifndef __SUNPRO_CC +using ::boost::random_device; +#endif +using ::boost::uniform_int; + +class bernoulli_distribution +{ +public: + // types + typedef int input_type; + typedef bool result_type; + // constructors and member function + explicit bernoulli_distribution(double p = 0.5) + : m_dist(p){} + double p() const + { return m_dist.p(); } + void reset() + { m_dist.reset(); } + template + result_type operator()(UniformRandomNumberGenerator& urng) + { + return m_dist(urng); + } +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const bernoulli_distribution& lcg) + { + return os << lcg.m_dist; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + bernoulli_distribution& lcg) + { + return is >> lcg.m_dist; + } +#endif + +private: + ::boost::bernoulli_distribution m_dist; +}; +//using ::boost::bernoulli_distribution; +using ::boost::geometric_distribution; +using ::boost::poisson_distribution; +using ::boost::binomial_distribution; +using ::boost::uniform_real; +using ::boost::exponential_distribution; +using ::boost::normal_distribution; +using ::boost::gamma_distribution; + +} } + +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/regex.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,147 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_REGEX_HPP_INCLUDED +# define BOOST_TR1_REGEX_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_REGEX + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(regex) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(regex)) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + +// [7.5] Regex constants +namespace regex_constants { + +using ::boost::regex_constants::syntax_option_type; +using ::boost::regex_constants::icase; +using ::boost::regex_constants::nosubs; +using ::boost::regex_constants::optimize; +using ::boost::regex_constants::collate; +using ::boost::regex_constants::ECMAScript; +using ::boost::regex_constants::basic; +using ::boost::regex_constants::extended; +using ::boost::regex_constants::awk; +using ::boost::regex_constants::grep; +using ::boost::regex_constants::egrep; + +using ::boost::regex_constants::match_flag_type; +using ::boost::regex_constants::match_default; +using ::boost::regex_constants::match_not_bol; +using ::boost::regex_constants::match_not_eol; +using ::boost::regex_constants::match_not_bow; +using ::boost::regex_constants::match_not_eow; +using ::boost::regex_constants::match_any; +using ::boost::regex_constants::match_not_null; +using ::boost::regex_constants::match_continuous; +using ::boost::regex_constants::match_prev_avail; +using ::boost::regex_constants::format_default; +using ::boost::regex_constants::format_sed; +using ::boost::regex_constants::format_no_copy; +using ::boost::regex_constants::format_first_only; + +using ::boost::regex_constants::error_type; +using ::boost::regex_constants::error_collate; +using ::boost::regex_constants::error_ctype; +using ::boost::regex_constants::error_escape; +using ::boost::regex_constants::error_backref; +using ::boost::regex_constants::error_brack; +using ::boost::regex_constants::error_paren; +using ::boost::regex_constants::error_brace; +using ::boost::regex_constants::error_badbrace; +using ::boost::regex_constants::error_range; +using ::boost::regex_constants::error_space; +using ::boost::regex_constants::error_badrepeat; +using ::boost::regex_constants::error_complexity; +using ::boost::regex_constants::error_stack; + +} // namespace regex_constants + +// [7.6] Class regex_error +using ::boost::regex_error; + +// [7.7] Class template regex_traits +using ::boost::regex_traits; + +// [7.8] Class template basic_regex +using ::boost::basic_regex; +using ::boost::regex; +#ifndef BOOST_NO_WREGEX +using ::boost::wregex; +#endif + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) +// [7.8.6] basic_regex swap +using ::boost::swap; +#endif + +// [7.9] Class template sub_match +using ::boost::sub_match; + +using ::boost::csub_match; +#ifndef BOOST_NO_WREGEX +using ::boost::wcsub_match; +#endif +using ::boost::ssub_match; +#ifndef BOOST_NO_WREGEX +using ::boost::wssub_match; +#endif + +// [7.10] Class template match_results +using ::boost::match_results; +using ::boost::cmatch; +#ifndef BOOST_NO_WREGEX +using ::boost::wcmatch; +#endif +using ::boost::smatch; +#ifndef BOOST_NO_WREGEX +using ::boost::wsmatch; +#endif + +using ::boost::regex_match; + +// [7.11.3] Function template regex_search +using ::boost::regex_search; + +// [7.11.4] Function template regex_replace +using ::boost::regex_replace; + +// [7.12.1] Class template regex_iterator +using ::boost::regex_iterator; +using ::boost::cregex_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wcregex_iterator; +#endif +using ::boost::sregex_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wsregex_iterator; +#endif + +// [7.12.2] Class template regex_token_iterator +using ::boost::regex_token_iterator; +using ::boost::cregex_token_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wcregex_token_iterator; +#endif +using ::boost::sregex_token_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wsregex_token_iterator; +#endif + +} } // namespaces + +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/algorithm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/algorithm Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_algorithm_INCLUDED +# define BOOST_TR1_algorithm_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_algorithm_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(algorithm) +# endif +# ifdef BOOST_TR1_NO_algorithm_RECURSION +# undef BOOST_TR1_NO_algorithm_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/array --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/array Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#if !defined(BOOST_TR1_ARRAY_INCLUDED) +# define BOOST_TR1_ARRAY_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(array) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_ARRAY +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(array) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(array)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +#endif +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/array.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/array.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// 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) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_ARRAY_H_INCLUDED) +# define BOOST_TR1_ARRAY_H_INCLUDED +# include +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/random.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/random.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// 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) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_RANDOM_H_INCLUDED) +# define BOOST_TR1_RANDOM_H_INCLUDED +# include +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/regex.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/regex.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// 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) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_REGEX_H_INCLUDED) +# define BOOST_TR1_REGEX_H_INCLUDED +# include +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/tuple.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/tuple.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// 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) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_TUPLE_H_INCLUDED) +# define BOOST_TR1_TUPLE_H_INCLUDED +# include +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/type_tra.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/type_tra.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// 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) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_TYPE_TRAITS_H_INCLUDED) +# define BOOST_TR1_TYPE_TRAITS_H_INCLUDED +# include +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/unordere.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/unordere.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,15 @@ +// (C) Copyright John Maddock 2008. +// 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) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_UNORDERED_H_INCLUDED) +# define BOOST_TR1_UNORDERED_H_INCLUDED +# include +# include +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/bitset --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bitset Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_bitset_INCLUDED +# define BOOST_TR1_bitset_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_bitset_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(bitset) +# endif +# ifdef BOOST_TR1_NO_bitset_RECURSION +# undef BOOST_TR1_NO_bitset_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/cmath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/cmath Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,41 @@ +// (C) Copyright John Maddock 2008. +// 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) + + +#if !defined(BOOST_TR1_CMATH_INCLUDED) || defined(BOOST_TR1_NO_RECURSION) +#ifndef BOOST_TR1_CMATH_INCLUDED +# define BOOST_TR1_CMATH_INCLUDED +#endif +# ifdef BOOST_TR1_NO_CMATH_RECURSION2 +# define BOOST_TR1_NO_CMATH_RECURSION3 +# elif defined(BOOST_TR1_NO_CMATH_RECURSION) +# define BOOST_TR1_NO_CMATH_RECURSION2 +# elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_CMATH_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_CHEADER(cmath) +# endif +#ifdef BOOST_TR1_NO_CMATH_RECURSION3 +# undef BOOST_TR1_NO_CMATH_RECURSION3 +#elif defined(BOOST_TR1_NO_CMATH_RECURSION2) +# undef BOOST_TR1_NO_CMATH_RECURSION2 +#elif defined(BOOST_TR1_NO_CMATH_RECURSION) +# undef BOOST_TR1_NO_RECURSION +# undef BOOST_TR1_NO_CMATH_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_CMATH_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_CMATH_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/complex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/complex Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,31 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#ifndef BOOST_TR1_COMPLEX_INCLUDED +# define BOOST_TR1_COMPLEX_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_COMPLEX_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(complex) +# endif +# ifdef BOOST_TR1_NO_COMPLEX_RECURSION +# undef BOOST_TR1_NO_COMPLEX_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_COMPLEX_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_COMPLEX_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/deque --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/deque Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_deque_INCLUDED +# define BOOST_TR1_deque_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_deque_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(deque) +# endif +# ifdef BOOST_TR1_NO_deque_RECURSION +# undef BOOST_TR1_NO_deque_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/exception --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/exception Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,39 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +// Important: there are no include guards on this header for Borland C++ +// The Borland version of has some peculiar circular dependencies +// that requires multiple inclusion. Likewise for gcc (gcc-2.95.3 fix). +// +#ifdef BOOST_TR1_NO_exception_RECURSION2 +# define BOOST_TR1_NO_exception_RECURSION3 +#elif defined(BOOST_TR1_NO_exception_RECURSION) +# define BOOST_TR1_NO_exception_RECURSION2 +#elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_exception_RECURSION +#endif + +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(exception) +# endif + +#ifdef BOOST_TR1_NO_exception_RECURSION3 +# undef BOOST_TR1_NO_exception_RECURSION3 +#elif defined(BOOST_TR1_NO_exception_RECURSION2) +# undef BOOST_TR1_NO_exception_RECURSION2 +#elif defined(BOOST_TR1_NO_exception_RECURSION) +# undef BOOST_TR1_NO_exception_RECURSION +# undef BOOST_TR1_NO_RECURSION +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/fstream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/fstream Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_fstream_INCLUDED +# define BOOST_TR1_fstream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_fstream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(fstream) +# endif +# ifdef BOOST_TR1_NO_fstream_RECURSION +# undef BOOST_TR1_NO_fstream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/functional --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/functional Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,30 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#if !defined(BOOST_TR1_FUNCTIONAL_INCLUDED) +# define BOOST_TR1_FUNCTIONAL_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_FUNCTIONAL_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(functional) +# endif +# ifdef BOOST_TR1_NO_FUNCTIONAL_RECURSION +# undef BOOST_TR1_NO_FUNCTIONAL_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_FUNCTIONAL_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_FUNCTIONAL_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/iomanip --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/iomanip Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_iomanip_INCLUDED +# define BOOST_TR1_iomanip_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_iomanip_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(iomanip) +# endif +# ifdef BOOST_TR1_NO_iomanip_RECURSION +# undef BOOST_TR1_NO_iomanip_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/ios --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/ios Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_ios_INCLUDED +# define BOOST_TR1_ios_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_ios_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(ios) +# endif +# ifdef BOOST_TR1_NO_ios_RECURSION +# undef BOOST_TR1_NO_ios_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/iostream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/iostream Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_iostream_INCLUDED +# define BOOST_TR1_iostream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_iostream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(iostream) +# endif +# ifdef BOOST_TR1_NO_iostream_RECURSION +# undef BOOST_TR1_NO_iostream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/istream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/istream Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_istream_INCLUDED +# define BOOST_TR1_istream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_istream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(istream) +# endif +# ifdef BOOST_TR1_NO_istream_RECURSION +# undef BOOST_TR1_NO_istream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/iterator --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/iterator Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_iterator_INCLUDED +# define BOOST_TR1_iterator_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_iterator_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(iterator) +# endif +# ifdef BOOST_TR1_NO_iterator_RECURSION +# undef BOOST_TR1_NO_iterator_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/limits --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/limits Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_limits_INCLUDED +# define BOOST_TR1_limits_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_limits_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(limits) +# endif +# ifdef BOOST_TR1_NO_limits_RECURSION +# undef BOOST_TR1_NO_limits_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/list Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_list_INCLUDED +# define BOOST_TR1_list_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_list_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(list) +# endif +# ifdef BOOST_TR1_NO_list_RECURSION +# undef BOOST_TR1_NO_list_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/locale --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/locale Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_locale_INCLUDED +# define BOOST_TR1_locale_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_locale_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(locale) +# endif +# ifdef BOOST_TR1_NO_locale_RECURSION +# undef BOOST_TR1_NO_locale_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/map Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_map_INCLUDED +# define BOOST_TR1_map_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_map_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(map) +# endif +# ifdef BOOST_TR1_NO_map_RECURSION +# undef BOOST_TR1_NO_map_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/memory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/memory Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,31 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#ifndef BOOST_TR1_MEMORY_INCLUDED +# define BOOST_TR1_MEMORY_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_MEMORY_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(memory) +# endif +# ifdef BOOST_TR1_NO_MEMORY_RECURSION +# undef BOOST_TR1_NO_MEMORY_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_MEMORY_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_MEMORY_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/new --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/new Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,35 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifdef BOOST_TR1_NO_new_RECURSION2 +# define BOOST_TR1_NO_new_RECURSION3 +#elif defined(BOOST_TR1_NO_new_RECURSION) +# define BOOST_TR1_NO_new_RECURSION2 +#elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_new_RECURSION +#endif + +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(new) +# endif + +#ifdef BOOST_TR1_NO_new_RECURSION3 +# undef BOOST_TR1_NO_new_RECURSION3 +#elif defined(BOOST_TR1_NO_new_RECURSION2) +# undef BOOST_TR1_NO_new_RECURSION2 +#elif defined(BOOST_TR1_NO_new_RECURSION) +# undef BOOST_TR1_NO_new_RECURSION +# undef BOOST_TR1_NO_RECURSION +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/numeric --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/numeric Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_numeric_INCLUDED +# define BOOST_TR1_numeric_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_numeric_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(numeric) +# endif +# ifdef BOOST_TR1_NO_numeric_RECURSION +# undef BOOST_TR1_NO_numeric_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/ostream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/ostream Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_ostream_INCLUDED +# define BOOST_TR1_ostream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_ostream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(ostream) +# endif +# ifdef BOOST_TR1_NO_ostream_RECURSION +# undef BOOST_TR1_NO_ostream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/queue --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/queue Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_queue_INCLUDED +# define BOOST_TR1_queue_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_queue_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(queue) +# endif +# ifdef BOOST_TR1_NO_queue_RECURSION +# undef BOOST_TR1_NO_queue_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/random --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/random Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#ifndef BOOST_TR1_RANDOM_INCLUDED +# define BOOST_TR1_RANDOM_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(random) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_RANDOM +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(random) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(random)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/regex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/regex Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,22 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#ifndef BOOST_TR1_REGEX_INCLUDED +# define BOOST_TR1_REGEX_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# ifdef BOOST_HAS_TR1_REGEX +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(regex) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(regex)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/set --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/set Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_set_INCLUDED +# define BOOST_TR1_set_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_set_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(set) +# endif +# ifdef BOOST_TR1_NO_set_RECURSION +# undef BOOST_TR1_NO_set_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sstream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sstream Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_sstream_INCLUDED +# define BOOST_TR1_sstream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_sstream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(sstream) +# endif +# ifdef BOOST_TR1_NO_sstream_RECURSION +# undef BOOST_TR1_NO_sstream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/stack --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/stack Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_stack_INCLUDED +# define BOOST_TR1_stack_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_stack_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(stack) +# endif +# ifdef BOOST_TR1_NO_stack_RECURSION +# undef BOOST_TR1_NO_stack_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/stdexcept --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/stdexcept Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifdef BOOST_TR1_NO_stdexcept_RECURSION2 +# define BOOST_TR1_NO_stdexcept_RECURSION3 +#elif defined(BOOST_TR1_NO_stdexcept_RECURSION) +# define BOOST_TR1_NO_stdexcept_RECURSION2 +#elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_stdexcept_RECURSION +#endif + +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(stdexcept) +# endif + +#ifdef BOOST_TR1_NO_stdexcept_RECURSION3 +# undef BOOST_TR1_NO_stdexcept_RECURSION3 +#elif defined(BOOST_TR1_NO_stdexcept_RECURSION2) +# undef BOOST_TR1_NO_stdexcept_RECURSION2 +#elif defined(BOOST_TR1_NO_stdexcept_RECURSION) +# undef BOOST_TR1_NO_stdexcept_RECURSION +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/streambuf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/streambuf Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_streambuf_INCLUDED +# define BOOST_TR1_streambuf_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_streambuf_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(streambuf) +# endif +# ifdef BOOST_TR1_NO_streambuf_RECURSION +# undef BOOST_TR1_NO_streambuf_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/string --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/string Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_string_INCLUDED +# define BOOST_TR1_string_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_string_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(string) +# endif +# ifdef BOOST_TR1_NO_string_RECURSION +# undef BOOST_TR1_NO_string_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/strstream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/strstream Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_strstream_INCLUDED +# define BOOST_TR1_strstream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_strstream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(strstream) +# endif +# ifdef BOOST_TR1_NO_strstream_RECURSION +# undef BOOST_TR1_NO_strstream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/algorithm.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/algorithm.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../algorithm" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/array.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/array.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../array" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bcc32.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bcc32.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../bcc32" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bitset.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bitset.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../bitset" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/cmath.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/cmath.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,7 @@ +// (C) Copyright John Maddock 2008. +// 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) +#include "../cmath" + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/complex.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/complex.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../complex" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/deque.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/deque.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../deque" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/exception.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/exception.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../exception" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/fstream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/fstream.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../fstream" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/functional.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/functional.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../functional" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iomanip.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iomanip.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../iomanip" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ios.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ios.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../ios" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iostream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iostream.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../iostream" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/istream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/istream.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../istream" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iterator.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iterator.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../iterator" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/limits.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/limits.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../limits" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/list.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/list.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../list" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/locale.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/locale.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../locale" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/map.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/map.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../map" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/memory.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/memory.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../memory" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/new.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/new.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../new" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/numeric.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/numeric.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../numeric" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ostream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ostream.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../ostream" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/queue.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/queue.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../queue" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/random.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/random.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../random" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/regex.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/regex.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../regex" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/set.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/set.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../set" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sstream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sstream.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../sstream" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stack.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stack.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../stack" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stdexcept.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stdexcept.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../stdexcept" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/streambuf.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/streambuf.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../streambuf" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/string.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/string.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../string" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/strstream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/strstream.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../strstream" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sun.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sun.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../sun" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/tuple.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/tuple.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../tuple" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/type_traits.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/type_traits.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../type_traits" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/typeinfo.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/typeinfo.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../typeinfo" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_map.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_map.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,7 @@ +// (C) Copyright John Maddock 2008. +// 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) +#include "../unordered_map" + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_set.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_set.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,7 @@ +// (C) Copyright John Maddock 2008. +// 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) +#include "../unordered_set" + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/utility.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/utility.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../utility" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/valarray.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/valarray.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../valarray" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/vector.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/vector.SUNWCCh Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// 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) +#include "../vector" + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/tuple --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/tuple Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#ifndef BOOST_TR1_TUPLE_INCLUDED +# define BOOST_TR1_TUPLE_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(tuple) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_TUPLE +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(tuple) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(tuple)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/type_traits --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/type_traits Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,43 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#include + +#if (!defined(BOOST_TR1_TYPE_TRAITS_INCLUDED) || defined(BOOST_TR1_NO_RECURSION)) && defined(BOOST_HAS_CPP_0X) +#ifndef BOOST_TR1_TYPE_TRAITS_INCLUDED +# define BOOST_TR1_TYPE_TRAITS_INCLUDED +#endif +# ifdef BOOST_TR1_NO_TYPE_TRAITS_RECURSION2 +# define BOOST_TR1_NO_TYPE_TRAITS_RECURSION3 +# elif defined(BOOST_TR1_NO_TYPE_TRAITS_RECURSION) +# define BOOST_TR1_NO_TYPE_TRAITS_RECURSION2 +# elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_TYPE_TRAITS_RECURSION +# endif +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(type_traits) +# endif +#ifdef BOOST_TR1_NO_TYPE_TRAITS_RECURSION3 +# undef BOOST_TR1_NO_TYPE_TRAITS_RECURSION3 +#elif defined(BOOST_TR1_NO_TYPE_TRAITS_RECURSION2) +# undef BOOST_TR1_NO_TYPE_TRAITS_RECURSION2 +#elif defined(BOOST_TR1_NO_TYPE_TRAITS_RECURSION) +# undef BOOST_TR1_NO_RECURSION +# undef BOOST_TR1_NO_TYPE_TRAITS_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_TYPE_TRAITS_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_TYPE_TRAITS_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/typeinfo --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/typeinfo Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_typeinfo_INCLUDED +# define BOOST_TR1_typeinfo_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_typeinfo_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(typeinfo) +# endif +# ifdef BOOST_TR1_NO_typeinfo_RECURSION +# undef BOOST_TR1_NO_typeinfo_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_map Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2008. +// 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) + + +#ifndef BOOST_TR1_UNORDERED_MAP_INCLUDED +# define BOOST_TR1_UNORDERED_MAP_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(unordered_map) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_UNORDERED_MAP +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_map) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_map)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_set --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_set Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2008. +// 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) + + +#ifndef BOOST_TR1_UNORDERED_SET_INCLUDED +# define BOOST_TR1_UNORDERED_SET_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(unordered_map) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_UNORDERED_SET +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_set) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_set)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/utility --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/utility Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,41 @@ +// (C) Copyright John Maddock 2005. +// 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) + + +#if !defined(BOOST_TR1_UTILITY_INCLUDED) || defined(BOOST_TR1_NO_RECURSION) +#ifndef BOOST_TR1_UTILITY_INCLUDED +# define BOOST_TR1_UTILITY_INCLUDED +#endif +# ifdef BOOST_TR1_NO_UTILITY_RECURSION2 +# define BOOST_TR1_NO_UTILITY_RECURSION3 +# elif defined(BOOST_TR1_NO_UTILITY_RECURSION) +# define BOOST_TR1_NO_UTILITY_RECURSION2 +# elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_UTILITY_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(utility) +# endif +#ifdef BOOST_TR1_NO_UTILITY_RECURSION3 +# undef BOOST_TR1_NO_UTILITY_RECURSION3 +#elif defined(BOOST_TR1_NO_UTILITY_RECURSION2) +# undef BOOST_TR1_NO_UTILITY_RECURSION2 +#elif defined(BOOST_TR1_NO_UTILITY_RECURSION) +# undef BOOST_TR1_NO_RECURSION +# undef BOOST_TR1_NO_UTILITY_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_UTILITY_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_UTILITY_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/valarray --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/valarray Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_valarray_INCLUDED +# define BOOST_TR1_valarray_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_valarray_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(valarray) +# endif +# ifdef BOOST_TR1_NO_valarray_RECURSION +# undef BOOST_TR1_NO_valarray_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tr1/vector --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/vector Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// 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) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_vector_INCLUDED +# define BOOST_TR1_vector_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_vector_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(vector) +# endif +# ifdef BOOST_TR1_NO_vector_RECURSION +# undef BOOST_TR1_NO_vector_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/tuple.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tuple.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,82 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_TUPLE_HPP_INCLUDED +# define BOOST_TR1_TUPLE_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_TUPLE + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(tuple) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(tuple)) +# endif + +#else + +#if defined(BOOST_TR1_USE_OLD_TUPLE) + +#include +#include +#include + +namespace std{ namespace tr1{ + +using ::boost::tuple; + +// [6.1.3.2] Tuple creation functions +using ::boost::tuples::ignore; +using ::boost::make_tuple; +using ::boost::tie; + +// [6.1.3.3] Tuple helper classes +template +struct tuple_size + : public ::boost::integral_constant + < ::std::size_t, ::boost::tuples::length::value> +{}; + +template < int I, class T> +struct tuple_element +{ + typedef typename boost::tuples::element::type type; +}; + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) +// [6.1.3.4] Element access +using ::boost::get; +#endif + +} } // namespaces + +#else + +#include +#include + +namespace std{ namespace tr1{ + +using ::boost::fusion::tuple; + +// [6.1.3.2] Tuple creation functions +using ::boost::fusion::ignore; +using ::boost::fusion::make_tuple; +using ::boost::fusion::tie; +using ::boost::fusion::get; + +// [6.1.3.3] Tuple helper classes +using ::boost::fusion::tuple_size; +using ::boost::fusion::tuple_element; + +}} + +#endif + +#endif + +#endif + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/type_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/type_traits.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,86 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_TYPE_TRAITS_HPP_INCLUDED +# define BOOST_TR1_TYPE_TRAITS_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_TYPE_TRAITS + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(type_traits) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(type_traits)) +# endif + +#else +// Boost Type Traits: +#include + +namespace std { namespace tr1{ + + using ::boost::integral_constant; + using ::boost::true_type; + using ::boost::false_type; + using ::boost::is_void; + using ::boost::is_integral; + using ::boost::is_floating_point; + using ::boost::is_array; + using ::boost::is_pointer; + using ::boost::is_reference; + using ::boost::is_member_object_pointer; + using ::boost::is_member_function_pointer; + using ::boost::is_enum; + using ::boost::is_union; + using ::boost::is_class; + using ::boost::is_function; + using ::boost::is_arithmetic; + using ::boost::is_fundamental; + using ::boost::is_object; + using ::boost::is_scalar; + using ::boost::is_compound; + using ::boost::is_member_pointer; + using ::boost::is_const; + using ::boost::is_volatile; + using ::boost::is_pod; + using ::boost::is_empty; + using ::boost::is_polymorphic; + using ::boost::is_abstract; + using ::boost::has_trivial_constructor; + using ::boost::has_trivial_copy; + using ::boost::has_trivial_assign; + using ::boost::has_trivial_destructor; + using ::boost::has_nothrow_constructor; + using ::boost::has_nothrow_copy; + using ::boost::has_nothrow_assign; + using ::boost::has_virtual_destructor; + using ::boost::is_signed; + using ::boost::is_unsigned; + using ::boost::alignment_of; + using ::boost::rank; + using ::boost::extent; + using ::boost::is_same; + using ::boost::is_base_of; + using ::boost::is_convertible; + using ::boost::remove_const; + using ::boost::remove_volatile; + using ::boost::remove_cv; + using ::boost::add_const; + using ::boost::add_volatile; + using ::boost::add_cv; + using ::boost::remove_reference; + using ::boost::add_reference; + using ::boost::remove_extent; + using ::boost::remove_all_extents; + using ::boost::remove_pointer; + using ::boost::add_pointer; + using ::boost::aligned_storage; + +} } + +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/unordered_map.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/unordered_map.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,33 @@ +// (C) Copyright John Maddock 2008. +// 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) + +#ifndef BOOST_TR1_UNORDERED_MAP_HPP_INCLUDED +# define BOOST_TR1_UNORDERED_MAP_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_UNORDERED_MAP + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_map) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_map)) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + + using ::boost::unordered_map; + using ::boost::unordered_multimap; + using ::boost::swap; + +} } // namespaces + +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/unordered_set.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/unordered_set.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,33 @@ +// (C) Copyright John Maddock 2008. +// 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) + +#ifndef BOOST_TR1_UNORDERED_SET_HPP_INCLUDED +# define BOOST_TR1_UNORDERED_SET_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_UNORDERED_SET + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_set) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_set)) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + + using ::boost::unordered_set; + using ::boost::unordered_multiset; + using ::boost::swap; + +} } // namespaces + +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/boostlibrary/boost/tr1/utility.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/utility.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,123 @@ +// (C) Copyright John Maddock 2005. +// 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) + +#ifndef BOOST_TR1_UTILITY_HPP_INCLUDED +# define BOOST_TR1_UTILITY_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_UTILITY + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(utility) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(utility)) +# endif + +#else + +#if defined(BOOST_TR1_USE_OLD_TUPLE) + +#include +#include +#include +#include + + +namespace std{ namespace tr1{ + +template struct tuple_size; // forward declaration +template < int I, class T> struct tuple_element; // forward declaration + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +struct tuple_size< ::std::pair > + : public ::boost::integral_constant< ::std::size_t, 2> +{ +}; + +template +struct tuple_element<0, ::std::pair > +{ + typedef typename std::pair::first_type type; +}; + +template +struct tuple_element<1, std::pair > +{ + typedef typename std::pair::second_type type; +}; +#endif + +namespace tuple_detail{ + template + struct tuple_get_result + { + typedef typename boost::mpl::if_c::type t1; + typedef typename boost::add_reference::type type; + }; + template + struct const_tuple_get_result + { + typedef typename boost::mpl::if_c::type t1; +# if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x582)) + // I have absolutely no idea why add_const is not working here for Borland! + // It passes all other free-standing tests, some strange interaction going on + typedef typename boost::add_reference< const t1 >::type type; +# else + typedef typename boost::add_const::type t2; + typedef typename boost::add_reference::type type; +# endif + }; + +template +inline typename tuple_detail::tuple_get_result::type get(std::pair& p, const ::boost::true_type&) +{ + return p.first; +} + +template +inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p, const ::boost::true_type&) +{ + return p.first; +} + +template +inline typename tuple_detail::tuple_get_result::type get(std::pair& p, const ::boost::false_type&) +{ + return p.second; +} + +template +inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p, const ::boost::false_type&) +{ + return p.second; +} + +} + +template +inline typename tuple_detail::tuple_get_result::type get(std::pair& p) +{ + return tuple_detail::get(p, boost::integral_constant()); +} + +template +inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p) +{ + return tuple_detail::get(p, boost::integral_constant()); +} + +} } // namespaces + +#else + +#include + +#endif + +#endif + +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/group/testutf16str.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/group/testutf16str.mmp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +TARGET testutf16str.exe +TARGETTYPE exe +SOURCEPATH ../host +SOURCE utf16string.cpp testutf16str.cpp +USERINCLUDE ../inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +VENDORID 0x70000001 + +option GCC -O2 -Wno-uninitialized diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/host/testutf16str.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/host/testutf16str.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "UTF16String.h" +#include +#include +#include +using namespace std ; + +#ifdef __LINUX__ +#define stricmp strcasecmp +#endif + +void PrintHelp(){ + cout << "Syntax: TestUTF16Str <-[mbtou|utomb] > -i inputfilename -o outputfilename "< 3){ + if(memcmp(buffer,utf8FileHdr,sizeof(utf8FileHdr)) == 0){ + mbstr += 3; + length -= 3 ; + } + } + UTF16String theStr(mbstr , length); + if(length > 0 && theStr.IsEmpty()){ + cerr << "Convert Error[From UTF8 To UTF16]."<(utf16FileHdr),sizeof(utf16FileHdr)); + ofs.write(reinterpret_cast(theStr.c_str()),length); + cout << "Done."<(buffer); + length >>= 1; + if(*unistr == 0xFEFF){ + unistr ++ ; + length -- ; + } + UTF16String theStr(unistr , length); + string mbstr ; + if(!theStr.ToUTF8(mbstr)){ + cerr << "Convert Error[From UTF16 To UTF8]."<(utf8FileHdr),sizeof(utf8FileHdr)); + ofs.write(mbstr.c_str(),mbstr.length()); + cout << "Done."< +#elif defined(WIN32) +#ifdef _STLP_INTERNAL_WINDOWS_H +#define __INTERLOCKED_DECLARED +#endif +#include +#endif +UTF16String::UTF16String() :iData(0), iLength(0){ +} +UTF16String::UTF16String(const UTF16String& aRight){ + iLength = aRight.iLength ; + iData = new TUint16[iLength + 1]; + memcpy(iData,aRight.iData, iLength << 1); + iData[iLength] = 0; +} +UTF16String::UTF16String(const string& aUtf8Str){ + iData = 0 ; + iLength = 0 ; + Assign(aUtf8Str.c_str(),aUtf8Str.length()); +} +UTF16String::UTF16String(const TUint16* aUtf16Str,TInt aLength /* = -1*/){ + + if(aLength < 0){ + const TUint16* p = aUtf16Str ; + while(*p){ + p++ ; + aLength ++ ; + } + } + if(aLength > 0){ + iLength = aLength ; + aLength <<= 1 ; + iData = new TUint16[iLength + 1] ; + memcpy(iData,aUtf16Str,aLength); + iData[iLength] = 0; + }else{ + iData = 0 ; + iLength = 0 ; + } + +} +UTF16String::UTF16String(const char* aUtf8Str,TInt aLength /*= -1 */){ + iData = 0 ; + iLength = 0 ; + Assign(aUtf8Str,aLength); +} +UTF16String::~UTF16String(){ + if(iData) + delete []iData ; +} + +UTF16String& UTF16String::operator = (const UTF16String& aRight){ + if(&aRight != this){ + if(iData) + delete []iData ; + iLength = aRight.iLength ; + iData = new TUint16[iLength + 1]; + memcpy(iData,aRight.iData, iLength << 1); + iData[iLength] = 0; + } + return *this; +} +bool UTF16String::FromFile(const char* aFileName){ + if(!aFileName || !(*aFileName)) + return false ; + ifstream ifs(aFileName,ios_base::in + ios_base::binary); + if(!ifs.is_open()) + return false ; + + ifs.seekg(0,ios_base::end); + size_t length = ifs.tellg(); + if((length % 2) == 1 ){ + ifs.close() ; + return false ; + } + ifs.seekg(0,ios_base::beg); + TUint16 hdr ; + size_t readLen = length - sizeof(hdr) ; + length >>= 1 ; + TUint16 *newData = new TUint16[length + 1]; + ifs.read(reinterpret_cast(&hdr),sizeof(hdr)); + if(hdr == 0xFEFF){ + ifs.read(reinterpret_cast(newData),readLen); + length -- ; + } + else{ + *newData = hdr ; + ifs.read(reinterpret_cast(&newData[1]),readLen); + } + ifs.close(); + iLength = length ; + if(iData) + delete []iData ; + iData = newData ; + iData[iLength] = 0; + return true ; +} +/** +* aResult will not changed on error +*/ +bool UTF16String::ToUTF8(string& aResult) const { + if(IsEmpty()){ + aResult = ""; + return true; + } + size_t bufLen = (iLength + 1) << 2 ; + char* buffer = new char[bufLen] ; +#ifdef WIN32 + int r = WideCharToMultiByte(CP_UTF8,0,reinterpret_cast(iData),iLength,buffer,bufLen,NULL,NULL); + if(r < 0){ + delete []buffer ; + return false ; + } + buffer[r] = 0; + aResult.assign(buffer,r); +#else + iconv_t it = iconv_open("UTF-8","UTF-16"); + if((iconv_t)(-1) == it){ + return false; + } + char* bufferEnd = buffer ; + char* in_ptr = reinterpret_cast(iData); + size_t in_len = iLength << 1 ; + iconv(it,&in_ptr,&in_len ,&bufferEnd,&bufLen); + iconv_close(it); + *bufferEnd = 0 ; + size_t length = bufferEnd - buffer ; + aResult.assign(buffer,length); +#endif + delete []buffer ; + return true ; +} +bool UTF16String::Assign(const char* aUtf8Str,TInt aLength /* = -1*/) { + if(0 == aUtf8Str) return false ; + if(aLength < 0) aLength = strlen(aUtf8Str); + +#ifdef WIN32 + size_t newLength = aLength + 1; + TUint16* newData = new TUint16[newLength]; + int r = MultiByteToWideChar(CP_UTF8,0,aUtf8Str,aLength,reinterpret_cast(newData),newLength); + if(r < 0){ + delete []newData ; + return false ; + } + iLength = r ; +#else + char* forFree = 0 ; + if(aUtf8Str[aLength - 1] != 0){ + forFree = new char[aLength + 1]; + memcpy(forFree,aUtf8Str,aLength ); + forFree[aLength] = 0; + aUtf8Str = forFree ; + } + iconv_t it = iconv_open("UTF-16","UTF-8"); + if((iconv_t)(-1) == it){ + + return false; + } + size_t newLength = aLength + 2; + TUint16* newData = new TUint16[newLength]; + newLength <<= 1; + char* out_ptr = reinterpret_cast(newData); + size_t in_len = aLength ; + char* in_ptr = const_cast(aUtf8Str); + iconv(it,&in_ptr,&in_len ,&out_ptr ,&newLength); + newLength = out_ptr - reinterpret_cast(newData); + iconv_close(it); + if(newLength % 2 == 1){ //should not be possible + delete []newData; + return false ; + } + iLength = (newLength >> 1) ; + if(forFree) + delete []forFree; +#endif + newData[iLength] = 0 ; + if(iData){ + delete []iData ; + } + iData = newData ; + if(*iData == 0xFEFF) + iLength -- ; + + return true ; +} +static const TUint16 NullUInt16Str[1] = {0}; +const TUint16* UTF16String::c_str() const { + if(0 == iData) + return NullUInt16Str; + else if(0xFEFF != *iData) + return iData ; + else + return iData + 1; +} +/// +/// aUtf16Str must end with '\0' +/// +int UTF16String::Compare(const TUint16* aUtf16Str) const { + if(!aUtf16Str || !(*aUtf16Str)) + return (iLength > 0) ? 1 : 0; + size_t i ; + for(i = 0 ; aUtf16Str[i] != 0 ; i++) { + if( iData[i] > aUtf16Str[i]) + return 1; + else if(iData[i] < aUtf16Str[i]) + return -1 ; + } + return (i < iLength) ? 1 : 0 ; +} +/// +/// aUtf16Str must end with '\0' +/// +int UTF16String::CompareNoCase(const TUint16* aUtf16Str) const { + if(!aUtf16Str || !(*aUtf16Str)) + return (iLength > 0) ? 1 : 0; + size_t i ; + TUint16 a, b; + for(i = 0 ; aUtf16Str[i] != 0 ; i++) { + a = iData[i]; + b = aUtf16Str[i] ; + if( a >= 'A' && a <= 'Z') a |= 0x20 ; + if( b >= 'A' && b <= 'Z') b |= 0x20 ; + + if( a > b ) + return 1; + else if( a < b ) + return -1 ; + } + return (i < iLength) ? 1 : 0 ; +} +TUint16* UTF16String::Alloc(size_t aNewLen) { + TUint16* newData = new TUint16[aNewLen + 1] ; + if(!newData) return 0; + if(iData) delete []iData ; + + iLength = aNewLen ; + iData = newData ; + *iData = 0 ; + iData[aNewLen] = 0; + return iData; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/imglib/inc/utf16string.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/inc/utf16string.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* @internalComponent * @released +* +*/ + +#ifndef __UTF16_STRING_H__ +#define __UTF16_STRING_H__ +#include +#include +#include +using namespace std ; + +class UTF16String { +public : + + UTF16String(); + UTF16String(const UTF16String& aRight); + UTF16String(const string& aUtf8Str); + UTF16String(const TUint16* aUtf16Str,TInt aLength = -1); + UTF16String(const char* aUtf8Str,TInt aLength = -1); + ~UTF16String(); + + bool FromFile(const char* aFileName); + bool ToUTF8(string& aResult) const ; + bool Assign(const char* aUtf8Str,TInt aLength = -1); + inline TUint length() const { return iLength ;} + inline TUint bytes() const { return (iLength << 1) ;} + const TUint16* c_str() const ; + inline bool IsEmpty() const { return (0 == iLength) ;} + UTF16String& operator = (const UTF16String& aRight); + int Compare(const TUint16* aUtf16Str) const ; + int CompareNoCase(const TUint16* aUtf16Str) const ; + TUint16* Alloc(size_t aNewLen); + +protected: + TUint16* iData ; + TUint iLength ; +}; +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/maksym/fixupsym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/fixupsym Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S fixupsym.pl $@ + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/maksym/hpsym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/hpsym Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S hpsym.pl $@ + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/maksym/maksym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/maksym Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S maksym.pl $@ + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/maksym/maksymrofs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/maksymrofs Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S maksymrofs.pl $@ + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/inc/cache/cache.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cache.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,74 @@ +/** + * @file cache.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_ + + +#define BOOST_FILESYSTEM_NO_DEPRECATED + + +/** + * @class Cache + * @brief Cache + */ +class Cache +{ +public: + /** + * @fn static Cache* Cache::GetInstance(void) + * @brief Retrieve singleton instance of class Cache. + * @return The singleton instance. + */ + static Cache* GetInstance(void) throw (CacheException); + + /** + * @fn void Cache::Initialize(path* CacheRoot) + * @brief Load Cache meta data file and initialize inner structures. + * @exception CacheException I/O operation failures or resource allocation failures. + */ + void Initialize(void) throw (CacheException); + + /** + * @fn CacheEntry Cache::GetEntryList(const char* OriginalFilename) + * @param OriginalFilename The filename of original executable which is being cached. + * @return A list of cached items for the original executables or NULL if there's no entries match the original filename. + */ + CacheEntry* GetEntryList(const char* OriginalFilaname); + + /** + * @fn void Cache::SetEntry(const char* OriginalFilename, CacheEntry* EntryRef) + * @brief Add a new cache entry into cache or update an existing cache entry. + * @param OriginalFilename The filename of the original executable file. + * @param EntryRef The address pointing to an instance of class CacheEntry, must be valid, verified by the caller. + */ + void AddEntry(const char* OriginalFilename, CacheEntry* EntryRef); + + /** + * @fn void Cache::CloseCache(void) + * @brief Update cache with all cache entries. + * @exception CacheException Catch errors occurring when the Cache gets updated. + */ + void CloseCache(void) throw (CacheException); +protected: + bool ValidateEntry(std::string& EntryRawText); + + static Cache* Only; + + std::string metafile; + + boost::mutex cachemutex; + + std::map entrymap; +private: + Cache(void); + + Cache(const Cache&); + + Cache& operator = (const Cache&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_ */ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/inc/cache/cacheablelist.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cacheablelist.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,56 @@ +/** + * @file cacheablelist.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEABLELIST_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEABLELIST_H_ + + +/** + * @class CacheableList + * @brief CacheableList is used to hold buffers for executable files to be written into the cache. + */ +class CacheableList +{ +public: + /** + * @fn CacheableList* CacheableList::GetInstance(void) + * @return The singleton instance of class CacheableList. + * @exception CacheException Not enough system resource to create an instance at the first this method gets called. + */ + static CacheableList* GetInstance(void) throw (CacheException); + + /** + * @fn void CacheableList::AddCacheable(CacheEntry* EntryRef) + * @brief Add a file which needs to be cached into the list, cache generator will process this list. + * @param EntryRef The instance of CacheEntry, it represents the file which is going to be cached. + */ + void AddCacheable(CacheEntry* EntryRef); + + /** + * @fn CacheEntry* CacheableList::GetCacheable(void) + * @brief Retrieve a file from this list and write it into cache, the write operation is performed by cache generator. + * @return The instance of CacheEntry, used by cache generator. + */ + CacheEntry* GetCacheable(void); + + virtual ~CacheableList(void); +protected: + static CacheableList* Only; + + std::queue filelist; + + boost::condition_variable queuecond; + + boost::mutex queuemutex; +private: + CacheableList(void); + + CacheableList(const CacheableList&); + + CacheableList& operator = (const CacheableList&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEABLELIST_H_ */ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/inc/cache/cacheentry.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cacheentry.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,96 @@ +/** + * @file cacheentry.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEENTRY_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEENTRY_H_ + + +/** + * @class CacheEntry + * @brief CacheEntry holds both original executable data and cached executable data. + */ +class CacheEntry +{ +public: + CacheEntry(void); + + /** + * @fn void CacheEntry::SetOriginalFilename(const char* OriginalFilename) + * @brief Assign the original filename of the executable to be cached. + * @param OriginalFilename The original filename. + */ + void SetOriginalFilename(const char* OriginalFilename); + + /** + * @fn const char* CacheEntry::GetOriginalFilename(void) + * @return The original filename. + */ + const char* GetOriginalFilename(void) const; + + void SetCachedFilename(const char* CachedFilename); + + const char* GetCachedFilename(void) const; + + void SetOriginalFileCreateTime(time_t* CreateRawTime); + + void SetOriginalFileCreateTime(const char* CreateRawTime); + + const char* GetOriginalFileCreateTime(void) const; + + void SetOriginalFileCompression(const char* CompressionMethodID); + + void SetOriginalFileCompression(unsigned int CompressionMethodID); + + const char* GetOriginalFileCompressionID(void) const; + + void SetCachedFileCompression(const char* CompressionMethodID); + + void SetCachedFileCompression(unsigned int CompressionMethodID); + + const char* GetCachedFileCompressionID(void) const; + + void SetCachedFileBuffer(char* FileBuffer, int FileBufferLen); + + const char* GetCachedFileBuffer(void) const; + + int GetCachedFileBufferLen(void) const; + + void AppendEntry(CacheEntry* EntryRef); + + CacheEntry* GetNextEntry(void) const; + + void SetNextEntry(CacheEntry* EntryRef); + + bool Equals(CacheEntry* EntryRef); + + virtual ~CacheEntry(void); +protected: + std::string originalfile; + + std::string cachedfile; + + std::string originalfilecreatetime; + + std::string originalfilecompression; + + std::string cachedfilecompression; + + std::string compressionenabled; + + std::string compressionindicator; + + CacheEntry* next; + + char* cachedfilebuffer; + + int cachedfilebuffersize; +private: + CacheEntry(const CacheEntry&); + + CacheEntry& operator = (const CacheEntry&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEENTRY_H_ */ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/inc/cache/cacheexception.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cacheexception.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,55 @@ +/** + * @file cacheexception.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEEXCEPTION_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEEXCEPTION_H_ + + +/** + * @class CacheException + * @brief Encapsulates all possible failures happening inside cache. + */ +class CacheException +{ +public: + /** + * @fn CacheException::CacheException(int ErrorCode) + * @brief Constructor + * @param ErrorCode The error code, must be one of the static constants. + */ + CacheException(int ErrorCode); + + /** + * @fn int CacheException::GetErrorCode(void) + * @brief Retrieve integer error number. + * @reurn The error code. + */ + int GetErrorCode(void); + + /** + * @fn const char* CacheException::GetErrorMessage(void) + * @brief Retrieve text error message. + * @return The error message. + */ + const char* GetErrorMessage(void); + + virtual ~CacheException(void); + + static int EPOCROOT_NOT_FOUND ; + static int RESOURCE_ALLOCATION_FAILURE; + static int CACHE_NOT_FOUND ; + static int CACHE_INVALID ; + static int CACHE_IS_EMPTY ; + static int HARDDRIVE_FAILURE ; +protected: + int errcode; +private: + CacheException(void); + + CacheException& operator = (const CacheException&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEEXCEPTION_H_ */ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/inc/cache/cachegenerator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cachegenerator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,41 @@ +/** + * @file cachegenerator.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEGENERATOR_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEGENERATOR_H_ + + +/** + * @class CacheGenerator + * @brief Cache Generator will be running in a separated thread, its job is to pick up an invalidated entry from the CacheableList and then write the content into the cache. + */ +class CacheGenerator : public boost::thread +{ +public: + /** + * @fn static CacheGenerator* CacheGenerator::GetInstance(void) + * @brief Get singleton instance. + * @return The singleton instance. + * @exception CacheException Catch resource allocation failures. + */ + static CacheGenerator* GetInstance(void) throw (CacheException); + + /** + * @fn void CacheGenerator::ProcessFiles(void) + * @brief Pick up an invalidated entry from the cacheable list and write the content into the cache (i.e. under cache root directory). + */ + static void ProcessFiles(void) throw (CacheException); +protected: + static CacheGenerator* Only; +private: + CacheGenerator(void); + + CacheGenerator(const CacheGenerator&); + + CacheGenerator& operator = (const CacheGenerator&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEGENERATOR_H_ */ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/inc/cache/cachemanager.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cachemanager.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,99 @@ +/** + * @file cachemanager.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_ + + +#define BOOST_FILESYSTEM_NO_DEPRECATED + + +/** + * @class CacheManager + * @brief Managing cache content and the processing of generating/updating cache. + * @note CacheManager will accept forward slashes as file separators and all input filenames will be normalized. + */ +class CacheManager +{ +public: + /** + * @fn static CacheManager* CacheManager::GetInstance(void) + * @brief This method is thread-safe as it's using double-check pattern for singleton creation. + * @exception CacheException Catch initialization failures. + * @return Retrieve the singleton instance of class CacheManager. + */ + static CacheManager* GetInstance(void) throw (CacheException); + + /** + * @fn E32ImageFile* CacheManager::GetE32ImageFile(char* Filename, int CurrentCompressionID) + * @brief Retrieve an instance of class E32ImageFile. + * @param OriginalFilename The filename of the original file. + * @param CurrentCompressionID The ID of compression method used over current image build. + * @return Instance of class E32ImageFile or NULL if the original file has not been cached yet. + */ + E32ImageFile* GetE32ImageFile(char* OriginalFilename, int CurrentCompressionID); + + /** + * @fn CacheEntry* CacheManager::GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID, int FileFlags) + * @param OriginalFilename The filename of the original executable file. + * @param CurrentCompressionID + * @return A valid cached entry or NULL if the original file has not been cached yet. + */ + CacheEntry* GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID); + + /** + * @fn void CacheManager::Invalidate(const char* Filename) + * @brief Add an invalidated cache entry into the cacheable list. + * @param Filename The filename of the original file. + * @param EntryRef The reference of newly created CacheEntry instance. + * @exception CacheException Catch resource allocation failures. + */ + void Invalidate(char* Filename, CacheEntry* EntryRef) throw (CacheException); + + /** + * @fn void CacheManager::CleanCache(void) + * @brief Remove all cache content from hard drive. + * @exception CacheException Catch I/O failures on deletion. + */ + void CleanCache(void) throw (CacheException); + + /** + * @fn const char* CacheManager::GetCacheRoot(void) + * @brief Retrieve the root directory of cache. + * @return The absolute path of root directory. + */ + const char* GetCacheRoot(void); + + /** + * @fn CacheManager::~CacheManager(void) + * @brief Clean up allocated resources and writes Cache class back in the cache. + * @note It's important to delete CacheManager instance if you created it with new operation. + */ + virtual ~CacheManager(void); + + /** + * @fn void CacheManager::NormalizeFilename(char* Filename) + * @brief Convert back slashes into forward slashes and remove redundant slashes. + * @param Filename The filename which will be normalized when this function gets returned. + */ + void NormalizeFilename(char* Filename); +protected: + void InitializeCache(void) throw (CacheException); + + char* cacheroot; + + static boost::mutex creationlock; + + static CacheManager* Only; +private: + CacheManager(void); + + CacheManager(const CacheManager&); + + CacheManager& operator = (const CacheManager&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_ */ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/inc/cache/cachevalidator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cachevalidator.hpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,44 @@ +/** + * @file cachevalidator.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEVALIDATOR_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEVALIDATOR_H_ + + +/** + * @class CacheValidator + * @brief Validate an existing cache entry. + */ +class CacheValidator +{ +public: + /** + * @fn CacheValidator* CacheValidator::GetInstance(void) + * @brief Get singleton instance of class CacheValidator. + * @return The singleton instance. + * @exception CacheException Catch allocation failures. + */ + static CacheValidator* GetInstance(void) throw (CacheException); + + /** + * @fn CacheEntry* CacheValidator::Validate(const char* OriginalFilename, int CurrentCompressionID) + * @brief Validate cached executable with original version. + * @param OriginalFilename The filename of original executable. + * @param CurrentCompressionID The ID of compression method used over current image build. + * @return The entry for cached file or zero if the given executable file is invalidated. + */ + CacheEntry* Validate(const char* OriginalFilename, int CurrentCompressionID); +protected: + static CacheValidator* Only; +private: + CacheValidator(void); + + CacheValidator(const CacheValidator&); + + CacheValidator& operator = (const CacheValidator&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEVALIDATOR_H_ */ diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/src/cache/cache.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cache.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,242 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "e32image.h" + +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cacheablelist.hpp" +#include "cache/cache.hpp" +#include "cache/cachegenerator.hpp" +#include "cache/cachevalidator.hpp" +#include "cache/cachemanager.hpp" +#include +#ifdef __LINUX__ +#define _alloca alloca +#endif + +Cache* Cache::Only = (Cache*)0; + + +Cache* Cache::GetInstance(void) throw (CacheException) +{ + if(! Cache::Only) + { + Cache::Only = new (std::nothrow) Cache(); + if(! Cache::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return Cache::Only; +} + + +void Cache::Initialize(void) throw (CacheException) +{ + //create and open cache meta data file. + + + metafile = CacheManager::GetInstance()->GetCacheRoot(); + metafile += "/.rofsmeta"; + boost::filesystem::path metafilepath(metafile.c_str()); + if(!exists(metafilepath)) + { + //create cache root directory if it's not present. + boost::filesystem::path createcacheroot(CacheManager::GetInstance()->GetCacheRoot()); + create_directory(createcacheroot); + + //create cache index file. + ofstream openmetafile(metafilepath.file_string().c_str(), ios_base::app | ios_base::out); + if(! openmetafile.is_open()) + throw CacheException(CacheException::CACHE_INVALID); + openmetafile.close(); + } + printf("Loading cache meta file : %s\r\n", metafilepath.file_string().c_str()); + ifstream metafileref(metafilepath.file_string().c_str(), ios_base::in); + if(! metafileref.is_open()) + throw CacheException(CacheException::HARDDRIVE_FAILURE); + + //read ROFS meta file and construct entry map. + string inboundbuffer; + while(getline(metafileref, inboundbuffer)) + { + //validate cache index record. + if(! ValidateEntry(inboundbuffer)) + throw CacheException(CacheException::CACHE_INVALID); + + //instantiate a new instance of class CacheEntry. + CacheEntry* entryref = new (nothrow) CacheEntry(); + if(!entryref) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //set entry's attributes. + + char* attrwalker = (char*)_alloca(inboundbuffer.length() + 1); + memcpy(attrwalker,inboundbuffer.c_str(),inboundbuffer.length() + 1); + + char* start = attrwalker ; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetOriginalFilename(attrwalker); + attrwalker = start; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetOriginalFileCreateTime(attrwalker); + attrwalker = start; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetOriginalFileCompression(attrwalker); + attrwalker = start; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetCachedFilename(attrwalker); + attrwalker = start; + entryref->SetCachedFileCompression(attrwalker); + + //add newly created entry into entry-map. + string newentrystring(entryref->GetOriginalFilename()); + CacheEntry* existentryref = entrymap[newentrystring]; + if(existentryref) { + while(existentryref->GetNextEntry()) + existentryref = existentryref->GetNextEntry(); + existentryref->AppendEntry(entryref); + } + else { + entrymap[newentrystring] = entryref; + } + + //reinitialize inbound buffer. + inboundbuffer.clear(); + } + + return; +} + + +CacheEntry* Cache::GetEntryList(const char* OriginalFilename) +{ + //retrieval could be performed concurrently. + boost::lock_guard lock(cachemutex); + string originalfile(OriginalFilename); + CacheEntry* resultentries = entrymap[originalfile]; + + return resultentries; +} + + +void Cache::AddEntry(const char* OriginalFilename, CacheEntry* EntryRef) +{ + string originalfile(OriginalFilename); + + //addtions could be performed concurrently. + boost::lock_guard lock(cachemutex); + + entrymap[originalfile] = EntryRef; + + return; +} + + +void Cache::CloseCache(void) throw (CacheException) +{ + //open up the cache meta file. + boost::filesystem::path metafilepath(metafile); + ofstream metafileref; + if(! exists(metafilepath)) + metafileref.open(metafilepath.file_string().c_str(), ios_base::out | ios_base::app); + else + metafileref.open(metafilepath.file_string().c_str(), ios_base::out | ios_base::trunc); + if(! metafileref.is_open()) + throw CacheException(CacheException::HARDDRIVE_FAILURE); + + //save cache meta onto hard drive along with changed cache files. + char* delimiter = ";"; + map::iterator mapitem; + for(mapitem=entrymap.begin(); mapitem != entrymap.end(); mapitem++) + { + CacheEntry* concreteentryref = (*mapitem).second; + while(concreteentryref) + { + metafileref.write(concreteentryref->GetOriginalFilename(), strlen(concreteentryref->GetOriginalFilename())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetOriginalFileCreateTime(), strlen(concreteentryref->GetOriginalFileCreateTime())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetOriginalFileCompressionID(), strlen(concreteentryref->GetOriginalFileCompressionID())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetCachedFilename(), strlen(concreteentryref->GetCachedFilename())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetCachedFileCompressionID(), strlen(concreteentryref->GetCachedFileCompressionID())); + metafileref.write("\n", strlen("\n")); + +// CacheEntry* tobedeletedentryref = concreteentryref; + concreteentryref = concreteentryref->GetNextEntry(); +// delete tobedeletedentryref; + } + } + + //close cache meta file. + metafileref.close(); + + return; +} + + +bool Cache::ValidateEntry(string& EntryRawText) +{ + //an entry is formed as original_filename;original_file_create_time;original_file_compression_id;cached_filename;cached_file_compression_id(end of line - '\n') + + //format validation. + int semicolon = 0; + size_t semicolonposition = 0; + while(1) { + semicolonposition = EntryRawText.find(';', semicolonposition); + if(semicolonposition != string::npos) { + semicolonposition++; + semicolon++; + } + else + break; + } + if(semicolon != 4) + return false; + + return true; +} + + +Cache::Cache(void) +{ + return; +} + diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/src/cache/cacheablelist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cacheablelist.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include + +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cacheablelist.hpp" + + +CacheableList* CacheableList::Only = (CacheableList*)0; + + +CacheableList* CacheableList::GetInstance(void) throw (CacheException) +{ + if(! CacheableList::Only) + { + CacheableList::Only = new (std::nothrow) CacheableList(); + if(! CacheableList::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return CacheableList::Only; +} + + +void CacheableList::AddCacheable(CacheEntry* EntryRef) +{ + if(1) + { + boost::mutex::scoped_lock lock(this->queuemutex); + this->filelist.push(EntryRef); + } + + this->queuecond.notify_all(); + + return; +} + + +CacheEntry* CacheableList::GetCacheable(void) +{ + boost::mutex::scoped_lock lock(this->queuemutex); + while(this->filelist.empty()) + this->queuecond.wait(lock); + + CacheEntry* resref = this->filelist.front(); + this->filelist.pop(); + + return resref; +} + + +CacheableList::~CacheableList(void) +{ + return; +} + + +CacheableList::CacheableList(void) +{ + return; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/src/cache/cacheentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cacheentry.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" + + +CacheEntry::CacheEntry(void) +{ + this->next = (CacheEntry*)0; + this->cachedfilebuffer = (char*)0 ; + this->cachedfilebuffersize = 0 ; + + return; +} + + +void CacheEntry::SetOriginalFilename(const char* OriginalFilename) +{ + this->originalfile.clear(); + this->originalfile.assign(OriginalFilename); + + return; +} + + +const char* CacheEntry::GetOriginalFilename(void) const +{ + return this->originalfile.c_str(); +} + + +void CacheEntry::SetCachedFilename(const char* CachedFilename) +{ + this->cachedfile.clear(); + this->cachedfile.assign(CachedFilename); + + return; +} + + +const char* CacheEntry::GetCachedFilename(void) const +{ + return this->cachedfile.c_str(); +} + + +void CacheEntry::SetOriginalFileCreateTime(time_t* CreateRawTime) +{ + this->originalfilecreatetime.clear(); + this->originalfilecreatetime.assign(ctime(CreateRawTime)); + + size_t newlinepos = this->originalfilecreatetime.find("\n"); + while(newlinepos != std::string::npos) + { + this->originalfilecreatetime.erase(newlinepos, 1); + newlinepos = this->originalfilecreatetime.find(("\n")); + } + + return; +} + + +void CacheEntry::SetOriginalFileCreateTime(const char* CreateRawTime) +{ + this->originalfilecreatetime.clear(); + this->originalfilecreatetime.assign(CreateRawTime); + + return; +} + + +const char* CacheEntry::GetOriginalFileCreateTime(void) const +{ + return this->originalfilecreatetime.c_str(); +} + + +void CacheEntry::SetOriginalFileCompression(const char* CompressionMethodID) +{ + this->originalfilecompression.clear(); + this->originalfilecompression.assign(CompressionMethodID); + + return; +} + + +void CacheEntry::SetOriginalFileCompression(unsigned int CompressionMethodID) +{ + char methodid[30]; + memset(methodid, 0, sizeof(methodid)); + sprintf(methodid, "%d", CompressionMethodID); + + this->originalfilecompression.clear(); + this->originalfilecompression.assign(methodid); + + return; +} + + +const char* CacheEntry::GetOriginalFileCompressionID(void) const +{ + return this->originalfilecompression.c_str(); +} + + +void CacheEntry::SetCachedFileCompression(const char* CompressionMethodID) +{ + this->cachedfilecompression.clear(); + this->cachedfilecompression.assign(CompressionMethodID); + + return; +} + + +void CacheEntry::SetCachedFileCompression(unsigned int CompressionMethodID) +{ + char methodid[128]; + memset(methodid, 0, sizeof(methodid)); + sprintf(methodid, "%d", CompressionMethodID); + + this->cachedfilecompression.clear(); + this->cachedfilecompression.assign(methodid); + + return; +} + + +const char* CacheEntry::GetCachedFileCompressionID(void) const +{ + return this->cachedfilecompression.c_str(); +} + + +void CacheEntry::SetCachedFileBuffer(char* FileBuffer, int FileBufferLen) +{ + this->cachedfilebuffer = (char*)malloc(sizeof(char)*FileBufferLen); + memcpy(this->cachedfilebuffer, FileBuffer, FileBufferLen); + this->cachedfilebuffersize = FileBufferLen; + + return; +} + + +const char* CacheEntry::GetCachedFileBuffer(void) const +{ + return this->cachedfilebuffer; +} + + +int CacheEntry::GetCachedFileBufferLen(void) const +{ + return this->cachedfilebuffersize; +} + + +void CacheEntry::AppendEntry(CacheEntry* EntryRef) +{ + //the parameter EntryRef must be valid, should be verified by the caller. + this->next = EntryRef; + + return; +} + + +CacheEntry* CacheEntry::GetNextEntry(void) const +{ + return this->next; +} + + +void CacheEntry::SetNextEntry(CacheEntry* EntryRef) +{ + this->next = EntryRef; + + return; +} + + +bool CacheEntry::Equals(CacheEntry* EntryRef) +{ + if( (this->originalfile.compare(EntryRef->GetOriginalFilename())==0) && + (this->originalfilecreatetime.compare(EntryRef->GetOriginalFileCreateTime())==0) && + (this->originalfilecompression.compare(EntryRef->GetOriginalFileCompressionID())==0) && + (this->cachedfile.compare(EntryRef->GetCachedFilename())==0) && + (this->cachedfilecompression.compare(EntryRef->GetCachedFileCompressionID())==0) + ) + return true; + + return false; +} + + +CacheEntry::~CacheEntry(void) +{ + if(this->cachedfilebuffer) + { + free(this->cachedfilebuffer); + this->cachedfilebuffer = NULL; + } + + return; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/src/cache/cacheexception.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cacheexception.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "cache/cacheexception.hpp" + + +int CacheException::EPOCROOT_NOT_FOUND = 1; +int CacheException::RESOURCE_ALLOCATION_FAILURE = 2; +int CacheException::CACHE_NOT_FOUND = 3; +int CacheException::CACHE_INVALID = 4; +int CacheException::CACHE_IS_EMPTY = 5; +int CacheException::HARDDRIVE_FAILURE = 6; + + +CacheException::CacheException(int ErrorCode) +{ + this->errcode = ErrorCode; + + return; +} + + +int CacheException::GetErrorCode(void) +{ + return this->errcode; +} + + +const char* CacheException::GetErrorMessage(void) +{ + if(this->errcode == CacheException::EPOCROOT_NOT_FOUND) + return "EPOCROOT environment variable is not set."; + else if(this->errcode == CacheException::RESOURCE_ALLOCATION_FAILURE) + return "Not enough system resources to initialize cache module."; + else if(this->errcode == CacheException::CACHE_NOT_FOUND) + return "Cache is not present in the current system."; + else if(this->errcode == CacheException::CACHE_INVALID) + return "Cache is invalid."; + else if(this->errcode == CacheException::CACHE_IS_EMPTY) + return "Cache is empty."; + else if(this->errcode == CacheException::HARDDRIVE_FAILURE) + return "A hard drive failure occurred in Cache operations."; + + return "Undefined error type."; +} + + +CacheException::~CacheException(void) +{ + return; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/src/cache/cachegenerator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cachegenerator.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cacheablelist.hpp" +#include "cache/cachegenerator.hpp" + +using namespace std ; +CacheGenerator* CacheGenerator::Only = (CacheGenerator*)0; + + +CacheGenerator* CacheGenerator::GetInstance(void) throw (CacheException) +{ + if(! CacheGenerator::Only) + { + CacheGenerator::Only = new (nothrow) CacheGenerator(); + if(! CacheGenerator::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return CacheGenerator::Only; +} + + +void CacheGenerator::ProcessFiles(void) throw (CacheException) +{ + while(1) + { + //pick one entry from the CacheableList. + CacheEntry* entryref = CacheableList::GetInstance()->GetCacheable(); + if(! entryref->GetCachedFileBuffer()) + break; + + //write cacheable content into the cache. + boost::filesystem::path filepath(entryref->GetCachedFilename()); + string filename = filepath.file_string(); + ofstream fileref(filename.c_str(), ios_base::binary | ios_base::out | ios_base::trunc); + if(! fileref.is_open()) + { + printf("Cannot write/update cached %s\r\n", filepath.file_string().c_str()); + continue; + } + + fileref.write(entryref->GetCachedFileBuffer(), entryref->GetCachedFileBufferLen()); + fileref.close(); + } + + return; +} + + +CacheGenerator::CacheGenerator(void) : boost::thread(ProcessFiles) +{ + return; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/src/cache/cachemanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cachemanager.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,231 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include + +#include "e32image.h" + +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cache.hpp" +#include "cache/cachegenerator.hpp" +#include "cache/cachevalidator.hpp" +#include "cache/cacheablelist.hpp" +#include "cache/cachemanager.hpp" + +using namespace std; + + +CacheManager* CacheManager::Only = (CacheManager*)0; +boost::mutex CacheManager::creationlock; + + +CacheManager* CacheManager::GetInstance(void) throw (CacheException) +{ + if(! CacheManager::Only) + { + boost::mutex::scoped_lock lock(CacheManager::creationlock); + if(! CacheManager::Only) + { + CacheManager::Only = new (nothrow) CacheManager(); + if(!CacheManager::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + CacheManager::Only->InitializeCache(); + } + } + + return CacheManager::Only; +} + + +E32ImageFile* CacheManager::GetE32ImageFile(char* OriginalFilename, int CurrentCompressionID) +{ + this->NormalizeFilename(OriginalFilename); + CacheEntry* validatedfile =CacheValidator::GetInstance()->Validate(OriginalFilename, CurrentCompressionID); + if(! validatedfile) + return (E32ImageFile*)0; + + printf("%s is validated in cache.\r\n", OriginalFilename); + E32ImageFile* cachedimagefile = new (nothrow) E32ImageFile(); + if(! cachedimagefile) + return (E32ImageFile*)0; + boost::filesystem::path cachedfile(validatedfile->GetCachedFilename()); + ifstream filecontentreader(cachedfile.file_string().c_str(), ios_base::in | ios_base::binary); + if(! filecontentreader.is_open()) + return (E32ImageFile*)0; + filecontentreader.seekg(0, ios_base::end); + int contentlength = filecontentreader.tellg(); + cachedimagefile->iData = (char*)malloc(sizeof(char)*contentlength); + filecontentreader.seekg(0, ios_base::beg); + filecontentreader.read(cachedimagefile->iData, contentlength); + cachedimagefile->iHdr->iUncompressedSize = contentlength - cachedimagefile->iHdr->TotalSize(); + + return cachedimagefile; +} + + +CacheEntry* CacheManager::GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID) +{ + this->NormalizeFilename(OriginalFilename); + + return CacheValidator::GetInstance()->Validate(OriginalFilename, CurrentCompressionID); +} + + +void CacheManager::Invalidate(char* Filename, CacheEntry* EntryRef) throw (CacheException) +{ + //update cache meta file. + this->NormalizeFilename(Filename); + Cache::GetInstance()->AddEntry(Filename, EntryRef); + + //update cache content. + CacheableList::GetInstance()->AddCacheable(EntryRef); + + printf("Caching %s\r\n", Filename); + + return; +} + + +void CacheManager::CleanCache(void) throw (CacheException) +{ + //check if the cache is present in the current system. + boost::filesystem::path cacherootdir(this->cacheroot); + if(! exists(cacherootdir)) + throw CacheException(CacheException::CACHE_NOT_FOUND); + + //remove files iteratively from cache root directory. + if(remove_all(cacherootdir) <= 0) + throw CacheException(CacheException::CACHE_IS_EMPTY); + + return; +} + + +const char* CacheManager::GetCacheRoot(void) +{ + return this->cacheroot; +} + + +CacheManager::~CacheManager(void) +{ + CacheEntry* newentryref = new (nothrow) CacheEntry(); + CacheableList::GetInstance()->AddCacheable(newentryref); + Cache::GetInstance()->CloseCache(); + CacheGenerator::GetInstance()->join(); + + delete CacheValidator::GetInstance(); + delete Cache::GetInstance(); + delete CacheGenerator::GetInstance(); + delete CacheableList::GetInstance(); + + return; +} + + +void CacheManager::InitializeCache(void) throw (CacheException) +{ + //assume the root directory is EPOCROOT/epoc32/build/.cache + char* epocroot = getenv("EPOCROOT"); + if(! epocroot) + throw CacheException(CacheException::EPOCROOT_NOT_FOUND); + + //initialize cacheroot member variable. + int cacherootstrlen = sizeof(char)*(strlen(epocroot)+strlen("/epoc32/build/.cache")+1); + this->cacheroot = (char*)malloc(cacherootstrlen); + if(! this->cacheroot) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + memset(this->cacheroot, 0, cacherootstrlen); + sprintf(this->cacheroot, "%s%s", epocroot, "/epoc32/build/.cache"); + + //normalize cache root path. + this->NormalizeFilename(this->cacheroot); + + //create cache root directory if it is not present. + boost::filesystem::path cacherootdir(this->cacheroot); + if(! exists(cacherootdir)) + create_directories(cacherootdir); + printf("Using %s as cache root directory.\r\n", cacherootdir.file_string().c_str()); + + //create cache instance. + Cache* cacheref = Cache::GetInstance(); + if(! cacheref) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //create cache validator instance. + if(! CacheValidator::GetInstance()) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //create cacheable list instance + if(! CacheableList::GetInstance()) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //initialize cache container. + cacheref->Initialize(); + + //start cache generator. + CacheGenerator::GetInstance(); + + return; +} + + +void CacheManager::NormalizeFilename(char* Filename) +{ + if(!Filename) + return; + + //convert back slashes into forward slashes. + char* normalizedfilename = Filename; + while(*normalizedfilename) + { + if(*normalizedfilename == '\\') + *normalizedfilename = '/'; + + normalizedfilename++; + } + + //remove redundant slashes. + char* redundantfilename = Filename; + while(*redundantfilename) + { + if((*redundantfilename=='/') && (*(redundantfilename+1)=='/')) + { + redundantfilename++; + continue; + } + *Filename++ = *redundantfilename++; + } + *Filename = 0; + + return; +} + + +CacheManager::CacheManager(void) +{ + return; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/src/cache/cachevalidator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cachevalidator.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cache.hpp" +#include "cache/cachevalidator.hpp" + +using namespace std ; +CacheValidator* CacheValidator::Only = (CacheValidator*)0; + + +CacheValidator* CacheValidator::GetInstance(void) throw (CacheException) +{ + if(! CacheValidator::Only) + { + CacheValidator::Only = new (nothrow) CacheValidator(); + if(! CacheValidator::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return CacheValidator::Only; +} + + +CacheEntry* CacheValidator::Validate(const char* OriginalFilename, int CurrentCompressionID) +{ + if(! OriginalFilename) + return (CacheEntry*)0; + + //an executable will be validated if its creation time does not altered and the compression method is not different against previous image build used. + CacheEntry* entryref = Cache::GetInstance()->GetEntryList(OriginalFilename); + if(! entryref) + { + return (CacheEntry*)0; + } + while(entryref) + { + boost::filesystem::path originalfile(OriginalFilename); + time_t originalcreationtime = last_write_time(originalfile); + string creationtime(ctime(&originalcreationtime)); + size_t newlinepos = creationtime.find("\n"); + while(newlinepos != string::npos) + { + creationtime.erase(newlinepos, 1); + newlinepos = creationtime.find(("\n")); + } + if((creationtime.compare(entryref->GetOriginalFileCreateTime())== 0) || (atoi(entryref->GetCachedFileCompressionID())==CurrentCompressionID)) + { + boost::filesystem::path cachedfile(entryref->GetCachedFilename()); + string filename = cachedfile.file_string(); + ifstream filecontentreader(filename.c_str(), ios_base::in | ios_base::binary); + if(! filecontentreader.is_open()){ + cerr << "Cannot open cached file " << filename << endl ; + return NULL; + } + filecontentreader.seekg(0, ios_base::end); + int contentlength = filecontentreader.tellg(); + char* bufferref = new char[contentlength + 1]; + filecontentreader.seekg(0, ios_base::beg); + filecontentreader.read(bufferref, contentlength); + bufferref[contentlength] = 0 ; + entryref->SetCachedFileBuffer(bufferref, contentlength); + delete []bufferref; + + cout << "Using cached" << OriginalFilename << endl ; + + return entryref; + } + + entryref = entryref->GetNextEntry(); + } + + return (CacheEntry*)0; +} + + +CacheValidator::CacheValidator(void) +{ + return; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/symbolgenerator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/symbolgenerator.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,279 @@ +#include +#define MAX_LINE 65535 +#include "symbolgenerator.h" +#include "e32image.h" + +#if defined(__LINUX__) +#define PATH_SEPARATOR '/' +#else +#define PATH_SEPARATOR '\\' +#endif + +boost::mutex SymbolGenerator::iMutexSingleton; +SymbolGenerator* SymbolGenerator::iInst = NULL; +SymbolGenerator* SymbolGenerator::GetInstance(){ + iMutexSingleton.lock(); + if(iInst == NULL) { + iInst = new SymbolGenerator(); + } + iMutexSingleton.unlock(); + return iInst; +} +void SymbolGenerator::Release() { + iMutexSingleton.lock(); + if(iInst != NULL) { + delete iInst; + iInst = NULL; + } + iMutexSingleton.unlock(); +} +void SymbolGenerator::SetSymbolFileName( const string& fileName ){ + if(iSymFile.is_open()) + iSymFile.close(); + string s = fileName.substr(0,fileName.rfind('.'))+".symbol"; + printf("* Writing %s - ROFS symbol file\n", s.c_str()); + iSymFile.open(s.c_str()); +} +void SymbolGenerator::AddFile( const string& fileName, bool isExecutable ){ + iMutex.lock(); + iQueueFiles.push(TPlacedEntry(fileName,isExecutable)); + iMutex.unlock(); + iCond.notify_all(); +} +void SymbolGenerator::ProcessExecutable( const string& fileName ){ + char str[MAX_LINE]; + string outString; + outString = "\nFrom "; + outString += fileName + "\n\n"; + iSymFile.write(outString.c_str(),outString.length()); + string mapFile2 = fileName+".map"; + size_t dot = fileName.rfind('.'); + string mapFile = fileName.substr(0,dot)+".map"; + ifstream fMap; + fMap.open(mapFile2.c_str()); + if(!fMap.is_open()) { + fMap.open(mapFile.c_str()); + } + + if(!fMap.is_open()) { + printf("%s\nWarning: Can't open \"%s\" or \"%s\"\n",fileName.c_str(),mapFile2.c_str(),mapFile.c_str()); + int binSize = GetSizeFromBinFile(fileName); + memset(str,0,sizeof(str)); + sprintf(str,"%04x", binSize); + outString = "00000000 "; + outString += str; + outString += " "; + outString += fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + else { + if(!fMap.good()) fMap.clear(); + boost::regex regARMV5("ARMV5", boost::regex::icase); + boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase); + boost::cmatch what; + if(regex_search(fileName, what, regARMV5)) { + ProcessArmv5File(fileName, fMap); + } + else if(regex_search(fileName, what, regGCCEoARMV4)) { + ProcessGcceOrArm4File(fileName, fMap); + } + else { + printf("\nWarning: cannot determine linker type used to create %s\n",fileName.c_str()); + outString = "00000000 0000 "; + outString += fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + } +} +void SymbolGenerator::ProcessDatafile( const string& fileName ){ + string line = "\nFrom "+fileName+"\n\n00000000 0000 "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(line.c_str(),line.length()); +} +void SymbolGenerator::ProcessArmv5File( const string& fileName, ifstream& aMap ){ + aMap.seekg (0, ios::beg); + char str[MAX_LINE]; + string outString; + aMap.getline(str,MAX_LINE); + boost::cmatch what; + boost::regex reg("^ARM Linker"); + if(!regex_search(str, what, reg)) { + printf("\nWarning: expecting %s to be generated by ARM linker\n", fileName.c_str()); + outString = "00000000 0000 "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + reg.assign("Global Symbols"); + while(aMap.getline(str,MAX_LINE)) { + if(regex_search(str, what, reg)) { + break; + } + } + + reg.assign("^\\s*(.+)\\s*0x(\\S+)\\s+[^\\d]*(\\d+)\\s+(.*)$"); + string sSym,sTmp,sSection; + unsigned int addr,size,baseOffset = 0; + map syms; + char symString[MAX_LINE]; + while(aMap.getline(str,MAX_LINE)) { + if(regex_search(str, what, reg)) { + sSym.assign(what[1].first,what[1].second-what[1].first); + sTmp.assign(what[2].first,what[2].second-what[2].first); + addr = strtol(sTmp.c_str(), NULL, 16); + sTmp.assign(what[3].first,what[3].second-what[3].first); + size = strtol(sTmp.c_str(), NULL, 10); + sSection.assign(what[4].first,what[4].second-what[4].first); + if(sSection.find("(StubCode)") != string::npos) + size = 8; + if(addr > 0) { + memset(symString,0,sizeof(symString)); + sprintf(symString,"%04x ",size); + outString = symString; + outString += sSym+" "; + outString += sSection; + if(baseOffset == 0) + baseOffset = addr; + unsigned int k = addr - baseOffset; + if( (syms.find(k) == syms.end()) || size != 0) + syms[k] = outString; + } + // end of addr>0 + } + // end of regex_search + } + + map::iterator it; + for(it = syms.begin(); it != syms.end(); it++) { + memset(str,0,sizeof(str)); + sprintf(str,"%08x",it->first); + outString = str; + outString += " "; + outString += it->second+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } +} +void SymbolGenerator::ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ){ + aMap.seekg (0, ios_base::beg); + char str[MAX_LINE]; + aMap.getline(str,MAX_LINE); + boost::cmatch what; + boost::regex reg("^\\.text\\s+"); + while(aMap.getline(str,MAX_LINE)) { + if(regex_search(str, what, reg)) { + break; + } + } + + reg.assign("^\\.text\\s+(\\w+)\\s+\\w+"); + if(!regex_search(str, what, reg)) { + printf("ERROR: Can't get .text section info for \"%s\"\n",fileName.c_str()); + } + else { + string sTmp, sLibFile; + sTmp.assign(what[1].first,what[1].second-what[1].first); + unsigned int imgText = strtol(sTmp.c_str(), NULL, 16); + + reg.assign("^LONG 0x.*", boost::regex::icase); + boost::cmatch what1; + boost::regex reg1("^\\s(\\.text)?\\s+(0x\\w+)\\s+(0x\\w+)\\s+(.*)$", boost::regex::icase); + boost::regex reg2("^\\s+(\\w+)\\s\\s+([a-zA-Z_].+)", boost::regex::icase); + boost::regex reg3(".*lib\\(.*d\\d*s_?\\d{5}.o\\)$", boost::regex::icase); + + map syms; + unsigned int addr, len, stubhex; + + while(aMap.getline(str,MAX_LINE)) { + if(strlen(str) == 0) + break; + else if(regex_search(str, what, reg1)) { + sLibFile.assign(what[4].first,what[4].second-what[4].first); + if(!regex_search(sLibFile, what1, reg)) { + sTmp.assign(what[2].first,what[2].second-what[2].first); + addr = strtol(sTmp.c_str(), NULL, 16); + sTmp.assign(what[3].first,what[3].second-what[3].first); + len = strtol(sTmp.c_str(), NULL, 16); + syms[addr+len] = ""; + if(regex_search(sLibFile, what, reg3)) { + stubhex = addr; + } + } + } + else if(regex_search(str, what, reg2)) { + sTmp.assign(what[1].first,what[1].second-what[1].first); + addr = strtol(sTmp.c_str(), NULL, 16); + sTmp.assign(what[2].first,what[2].second-what[2].first); + syms[addr] = (addr == stubhex)? ("stub "+sTmp) : sTmp; + } + } + + map::iterator it = syms.begin(); + map::iterator itp = it++; + string outString; + for(; it != syms.end(); itp = it++) { + if(itp->second != "") { + memset(str,0,sizeof(str)); + sprintf(str,"%08x %04x ",(itp->first-imgText), (it->first-itp->first)); + outString = str; + outString += it->second+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + } + } +} +int SymbolGenerator::GetSizeFromBinFile( const string& fileName ){ + TInt ret = 0; + ifstream aIf(fileName.c_str(), ios_base::binary); + if( !aIf.is_open() ) { + printf("Warning: Cannot open file \n"); + } + else { + E32ImageFile e32Image; + TUint32 aSz; + + aIf.seekg(0,ios_base::end); + aSz = aIf.tellg(); + + e32Image.Adjust(aSz); + e32Image.iFileSize = aSz; + + aIf.seekg(0,ios_base::beg); + aIf >> e32Image; + ret = e32Image.iOrigHdr->iCodeSize; + } + return ret; +} +void SymbolGenerator::thrd_func(){ + SymbolGenerator* me = GetInstance(); + + TPlacedEntry pe("",false); + while(1) { + if(1) { + //scope the code block with if(1) for lock + boost::mutex::scoped_lock lock(me->iMutex); + while(me->iQueueFiles.empty()) + me->iCond.wait(lock); + /* + if(me->iQueueFiles.empty()) { + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + continue; + } + */ + + pe = me->iQueueFiles.front(); + me->iQueueFiles.pop(); + } + + if(pe.iFileName == "") + break; + else if(pe.iExecutable) + me->ProcessExecutable(pe.iFileName); + else + me->ProcessDatafile(pe.iFileName); + } +} +SymbolGenerator::SymbolGenerator() : boost::thread(thrd_func) { +} +SymbolGenerator::~SymbolGenerator(){ + if(joinable()) + join(); + iSymFile.flush(); + iSymFile.close(); +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rofsbuild/symbolgenerator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/symbolgenerator.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,43 @@ +#ifndef __SYMBOLGENERATOR_H__ +#define __SYMBOLGENERATOR_H__ +#include +#include +#include +using namespace std; +#include +#include + + +struct TPlacedEntry{ + string iFileName; + bool iExecutable; + TPlacedEntry(const string& aName, bool aExecutable) { + iFileName = aName; + iExecutable = aExecutable; + } +}; +class SymbolGenerator : public boost::thread { + public: + static SymbolGenerator* GetInstance(); + static void Release(); + void SetSymbolFileName( const string& fileName ); + void AddFile( const string& fileName, bool isExecutable ); + private: + SymbolGenerator(); + ~SymbolGenerator(); + void ProcessExecutable( const string& fileName ); + void ProcessDatafile( const string& fileName ); + void ProcessArmv5File( const string& fileName, ifstream& aMap ); + void ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ); + int GetSizeFromBinFile( const string& fileName ); + static void thrd_func(); + + queue iQueueFiles; + boost::mutex iMutex; + static boost::mutex iMutexSingleton; + static SymbolGenerator* iInst; + boost::condition_variable iCond; + + ofstream iSymFile; +}; +#endif diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rombuild/symbolgenerator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rombuild/symbolgenerator.cpp Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,536 @@ +#include +#include +#include "symbolgenerator.h" +#include "r_rom.h" +#include +#include "h_utl.h" +typedef boost::unique_lock scoped_lock ; +typedef boost::lock_guard guarded_lock ; + +SymbolGenerator::SymbolGenerator(const char* aSymbolFileName, int aMultiThreadsCount/* = 1*/) : +iOutput(aSymbolFileName,ios_base::out |ios_base::binary | ios_base::trunc) { + if(iOutput.is_open()){ + if(aMultiThreadsCount < 1) + aMultiThreadsCount = 1; + + for(int i = 0 ; i < aMultiThreadsCount ; i++){ + iThreads.add_thread(new boost::thread(ThreadFunc,this)); + } + } + else { + cerr << "\nWarning: Can't write data to \""<::iterator i = iErrMsgs.begin() ; i != iErrMsgs.end() ; i++){ + char* msg = *i ; + cerr << msg ; + delete []msg ; + } + iErrMsgs.clear(); +} + +void SymbolGenerator::AddEntry(const SymGenContext& aEntry){ + if(iOutput.is_open()){ + guarded_lock lock(iQueueMutex); + iEntries.push(aEntry); + iCond.notify_all(); + } +} +void SymbolGenerator::ThreadFunc(SymbolGenerator* aInst) { + SymGenContext entry ; + while(1){ + entry.iFileName = 0; + if(1) { + scoped_lock lock(aInst->iQueueMutex); + while(aInst->iEntries.empty()){ + aInst->iCond.wait(lock); + } + entry = aInst->iEntries.front(); + if(0 == entry.iFileName) // end , exit + return ; + + aInst->iEntries.pop(); + } + aInst->ProcessEntry(entry); + } + +} +#define MAX_LINE_LENGTH 65535 +#define SKIP_WS(p) while((*p) == ' ' || (*p) == '\t') (p)++ +#define FIND_WS(p) while((*p) != ' ' && (*p) != '\t' && (*p) != 0) (p)++ +static void split(char* str, vector& result) { + result.clear(); + while(*str) { + SKIP_WS(str); + char* saved = str ; + FIND_WS(str); + bool end = (0 == *str); + *str = 0 ; + if(saved != str) + result.push_back(saved); + if(!end) str ++ ; + } +} +static void make_lower(char* str){ + while(*str){ + if(*str >= 'A' && *str >= 'Z') { + *str += ('a' - 'A'); + } + str++; + } +} +bool SymbolGenerator::ProcessEntry(const SymGenContext& aContext) { + size_t allocBytes ; + if(aContext.iExecutable ) { + string mapFileName(aContext.iFileName); + mapFileName += ".map"; + ifstream ifs(mapFileName.c_str()); + if(!ifs.is_open()){ + int index = mapFileName.length() - 5 ; + int count = 1 ; + while(index > 0 && mapFileName.at(index) != '.'){ + index -- ; + count ++ ; + } + mapFileName.erase(index,count); + ifs.open(mapFileName.c_str()); + } + if(!ifs.is_open()){ + guarded_lock lock(iFileMutex); + allocBytes = mapFileName.length() + 60 ; + char* msg = new char[ allocBytes] ; + snprintf(msg,allocBytes,"\nWarning: Can't open \"%s.map\"\n",aContext.iFileName ); + iErrMsgs.push_back(msg); + msg = new char[allocBytes] ; + int n = snprintf(msg,allocBytes,"%08x %04x %s\r\n",(unsigned int)aContext.iCodeAddress,(unsigned int)aContext.iTotalSize,aContext.iFileName); + iOutput.write(msg,n); + iOutput.flush(); + return false ; + } + if(!ifs.good()) ifs.clear(); + char buffer[100]; + *buffer = 0; + //See if we're dealing with the RVCT output + ifs.getline(buffer,100); + if(!ifs.good()) { + ifs.close(); + guarded_lock lock(iFileMutex); + allocBytes = mapFileName.length() + 60; + char* msg = new char[allocBytes] ; + snprintf(msg,allocBytes,"\nWarning: File \"%s\" is opened yet can not be read!",mapFileName.c_str()); + iErrMsgs.push_back(msg); + return false ; + } + if(strncmp(buffer,"ARM Linker",10) == 0){ + return ProcessARMV5Map(ifs,aContext); + } + // See if we're dealing with the GCC output + else if ( 0 == strncmp(buffer,"Archive member included",23)){ + return ProcessGCCMap(ifs,aContext); + } + else { // Must be x86 output + ifs.seekg(0,ios_base::beg); + return ProcessX86Map(ifs,aContext); + } + } + else { + const char* fileName = aContext.iFileName; + size_t len = strlen(fileName); + size_t index = len - 1; + while(index > 0 && (fileName[index] != '\\' && fileName[index] != '/')) + index -- ; + const char* basename = fileName + index + 1 ; + allocBytes = (len << 1) + 40 ; + char* msg = new char[allocBytes] ; + int n = snprintf(msg,allocBytes,"\r\nFrom %s\r\n\r\n%08x 0000 %s\r\n", fileName ,(unsigned int)aContext.iDataAddress,basename); + guarded_lock lock(iFileMutex); + iOutput.write(msg,n); + iOutput.flush(); + delete []msg ; + return true ; + } + return true ; +} +struct ArmSymbolInfo { + string name ; + TUint size ; + string section ; +}; +typedef multimap ArmSymMap ; + +bool SymbolGenerator::ProcessARMV5Map(ifstream& aStream, const SymGenContext& aContext) { + string symName ; + ArmSymMap symbols ; + vector words ; + ArmSymbolInfo info; + char* lineStart ; + char buffer[MAX_LINE_LENGTH]; + while(aStream.good() && (!aStream.eof())){ + *buffer = 0; + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if(strstr(lineStart,"Global Symbols")) + break ; + char* armstamp = strstr(lineStart,"ARM Code"); + if(0 == armstamp) + armstamp = strstr(lineStart,"Thumb Code") ; + if(0 == armstamp) continue ; + *(armstamp - 1) = 0 ; + + char* hexStr = lineStart ; + char* nameEnd; + while(1) { + hexStr = strstr(hexStr,"0x"); + if(0 == hexStr) break ; + nameEnd = hexStr - 1; + if(*nameEnd == ' ' || *nameEnd == '\t') break ; + hexStr += 2 ; + } + if(0 == hexStr) continue ; + while(nameEnd > lineStart && (*nameEnd == ' ' || *nameEnd == '\t')) + nameEnd -- ; + + nameEnd[1] = 0; + info.name = lineStart; + char* temp ; + TUint32 addr = strtoul(hexStr + 2,&temp,16); + char* decStr ; + if(*armstamp == 'A') + decStr = armstamp + 9 ; + else + decStr = armstamp + 11 ; + SKIP_WS(decStr); + info.size = strtoul(decStr,&temp,10); + SKIP_WS(temp); + info.section = temp; + if(info.section.find("(StubCode)") != string::npos ) + info.size = 8 ; + if(addr > 0){ + symbols.insert(pair(addr,info)); + } + } + size_t lenOfFileName = strlen(aContext.iFileName); + while(aStream.good() && (!aStream.eof())){ + *buffer = 0; + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + char* hexStr = lineStart ; + char* nameEnd; + while(1) { + hexStr = strstr(hexStr,"0x"); + if(0 == hexStr) break ; + nameEnd = hexStr - 1; + if(*nameEnd == ' ' || *nameEnd == '\t') + break ; + hexStr += 2 ; + } + if(0 == hexStr) continue ; + while(nameEnd > lineStart && (*nameEnd == ' ' || *nameEnd == '\t')){ + nameEnd -- ; + } + nameEnd[1] = 0; + info.name = lineStart; + char *temp ; + TUint32 addr = strtoul(hexStr + 2,&temp,16); + while(*temp < '0' || *temp > '9' )//[^\d]* + temp++ ; + char* decStr = temp ; + info.size = strtoul(decStr,&temp,10); + SKIP_WS(temp); + info.section = temp; + if(info.section.find("(StubCode)") != string::npos ) + info.size = 8 ; + if(addr > 0){ + symbols.insert(pair(addr,info)); + } + } + + TUint32 textSectAddr = 0x00008000; // .text gets linked at 0x00008000 + TUint32 dataSectAddr = 0x00400000 ; // .data gets linked at 0x00400000 + vector > lines ; + size_t allocBytes; + for( ArmSymMap::iterator it = symbols.begin(); it != symbols.end() ; it++){ + TUint32 thisAddr = it->first ; + TUint32 romAddr ; + ArmSymbolInfo& info = it->second; + if (thisAddr >= textSectAddr && thisAddr <= (textSectAddr + aContext.iTextSize)) { + romAddr = thisAddr - textSectAddr + aContext.iCodeAddress ; + } + else if ( aContext.iDataAddress && + ( thisAddr >= dataSectAddr && thisAddr <= (dataSectAddr + aContext.iTextSize))) { + romAddr = thisAddr-dataSectAddr + aContext.iDataBssLinearBase; + } + else if ( aContext.iDataBssLinearBase && + ( thisAddr >= dataSectAddr && thisAddr <= (dataSectAddr+ aContext.iTotalDataSize))) { + romAddr = thisAddr - dataSectAddr + aContext.iDataBssLinearBase; + } + else { + guarded_lock lock(iFileMutex); + allocBytes = info.name.length() + 60; + char* msg = new char[allocBytes] ; + snprintf(msg,allocBytes,"\r\nWarning: Symbol %s @ 0x%08x not in text or data segments\r\n", \ + info.name.c_str() ,(unsigned int)thisAddr) ; + iErrMsgs.push_back(msg); + allocBytes = lenOfFileName + 80; + msg = new char[allocBytes]; + snprintf(msg,allocBytes,"Warning: The map file for binary %s is out-of-sync with the binary itself\r\n\r\n",aContext.iFileName); + iErrMsgs.push_back(msg); + continue ; + } + allocBytes = info.section.length() + info.name.length() + 140; + char* outputLine = new char[allocBytes]; + int len = snprintf(outputLine,allocBytes,"%08x %04x %-40s %s\r\n",(unsigned int)romAddr,info.size, + info.name.c_str(),info.section.c_str()); + if((size_t)len > allocBytes) { + allocBytes = len + 4 ; + delete []outputLine; + outputLine = new char[allocBytes]; + len = snprintf(outputLine,allocBytes,"%08x %04x %-40s %s\r\n",(unsigned int)romAddr,info.size, + info.name.c_str(),info.section.c_str()); + } + lines.push_back(pair(len,outputLine)); + + } + guarded_lock lock(iFileMutex); + allocBytes = lenOfFileName + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"\r\nFrom %s\r\n\r\n",aContext.iFileName); + iOutput.write(outputLine,n); + delete []outputLine ; + for (vector >::iterator i = lines.begin() ; i < lines.end(); i ++ ) { + int len = i->first ; + char* line = i->second; + iOutput.write(line,len); + delete []line ; + } + iOutput.flush(); + return true ; + +} +template +static void put_to_map(M& m,const K& k, const V& v) { + typedef typename M::iterator iterator; + iterator it = m.find(k); + if(m.end() == it){ + m.insert(pair(k,v)); + } + else { + it->second = v ; + } +} +bool SymbolGenerator::ProcessGCCMap(ifstream& aStream, const SymGenContext& aContext){ + char* lineStart; + vector words ; + char buffer[MAX_LINE_LENGTH]; + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if( 0 == strncmp(lineStart,".text",5)) { + lineStart += 5; + break ; + } + } + split(lineStart,words); + TUint32 codeAddr , codeSize; + size_t allocBytes ; + if(words.size() != 2 || + KErrNone != Val(codeAddr,words.at(0)) || + KErrNone != Val(codeSize,words.at(1))) { + allocBytes = strlen(aContext.iFileName) + 60; + char* msg = new char[allocBytes]; + snprintf(msg,allocBytes,"\nError: Can't get .text section info for \"%s\"\r\n",aContext.iFileName); + guarded_lock lock(iFileMutex); + iErrMsgs.push_back(msg); + return false ; + } + map symbols ; + TUint32 stubHex = 0; + //Slurp symbols 'til the end of the text section + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if(0 == *lineStart) break ; //blank line marks the end of the text section + + // .text + // .text$something + // + // LONG 0x0 + // (/^\s(\.text)?\s+(0x\w+)\s+(0x\w+)\s+(.*)$/io) + if(strncmp(lineStart,".text",5) == 0){ + lineStart += 5 ; + SKIP_WS(lineStart); + } + char* hex1 = NULL ; + char* hex2 = NULL ; + char* strAfterhex1 = NULL ; + TUint32 addr,size ; + if(strncmp(lineStart,"0x",2) == 0){ + hex1 = lineStart + 2; + char* temp ; + addr = strtoul(hex1,&temp,16); + SKIP_WS(temp); + strAfterhex1 = temp ; + if(strncmp(temp,"0x",2) == 0){ + hex2 = temp + 2 ; + } + } + if(NULL != hex2){ + char* libraryfile ; + size = strtoul(hex2,&libraryfile,16); + SKIP_WS(libraryfile); + TUint32 key = addr + size ; + put_to_map(symbols,key,string(""));//impossible symbol as end marker + make_lower(libraryfile); + // EUSER.LIB(ds01423.o) + // EUSER.LIB(C:/TEMP/d1000s_01423.o) + size_t len = strlen(libraryfile); + char* p1 = strstr(libraryfile,".lib("); + if(NULL == p1) + continue ; + p1 += 5; + if(strcmp(libraryfile + len - 3,".o)")!= 0) + continue ; + len -= 3 ; + libraryfile[len] = 0; + if(EFalse == IsValidNumber(libraryfile + len - 5)) + continue ; + len -= 7 ; + if('_' == libraryfile[len]) + len -- ; + if('s' != libraryfile[len]) + continue ; + char* p2 = libraryfile + len - 1; + while(p2 > p1 ) { + if(*p2 < '0' || *p2 > '9') + break ; + p2 -- ; + } + if(*p2 != 'd') + continue ; + stubHex = addr ; + } + else if(NULL != hex1 && NULL != strAfterhex1){ + //# + //(/^\s+(\w+)\s\s+([a-zA-Z_].+)/o) + char* symName = strAfterhex1; + if((*symName >= 'A' && *symName <= 'Z') || + (*symName >= 'a' && *symName <= 'z') || *symName == '_') { + string symbol(symName); + if(addr == stubHex) + symbol.insert(0,"stub "); + + put_to_map(symbols,addr,symbol); + + } + } + } + map::iterator it = symbols.begin(); + TUint32 lastAddr = it->first; + string lastSymName = it->second; + vector >lines ; + it ++ ; + while(it != symbols.end()) { + TUint32 addr = it->first ; + unsigned int fixedupAddr = lastAddr - codeAddr + aContext.iCodeAddress; + TUint size = addr - lastAddr ; + if(!lastSymName.empty()) { + allocBytes = lastSymName.length() + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"%08x %04x %s\r\n", fixedupAddr,size,lastSymName.c_str()); + lines.push_back(pair(n,outputLine)); + } + lastAddr = addr ; + lastSymName = it->second; + it ++ ; + } + + guarded_lock lock(iFileMutex); + allocBytes = strlen(aContext.iFileName) + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"\r\nFrom %s\r\n\r\n",aContext.iFileName); + iOutput.write(outputLine,n); + delete []outputLine ; + vector >::iterator i; + for ( i = lines.begin() ; i < lines.end(); i ++ ) { + int len = i->first ; + char* line = i->second ; + iOutput.write(line,len); + delete []line ; + } + iOutput.flush(); + return true ; +} +bool SymbolGenerator::ProcessX86Map(ifstream& aStream, const SymGenContext& aContext) { + char buffer[MAX_LINE_LENGTH]; + char* lineStart; + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if( 0 == strncmp(lineStart,"Address",7)) { + break ; + } + } + aStream.getline(buffer,MAX_LINE_LENGTH); + string lastName ; + TUint32 lastAddr = 0; + size_t allocBytes ; + vector >lines ; + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if(0 != strncmp(lineStart,"0001:",5)) + break ; + char* end ; + TUint32 addr = strtoul(lineStart + 5,&end,16); + char* name = end + 1; + SKIP_WS(name); + end = name + 1; + FIND_WS(end); + *end = 0 ; + if(!lastName.empty()){ + unsigned int size = addr - lastAddr ; + unsigned int romAddr = lastAddr + aContext.iCodeAddress; + allocBytes = lastName.length() + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"%08x %04x %s\r\n",romAddr,size,lastName.c_str()); + lines.push_back(pair(n,outputLine)); + } + } + guarded_lock lock(iFileMutex); + allocBytes = strlen(aContext.iFileName) + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"\r\nFrom %s\r\n\r\n",aContext.iFileName); + iOutput.write(outputLine,n); + delete []outputLine ; + vector >::iterator it; + for ( it = lines.begin() ; it < lines.end(); it ++ ) { + int len = it->first ; + char* line = it->second ; + iOutput.write(line,len); + delete []line ; + } + if(!lastName.empty()){ + allocBytes = lastName.length() + 40 ; + outputLine = new char[allocBytes]; + unsigned int romAddr = lastAddr + aContext.iCodeAddress; + n = snprintf(outputLine,allocBytes,"%08x 0000 %s\r\n",romAddr,lastName.c_str()); + iOutput.write(outputLine,n); + delete []outputLine ; + } + iOutput.flush(); + return false ; +} diff -r fa7a3cc6effd -r 6d08f4a05d93 imgtools/romtools/rombuild/symbolgenerator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rombuild/symbolgenerator.h Fri Jun 25 18:11:34 2010 +0800 @@ -0,0 +1,51 @@ +#ifndef __SYMBOLSCREATER_H__ +#define __SYMBOLSCREATER_H__ +#include +#include +#include +#include +#include + +using namespace std; + +#include +#include + +struct SymGenContext { + const char* iFileName ; + TUint32 iTotalSize ; + TUint32 iCodeAddress; + TUint32 iDataAddress; + TUint32 iDataBssLinearBase; + TInt iTextSize; + TInt iDataSize; + TInt iBssSize; + TInt iTotalDataSize; + TBool iExecutable ; +}; + +class SymbolGenerator { +public : + SymbolGenerator(const char* aSymbolFileName, int aMultiThreadsCount = 1); + ~SymbolGenerator(); + void AddEntry(const SymGenContext& aEntry); + void WaitThreads(); +private : + SymbolGenerator(); + SymbolGenerator& operator = (const SymbolGenerator& aRight); + static void ThreadFunc(SymbolGenerator* aInst); + bool ProcessEntry(const SymGenContext& aContext); + bool ProcessARMV5Map(ifstream& aStream, const SymGenContext& aContext); + bool ProcessGCCMap(ifstream& aStream, const SymGenContext& aContext); + bool ProcessX86Map(ifstream& aStream, const SymGenContext& aContext); + ofstream iOutput ; + boost::thread_group iThreads ; + boost::condition_variable iCond; + boost::mutex iQueueMutex; + boost::mutex iFileMutex ; + queue iEntries ; + vector iErrMsgs ; + +}; + +#endif //__ROMSYMBOLGENERATOR_H__