diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:11:56 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:11:56 +0200 |
commit | 98ecf620f7de377dc8ae9ad7fbd1e3b24477e138 (patch) | |
tree | faadc6d8822c20cd3bc6f50b2a98e6c580585949 /shared | |
parent | 3.16 (diff) | |
download | FreeFileSync-98ecf620f7de377dc8ae9ad7fbd1e3b24477e138.tar.gz FreeFileSync-98ecf620f7de377dc8ae9ad7fbd1e3b24477e138.tar.bz2 FreeFileSync-98ecf620f7de377dc8ae9ad7fbd1e3b24477e138.zip |
3.17
Diffstat (limited to 'shared')
107 files changed, 5132 insertions, 6244 deletions
diff --git a/shared/IFileOperation/file_op.h b/shared/IFileOperation/file_op.h index a7b0434f..25098e45 100644 --- a/shared/IFileOperation/file_op.h +++ b/shared/IFileOperation/file_op.h @@ -45,9 +45,9 @@ typedef void (*GetLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen); |symbol names| --------------*/ //(use const pointers to ensure internal linkage) -const char* const moveToRecycleBinFctName = "moveToRecycleBin"; -const char* const copyFileFctName = "copyFile"; -const char* const getLastErrorFctName = "getLastError"; +const char moveToRecycleBinFctName[] = "moveToRecycleBin"; +const char copyFileFctName[] = "copyFile"; +const char getLastErrorFctName[] = "getLastError"; } diff --git a/shared/ShadowCopy/shadow.h b/shared/ShadowCopy/shadow.h index 5495633d..a96d8578 100644 --- a/shared/ShadowCopy/shadow.h +++ b/shared/ShadowCopy/shadow.h @@ -58,8 +58,8 @@ typedef void (*ReleaseShadowCopyFct)(ShadowHandle handle); |symbol names| --------------*/ //(use const pointers to ensure internal linkage) -const char* const createShadowCopyFctName = "createShadowCopy"; -const char* const releaseShadowCopyFctName = "releaseShadowCopy"; +const char createShadowCopyFctName[] = "createShadowCopy"; +const char releaseShadowCopyFctName[] = "releaseShadowCopy"; } diff --git a/shared/Taskbar_Seven/taskbar.h b/shared/Taskbar_Seven/taskbar.h index 7b6efbb5..d52420ab 100644 --- a/shared/Taskbar_Seven/taskbar.h +++ b/shared/Taskbar_Seven/taskbar.h @@ -57,9 +57,9 @@ typedef void (*GetLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen); |symbol names| --------------*/ //(use const pointers to ensure internal linkage) -const char* const setStatusFctName = "setStatus"; -const char* const setProgressFctName = "setProgress"; -const char* const getLastErrorFctName = "getLastError"; +const char setStatusFctName[] = "setStatus"; +const char setProgressFctName[] = "setProgress"; +const char getLastErrorFctName[] = "getLastError"; } #endif //TASKBAR_SEVEN_DLL_H diff --git a/shared/app_main.cpp b/shared/app_main.cpp index 6b87cf45..b727724f 100644 --- a/shared/app_main.cpp +++ b/shared/app_main.cpp @@ -8,13 +8,13 @@ #include <wx/window.h> #include <wx/app.h> -using namespace ffs3; +using namespace zen; bool AppMainWindow::mainWndActive = false; -void ffs3::AppMainWindow::setMainWindow(wxWindow* window) +void zen::AppMainWindow::setMainWindow(wxWindow* window) { wxTheApp->SetTopWindow(window); wxTheApp->SetExitOnFrameDelete(true); diff --git a/shared/app_main.h b/shared/app_main.h index bdfb9b08..33ddcfb6 100644 --- a/shared/app_main.h +++ b/shared/app_main.h @@ -9,7 +9,7 @@ class wxWindow; -namespace ffs3 +namespace zen { //just some wrapper around a global variable representing the (logical) main application window class AppMainWindow diff --git a/shared/assert_static.h b/shared/assert_static.h index 198943cf..37705ded 100644 --- a/shared/assert_static.h +++ b/shared/assert_static.h @@ -11,7 +11,7 @@ #ifdef NDEBUG -#define assert_static(x) ((void)0) +#define assert_static(x) //((void)0) -> leads to error when seen in namespace scope! #else /* debugging enabled */ namespace StaticCheckImpl diff --git a/shared/check_exist.cpp b/shared/check_exist.cpp index 97a25ec8..218b1a0c 100644 --- a/shared/check_exist.cpp +++ b/shared/check_exist.cpp @@ -81,11 +81,13 @@ util::ResultExist checkExistence(const Zstring& objName, size_t timeout) //timeo util::ResultExist util::fileExists(const Zstring& filename, size_t timeout) //timeout in ms { - return ::checkExistence<ffs3::fileExists>(filename, timeout); + assert(!filename.empty()); + return ::checkExistence<zen::fileExists>(filename, timeout); } util::ResultExist util::dirExists(const Zstring& dirname, size_t timeout) //timeout in ms { - return ::checkExistence<ffs3::dirExists>(dirname, timeout); + assert(!dirname.empty()); + return ::checkExistence<zen::dirExists>(dirname, timeout); } diff --git a/shared/dir_name.cpp b/shared/dir_name.cpp index 977751f5..dda9407e 100644 --- a/shared/dir_name.cpp +++ b/shared/dir_name.cpp @@ -17,39 +17,13 @@ #include "i18n.h" #include "system_constants.h" +using namespace zen; -//define new event type -const wxEventType FFS_DROP_FILE_EVENT = wxNewEventType(); -typedef void (wxEvtHandler::*FFSFileDropEventFunction)(FFSFileDropEvent&); - -#define FFSFileDropEventHandler(func) \ - (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(FFSFileDropEventFunction, &func) - -struct FFSFileDropEvent : public wxCommandEvent -{ - FFSFileDropEvent(const std::vector<wxString>& filesDropped, const wxWindow& dropWindow) : - wxCommandEvent(FFS_DROP_FILE_EVENT), - filesDropped_(filesDropped), - dropWindow_(dropWindow) {} - - virtual wxEvent* Clone() const - { - return new FFSFileDropEvent(filesDropped_, dropWindow_); - } - - const std::vector<wxString> filesDropped_; - const wxWindow& dropWindow_; -}; - - -//############################################################################################################## namespace { void setDirectoryNameImpl(const wxString& dirname, wxDirPickerCtrl* dirPicker, wxWindow& tooltipWnd, wxStaticBoxSizer* staticBox, size_t timeout) { - using namespace ffs3; - const wxString dirFormatted = zToWx(getFormattedDirectoryName(wxToZ(dirname))); tooltipWnd.SetToolTip(dirFormatted); //wxComboBox bug: the edit control is not updated... hope this will be fixed: http://trac.wxwidgets.org/ticket/12659 @@ -68,7 +42,7 @@ void setDirectoryNameImpl(const wxString& dirname, wxDirPickerCtrl* dirPicker, w if (dirPicker) { - if (util::dirExists(wxToZ(dirFormatted), timeout) == util::EXISTING_TRUE) //potentially slow network access: wait 200ms at most + if (!dirFormatted.empty() && util::dirExists(wxToZ(dirFormatted), timeout) == util::EXISTING_TRUE) //potentially slow network access: wait 200ms at most dirPicker->SetPath(dirFormatted); } } @@ -105,33 +79,7 @@ void setDirectoryName(const wxString& dirname, //############################################################################################################## -class WindowDropTarget : public wxFileDropTarget -{ -public: - WindowDropTarget(wxWindow& dropWindow) : dropWindow_(dropWindow) {} - - virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& fileArray) - { - std::vector<wxString> filenames; - for (size_t i = 0; i < fileArray.GetCount(); ++i) - filenames.push_back(fileArray[i]); - - if (!filenames.empty()) - { - //create a custom event on drop window: execute event after file dropping is completed! (e.g. after mouse is released) - FFSFileDropEvent evt(filenames, dropWindow_); - dropWindow_.GetEventHandler()->AddPendingEvent(evt); - } - return false; - } - -private: - wxWindow& dropWindow_; -}; - - -//############################################################################################################## -using ffs3::DirectoryNameMainDlg; +using zen::DirectoryNameMainDlg; DirectoryNameMainDlg::DirectoryNameMainDlg(wxWindow& dropWindow1, wxWindow& dropWindow2, @@ -145,8 +93,8 @@ DirectoryNameMainDlg::DirectoryNameMainDlg(wxWindow& dropWindow1, staticBox_(staticBox) { //prepare drag & drop - dropWindow1.SetDropTarget(new WindowDropTarget(dropWindow1)); //takes ownership - dropWindow2.SetDropTarget(new WindowDropTarget(dropWindow2)); //takes ownership + setupFileDrop(dropWindow1); + setupFileDrop(dropWindow2); //redirect drag & drop event back to this class dropWindow1.Connect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(DirectoryNameMainDlg::OnFilesDropped), NULL, this); @@ -160,23 +108,19 @@ DirectoryNameMainDlg::DirectoryNameMainDlg(wxWindow& dropWindow1, void DirectoryNameMainDlg::OnFilesDropped(FFSFileDropEvent& event) { - if (event.filesDropped_.empty()) + if (event.getFiles().empty()) return; - if (&dropWindow1_ == &event.dropWindow_ || //file may be dropped on window 1 or 2 - &dropWindow2_ == &event.dropWindow_) + if (AcceptDrop(event.getFiles())) { - if (AcceptDrop(event.filesDropped_)) + Zstring fileName = wxToZ(event.getFiles()[0]); + if (dirExists(fileName)) + setDirectoryName(zToWx(fileName), &dirName_, &dirPicker_, dirName_, staticBox_); + else { - Zstring fileName = wxToZ(event.filesDropped_[0]); + fileName = fileName.BeforeLast(common::FILE_NAME_SEPARATOR); if (dirExists(fileName)) setDirectoryName(zToWx(fileName), &dirName_, &dirPicker_, dirName_, staticBox_); - else - { - fileName = fileName.BeforeLast(common::FILE_NAME_SEPARATOR); - if (dirExists(fileName)) - setDirectoryName(zToWx(fileName), &dirName_, &dirPicker_, dirName_, staticBox_); - } } } } @@ -198,20 +142,20 @@ void DirectoryNameMainDlg::OnDirSelected(wxFileDirPickerEvent& event) } -Zstring DirectoryNameMainDlg::getName() const +wxString DirectoryNameMainDlg::getName() const { - return wxToZ(dirName_.GetValue()); + return dirName_.GetValue(); } -void DirectoryNameMainDlg::setName(const Zstring& dirname) +void DirectoryNameMainDlg::setName(const wxString& dirname) { - setDirectoryName(zToWx(dirname), &dirName_, &dirPicker_, dirName_, staticBox_); + setDirectoryName(dirname, &dirName_, &dirPicker_, dirName_, staticBox_); } //############################################################################################################## -using ffs3::DirectoryName; +using zen::DirectoryName; DirectoryName::DirectoryName(wxWindow& dropWindow, wxDirPickerCtrl& dirPicker, @@ -223,7 +167,7 @@ DirectoryName::DirectoryName(wxWindow& dropWindow, staticBox_(staticBox) { //prepare drag & drop - dropWindow.SetDropTarget(new WindowDropTarget(dropWindow)); //takes ownership + setupFileDrop(dropWindow); //redirect drag & drop event back to this class dropWindow.Connect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(DirectoryName::OnFilesDropped), NULL, this); @@ -236,20 +180,17 @@ DirectoryName::DirectoryName(wxWindow& dropWindow, void DirectoryName::OnFilesDropped(FFSFileDropEvent& event) { - if (event.filesDropped_.empty()) + if (event.getFiles().empty()) return; - if (&dropWindow_ == &event.dropWindow_) + Zstring fileName = wxToZ(event.getFiles()[0]); + if (dirExists(fileName)) + setDirectoryName(zToWx(fileName), &dirName_, &dirPicker_, dirName_, staticBox_); + else { - Zstring fileName = wxToZ(event.filesDropped_[0]); + fileName = fileName.BeforeLast(common::FILE_NAME_SEPARATOR); if (dirExists(fileName)) setDirectoryName(zToWx(fileName), &dirName_, &dirPicker_, dirName_, staticBox_); - else - { - fileName = fileName.BeforeLast(common::FILE_NAME_SEPARATOR); - if (dirExists(fileName)) - setDirectoryName(zToWx(fileName), &dirName_, &dirPicker_, dirName_, staticBox_); - } } } @@ -270,13 +211,13 @@ void DirectoryName::OnDirSelected(wxFileDirPickerEvent& event) } -Zstring DirectoryName::getName() const +wxString DirectoryName::getName() const { - return wxToZ(dirName_.GetValue()); + return dirName_.GetValue(); } -void DirectoryName::setName(const Zstring& dirname) +void DirectoryName::setName(const wxString& dirname) { - setDirectoryName(zToWx(dirname), &dirName_, &dirPicker_, dirName_, staticBox_); + setDirectoryName(dirname, &dirName_, &dirPicker_, dirName_, staticBox_); } diff --git a/shared/dir_name.h b/shared/dir_name.h index 387f5668..4bf07231 100644 --- a/shared/dir_name.h +++ b/shared/dir_name.h @@ -7,19 +7,17 @@ #ifndef DRAGANDDROP_H_INCLUDED #define DRAGANDDROP_H_INCLUDED -#include <wx/event.h> #include <vector> +#include <wx/event.h> #include <wx/sizer.h> #include <wx/filepicker.h> #include <wx/combobox.h> -#include "zstring.h" +#include "file_drop.h" -struct FFSFileDropEvent; -class wxCommandEvent; class wxFileDirPickerEvent; -namespace ffs3 +namespace zen { //handle drag and drop, tooltip, label and manual input, coordinating a wxWindow, wxDirPickerCtrl, and wxComboBox/wxTextCtrl @@ -34,8 +32,8 @@ public: virtual ~DirectoryNameMainDlg() {} - Zstring getName() const; - void setName(const Zstring& dirname); + wxString getName() const; + void setName(const wxString& dirname); virtual bool AcceptDrop(const std::vector<wxString>& droppedFiles) = 0; //return true if drop should be processed @@ -60,8 +58,8 @@ public: wxTextCtrl& dirName, wxStaticBoxSizer* staticBox = NULL); //optional - Zstring getName() const; - void setName(const Zstring& dirname); + wxString getName() const; + void setName(const wxString& dirname); private: void OnFilesDropped(FFSFileDropEvent& event); diff --git a/shared/disable_standby.h b/shared/disable_standby.h index 399d0b9c..1a2a2b8a 100644 --- a/shared/disable_standby.h +++ b/shared/disable_standby.h @@ -10,20 +10,17 @@ namespace util class DisableStandby { public: +#ifdef FFS_WIN DisableStandby() { -#ifdef FFS_WIN ::SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED /* | ES_AWAYMODE_REQUIRED*/ ); -#endif } ~DisableStandby() { -#ifdef FFS_WIN ::SetThreadExecutionState(ES_CONTINUOUS); -#endif } - +#endif }; } diff --git a/shared/dll_loader.cpp b/shared/dll_loader.cpp index 03b9bf6e..e942a168 100644 --- a/shared/dll_loader.cpp +++ b/shared/dll_loader.cpp @@ -5,9 +5,7 @@ // ************************************************************************** // #include "dll_loader.h" -#include <wx/msw/wrapwin.h> //includes "windows.h" #include <map> -#include <cassert> namespace { diff --git a/shared/dll_loader.h b/shared/dll_loader.h index 24dd4f14..6dedc06e 100644 --- a/shared/dll_loader.h +++ b/shared/dll_loader.h @@ -8,7 +8,14 @@ #define DLLLOADER_H_INCLUDED #include <string> + +#ifdef __WXMSW__ //we have wxWidgets #include <wx/msw/wrapwin.h> //includes "windows.h" +#else +#include <windows.h> +#undef max +#undef min +#endif namespace util diff --git a/shared/dst_hack.cpp b/shared/dst_hack.cpp index 5ec58e06..72267e54 100644 --- a/shared/dst_hack.cpp +++ b/shared/dst_hack.cpp @@ -3,14 +3,14 @@ #include "i18n.h" #include "long_path_prefix.h" #include "string_conv.h" -#include "system_func.h" -#include <wx/longlong.h> +#include "last_error.h" #include "assert_static.h" #include <bitset> #include "global_func.h" #include <limits> +#include "int64.h" -using namespace ffs3; +using namespace zen; namespace @@ -58,7 +58,7 @@ Zstring getVolumeName(const Zstring& filename) bool dst::isFatDrive(const Zstring& fileName) //throw() { - using namespace ffs3; + using namespace zen; const size_t BUFFER_SIZE = MAX_PATH + 1; wchar_t fsName[BUFFER_SIZE]; @@ -90,6 +90,40 @@ bool dst::isFatDrive(const Zstring& fileName) //throw() namespace { +//convert zen::UInt64 and zen::Int64 to FILETIME +inline +FILETIME toFiletime(zen::Int64 number) +{ + const zen::UInt64 unsig = to<zen::UInt64>(number); + + FILETIME output = {}; + output.dwLowDateTime = unsig.getLo(); + output.dwHighDateTime = unsig.getHi(); + return output; +} + +FILETIME toFiletime(zen::UInt64 number) +{ + FILETIME output = {}; + output.dwLowDateTime = number.getLo(); + output.dwHighDateTime = number.getHi(); + return output; +} + +inline +zen::UInt64 toUInt64(const FILETIME& fileTime) +{ + return zen::UInt64(fileTime.dwLowDateTime, fileTime.dwHighDateTime); +} + + +inline +zen::Int64 toInt64(const FILETIME& fileTime) +{ + return to<zen::Int64>(zen::UInt64(fileTime.dwLowDateTime, fileTime.dwHighDateTime)); +} + + FILETIME utcToLocal(const FILETIME& utcTime) //throw (std::runtime_error) { //treat binary local time representation (which is invariant under DST time zone shift) as logical UTC: @@ -98,8 +132,9 @@ FILETIME utcToLocal(const FILETIME& utcTime) //throw (std::runtime_error) &utcTime, //__in const FILETIME *lpFileTime, &localTime)) //__out LPFILETIME lpLocalFileTime { - const wxString errorMessage = wxString(_("Conversion error:")) + wxT(" FILETIME -> local FILETIME: ") + - wxT("(") + wxULongLong(utcTime.dwHighDateTime, utcTime.dwLowDateTime).ToString() + wxT(") ") + wxT("\n\n") + ffs3::getLastErrorFormatted(); + const wxString errorMessage = wxString(_("Conversion error:")) + wxT(" FILETIME -> local FILETIME: ") + wxT("(") + + wxT("High: ") + Zstring::fromNumber(utcTime.dwHighDateTime) + wxT(" ") + + wxT("Low: ") + Zstring::fromNumber(utcTime.dwLowDateTime) + wxT(") ") + wxT("\n\n") + zen::getLastErrorFormatted(); throw std::runtime_error(std::string((errorMessage).ToUTF8())); } return localTime; @@ -114,58 +149,15 @@ FILETIME localToUtc(const FILETIME& localTime) //throw (std::runtime_error) &localTime, //__in const FILETIME *lpLocalFileTime, &utcTime)) //__out LPFILETIME lpFileTime { - const wxString errorMessage = wxString(_("Conversion error:")) + wxT(" local FILETIME -> FILETIME: ") + - wxT("(") + wxULongLong(localTime.dwHighDateTime, localTime.dwLowDateTime).ToString() + wxT(") ") + wxT("\n\n") + ffs3::getLastErrorFormatted(); + const wxString errorMessage = wxString(_("Conversion error:")) + wxT(" local FILETIME -> FILETIME: ") + wxT("(") + + wxT("High: ") + Zstring::fromNumber(localTime.dwHighDateTime) + wxT(" ") + + wxT("Low: ") + Zstring::fromNumber(localTime.dwLowDateTime) + wxT(") ") + wxT("\n\n") + zen::getLastErrorFormatted(); throw std::runtime_error(std::string((errorMessage).ToUTF8())); } return utcTime; } -int cmpFileTime(const FILETIME& a, const FILETIME& b) -{ - if (a.dwHighDateTime != b.dwHighDateTime) - return a.dwHighDateTime - b.dwHighDateTime; - return a.dwLowDateTime - b.dwLowDateTime; -} - - -template <class T> //convert wxULongLong and wxLongLong to FILETIME -inline -FILETIME toFiletime(const T& number) -{ - assert_static(sizeof(DWORD) == sizeof(long)); - assert_static(sizeof(long) == 4); - assert(number.GetHi() >= 0); //for wxLongLong - - FILETIME output = {}; - output.dwHighDateTime = number.GetHi(); - output.dwLowDateTime = number.GetLo(); - return output; -} - - -inline -wxULongLong toULonglong(const FILETIME& fileTime) -{ - assert_static(sizeof(DWORD) == sizeof(long)); - assert_static(sizeof(long) == 4); - - return wxULongLong(fileTime.dwHighDateTime, fileTime.dwLowDateTime); -} - - -inline -wxLongLong toLonglong(const FILETIME& fileTime) -{ - assert_static(sizeof(DWORD) == sizeof(long)); - assert_static(sizeof(long) == 4); - assert(fileTime.dwHighDateTime <= static_cast<unsigned long>(std::numeric_limits<long>::max())); - - return wxLongLong(fileTime.dwHighDateTime, fileTime.dwLowDateTime); -} - - //struct FILETIME {DWORD dwLowDateTime; DWORD dwHighDateTime;}; const FILETIME FAT_MIN_TIME = {13374976, 27846544}; //1980 \ both are valid max/min FAT dates for 2 second precision const FILETIME FAT_MAX_TIME = {14487552, 37251238}; //2107 / @@ -189,40 +181,38 @@ const size_t WRITE_TIME_HASH_BITS = CREATE_TIME_INFO_BITS - INDICATOR_EXISTING_B template <size_t precision> -FILETIME encodeRawInformation(wxULongLong rawInfo) +FILETIME encodeRawInformation(zen::UInt64 rawInfo) { rawInfo *= precision; - rawInfo += toULonglong(FAT_MIN_TIME); + rawInfo += toUInt64(FAT_MIN_TIME); - assert(rawInfo <= toULonglong(FAT_MAX_TIME)); + assert(rawInfo <= toUInt64(FAT_MAX_TIME)); return toFiletime(rawInfo); } template <size_t precision> -wxULongLong extractRawInformation(const FILETIME& createTime) +zen::UInt64 extractRawInformation(const FILETIME& createTime) { - assert(cmpFileTime(FAT_MIN_TIME, createTime) <= 0); - assert(cmpFileTime(createTime, FAT_MAX_TIME) <= 0); + assert(toUInt64(FAT_MIN_TIME) <= toUInt64(createTime)); + assert(toUInt64(createTime) <= toUInt64(FAT_MAX_TIME)); //FAT create time ranges from 1980 - 2107 (2^7 years) with 1/100 seconds precision - wxULongLong rawInfo = toULonglong(createTime); - assert_static(sizeof(DWORD) == sizeof(long)); - assert_static(sizeof(long) == 4); + zen::UInt64 rawInfo = toUInt64(createTime); - rawInfo -= toULonglong(FAT_MIN_TIME); + rawInfo -= toUInt64(FAT_MIN_TIME); rawInfo /= precision; //reduce precision (FILETIME has unit 10^-7 s) - assert(cmpFileTime(encodeRawInformation<precision>(rawInfo), createTime) == 0); //must be reversible + assert(toUInt64(encodeRawInformation<precision>(rawInfo)) == toUInt64(createTime)); //must be reversible return rawInfo; } //convert write time to it's minimal representation (no restriction to FAT range "1980 - 2107") -wxULongLong extractRawWriteTime(const FILETIME& writeTime) +zen::UInt64 extractRawWriteTime(const FILETIME& writeTime) { - wxULongLong rawInfo = toULonglong(writeTime); - assert(rawInfo % PRECISION_WRITE_TIME == 0); + zen::UInt64 rawInfo = toUInt64(writeTime); + assert(rawInfo % PRECISION_WRITE_TIME == 0U); rawInfo /= PRECISION_WRITE_TIME; //reduce precision (FILETIME has unit 10^-7 s) return rawInfo; } @@ -231,9 +221,9 @@ wxULongLong extractRawWriteTime(const FILETIME& writeTime) //files with different resolution than 2 seconds are rounded up when written to FAT FILETIME roundToFatWriteTime(const FILETIME& writeTime) { - wxULongLong rawData = toULonglong(writeTime); + zen::UInt64 rawData = toUInt64(writeTime); - if (rawData % PRECISION_WRITE_TIME != 0) + if (rawData % PRECISION_WRITE_TIME != 0U) rawData += PRECISION_WRITE_TIME; rawData /= PRECISION_WRITE_TIME; @@ -250,7 +240,7 @@ std::bitset<UTC_LOCAL_OFFSET_BITS> getUtcLocalShift() const FILETIME localTime = utcToLocal(utcTime); - const int timeShiftSec = ((toLonglong(localTime) - toLonglong(utcTime)) / 10000000).ToLong(); //time shift in seconds + const int timeShiftSec = to<int>((toInt64(localTime) - toInt64(utcTime)) / 10000000); //time shift in seconds const int timeShiftQuarter = timeShiftSec / (60 * 15); //time shift in quarter-hours @@ -260,7 +250,7 @@ std::bitset<UTC_LOCAL_OFFSET_BITS> getUtcLocalShift() timeShiftSec % (60 * 15) != 0) //all known time shift have at least 15 minute granularity! { const wxString errorMessage = wxString(_("Conversion error:")) + wxT(" Unexpected UTC <-> local time shift: ") + - wxT("(") + wxLongLong(timeShiftSec).ToString() + wxT(") ") + wxT("\n\n") + ffs3::getLastErrorFormatted(); + wxT("(") + Zstring::fromNumber(timeShiftSec) + wxT(") ") + wxT("\n\n") + zen::getLastErrorFormatted(); throw std::runtime_error(std::string((errorMessage).ToUTF8())); } @@ -279,26 +269,26 @@ int convertUtcLocalShift(std::bitset<UTC_LOCAL_OFFSET_BITS> rawShift) assert_static(UTC_LOCAL_OFFSET_BITS <= sizeof(unsigned long) * 8); return hasSign ? - rawShift.to_ulong() * 15 * 60 * -1 : - rawShift.to_ulong() * 15 * 60; + static_cast<int>(rawShift.to_ulong()) * 15 * 60 * -1 : + static_cast<int>(rawShift.to_ulong()) * 15 * 60; } } bool dst::fatHasUtcEncoded(const RawTime& rawTime) //"createTimeRaw" as retrieved by ::FindFirstFile() and ::GetFileAttributesEx(); throw (std::runtime_error) { - if (cmpFileTime(rawTime.createTimeRaw, FAT_MIN_TIME) < 0 || - cmpFileTime(FAT_MAX_TIME, rawTime.createTimeRaw) < 0) + if (toUInt64(rawTime.createTimeRaw) < toUInt64(FAT_MIN_TIME) || + toUInt64(FAT_MAX_TIME) < toUInt64(rawTime.createTimeRaw)) { assert(false); //shouldn't be possible according to FAT specification return false; } - const wxULongLong rawInfo = extractRawInformation<PRECISION_CREATE_TIME>(utcToLocal(rawTime.createTimeRaw)); + const zen::UInt64 rawInfo = extractRawInformation<PRECISION_CREATE_TIME>(utcToLocal(rawTime.createTimeRaw)); assert_static(WRITE_TIME_HASH_BITS == 30); - return (extractRawWriteTime(utcToLocal(rawTime.writeTimeRaw)) & 0x3FFFFFFF) == (rawInfo & 0x3FFFFFFF) && //ensure write time wasn't changed externally - rawInfo >> (CREATE_TIME_INFO_BITS - INDICATOR_EXISTING_BITS) == 1; //extended data available + return (extractRawWriteTime(utcToLocal(rawTime.writeTimeRaw)) & 0x3FFFFFFFU) == (rawInfo & 0x3FFFFFFFU) && //ensure write time wasn't changed externally + rawInfo >> (CREATE_TIME_INFO_BITS - INDICATOR_EXISTING_BITS) == 1U; //extended data available } @@ -309,19 +299,19 @@ dst::RawTime dst::fatEncodeUtcTime(const FILETIME& writeTimeRealUtc) //throw (st //create time lets us store 40 bit of information //indicator that utc time is encoded -> hopefully results in a date long way in the future; but even if this bit is accidentally set, we still have the hash! - wxULongLong data = 1; + zen::UInt64 data = 1U; const std::bitset<UTC_LOCAL_OFFSET_BITS> utcShift = getUtcLocalShift(); data <<= UTC_LOCAL_OFFSET_BITS; data |= utcShift.to_ulong(); data <<= WRITE_TIME_HASH_BITS; - data |= extractRawWriteTime(utcToLocal(fatWriteTimeUtc)) & 0x3FFFFFFF; //trim to last 30 bit of information + data |= extractRawWriteTime(utcToLocal(fatWriteTimeUtc)) & 0x3FFFFFFFU; //trim to last 30 bit of information assert_static(WRITE_TIME_HASH_BITS == 30); const FILETIME encodedData = localToUtc(encodeRawInformation<PRECISION_CREATE_TIME>(data)); //localToUtc: make sure data is physically saved as FAT local time - assert(cmpFileTime(FAT_MIN_TIME, encodedData) <= 0); - assert(cmpFileTime(encodedData, FAT_MAX_TIME) <= 0); + assert(toUInt64(FAT_MIN_TIME) <= toUInt64(encodedData)); + assert(toUInt64(encodedData) <= toUInt64(FAT_MAX_TIME)); return RawTime(encodedData, fatWriteTimeUtc); //keep compatible with other applications, at least until DST shift actually occurs } @@ -332,14 +322,14 @@ FILETIME dst::fatDecodeUtcTime(const RawTime& rawTime) //return real UTC time; t if (!fatHasUtcEncoded(rawTime)) return rawTime.writeTimeRaw; - const wxULongLong rawInfo = extractRawInformation<PRECISION_CREATE_TIME>(utcToLocal(rawTime.createTimeRaw)); + const zen::UInt64 rawInfo = extractRawInformation<PRECISION_CREATE_TIME>(utcToLocal(rawTime.createTimeRaw)); - const std::bitset<UTC_LOCAL_OFFSET_BITS> rawShift(static_cast<int>(((rawInfo >> WRITE_TIME_HASH_BITS) & 0x7F).ToULong())); //static_cast<int>: a shame MSC... + const std::bitset<UTC_LOCAL_OFFSET_BITS> rawShift(zen::to<int>((rawInfo >> WRITE_TIME_HASH_BITS) & 0x7FU)); //static_cast<int>: a shame MSC... "unsigned long" should be supported instead! assert_static(UTC_LOCAL_OFFSET_BITS == 7); const int timeShiftSec = convertUtcLocalShift(rawShift); const FILETIME writeTimeLocal = utcToLocal(rawTime.writeTimeRaw); - const wxLongLong realUTC = toLonglong(writeTimeLocal) - wxLongLong(timeShiftSec) * 10000000; + const zen::Int64 realUTC = toInt64(writeTimeLocal) - zen::Int64(timeShiftSec) * 10000000; return toFiletime(realUTC); } diff --git a/shared/file_drop.h b/shared/file_drop.h new file mode 100644 index 00000000..c85d4cbb --- /dev/null +++ b/shared/file_drop.h @@ -0,0 +1,113 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef FILE_DROP_H_INCLUDED +#define FILE_DROP_H_INCLUDED + +#include <wx/event.h> +#include <wx/dnd.h> + +namespace zen +{ +//register simple file drop event (without issue of freezing dialogs and without wxFileDropTarget overdesign) + +//1. have a window emit FFS_DROP_FILE_EVENT +void setupFileDrop(wxWindow& wnd); + +//2. register events: +//wnd.Connect (FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(MyDlg::OnFilesDropped), NULL, this); +//wnd.Disconnect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(MyDlg::OnFilesDropped), NULL, this); + +//3. do something: +//void MyDlg::OnFilesDropped(FFSFileDropEvent& event); + + + + + + + + + + + + + + + + + +inline +wxEventType createNewEventType() +{ + //inline functions have external linkage by default => this static is also extern, i.e. program wide unique! but defined in a header... ;) + static wxEventType dummy = wxNewEventType(); + return dummy; +} + +//define new event type +const wxEventType FFS_DROP_FILE_EVENT = createNewEventType(); + +class FFSFileDropEvent : public wxCommandEvent +{ +public: + FFSFileDropEvent(const std::vector<wxString>& filesDropped, const wxWindow& dropWindow, wxPoint dropPos) : + wxCommandEvent(FFS_DROP_FILE_EVENT), + filesDropped_(filesDropped), + dropWindow_(dropWindow), + dropPos_(dropPos) {} + + virtual wxEvent* Clone() const + { + return new FFSFileDropEvent(filesDropped_, dropWindow_, dropPos_); + } + + const std::vector<wxString>& getFiles() const { return filesDropped_; } + const wxWindow& getDropWindow() const { return dropWindow_; } + wxPoint getDropPosition() const { return dropPos_; } //position relative to drop window + +private: + const std::vector<wxString> filesDropped_; + const wxWindow& dropWindow_; + wxPoint dropPos_; +}; + +typedef void (wxEvtHandler::*FFSFileDropEventFunction)(FFSFileDropEvent&); + +#define FFSFileDropEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(FFSFileDropEventFunction, &func) + + +class WindowDropTarget : public wxFileDropTarget +{ +public: + WindowDropTarget(wxWindow& dropWindow) : dropWindow_(dropWindow) {} + + virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& fileArray) + { + std::vector<wxString> filenames(fileArray.begin(), fileArray.end()); + if (!filenames.empty()) + { + //create a custom event on drop window: execute event after file dropping is completed! (after mouse is released) + FFSFileDropEvent evt(filenames, dropWindow_, wxPoint(x, y)); + dropWindow_.GetEventHandler()->AddPendingEvent(evt); + } + return true; + } + +private: + wxWindow& dropWindow_; +}; + + +inline +void setupFileDrop(wxWindow& wnd) +{ + wnd.SetDropTarget(new WindowDropTarget(wnd)); //takes ownership +} +} + +#endif // FILE_DROP_H_INCLUDED diff --git a/shared/file_error.h b/shared/file_error.h index e8497a92..7325e14b 100644 --- a/shared/file_error.h +++ b/shared/file_error.h @@ -10,7 +10,7 @@ #include <wx/string.h> -namespace ffs3 +namespace zen { class FileError //Exception base class used to notify file/directory copy/delete errors { diff --git a/shared/file_handling.cpp b/shared/file_handling.cpp index 178fe26f..5dc1757c 100644 --- a/shared/file_handling.cpp +++ b/shared/file_handling.cpp @@ -7,19 +7,17 @@ #include "file_handling.h" #include <map> #include <algorithm> -#include <boost/scoped_array.hpp> #include <boost/bind.hpp> #include <stdexcept> -#include "system_func.h" -#include "global_func.h" +#include "last_error.h" #include "system_constants.h" #include "file_traverser.h" #include "string_conv.h" -#include "loki/TypeManip.h" #include "loki/ScopeGuard.h" #include "symlink_target.h" #include "file_io.h" #include "i18n.h" +#include "assert_static.h" #ifdef FFS_WIN #include "privilege.h" @@ -41,11 +39,10 @@ #endif #endif -using ffs3::FileError; -using namespace ffs3; +using namespace zen; -bool ffs3::fileExists(const Zstring& filename) +bool zen::fileExists(const Zstring& filename) { //symbolic links (broken or not) are also treated as existing files! #ifdef FFS_WIN @@ -62,7 +59,7 @@ bool ffs3::fileExists(const Zstring& filename) } -bool ffs3::dirExists(const Zstring& dirname) +bool zen::dirExists(const Zstring& dirname) { //symbolic links (broken or not) are also treated as existing directories! #ifdef FFS_WIN @@ -79,7 +76,7 @@ bool ffs3::dirExists(const Zstring& dirname) } -bool ffs3::symlinkExists(const Zstring& objname) +bool zen::symlinkExists(const Zstring& objname) { #ifdef FFS_WIN const DWORD ret = ::GetFileAttributes(applyLongPathPrefix(objname).c_str()); @@ -93,7 +90,7 @@ bool ffs3::symlinkExists(const Zstring& objname) } -bool ffs3::somethingExists(const Zstring& objname) //throw() check whether any object with this name exists +bool zen::somethingExists(const Zstring& objname) //throw() check whether any object with this name exists { #ifdef FFS_WIN return ::GetFileAttributes(applyLongPathPrefix(objname).c_str()) != INVALID_FILE_ATTRIBUTES; @@ -108,10 +105,10 @@ bool ffs3::somethingExists(const Zstring& objname) //throw() check whether #ifdef FFS_WIN namespace { -wxULongLong getFileSizeSymlink(const Zstring& linkName) //throw (FileError) +zen::UInt64 getFileSizeSymlink(const Zstring& linkName) //throw (FileError) { //open handle to target of symbolic link - const HANDLE hFile = ::CreateFile(ffs3::applyLongPathPrefix(linkName).c_str(), + const HANDLE hFile = ::CreateFile(zen::applyLongPathPrefix(linkName).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, @@ -120,52 +117,52 @@ wxULongLong getFileSizeSymlink(const Zstring& linkName) //throw (FileError) NULL); if (hFile == INVALID_HANDLE_VALUE) { - const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + ffs3::zToWx(linkName) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zen::zToWx(linkName) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hFile); (void)dummy; //silence warning "unused variable" - BY_HANDLE_FILE_INFORMATION fileInfoByHandle = {}; - if (!::GetFileInformationByHandle(hFile, &fileInfoByHandle)) + BY_HANDLE_FILE_INFORMATION fileInfo = {}; + if (!::GetFileInformationByHandle(hFile, &fileInfo)) { - const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + ffs3::zToWx(linkName) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zen::zToWx(linkName) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } - return wxULongLong(fileInfoByHandle.nFileSizeHigh, fileInfoByHandle.nFileSizeLow); + return zen::UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); } } #endif -wxULongLong ffs3::getFilesize(const Zstring& filename) //throw (FileError) +zen::UInt64 zen::getFilesize(const Zstring& filename) //throw (FileError) { #ifdef FFS_WIN - WIN32_FIND_DATA fileMetaData; - const HANDLE searchHandle = ::FindFirstFile(applyLongPathPrefix(filename).c_str(), &fileMetaData); + WIN32_FIND_DATA fileInfo = {}; + const HANDLE searchHandle = ::FindFirstFile(applyLongPathPrefix(filename).c_str(), &fileInfo); if (searchHandle == INVALID_HANDLE_VALUE) { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(filename) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } ::FindClose(searchHandle); - const bool isSymbolicLink = (fileMetaData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + const bool isSymbolicLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; if (isSymbolicLink) return getFileSizeSymlink(filename); //throw (FileError) - return wxULongLong(fileMetaData.nFileSizeHigh, fileMetaData.nFileSizeLow); + return zen::UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); #elif defined FFS_LINUX - struct stat fileInfo; + struct stat fileInfo = {}; if (::stat(filename.c_str(), &fileInfo) != 0) //follow symbolic links { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(filename) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } - return fileInfo.st_size; + return zen::UInt64(fileInfo.st_size); #endif } @@ -175,16 +172,15 @@ namespace #ifdef FFS_WIN DWORD retrieveVolumeSerial(const Zstring& pathName) //return 0 on error! { - const size_t bufferSize = std::max(pathName.size(), static_cast<size_t>(10000)); - boost::scoped_array<wchar_t> buffer(new wchar_t[bufferSize]); + std::vector<wchar_t> buffer(std::max(pathName.size(), static_cast<size_t>(10000))); //full pathName need not yet exist! if (!::GetVolumePathName(pathName.c_str(), //__in LPCTSTR lpszFileName, - buffer.get(), //__out LPTSTR lpszVolumePathName, - static_cast<DWORD>(bufferSize))) //__in DWORD cchBufferLength + &buffer[0], //__out LPTSTR lpszVolumePathName, + static_cast<DWORD>(buffer.size()))) //__in DWORD cchBufferLength return 0; - Zstring volumePath = buffer.get(); + Zstring volumePath = &buffer[0]; if (!volumePath.EndsWith(common::FILE_NAME_SEPARATOR)) volumePath += common::FILE_NAME_SEPARATOR; @@ -225,7 +221,7 @@ dev_t retrieveVolumeSerial(const Zstring& pathName) //return 0 on error! } -ffs3::ResponseSameVol ffs3::onSameVolume(const Zstring& folderLeft, const Zstring& folderRight) //throw() +zen::ResponseSameVol zen::onSameVolume(const Zstring& folderLeft, const Zstring& folderRight) //throw() { #ifdef FFS_WIN typedef DWORD VolSerial; @@ -241,7 +237,7 @@ ffs3::ResponseSameVol ffs3::onSameVolume(const Zstring& folderLeft, const Zstrin } -bool ffs3::removeFile(const Zstring& filename) //throw (FileError); +bool zen::removeFile(const Zstring& filename) //throw (FileError); { #ifdef FFS_WIN //remove file, support for \\?\-prefix @@ -264,7 +260,8 @@ bool ffs3::removeFile(const Zstring& filename) //throw (FileError); } #endif //eval error code before next call - const wxString errorMessage = wxString(_("Error deleting file:")) + wxT("\n\"") + zToWx(filename) + wxT("\"") + wxT("\n\n") + ffs3::getLastErrorFormatted(); + wxString errorMessage = wxString(_("Error deleting file:")) + wxT("\n\"") + zToWx(filename) + wxT("\""); + errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(); //no error situation if file is not existing! manual deletion relies on it! //perf: place check in error handling block @@ -293,7 +290,7 @@ DEFINE_NEW_FILE_ERROR(ErrorDifferentVolume); //throw (FileError); ErrorDifferentVolume if it is due to moving file to another volume void renameFileInternal(const Zstring& oldName, const Zstring& newName) //throw (FileError: ErrorDifferentVolume, ErrorTargetExisting) { - using namespace ffs3; //for zToWx() + using namespace zen; //for zToWx() #ifdef FFS_WIN const Zstring oldNameFmt = applyLongPathPrefix(oldName); @@ -333,8 +330,10 @@ void renameFileInternal(const Zstring& oldName, const Zstring& newName) //throw } const DWORD lastError = ::GetLastError(); - const wxString errorMessage = wxString(_("Error moving file:")) + wxT("\n\"") + zToWx(oldName) + wxT("\" ->\n\"") + zToWx(newName) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); + + wxString errorMessage = wxString(_("Error moving file:")) + wxT("\n\"") + zToWx(oldName) + wxT("\" ->\n\"") + zToWx(newName) + wxT("\""); + errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(lastError); + if (lastError == ERROR_NOT_SAME_DEVICE) throw ErrorDifferentVolume(errorMessage); else if (lastError == ERROR_FILE_EXISTS) @@ -347,8 +346,10 @@ void renameFileInternal(const Zstring& oldName, const Zstring& newName) //throw if (::rename(oldName.c_str(), newName.c_str()) != 0) { const int lastError = errno; - const wxString errorMessage = wxString(_("Error moving file:")) + wxT("\n\"") + zToWx(oldName) + wxT("\" ->\n\"") + zToWx(newName) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); + + wxString errorMessage = wxString(_("Error moving file:")) + wxT("\n\"") + zToWx(oldName) + wxT("\" ->\n\"") + zToWx(newName) + wxT("\""); + errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(lastError); + if (lastError == EXDEV) throw ErrorDifferentVolume(errorMessage); else if (lastError == EEXIST) @@ -367,21 +368,21 @@ void renameFileInternal(const Zstring& oldName, const Zstring& newName) //throw template <typename Function> Zstring getFilenameFmt(const Zstring& filename, Function fun) //throw(); returns empty string on error { - const Zstring filenameFmt = ffs3::applyLongPathPrefix(filename); + const Zstring filenameFmt = zen::applyLongPathPrefix(filename); const DWORD bufferSize = fun(filenameFmt.c_str(), NULL, 0); if (bufferSize == 0) return Zstring(); - boost::scoped_array<wchar_t> buffer(new wchar_t[bufferSize]); + std::vector<wchar_t> buffer(bufferSize); const DWORD rv = fun(filenameFmt.c_str(), //__in LPCTSTR lpszShortPath, - buffer.get(), //__out LPTSTR lpszLongPath, - bufferSize); //__in DWORD cchBuffer - if (rv == 0 || rv >= bufferSize) + &buffer[0], //__out LPTSTR lpszLongPath, + static_cast<DWORD>(buffer.size())); //__in DWORD cchBuffer + if (rv == 0 || rv >= buffer.size()) return Zstring(); - return buffer.get(); + return &buffer[0]; } @@ -398,7 +399,7 @@ Zstring createTemp8Dot3Name(const Zstring& fileName) //find a unique 8.3 short n for (int index = 0; index < 100000000; ++index) //filename must be representable by <= 8 characters { const Zstring output = pathPrefix + Zstring::fromNumber(index) + Zchar('.') + extension; - if (!ffs3::somethingExists(output)) //ensure uniqueness + if (!zen::somethingExists(output)) //ensure uniqueness return output; } @@ -409,12 +410,12 @@ Zstring createTemp8Dot3Name(const Zstring& fileName) //find a unique 8.3 short n //try to handle issues with already existing short 8.3 file names on Windows 7 bool fix8Dot3NameClash(const Zstring& oldName, const Zstring& newName) //throw (FileError); return "true" if rename operation succeeded { - using namespace ffs3; + using namespace zen; if (newName.find(common::FILE_NAME_SEPARATOR) == Zstring::npos) return false; - if (ffs3::somethingExists(newName)) //name OR directory! + if (zen::somethingExists(newName)) //name OR directory! { const Zstring fileNameOrig = newName.AfterLast(common::FILE_NAME_SEPARATOR); //returns the whole string if ch not found const Zstring fileNameShort = getFilenameFmt(newName, ::GetShortPathName).AfterLast(common::FILE_NAME_SEPARATOR); //throw() returns empty string on error @@ -436,7 +437,7 @@ bool fix8Dot3NameClash(const Zstring& oldName, const Zstring& newName) //throw //move already existing short name out of the way for now renameFileInternal(unrelatedPathLong, parkedTarget); //throw (FileError: ErrorDifferentVolume); - //DON'T call ffs3::renameFile() to avoid reentrance! + //DON'T call zen::renameFile() to avoid reentrance! //schedule cleanup; the file system should assign this unrelated file a new (unique) short name Loki::ScopeGuard guard = Loki::MakeGuard(renameFileInternal, parkedTarget, unrelatedPathLong);//equivalent to Boost.ScopeExit in this case @@ -453,7 +454,7 @@ bool fix8Dot3NameClash(const Zstring& oldName, const Zstring& newName) //throw //rename file: no copying!!! -void ffs3::renameFile(const Zstring& oldName, const Zstring& newName) //throw (FileError: ErrorDifferentVolume, ErrorTargetExisting); +void zen::renameFile(const Zstring& oldName, const Zstring& newName) //throw (FileError: ErrorDifferentVolume, ErrorTargetExisting); { try { @@ -470,16 +471,16 @@ void ffs3::renameFile(const Zstring& oldName, const Zstring& newName) //throw (F } -using ffs3::CallbackMoveFile; +using zen::CallbackMoveFile; -class CopyCallbackImpl : public ffs3::CallbackCopyFile //callback functionality +class CopyCallbackImpl : public zen::CallbackCopyFile //callback functionality { public: CopyCallbackImpl(const Zstring& sourceFile, CallbackMoveFile& callback) : sourceFile_(sourceFile), moveCallback(callback) {} virtual void deleteTargetFile(const Zstring& targetFile) { assert(!fileExists(targetFile)); } - virtual Response updateCopyStatus(const wxULongLong& totalBytesTransferred) + virtual Response updateCopyStatus(zen::UInt64 totalBytesTransferred) { switch (moveCallback.requestUiRefresh(sourceFile_)) { @@ -498,7 +499,7 @@ private: }; -void ffs3::moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); +void zen::moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); { //call back once per file (moveFile() is called by moveDirectory()) if (callback) @@ -545,7 +546,7 @@ void ffs3::moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool i namespace { -class TraverseOneLevel : public ffs3::TraverseCallback +class TraverseOneLevel : public zen::TraverseCallback { public: typedef std::pair<Zstring, Zstring> NamePair; @@ -585,7 +586,7 @@ private: }; -struct RemoveCallbackImpl : public ffs3::CallbackRemoveDir +struct RemoveCallbackImpl : public zen::CallbackRemoveDir { RemoveCallbackImpl(const Zstring& sourceDir, const Zstring& targetDir, @@ -601,8 +602,8 @@ struct RemoveCallbackImpl : public ffs3::CallbackRemoveDir case CallbackMoveFile::CONTINUE: break; case CallbackMoveFile::CANCEL: //a user aborted operation IS an error condition! - throw ffs3::FileError(wxString(_("Error moving directory:")) + wxT("\n\"") + ffs3::zToWx(sourceDir_) + wxT("\" ->\n\"") + - ffs3::zToWx(targetDir_) + wxT("\"") + wxT("\n\n") + _("Operation aborted!")); + throw zen::FileError(wxString(_("Error moving directory:")) + wxT("\n\"") + zen::zToWx(sourceDir_) + wxT("\" ->\n\"") + + zen::zToWx(targetDir_) + wxT("\"") + wxT("\n\n") + _("Operation aborted!")); } } @@ -616,7 +617,7 @@ private: void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); { - using namespace ffs3; + using namespace zen; //call back once per folder if (callback) @@ -671,7 +672,7 @@ void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool //move files for (TraverseOneLevel::NameList::const_iterator i = fileList.begin(); i != fileList.end(); ++i) - ffs3::moveFile(i->second, targetDirFormatted + i->first, ignoreExisting, callback); //throw (FileError: ErrorTargetExisting); + zen::moveFile(i->second, targetDirFormatted + i->first, ignoreExisting, callback); //throw (FileError: ErrorTargetExisting); //move directories for (TraverseOneLevel::NameList::const_iterator i = dirList.begin(); i != dirList.end(); ++i) @@ -686,7 +687,7 @@ void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool } -void ffs3::moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); +void zen::moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); { #ifdef FFS_WIN const Zstring& sourceDirFormatted = sourceDir; @@ -707,7 +708,7 @@ void ffs3::moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, boo } -class FilesDirsOnlyTraverser : public ffs3::TraverseCallback +class FilesDirsOnlyTraverser : public zen::TraverseCallback { public: FilesDirsOnlyTraverser(std::vector<Zstring>& files, std::vector<Zstring>& dirs) : @@ -741,7 +742,7 @@ private: }; -void ffs3::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback) +void zen::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback) { //no error situation if directory is not existing! manual deletion relies on it! if (!somethingExists(directory)) @@ -764,7 +765,7 @@ void ffs3::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback #endif { wxString errorMessage = wxString(_("Error deleting directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } if (callback) callback->notifyDeletion(directory); //once per symlink return; @@ -775,7 +776,7 @@ void ffs3::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback //get all files and directories from current directory (WITHOUT subdirectories!) FilesDirsOnlyTraverser traverser(fileList, dirList); - ffs3::traverseFolder(directory, false, traverser); //don't follow symlinks + zen::traverseFolder(directory, false, traverser); //don't follow symlinks //delete files for (std::vector<Zstring>::const_iterator i = fileList.begin(); i != fileList.end(); ++i) @@ -796,13 +797,13 @@ void ffs3::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback #endif { wxString errorMessage = wxString(_("Error deleting directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } if (callback) callback->notifyDeletion(directory); //and once per folder } -void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, bool deRefSymlinks) //throw (FileError) +void zen::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, bool deRefSymlinks) //throw (FileError) { #ifdef FFS_WIN FILETIME creationTime = {}; @@ -815,7 +816,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo &sourceAttr)) //__out LPVOID lpFileInformation { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } const bool isReparsePoint = (sourceAttr.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; @@ -833,7 +834,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo if (hSource == INVALID_HANDLE_VALUE) { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hSource); @@ -845,7 +846,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo &lastWriteTime)) //__out_opt LPFILETIME lpLastWriteTime { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } } else @@ -892,7 +893,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo if (hTarget == INVALID_HANDLE_VALUE) { wxString errorMessage = wxString(_("Error changing modification time:")) + wxT("\n\"") + zToWx(targetObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hTarget); (void)dummy; //silence warning "unused variable" @@ -903,11 +904,11 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo &lastWriteTime)) { wxString errorMessage = wxString(_("Error changing modification time:")) + wxT("\n\"") + zToWx(targetObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } #ifndef NDEBUG //dst hack: verify data written - if (dst::isFatDrive(targetObj) && !ffs3::dirExists(targetObj)) //throw() + if (dst::isFatDrive(targetObj) && !zen::dirExists(targetObj)) //throw() { WIN32_FILE_ATTRIBUTE_DATA debugeAttr = {}; assert(::GetFileAttributesEx(applyLongPathPrefix(targetObj).c_str(), //__in LPCTSTR lpFileName, @@ -926,7 +927,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo if (::stat(sourceObj.c_str(), &objInfo) != 0) //read file attributes from source directory { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } struct utimbuf newTimes = {}; @@ -937,7 +938,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo if (::utime(targetObj.c_str(), &newTimes) != 0) //return value not evaluated! { wxString errorMessage = wxString(_("Error changing modification time:")) + wxT("\n\"") + zToWx(targetObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } } else @@ -946,7 +947,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo if (::lstat(sourceObj.c_str(), &objInfo) != 0) //read file attributes from source directory { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } struct timeval newTimes[2] = {}; @@ -959,7 +960,7 @@ void ffs3::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, boo if (::lutimes(targetObj.c_str(), newTimes) != 0) //return value not evaluated! { wxString errorMessage = wxString(_("Error changing modification time:")) + wxT("\n\"") + zToWx(targetObj) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } } #endif @@ -974,7 +975,7 @@ struct TryCleanUp { try { - ffs3::removeDirectory(dirname, NULL); + zen::removeDirectory(dirname, NULL); } catch (...) {} } @@ -983,7 +984,7 @@ struct TryCleanUp { try { - ffs3::removeFile(filename); + zen::removeFile(filename); } catch (...) {} } @@ -994,7 +995,7 @@ struct TryCleanUp Zstring resolveDirectorySymlink(const Zstring& dirLinkName) //get full target path of symbolic link to a directory; throw (FileError) { //open handle to target of symbolic link - const HANDLE hDir = ::CreateFile(ffs3::applyLongPathPrefix(dirLinkName).c_str(), + const HANDLE hDir = ::CreateFile(zen::applyLongPathPrefix(dirLinkName).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, @@ -1003,8 +1004,8 @@ Zstring resolveDirectorySymlink(const Zstring& dirLinkName) //get full target pa NULL); if (hDir == INVALID_HANDLE_VALUE) { - wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(dirLinkName) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(dirLinkName) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hDir); @@ -1032,8 +1033,8 @@ Zstring resolveDirectorySymlink(const Zstring& dirLinkName) //get full target pa 0); //__in DWORD dwFlags if (rv >= BUFFER_SIZE || rv == 0) { - wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(dirLinkName) + wxT("\""); - if (rv == 0) errorMessage += wxT("\n\n") + ffs3::getLastErrorFormatted(); + wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(dirLinkName) + wxT("\""); + if (rv == 0) errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(); throw FileError(errorMessage); } @@ -1046,7 +1047,7 @@ Zstring resolveDirectorySymlink(const Zstring& dirLinkName) //get full target pa //copy SELinux security context void copySecurityContext(const Zstring& source, const Zstring& target, bool derefSymlinks) //throw (FileError) { - using ffs3::zToWx; + using zen::zToWx; security_context_t contextSource = NULL; const int rv = derefSymlinks ? @@ -1059,7 +1060,7 @@ void copySecurityContext(const Zstring& source, const Zstring& target, bool dere return; wxString errorMessage = wxString(_("Error reading security context:")) + wxT("\n\"") + zToWx(source) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy1 = Loki::MakeGuard(::freecon, contextSource); (void)dummy1; //silence warning "unused variable" @@ -1091,7 +1092,7 @@ void copySecurityContext(const Zstring& source, const Zstring& target, bool dere if (rv3 < 0) { wxString errorMessage = wxString(_("Error writing security context:")) + wxT("\n\"") + zToWx(target) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } } #endif //HAVE_SELINUX @@ -1119,7 +1120,7 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de PACL sacl = NULL; //http://msdn.microsoft.com/en-us/library/aa364399(v=VS.85).aspx - const HANDLE hSource = ::CreateFile(ffs3::applyLongPathPrefix(source).c_str(), + const HANDLE hSource = ::CreateFile(zen::applyLongPathPrefix(source).c_str(), READ_CONTROL | ACCESS_SYSTEM_SECURITY, //ACCESS_SYSTEM_SECURITY required for SACL access FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, @@ -1128,8 +1129,8 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de NULL); if (hSource == INVALID_HANDLE_VALUE) { - const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted() + wxT(" (OR)")); + const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted() + wxT(" (OR)")); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hSource); (void)dummy; //silence warning "unused variable" @@ -1146,15 +1147,15 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de &buffer); //__out_opt PSECURITY_DESCRIPTOR *ppSecurityDescriptor if (rc != ERROR_SUCCESS) { - const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted(rc) + wxT(" (R)")); + const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted(rc) + wxT(" (R)")); } Loki::ScopeGuard dummy4 = Loki::MakeGuard(::LocalFree, buffer); (void)dummy4; //silence warning "unused variable" - const Zstring targetFmt = ffs3::applyLongPathPrefix(target); + const Zstring targetFmt = zen::applyLongPathPrefix(target); //read-only file attribute may cause trouble: temporarily reset it const DWORD targetAttr = ::GetFileAttributes(targetFmt.c_str()); @@ -1175,8 +1176,8 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de NULL); // hTemplateFile if (hTarget == INVALID_HANDLE_VALUE) { - const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted() + wxT(" (OW)")); + const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted() + wxT(" (OW)")); } Loki::ScopeGuard dummy2 = Loki::MakeGuard(::CloseHandle, hTarget); (void)dummy2; //silence warning "unused variable" @@ -1193,8 +1194,8 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de if (rc != ERROR_SUCCESS) { - const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted(rc) + wxT(" (W)")); + const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted(rc) + wxT(" (W)")); } #elif defined FFS_LINUX @@ -1210,8 +1211,8 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de ::chown(target.c_str(), fileInfo.st_uid, fileInfo.st_gid) != 0 || // may require admin rights! ::chmod(target.c_str(), fileInfo.st_mode) != 0) { - const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted() + wxT(" (R)")); + const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted() + wxT(" (R)")); } } else @@ -1221,8 +1222,8 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de ::lchown(target.c_str(), fileInfo.st_uid, fileInfo.st_gid) != 0 || // may require admin rights! (!symlinkExists(target) && ::chmod(target.c_str(), fileInfo.st_mode) != 0)) //setting access permissions doesn't make sense for symlinks on Linux: there is no lchmod() { - const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted() + wxT(" (W)")); + const wxString errorMessage = wxString(_("Error copying file permissions:")) + wxT("\n\"") + zToWx(source) + wxT("\" ->\n\"") + zToWx(target) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted() + wxT(" (W)")); } } #endif @@ -1231,9 +1232,9 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de void createDirectoryRecursively(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions, int level) { - using namespace ffs3; + using namespace zen; - if (ffs3::dirExists(directory)) + if (zen::dirExists(directory)) return; if (level == 100) //catch endless recursion @@ -1241,7 +1242,7 @@ void createDirectoryRecursively(const Zstring& directory, const Zstring& templat //try to create parent folders first const Zstring dirParent = directory.BeforeLast(common::FILE_NAME_SEPARATOR); - if (!dirParent.empty() && !ffs3::dirExists(dirParent)) + if (!dirParent.empty() && !zen::dirExists(dirParent)) { //call function recursively const Zstring templateParent = templateDir.BeforeLast(common::FILE_NAME_SEPARATOR); @@ -1263,7 +1264,7 @@ void createDirectoryRecursively(const Zstring& directory, const Zstring& templat { if (level != 0) return; wxString errorMessage = wxString(_("Error creating directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } if (!templateDir.empty()) @@ -1348,7 +1349,7 @@ void createDirectoryRecursively(const Zstring& directory, const Zstring& templat } -void ffs3::createDirectory(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions) +void zen::createDirectory(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions) { //remove trailing separator const Zstring dirFormatted = directory.EndsWith(common::FILE_NAME_SEPARATOR) ? @@ -1363,13 +1364,13 @@ void ffs3::createDirectory(const Zstring& directory, const Zstring& templateDir, } -void ffs3::createDirectory(const Zstring& directory) +void zen::createDirectory(const Zstring& directory) { - ffs3::createDirectory(directory, Zstring(), false); + zen::createDirectory(directory, Zstring(), false); } -void ffs3::copySymlink(const Zstring& sourceLink, const Zstring& targetLink, ffs3::SymlinkType type, bool copyFilePermissions) //throw (FileError) +void zen::copySymlink(const Zstring& sourceLink, const Zstring& targetLink, zen::SymlinkType type, bool copyFilePermissions) //throw (FileError) { const Zstring linkPath = getSymlinkRawTargetString(sourceLink); //accept broken symlinks; throw (FileError) @@ -1386,14 +1387,14 @@ void ffs3::copySymlink(const Zstring& sourceLink, const Zstring& targetLink, ffs (type == SYMLINK_TYPE_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0))) //__in DWORD dwFlags { const wxString errorMessage = wxString(_("Error copying symbolic link:")) + wxT("\n\"") + zToWx(sourceLink) + wxT("\" ->\n\"") + zToWx(targetLink) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } #elif defined FFS_LINUX if (::symlink(linkPath.c_str(), targetLink.c_str()) != 0) { const wxString errorMessage = wxString(_("Error copying symbolic link:")) + wxT("\n\"") + zToWx(sourceLink) + wxT("\" ->\n\"") + zToWx(targetLink) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } #endif @@ -1416,11 +1417,11 @@ namespace { Zstring createTempName(const Zstring& filename) { - Zstring output = filename + ffs3::TEMP_FILE_ENDING; + Zstring output = filename + zen::TEMP_FILE_ENDING; //ensure uniqueness - for (int i = 1; ffs3::somethingExists(output); ++i) - output = filename + Zchar('_') + Zstring::fromNumber(i) + ffs3::TEMP_FILE_ENDING; + for (int i = 1; zen::somethingExists(output); ++i) + output = filename + Zchar('_') + Zstring::fromNumber(i) + zen::TEMP_FILE_ENDING; return output; } @@ -1437,7 +1438,7 @@ DWORD CALLBACK copyCallbackInternal( HANDLE hDestinationFile, LPVOID lpData) { - using ffs3::CallbackCopyFile; + using zen::CallbackCopyFile; //small performance optimization: it seems this callback function is called for every 64 kB (depending on cluster size). static size_t callNr = 0; @@ -1446,7 +1447,7 @@ DWORD CALLBACK copyCallbackInternal( if (lpData != NULL) { //some odd check for some possible(?) error condition - if (totalBytesTransferred.HighPart < 0) //let's see if someone answers the call... + if (totalBytesTransferred.QuadPart < 0) //let's see if someone answers the call... ::MessageBox(NULL, wxT("You've just discovered a bug in WIN32 API function \"CopyFileEx\"! \n\n\ Please write a mail to the author of FreeFileSync at zhnmju123@gmx.de and simply state that\n\ \"totalBytesTransferred.HighPart can be below zero\"!\n\n\ @@ -1456,7 +1457,7 @@ DWORD CALLBACK copyCallbackInternal( CallbackCopyFile* callback = static_cast<CallbackCopyFile*>(lpData); try { - switch (callback->updateCopyStatus(wxULongLong(totalBytesTransferred.HighPart, totalBytesTransferred.LowPart))) + switch (callback->updateCopyStatus(zen::UInt64(totalBytesTransferred.QuadPart))) { case CallbackCopyFile::CONTINUE: break; @@ -1466,7 +1467,7 @@ DWORD CALLBACK copyCallbackInternal( } catch (...) { - ::MessageBox(NULL, wxT("Exception in callback ffs3::copyFile! Please contact the author of FFS."), NULL, 0); + ::MessageBox(NULL, wxT("Exception in callback zen::copyFile! Please contact the author of FFS."), NULL, 0); } } } @@ -1541,7 +1542,7 @@ void rawCopyWinApi(const Zstring& sourceFile, //assemble error message... wxString errorMessage = wxString(_("Error copying file:")) + wxT("\n\"") + sourceFile.c_str() + wxT("\" ->\n\"") + targetFile.c_str() + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); + wxT("\n\n") + zen::getLastErrorFormatted(lastError); //if file is locked (try to) use Windows Volume Shadow Copy Service if (lastError == ERROR_SHARING_VIOLATION || @@ -1565,8 +1566,8 @@ void rawCopyWinApi(const Zstring& sourceFile, //trying to copy > 4GB file to FAT/FAT32 volume gives obscure ERROR_INVALID_PARAMETER (FAT can indeed handle files up to 4 Gig, tested!) if (lastError == ERROR_INVALID_PARAMETER && dst::isFatDrive(targetFile) && - getFilesize(sourceFile) >= wxULongLong(1024 * 1024 * 1024) * 4) //throw (FileError) - errorMessage += wxT("\nFAT volume cannot store file larger than 4 gigabyte!"); + getFilesize(sourceFile) >= 4U * zen::UInt64(1024U * 1024 * 1024)) //throw (FileError) + errorMessage += wxT("\nFAT volume cannot store files larger than 4 gigabyte!"); } catch(...) {} @@ -1600,7 +1601,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // */ // // //open sourceFile for reading -// HANDLE hFileIn = ::CreateFile(ffs3::applyLongPathPrefix(sourceFile).c_str(), +// HANDLE hFileIn = ::CreateFile(zen::applyLongPathPrefix(sourceFile).c_str(), // GENERIC_READ, // FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //all shared modes are required to read files that are open in other applications // NULL, @@ -1610,7 +1611,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // if (hFileIn == INVALID_HANDLE_VALUE) // { // const DWORD lastError = ::GetLastError(); -// const wxString& errorMessage = wxString(_("Error opening file:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\"") + wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); +// const wxString& errorMessage = wxString(_("Error opening file:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\"") + wxT("\n\n") + zen::getLastErrorFormatted(lastError); // // //if file is locked (try to) use Windows Volume Shadow Copy Service // if (lastError == ERROR_SHARING_VIOLATION || @@ -1627,7 +1628,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // if (!::GetFileInformationByHandle(hFileIn, &infoFileIn)) // { // const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\""); -// throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); +// throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); // } // // //####################################### DST hack ########################################### @@ -1657,7 +1658,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // FILE_ATTRIBUTE_ENCRYPTED; // // //create targetFile and open it for writing -// HANDLE hFileOut = ::CreateFile(ffs3::applyLongPathPrefix(targetFile).c_str(), +// HANDLE hFileOut = ::CreateFile(zen::applyLongPathPrefix(targetFile).c_str(), // GENERIC_READ | GENERIC_WRITE, //read access required for FSCTL_SET_COMPRESSION // FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, // NULL, @@ -1668,7 +1669,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // { // const DWORD lastError = ::GetLastError(); // const wxString& errorMessage = wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(targetFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); +// wxT("\n\n") + zen::getLastErrorFormatted(lastError); // // if (lastError == ERROR_FILE_EXISTS) // throw ErrorTargetExisting(errorMessage); @@ -1698,7 +1699,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // 0)) //__in DWORD nFileSystemNameSize // { // const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\""); -// throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); +// throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); // } // // const bool sourceIsEncrypted = (infoFileIn.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) != 0; @@ -1726,7 +1727,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // &bytesReturned, //number of bytes returned // NULL)) //OVERLAPPED structure // throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(targetFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted() + +// wxT("\n\n") + zen::getLastErrorFormatted() + // wxT("\nFailed to write NTFS compressed attribute!")); // } // @@ -1745,7 +1746,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // &bytesReturned, //number of bytes returned // NULL)) //OVERLAPPED structure // throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(targetFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted() + +// wxT("\n\n") + zen::getLastErrorFormatted() + // wxT("\nFailed to write NTFS sparse attribute!")); // } // } @@ -1770,7 +1771,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // } context; // // //copy contents of sourceFile to targetFile -// wxULongLong totalBytesTransferred; +// zen::UInt64 totalBytesTransferred; // // bool eof = false; // do @@ -1787,7 +1788,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // false, //__in BOOL bProcessSecurity, // &context.read)) //__out LPVOID *lpContext // throw FileError(wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted()); +// wxT("\n\n") + zen::getLastErrorFormatted()); // } // else if (!::ReadFile(hFileIn, //__in HANDLE hFile, // memory.get(), //__out LPVOID lpBuffer, @@ -1795,7 +1796,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // &bytesRead, //__out_opt LPDWORD lpNumberOfBytesRead, // NULL)) //__inout_opt LPOVERLAPPED lpOverlapped // throw FileError(wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted()); +// wxT("\n\n") + zen::getLastErrorFormatted()); // // if (bytesRead > BUFFER_SIZE) // throw FileError(wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\"") + @@ -1816,7 +1817,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // false, //__in BOOL bProcessSecurity, // &context.write)) //__out LPVOID *lpContext // throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(targetFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted() + wxT(" (w)")); //w -> distinguish from fopen error message! +// wxT("\n\n") + zen::getLastErrorFormatted() + wxT(" (w)")); //w -> distinguish from fopen error message! // } // else if (!::WriteFile(hFileOut, //__in HANDLE hFile, // memory.get(), //__out LPVOID lpBuffer, @@ -1824,7 +1825,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // &bytesWritten, //__out_opt LPDWORD lpNumberOfBytesWritten, // NULL)) //__inout_opt LPOVERLAPPED lpOverlapped // throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(targetFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted() + wxT(" (w)")); //w -> distinguish from fopen error message! +// wxT("\n\n") + zen::getLastErrorFormatted() + wxT(" (w)")); //w -> distinguish from fopen error message! // // if (bytesWritten != bytesRead) // throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(targetFile) + wxT("\"") + @@ -1856,7 +1857,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // LARGE_INTEGER inputSize = {}; // if (!::GetFileSizeEx(hFileIn, &inputSize)) // throw FileError(wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted()); +// wxT("\n\n") + zen::getLastErrorFormatted()); // // if (inputSize.QuadPart != 0) // throw FileError(wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(sourceFile) + wxT("\"") + @@ -1869,7 +1870,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // NULL, // &infoFileIn.ftLastWriteTime)) // throw FileError(wxString(_("Error changing modification time:")) + wxT("\n\"") + zToWx(targetFile) + wxT("\"") + -// wxT("\n\n") + ffs3::getLastErrorFormatted()); +// wxT("\n\n") + zen::getLastErrorFormatted()); // // //#ifndef NDEBUG //dst hack: verify data written @@ -1889,7 +1890,6 @@ void rawCopyWinApi(const Zstring& sourceFile, // // /* // //create test sparse file -// size_t sparseSize = 50 * 1024 * 1024; // HANDLE hSparse = ::CreateFile(L"C:\\sparse.file", // GENERIC_READ | GENERIC_WRITE, //read access required for FSCTL_SET_COMPRESSION // FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, @@ -1902,7 +1902,8 @@ void rawCopyWinApi(const Zstring& sourceFile, // throw 1; // // LARGE_INTEGER liDistanceToMove = {}; -// liDistanceToMove.QuadPart = sparseSize; +// liDistanceToMove.QuadPart = 1024 * 1024 * 1024; //create 5 TB sparse file +// liDistanceToMove.QuadPart *= 5 * 1024; // // if (!::SetFilePointerEx(hSparse, liDistanceToMove, NULL, FILE_BEGIN)) // throw 1; // @@ -1910,7 +1911,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // throw 1; // // FILE_ZERO_DATA_INFORMATION zeroInfo = {}; -// zeroInfo.BeyondFinalZero.QuadPart = sparseSize; +// zeroInfo.BeyondFinalZero.QuadPart = liDistanceToMove.QuadPart; // if (!::DeviceIoControl(hSparse, FSCTL_SET_ZERO_DATA, &zeroInfo, sizeof(zeroInfo), NULL, 0, &br, NULL)) // throw 1; // @@ -1933,16 +1934,15 @@ void rawCopyStream(const Zstring& sourceFile, //create targetFile and open it for writing FileOutput fileOut(targetFile, FileOutput::ACC_CREATE_NEW); //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting) - const size_t BUFFER_SIZE = 512 * 1024; //512 kb seems to be a reasonable buffer size - static const boost::scoped_array<char> memory(new char[BUFFER_SIZE]); + static std::vector<wchar_t> buffer(512 * 1024); //512 kb seems to be a reasonable buffer size //copy contents of sourceFile to targetFile - wxULongLong totalBytesTransferred; + zen::UInt64 totalBytesTransferred; do { - const size_t bytesRead = fileIn.read(memory.get(), BUFFER_SIZE); //throw (FileError) + const size_t bytesRead = fileIn.read(&buffer[0], buffer.size()); //throw (FileError) - fileOut.write(memory.get(), bytesRead); //throw (FileError) + fileOut.write(&buffer[0], bytesRead); //throw (FileError) totalBytesTransferred += bytesRead; @@ -1989,7 +1989,7 @@ void copyFileImpl(const Zstring& sourceFile, Compressed NO YES Sparse NO YES PERF - 6% faster - SAMBA, ect. YES UNKNOWN! + SAMBA, ect. YES UNKNOWN! -> issues writing ADS to Samba, issues reading from NAS, error copying files having "blocked" state... ect. damn! */ rawCopyWinApi(sourceFile, targetFile, callback); //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked) @@ -2002,12 +2002,12 @@ void copyFileImpl(const Zstring& sourceFile, } -void ffs3::copyFile(const Zstring& sourceFile, //throw (FileError: ErrorTargetPathMissing, ErrorFileLocked); - const Zstring& targetFile, - bool copyFilePermissions, - CallbackCopyFile* callback) +void zen::copyFile(const Zstring& sourceFile, //throw (FileError: ErrorTargetPathMissing, ErrorFileLocked); + const Zstring& targetFile, + bool copyFilePermissions, + CallbackCopyFile* callback) { - Zstring temporary = targetFile + ffs3::TEMP_FILE_ENDING; //use temporary file until a correct date has been set + Zstring temporary = targetFile + zen::TEMP_FILE_ENDING; //use temporary file until a correct date has been set Loki::ScopeGuard guardTempFile = Loki::MakeGuard(&removeFile, boost::cref(temporary)); //transactional behavior: ensure cleanup (e.g. network drop) -> cref [!] //raw file copy diff --git a/shared/file_handling.h b/shared/file_handling.h index 8867bb04..67540de5 100644 --- a/shared/file_handling.h +++ b/shared/file_handling.h @@ -7,12 +7,11 @@ #ifndef FILE_HANDLING_H_INCLUDED #define FILE_HANDLING_H_INCLUDED -#include <wx/longlong.h> #include "zstring.h" #include "file_error.h" +#include "int64.h" - -namespace ffs3 +namespace zen { struct CallbackRemoveDir; struct CallbackMoveFile; @@ -38,7 +37,7 @@ ResponseSameVol onSameVolume(const Zstring& folderLeft, const Zstring& folderRig void copyFileTimes(const Zstring& sourceDir, const Zstring& targetDir, bool derefSymlinks); //throw (FileError) //symlink handling: always evaluate target -wxULongLong getFilesize(const Zstring& filename); //throw (FileError) +zen::UInt64 getFilesize(const Zstring& filename); //throw (FileError) //file handling @@ -115,7 +114,7 @@ struct CallbackCopyFile //callback functionality CONTINUE, CANCEL }; - virtual Response updateCopyStatus(const wxULongLong& totalBytesTransferred) = 0; //DON'T throw exceptions here, at least in Windows build! + virtual Response updateCopyStatus(zen::UInt64 totalBytesTransferred) = 0; //DON'T throw exceptions here, at least in Windows build! }; } diff --git a/shared/file_id.cpp b/shared/file_id.cpp index eb3be8d6..b111b9a2 100644 --- a/shared/file_id.cpp +++ b/shared/file_id.cpp @@ -20,7 +20,7 @@ namespace { template <class T> inline -std::string numberToString(T number) +std::string numberToBytes(T number) { const char* rawBegin = reinterpret_cast<const char*>(&number); return std::string(rawBegin, rawBegin + sizeof(number)); @@ -38,9 +38,8 @@ std::string util::retrieveFileID(const Zstring& filename) //privilege SE_BACKUP_NAME doesn't seem to be required here at all - //note: setting privileges requires admin rights! - const HANDLE hFile = ::CreateFile(ffs3::applyLongPathPrefix(filename).c_str(), + const HANDLE hFile = ::CreateFile(zen::applyLongPathPrefix(filename).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, @@ -55,9 +54,9 @@ std::string util::retrieveFileID(const Zstring& filename) BY_HANDLE_FILE_INFORMATION fileInfo = {}; if (::GetFileInformationByHandle(hFile, &fileInfo)) { - fileID += numberToString(fileInfo.dwVolumeSerialNumber); - fileID += numberToString(fileInfo.nFileIndexHigh); - fileID += numberToString(fileInfo.nFileIndexLow); + fileID += numberToBytes(fileInfo.dwVolumeSerialNumber); + fileID += numberToBytes(fileInfo.nFileIndexHigh); + fileID += numberToBytes(fileInfo.nFileIndexLow); } } @@ -65,8 +64,8 @@ std::string util::retrieveFileID(const Zstring& filename) struct stat fileInfo = {}; if (::lstat(filename.c_str(), &fileInfo) == 0) //lstat() does not follow symlinks { - fileID += numberToString(fileInfo.st_dev); - fileID += numberToString(fileInfo.st_ino); + fileID += numberToBytes(fileInfo.st_dev); + fileID += numberToBytes(fileInfo.st_ino); } #endif diff --git a/shared/file_io.cpp b/shared/file_io.cpp index 0afe17dd..51f81da9 100644 --- a/shared/file_io.cpp +++ b/shared/file_io.cpp @@ -6,7 +6,7 @@ // #include "file_io.h" #include "string_conv.h" -#include "system_func.h" +#include "last_error.h" #include "i18n.h" #ifdef FFS_WIN @@ -15,25 +15,21 @@ #include <cerrno> #endif -using namespace ffs3; +using namespace zen; FileInput::FileInput(FileHandle handle, const Zstring& filename) : -#ifdef FFS_WIN eofReached(false), -#endif fileHandle(handle), filename_(filename) {} FileInput::FileInput(const Zstring& filename) : //throw (FileError, ErrorNotExisting) -#ifdef FFS_WIN eofReached(false), -#endif filename_(filename) { #ifdef FFS_WIN - fileHandle = ::CreateFile(ffs3::applyLongPathPrefix(filename).c_str(), + fileHandle = ::CreateFile(zen::applyLongPathPrefix(filename).c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //all shared modes are required to read files that are open in other applications NULL, @@ -67,7 +63,10 @@ FileInput::FileInput(const Zstring& filename) : //throw (FileError, ErrorNotExi if (fileHandle == INVALID_HANDLE_VALUE) { const DWORD lastError = ::GetLastError(); - const wxString& errorMessage = wxString(_("Error opening file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); + + wxString errorMessage = wxString(_("Error opening file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(lastError); + if (lastError == ERROR_FILE_NOT_FOUND || lastError == ERROR_PATH_NOT_FOUND) throw ErrorNotExisting(errorMessage); @@ -79,7 +78,10 @@ FileInput::FileInput(const Zstring& filename) : //throw (FileError, ErrorNotExi if (fileHandle == NULL) { const int lastError = errno; - const wxString& errorMessage = wxString(_("Error opening file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); + + wxString errorMessage = wxString(_("Error opening file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(lastError); + if (lastError == ENOENT) throw ErrorNotExisting(errorMessage); @@ -103,41 +105,40 @@ size_t FileInput::read(void* buffer, size_t bytesToRead) //returns actual number { #ifdef FFS_WIN DWORD bytesRead = 0; - if (!::ReadFile(fileHandle, //__in HANDLE hFile, buffer, //__out LPVOID lpBuffer, static_cast<DWORD>(bytesToRead), //__in DWORD nNumberOfBytesToRead, &bytesRead, //__out_opt LPDWORD lpNumberOfBytesRead, - NULL)) //__inout_opt LPOVERLAPPED lpOverlapped - throw FileError(wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted()); - - if (bytesRead > bytesToRead) - throw FileError(wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + wxT("buffer overflow")); - - if (bytesRead < bytesToRead) - eofReached = bytesRead < bytesToRead; - - return bytesRead; - + NULL)) //__inout_opt LPOVERLAPPED lpOverlapped #elif defined FFS_LINUX const size_t bytesRead = ::fread(buffer, 1, bytesToRead, fileHandle); if (::ferror(fileHandle) != 0) - throw FileError(wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted()); - return bytesRead; #endif + { + wxString errorMessage = wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); + } + +#ifdef FFS_WIN + if (bytesRead < bytesToRead) //falsify only! +#elif defined FFS_LINUX + if (::feof(fileHandle) != 0) +#endif + eofReached = true; + + if (bytesRead > bytesToRead) + { + wxString errorMessage = wxString(_("Error reading file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + wxT("buffer overflow")); + } + + return bytesRead; } bool FileInput::eof() //end of file reached { -#ifdef FFS_WIN return eofReached; -#elif defined FFS_LINUX - return ::feof(fileHandle) != 0; -#endif } @@ -148,7 +149,7 @@ FileOutput::FileOutput(const Zstring& filename, AccessFlag access) : //throw (Fi filename_(filename) { #ifdef FFS_WIN - fileHandle = ::CreateFile(ffs3::applyLongPathPrefix(filename).c_str(), + fileHandle = ::CreateFile(zen::applyLongPathPrefix(filename).c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //note: FILE_SHARE_DELETE is required to rename file while handle is open! NULL, @@ -158,8 +159,8 @@ FileOutput::FileOutput(const Zstring& filename, AccessFlag access) : //throw (Fi if (fileHandle == INVALID_HANDLE_VALUE) { const DWORD lastError = ::GetLastError(); - const wxString& errorMessage = wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); + wxString errorMessage = wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(lastError); if (lastError == ERROR_FILE_EXISTS) throw ErrorTargetExisting(errorMessage); @@ -177,8 +178,8 @@ FileOutput::FileOutput(const Zstring& filename, AccessFlag access) : //throw (Fi if (fileHandle == NULL) { const int lastError = errno; - const wxString& errorMessage = wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted(lastError); + wxString errorMessage = wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + errorMessage += wxT("\n\n") + zen::getLastErrorFormatted(lastError); if (lastError == EEXIST) throw ErrorTargetExisting(errorMessage); @@ -205,23 +206,23 @@ void FileOutput::write(const void* buffer, size_t bytesToWrite) //throw (FileErr { #ifdef FFS_WIN DWORD bytesWritten = 0; - if (!::WriteFile(fileHandle, //__in HANDLE hFile, buffer, //__out LPVOID lpBuffer, static_cast<DWORD>(bytesToWrite), //__in DWORD nNumberOfBytesToWrite, &bytesWritten, //__out_opt LPDWORD lpNumberOfBytesWritten, NULL)) //__inout_opt LPOVERLAPPED lpOverlapped - throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted() + wxT(" (w)")); //w -> distinguish from fopen error message! - - if (bytesWritten != bytesToWrite) //must be fulfilled for synchronous writes! - throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + wxT("incomplete write")); - #elif defined FFS_LINUX const size_t bytesWritten = ::fwrite(buffer, 1, bytesToWrite, fileHandle); - if (::ferror(fileHandle) != 0 || bytesWritten != bytesToWrite) - throw FileError(wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\"") + - wxT("\n\n") + ffs3::getLastErrorFormatted() + wxT(" (w)")); //w -> distinguish from fopen error message! + if (::ferror(fileHandle) != 0) #endif + { + wxString errorMessage = wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted() + wxT(" (w)")); //w -> distinguish from fopen error message! + } + + if (bytesWritten != bytesToWrite) //must be fulfilled for synchronous writes! + { + wxString errorMessage = wxString(_("Error writing file:")) + wxT("\n\"") + zToWx(filename_) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + wxT("incomplete write")); + } } diff --git a/shared/file_io.h b/shared/file_io.h index a1460f53..d311346a 100644 --- a/shared/file_io.h +++ b/shared/file_io.h @@ -7,8 +7,6 @@ #ifndef FILEIO_H_INCLUDED #define FILEIO_H_INCLUDED -#include <wx/stream.h> - #ifdef FFS_WIN #include <wx/msw/wrapwin.h> //includes "windows.h" #elif defined FFS_LINUX @@ -18,7 +16,7 @@ #include "zstring.h" #include "file_error.h" -namespace ffs3 +namespace zen { //file IO optimized for sequential read/write accesses + better error reporting + long path support (following symlinks) @@ -39,9 +37,7 @@ public: bool eof(); //end of file reached private: -#ifdef FFS_WIN bool eofReached; -#endif FileHandle fileHandle; const Zstring filename_; }; @@ -66,40 +62,6 @@ private: const Zstring filename_; }; - -//############# wxWidgets stream adapter ############# -// can be used as base classes (have virtual destructors) -class FileInputStream : public wxInputStream -{ -public: - FileInputStream(const Zstring& filename) : //throw (FileError) - fileObj(filename) {} - -private: - virtual size_t OnSysRead(void* buffer, size_t bufsize) //throw (FileError) - { - return fileObj.read(buffer, bufsize); - } - - FileInput fileObj; -}; - - -class FileOutputStream : public wxOutputStream -{ -public: - FileOutputStream(const Zstring& filename) : //throw (FileError) - fileObj(filename, FileOutput::ACC_OVERWRITE) {} - -private: - virtual size_t OnSysWrite(const void* buffer, size_t bufsize) //throw (FileError) - { - fileObj.write(buffer, bufsize); - return bufsize; - } - - FileOutput fileObj; -}; } #endif // FILEIO_H_INCLUDED diff --git a/shared/file_traverser.cpp b/shared/file_traverser.cpp index 2af0f4af..90a5bd79 100644 --- a/shared/file_traverser.cpp +++ b/shared/file_traverser.cpp @@ -7,7 +7,7 @@ #include "file_traverser.h" #include <limits> #include "system_constants.h" -#include "system_func.h" +#include "last_error.h" #include "string_conv.h" #include "assert_static.h" #include "symlink_target.h" @@ -26,36 +26,20 @@ #ifdef FFS_WIN inline -wxLongLong getWin32TimeInformation(const FILETIME& lastWriteTime) +zen::Int64 filetimeToTimeT(const FILETIME& lastWriteTime) { //convert UTC FILETIME to ANSI C format (number of seconds since Jan. 1st 1970 UTC) - wxLongLong writeTimeLong(lastWriteTime.dwHighDateTime, lastWriteTime.dwLowDateTime); - writeTimeLong /= 10000000; //reduce precision to 1 second (FILETIME has unit 10^-7 s) - writeTimeLong -= wxLongLong(2, 3054539008UL); //timeshift between ansi C time and FILETIME in seconds == 11644473600s - - assert(lastWriteTime.dwHighDateTime <= static_cast<unsigned long>(std::numeric_limits<long>::max())); - assert_static(sizeof(DWORD) == sizeof(long)); - assert_static(sizeof(long) == 4); + zen::Int64 writeTimeLong = zen::to<zen::Int64>(zen::UInt64(lastWriteTime.dwLowDateTime, lastWriteTime.dwHighDateTime) / 10000000U); //reduce precision to 1 second (FILETIME has unit 10^-7 s) + writeTimeLong -= zen::Int64(3054539008UL, 2); //timeshift between ansi C time and FILETIME in seconds == 11644473600s return writeTimeLong; } inline -void setWin32FileInformation(const FILETIME& lastWriteTime, - const DWORD fileSizeHigh, - const DWORD fileSizeLow, - ffs3::TraverseCallback::FileInfo& output) -{ - output.lastWriteTimeRaw = getWin32TimeInformation(lastWriteTime); - output.fileSize = wxULongLong(fileSizeHigh, fileSizeLow); -} - - -inline -bool setWin32FileInformationFromSymlink(const Zstring& linkName, ffs3::TraverseCallback::FileInfo& output) +bool setWin32FileInformationFromSymlink(const Zstring& linkName, zen::TraverseCallback::FileInfo& output) { //open handle to target of symbolic link - HANDLE hFile = ::CreateFile(ffs3::applyLongPathPrefix(linkName).c_str(), + HANDLE hFile = ::CreateFile(zen::applyLongPathPrefix(linkName).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, @@ -68,12 +52,13 @@ bool setWin32FileInformationFromSymlink(const Zstring& linkName, ffs3::TraverseC Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hFile); (void)dummy; //silence warning "unused variable" - BY_HANDLE_FILE_INFORMATION fileInfoByHandle; + BY_HANDLE_FILE_INFORMATION fileInfoByHandle = {}; if (!::GetFileInformationByHandle(hFile, &fileInfoByHandle)) return false; //write output - setWin32FileInformation(fileInfoByHandle.ftLastWriteTime, fileInfoByHandle.nFileSizeHigh, fileInfoByHandle.nFileSizeLow, output); + output.lastWriteTimeRaw = filetimeToTimeT(fileInfoByHandle.ftLastWriteTime); + output.fileSize = zen::UInt64(fileInfoByHandle.nFileSizeLow, fileInfoByHandle.nFileSizeHigh); return true; } #endif @@ -82,7 +67,7 @@ bool setWin32FileInformationFromSymlink(const Zstring& linkName, ffs3::TraverseC class DirTraverser { public: - DirTraverser(const Zstring& baseDirectory, bool followSymlinks, ffs3::TraverseCallback& sink, ffs3::DstHackCallback* dstCallback) + DirTraverser(const Zstring& baseDirectory, bool followSymlinks, zen::TraverseCallback& sink, zen::DstHackCallback* dstCallback) #ifdef FFS_WIN : isFatFileSystem(dst::isFatDrive(baseDirectory)) #endif @@ -113,9 +98,9 @@ public: private: template <bool followSymlinks> - void traverse(const Zstring& directory, ffs3::TraverseCallback& sink, int level) + void traverse(const Zstring& directory, zen::TraverseCallback& sink, int level) { - using namespace ffs3; + using namespace zen; if (level == 100) //catch endless recursion { @@ -129,9 +114,9 @@ private: directory : directory + common::FILE_NAME_SEPARATOR; - WIN32_FIND_DATA fileMetaData = {}; + WIN32_FIND_DATA fileInfo = {}; HANDLE searchHandle = ::FindFirstFile(applyLongPathPrefix(directoryFormatted + Zchar('*')).c_str(), //__in LPCTSTR lpFileName - &fileMetaData); //__out LPWIN32_FIND_DATA lpFindFileData + &fileInfo); //__out LPWIN32_FIND_DATA lpFindFileData //no noticable performance difference compared to FindFirstFileEx with FindExInfoBasic, FIND_FIRST_EX_CASE_SENSITIVE and/or FIND_FIRST_EX_LARGE_FETCH if (searchHandle == INVALID_HANDLE_VALUE) @@ -141,10 +126,9 @@ private: return; //else: we have a problem... report it: - const wxString errorMessage = wxString(_("Error traversing directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\"") + wxT("\n\n") + - ffs3::getLastErrorFormatted(lastError); + const wxString errorMessage = wxString(_("Error traversing directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\""); - sink.onError(errorMessage); + sink.onError(errorMessage + wxT("\n\n") +zen::getLastErrorFormatted(lastError)); return; } @@ -154,7 +138,7 @@ private: do { //don't return "." and ".." - const Zchar* const shortName = fileMetaData.cFileName; + const Zchar* const shortName = fileInfo.cFileName; if ( shortName[0] == Zstr('.') && ((shortName[1] == Zstr('.') && shortName[2] == Zstr('\0')) || shortName[1] == Zstr('\0'))) @@ -162,7 +146,7 @@ private: const Zstring& fullName = directoryFormatted + shortName; - const bool isSymbolicLink = (fileMetaData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + const bool isSymbolicLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; if (isSymbolicLink && !followSymlinks) //evaluate symlink directly { @@ -179,11 +163,11 @@ private: #endif } - details.lastWriteTimeRaw = getWin32TimeInformation(fileMetaData.ftLastWriteTime); - details.dirLink = (fileMetaData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; //directory symlinks have this flag on Windows + details.lastWriteTimeRaw = filetimeToTimeT(fileInfo.ftLastWriteTime); + details.dirLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; //directory symlinks have this flag on Windows sink.onSymlink(shortName, fullName, details); } - else if (fileMetaData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //a directory... or symlink that needs to be followed (for directory symlinks this flag is set too!) + else if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //a directory... or symlink that needs to be followed (for directory symlinks this flag is set too!) { const TraverseCallback::ReturnValDir rv = sink.onDir(shortName, fullName); switch (rv.returnCode) @@ -206,7 +190,7 @@ private: { //broken symlink... details.lastWriteTimeRaw = 0; //we are not interested in the modification time of the link - details.fileSize = 0; + details.fileSize = 0U; } } else @@ -214,29 +198,30 @@ private: //####################################### DST hack ########################################### if (isFatFileSystem) { - const dst::RawTime rawTime(fileMetaData.ftCreationTime, fileMetaData.ftLastWriteTime); + const dst::RawTime rawTime(fileInfo.ftCreationTime, fileInfo.ftLastWriteTime); if (dst::fatHasUtcEncoded(rawTime)) //throw (std::runtime_error) - fileMetaData.ftLastWriteTime = dst::fatDecodeUtcTime(rawTime); //return real UTC time; throw (std::runtime_error) + fileInfo.ftLastWriteTime = dst::fatDecodeUtcTime(rawTime); //return real UTC time; throw (std::runtime_error) else - markForDstHack.push_back(std::make_pair(fullName, fileMetaData.ftLastWriteTime)); + markForDstHack.push_back(std::make_pair(fullName, fileInfo.ftLastWriteTime)); } //####################################### DST hack ########################################### - setWin32FileInformation(fileMetaData.ftLastWriteTime, fileMetaData.nFileSizeHigh, fileMetaData.nFileSizeLow, details); + details.lastWriteTimeRaw = filetimeToTimeT(fileInfo.ftLastWriteTime); + details.fileSize = zen::UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); } sink.onFile(shortName, fullName, details); } } while (::FindNextFile(searchHandle, // handle to search - &fileMetaData)); // pointer to structure for data on found file + &fileInfo)); // pointer to structure for data on found file const DWORD lastError = ::GetLastError(); if (lastError != ERROR_NO_MORE_FILES) //this is fine { //else we have a problem... report it: const wxString errorMessage = wxString(_("Error traversing directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\"") ; - sink.onError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted(lastError)); + sink.onError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted(lastError)); } #elif defined FFS_LINUX @@ -244,7 +229,7 @@ private: if (dirObj == NULL) { const wxString errorMessage = wxString(_("Error traversing directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\"") ; - sink.onError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + sink.onError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); return; } @@ -262,7 +247,7 @@ private: //else: we have a problem... report it: const wxString errorMessage = wxString(_("Error traversing directory:")) + wxT("\n\"") + zToWx(directory) + wxT("\"") ; - sink.onError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + sink.onError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); return; } @@ -281,7 +266,7 @@ private: if (::lstat(fullName.c_str(), &fileInfo) != 0) //lstat() does not resolve symlinks { const wxString errorMessage = wxString(_("Error reading file attributes:")) + wxT("\n\"") + zToWx(fullName) + wxT("\""); - sink.onError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + sink.onError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); continue; } @@ -296,7 +281,7 @@ private: //a broken symbolic link TraverseCallback::FileInfo details; details.lastWriteTimeRaw = 0; //we are not interested in the modifiation time of the link - details.fileSize = 0; + details.fileSize = 0U; sink.onFile(shortName, fullName, details); //report broken symlink as file! continue; } @@ -341,7 +326,7 @@ private: { TraverseCallback::FileInfo details; details.lastWriteTimeRaw = fileInfo.st_mtime; //UTC time(ANSI C format); unit: 1 second - details.fileSize = fileInfo.st_size; + details.fileSize = zen::UInt64(fileInfo.st_size); sink.onFile(shortName, fullName, details); } @@ -352,7 +337,7 @@ private: #ifdef FFS_WIN //####################################### DST hack ########################################### - void applyDstHack(ffs3::DstHackCallback& dstCallback) + void applyDstHack(zen::DstHackCallback& dstCallback) { int failedAttempts = 0; int filesToValidate = 50; //don't let data verification become a performance issue @@ -366,7 +351,7 @@ private: const dst::RawTime encodedTime = dst::fatEncodeUtcTime(i->second); //throw (std::runtime_error) { - HANDLE hTarget = ::CreateFile(ffs3::applyLongPathPrefix(i->first).c_str(), + HANDLE hTarget = ::CreateFile(zen::applyLongPathPrefix(i->first).c_str(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, @@ -400,7 +385,7 @@ private: //dst hack: verify data written; attention: this check may fail for "sync.ffs_lock" WIN32_FILE_ATTRIBUTE_DATA debugeAttr = {}; - ::GetFileAttributesEx(ffs3::applyLongPathPrefix(i->first).c_str(), //__in LPCTSTR lpFileName, + ::GetFileAttributesEx(zen::applyLongPathPrefix(i->first).c_str(), //__in LPCTSTR lpFileName, GetFileExInfoStandard, //__in GET_FILEEX_INFO_LEVELS fInfoLevelId, &debugeAttr); //__out LPVOID lpFileInformation @@ -423,7 +408,7 @@ private: }; -void ffs3::traverseFolder(const Zstring& directory, bool followSymlinks, TraverseCallback& sink, DstHackCallback* dstCallback) +void zen::traverseFolder(const Zstring& directory, bool followSymlinks, TraverseCallback& sink, DstHackCallback* dstCallback) { DirTraverser(directory, followSymlinks, sink, dstCallback); } diff --git a/shared/file_traverser.h b/shared/file_traverser.h index 0e25886b..db77f7cd 100644 --- a/shared/file_traverser.h +++ b/shared/file_traverser.h @@ -7,13 +7,14 @@ #ifndef FILETRAVERSER_H_INCLUDED #define FILETRAVERSER_H_INCLUDED +#include <wx/string.h> #include "zstring.h" -#include <wx/longlong.h> #include "loki/TypeManip.h" +#include "int64.h" //advanced file traverser returning metadata and hierarchical information on files and directories -namespace ffs3 +namespace zen { class TraverseCallback { @@ -22,13 +23,13 @@ public: struct FileInfo { - wxULongLong fileSize; //unit: bytes! - wxLongLong lastWriteTimeRaw; //number of seconds since Jan. 1st 1970 UTC + zen::UInt64 fileSize; //unit: bytes! + zen::Int64 lastWriteTimeRaw; //number of seconds since Jan. 1st 1970 UTC }; struct SymlinkInfo { - wxLongLong lastWriteTimeRaw; //number of seconds since Jan. 1st 1970 UTC + zen::Int64 lastWriteTimeRaw; //number of seconds since Jan. 1st 1970 UTC Zstring targetPath; //may be empty if something goes wrong bool dirLink; //"true": point to dir; "false": point to file (or broken Link on Linux) }; diff --git a/shared/global_func.cpp b/shared/global_func.cpp index 07a68187..d25f30d2 100644 --- a/shared/global_func.cpp +++ b/shared/global_func.cpp @@ -5,11 +5,15 @@ // ************************************************************************** // #include "global_func.h" +#include "string_tools.h" #include <wx/msgdlg.h> #include <wx/file.h> #include <wx/stopwatch.h> #include "system_constants.h" +using namespace common; +using namespace zen; + size_t common::getDigitCount(size_t number) //count number of digits { @@ -55,13 +59,13 @@ void DebugLog::write(const wxString& logText) } logFile->Write(wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ")); - logFile->Write(logText + common::LINE_BREAK); + logFile->Write(logText + LINE_BREAK); } //DebugLog logDebugInfo; -wxString getCodeLocation(const wxString file, const int line) +wxString getCodeLocation(const wxString& file, int line) { - return wxString(file).AfterLast(common::FILE_NAME_SEPARATOR) + wxT(", LINE ") + wxLongLong(line).ToString() + wxT(" | "); + return wxString(file).AfterLast(FILE_NAME_SEPARATOR) + wxT(", LINE ") + toString<wxString>(line) + wxT(" | "); } diff --git a/shared/global_func.h b/shared/global_func.h index e0f5434a..9dd1faf7 100644 --- a/shared/global_func.h +++ b/shared/global_func.h @@ -12,57 +12,20 @@ #include <vector> #include <set> #include <wx/string.h> -#include <wx/longlong.h> -#include <memory> -#include <sstream> - -class wxStopWatch; +//#include <memory> +//#include <sstream> namespace common { -//------------------------------------------------ -// FUNCTIONS -//------------------------------------------------ -inline -int round(double d) //little rounding function -{ - return static_cast<int>(d < 0 ? d - .5 : d + .5); -} - -template <class T> -inline -T abs(const T& d) //absolute value -{ - return d < 0 ? -d : d; -} - - -//formatted number conversion C++ ANSI/wide char versions -template <class CharType, class T> -std::basic_string<CharType> numberToString(const T& number); //convert number to string the C++ way - -template <class T, class CharType> -T stringToNumber(const std::basic_string<CharType>& input); //convert number to string the C++ way - -//formatted number conversion wxWidgets -template <class T> wxString numberToString(const T& number); -template <class T> T stringToNumber(const wxString& input); +//little rounding function +inline int round(double d) { return static_cast<int>(d < 0 ? d - .5 : d + .5); } +//absolute value +template <class T> inline T abs(const T& d) { return d < 0 ? -d : d; } size_t getDigitCount(size_t number); //count number of digits -//serialization: read/write numbers: int, long, unsigned int ... ect -template <class T> T readNumber(std::istream& stream); -template <class T> void writeNumber(std::ostream& stream, T number); - -inline -wxLongLong convertToSigned(const wxULongLong number) -{ - return wxLongLong(number.GetHi(), number.GetLo()); -} - - //Note: the following lines are a performance optimization for deleting elements from a vector: linear runtime at most! template <class T> void removeRowsFromVector(const std::set<size_t>& rowsToRemove, std::vector<T>& grid); @@ -118,43 +81,6 @@ wxString getCodeLocation(const wxString file, const int line); //---------------Inline Implementation--------------------------------------------------- -template <class CharType, class T> -inline -std::basic_string<CharType> common::numberToString(const T& number) //convert number to string the C++ way -{ - std::basic_ostringstream<CharType> ss; - ss << number; - return ss.str(); -} - - -template <class T, class CharType> -inline -T common::stringToNumber(const std::basic_string<CharType>& input) //convert number to string the C++ way -{ - T number = 0; - std::basic_istringstream<CharType>(input) >> number; - return number; -} - - -template <class T> -inline -wxString common::numberToString(const T& number) -{ - return numberToString<wxChar, T>(number).c_str(); -} - - -template <class T> -inline -T common::stringToNumber(const wxString& input) -{ - const std::basic_string<wxChar> inputConv(input.c_str()); - return stringToNumber<T, wxChar>(inputConv); -} - - //Note: the following lines are a performance optimization for deleting elements from a vector: linear runtime at most! template <class T> void common::removeRowsFromVector(const std::set<size_t>& rowsToRemove, std::vector<T>& grid) @@ -200,23 +126,4 @@ ForwardIterator common::custom_binary_search(ForwardIterator first, ForwardItera return last; } - -template <class T> -inline -T common::readNumber(std::istream& stream) -{ - T result = 0; - stream.read(reinterpret_cast<char*>(&result), sizeof(T)); - return result; -} - - -template <class T> -inline -void common::writeNumber(std::ostream& stream, T number) -{ - stream.write(reinterpret_cast<const char*>(&number), sizeof(T)); -} - - -#endif // GLOBALFUNCTIONS_H_INCLUDED +#endif // GLOBALFUNCTIONS_H_INCLUDED
\ No newline at end of file diff --git a/shared/guid.cpp b/shared/guid.cpp index dcf63e60..5e6a64a7 100644 --- a/shared/guid.cpp +++ b/shared/guid.cpp @@ -9,16 +9,11 @@ //boost really should clean a bit up... #ifdef __MINGW32__ -#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #endif #include <boost/uuid/uuid_generators.hpp> -#ifdef __MINGW32__ -#pragma GCC diagnostic pop -#endif - std::string util::generateGUID() //creates a 16 byte GUID { diff --git a/shared/help_provider.cpp b/shared/help_provider.cpp index 9b9e1bc6..2c5d5aa9 100644 --- a/shared/help_provider.cpp +++ b/shared/help_provider.cpp @@ -16,7 +16,7 @@ class HelpProvider public: HelpProvider() { - controller.Initialize(ffs3::getResourceDir() + + controller.Initialize(zen::getResourceDir() + #ifdef FFS_WIN wxT("FreeFileSync.chm")); #elif defined FFS_LINUX @@ -37,7 +37,7 @@ private: }; } -void ffs3::displayHelpEntry(const wxString& section) +void zen::displayHelpEntry(const wxString& section) { static HelpProvider provider; provider.showHelp(section); diff --git a/shared/help_provider.h b/shared/help_provider.h index 0fd9ab2f..01ac3054 100644 --- a/shared/help_provider.h +++ b/shared/help_provider.h @@ -9,7 +9,7 @@ #include <wx/string.h> -namespace ffs3 +namespace zen { void displayHelpEntry(const wxString& section = wxEmptyString); } diff --git a/shared/i18n.cpp b/shared/i18n.cpp index 8e0bc22c..8c0e900c 100644 --- a/shared/i18n.cpp +++ b/shared/i18n.cpp @@ -1,1076 +1,20 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// #include "i18n.h" -#include <fstream> -#include <map> -#include <wx/ffile.h> -#include <wx/intl.h> -#include <wx/msgdlg.h> -#include "../shared/standard_paths.h" -#include "../shared/string_conv.h" -#include "system_constants.h" -#include <boost/any.hpp> -#include <boost/shared_ptr.hpp> -#include <list> -#include <iterator> - -using ffs3::LocalizationInfo; - - -namespace -{ -//will receive their proper value in CustomLocale::CustomLocale() -wxString THOUSANDS_SEPARATOR = wxT(","); -wxString DECIMAL_POINT = wxT("."); - -typedef std::map<wxString, wxString> Translation; -Translation activeTranslation; //map original text |-> translation - -int activeLanguage = wxLANGUAGE_ENGLISH; -} - - -wxString ffs3::getThousandsSeparator() -{ - return THOUSANDS_SEPARATOR; -} - - -wxString ffs3::getDecimalPoint() -{ - return DECIMAL_POINT; -} - - -const std::vector<ffs3::LocInfoLine>& LocalizationInfo::get() -{ - static LocalizationInfo instance; - return instance.locMapping; -} - - -LocalizationInfo::LocalizationInfo() -{ - ffs3::LocInfoLine newEntry; - - newEntry.languageID = wxLANGUAGE_CZECH; - newEntry.languageName = wxT("ÄŒeÅ¡tina"); - newEntry.languageFile = wxT("czech.lng"); - newEntry.translatorName = wxT("ViCi"); - newEntry.languageFlag = wxT("czechRep.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_GERMAN; - newEntry.languageName = wxT("Deutsch"); - newEntry.languageFile = wxT("german.lng"); - newEntry.translatorName = wxT("ZenJu"); - newEntry.languageFlag = wxT("germany.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ENGLISH_UK; - newEntry.languageName = wxT("English (UK)"); - newEntry.languageFile = wxT("english_uk.lng"); - newEntry.translatorName = wxT("Robert Readman"); - newEntry.languageFlag = wxT("england.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ENGLISH; - newEntry.languageName = wxT("English (US)"); - newEntry.languageFile = wxT(""); - newEntry.translatorName = wxT("ZenJu"); - newEntry.languageFlag = wxT("usa.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_SPANISH; - newEntry.languageName = wxT("Español"); - newEntry.languageFile = wxT("spanish.lng"); - newEntry.translatorName = wxT("Alexis MartÃnez"); - newEntry.languageFlag = wxT("spain.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_GREEK; - newEntry.languageName = wxT("Ελληνικά"); - newEntry.languageFile = wxT("greek.lng"); - newEntry.translatorName = wxT("ΓιώÏγος Γιαγλής"); - newEntry.languageFlag = wxT("greece.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_FRENCH; - newEntry.languageName = wxT("Français"); - newEntry.languageFile = wxT("french.lng"); - newEntry.translatorName = wxT("Jean-François Hartmann"); - newEntry.languageFlag = wxT("france.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ITALIAN; - newEntry.languageName = wxT("Italiano"); - newEntry.languageFile = wxT("italian.lng"); - newEntry.translatorName = wxT("Emmo"); - newEntry.languageFlag = wxT("italy.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_HUNGARIAN; - newEntry.languageName = wxT("Magyar"); - newEntry.languageFile = wxT("hungarian.lng"); - newEntry.translatorName = wxT("Demon"); - newEntry.languageFlag = wxT("hungary.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_DUTCH; - newEntry.languageName = wxT("Nederlands"); - newEntry.languageFile = wxT("dutch.lng"); - newEntry.translatorName = wxT("Dion van Lieshout"); - newEntry.languageFlag = wxT("holland.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_POLISH; - newEntry.languageName = wxT("Polski"); - newEntry.languageFile = wxT("polish.lng"); - newEntry.translatorName = wxT("Wojtek Pietruszewski"); - newEntry.languageFlag = wxT("poland.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_PORTUGUESE; - newEntry.languageName = wxT("Português"); - newEntry.languageFile = wxT("portuguese.lng"); - newEntry.translatorName = wxT("QuestMark"); - newEntry.languageFlag = wxT("portugal.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_PORTUGUESE_BRAZILIAN; - newEntry.languageName = wxT("Português do Brasil"); - newEntry.languageFile = wxT("portuguese_br.lng"); - newEntry.translatorName = wxT("Edison Aranha"); - newEntry.languageFlag = wxT("brazil.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_RUSSIAN; - newEntry.languageName = wxT("PуÑÑкий"); - newEntry.languageFile = wxT("russian.lng"); - newEntry.translatorName = wxT("Fayzullin T.N. aka Svobodniy"); - newEntry.languageFlag = wxT("russia.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ROMANIAN; - newEntry.languageName = wxT("Română"); - newEntry.languageFile = wxT("romanian.lng"); - newEntry.translatorName = wxT("Alexandru Bogdan Munteanu"); - newEntry.languageFlag = wxT("romania.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_SLOVENIAN; - newEntry.languageName = wxT("SlovenÅ¡Äina"); - newEntry.languageFile = wxT("slovenian.lng"); - newEntry.translatorName = wxT("Matej Badalic"); - newEntry.languageFlag = wxT("slovakia.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_FINNISH; - newEntry.languageName = wxT("Suomi"); - newEntry.languageFile = wxT("finnish.lng"); - newEntry.translatorName = wxT("Nalle Juslén"); - newEntry.languageFlag = wxT("finland.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_SWEDISH; - newEntry.languageName = wxT("Svenska"); - newEntry.languageFile = wxT("swedish.lng"); - newEntry.translatorName = wxT("Ã…ke Engelbrektson"); - newEntry.languageFlag = wxT("sweden.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_TURKISH; - newEntry.languageName = wxT("Türkçe"); - newEntry.languageFile = wxT("turkish.lng"); - newEntry.translatorName = wxT("Kaya Zeren"); - newEntry.languageFlag = wxT("turkey.png"); - locMapping.push_back(newEntry); - - // newEntry.languageID = wxLANGUAGE_HEBREW; - // newEntry.languageName = wxT("עִבְרִית"); - // newEntry.languageFile = wxT("hebrew.lng"); - // newEntry.translatorName = wxT("Moshe Olshevsky"); - // newEntry.languageFlag = wxT("isreal.png"); - // locMapping.push_back(newEntry); - - // newEntry.languageID = wxLANGUAGE_ARABIC; - // newEntry.languageName = wxT("العربية"); - // newEntry.languageFile = wxT("arabic.lng"); - // newEntry.translatorName = wxT("Yousef Shamshoum"); - // newEntry.languageFlag = wxT("arabic-language.png"); - // locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_JAPANESE; - newEntry.languageName = wxT("日本語"); - newEntry.languageFile = wxT("japanese.lng"); - newEntry.translatorName = wxT("Tilt"); - newEntry.languageFlag = wxT("japan.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_CHINESE_TRADITIONAL; - newEntry.languageName = wxT("æ£é«”ä¸æ–‡"); - newEntry.languageFile = wxT("chinese_traditional.lng"); - newEntry.translatorName = wxT("Carlos"); - newEntry.languageFlag = wxT("taiwan.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_CHINESE_SIMPLIFIED; - newEntry.languageName = wxT("简体ä¸æ–‡"); - newEntry.languageFile = wxT("chinese_simple.lng"); - newEntry.translatorName = wxT("CyberCowBoy"); - newEntry.languageFlag = wxT("china.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_KOREAN; - newEntry.languageName = wxT("í•œêµì–´"); - newEntry.languageFile = wxT("korean.lng"); - newEntry.translatorName = wxT("Simon Park"); - newEntry.languageFlag = wxT("south_korea.png"); - locMapping.push_back(newEntry); -} +#include <memory> +using namespace zen; namespace { -int mapLanguageDialect(int language) -{ - switch (language) //map language dialects - { - //variants of wxLANGUAGE_GERMAN - case wxLANGUAGE_GERMAN_AUSTRIAN: - case wxLANGUAGE_GERMAN_BELGIUM: - case wxLANGUAGE_GERMAN_LIECHTENSTEIN: - case wxLANGUAGE_GERMAN_LUXEMBOURG: - case wxLANGUAGE_GERMAN_SWISS: - return wxLANGUAGE_GERMAN; - - //variants of wxLANGUAGE_FRENCH - case wxLANGUAGE_FRENCH_BELGIAN: - case wxLANGUAGE_FRENCH_CANADIAN: - case wxLANGUAGE_FRENCH_LUXEMBOURG: - case wxLANGUAGE_FRENCH_MONACO: - case wxLANGUAGE_FRENCH_SWISS: - return wxLANGUAGE_FRENCH; - - //variants of wxLANGUAGE_DUTCH - case wxLANGUAGE_DUTCH_BELGIAN: - return wxLANGUAGE_DUTCH; - - //variants of wxLANGUAGE_ITALIAN - case wxLANGUAGE_ITALIAN_SWISS: - return wxLANGUAGE_ITALIAN; - - //variants of wxLANGUAGE_CHINESE_SIMPLIFIED - case wxLANGUAGE_CHINESE: - case wxLANGUAGE_CHINESE_SINGAPORE: - return wxLANGUAGE_CHINESE_SIMPLIFIED; - - //variants of wxLANGUAGE_CHINESE_TRADITIONAL - case wxLANGUAGE_CHINESE_TAIWAN: - case wxLANGUAGE_CHINESE_HONGKONG: - case wxLANGUAGE_CHINESE_MACAU: - return wxLANGUAGE_CHINESE_TRADITIONAL; - - //variants of wxLANGUAGE_RUSSIAN - case wxLANGUAGE_RUSSIAN_UKRAINE: - return wxLANGUAGE_RUSSIAN; - - //variants of wxLANGUAGE_SPANISH - case wxLANGUAGE_SPANISH_ARGENTINA: - case wxLANGUAGE_SPANISH_BOLIVIA: - case wxLANGUAGE_SPANISH_CHILE: - case wxLANGUAGE_SPANISH_COLOMBIA: - case wxLANGUAGE_SPANISH_COSTA_RICA: - case wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC: - case wxLANGUAGE_SPANISH_ECUADOR: - case wxLANGUAGE_SPANISH_EL_SALVADOR: - case wxLANGUAGE_SPANISH_GUATEMALA: - case wxLANGUAGE_SPANISH_HONDURAS: - case wxLANGUAGE_SPANISH_MEXICAN: - case wxLANGUAGE_SPANISH_MODERN: - case wxLANGUAGE_SPANISH_NICARAGUA: - case wxLANGUAGE_SPANISH_PANAMA: - case wxLANGUAGE_SPANISH_PARAGUAY: - case wxLANGUAGE_SPANISH_PERU: - case wxLANGUAGE_SPANISH_PUERTO_RICO: - case wxLANGUAGE_SPANISH_URUGUAY: - case wxLANGUAGE_SPANISH_US: - case wxLANGUAGE_SPANISH_VENEZUELA: - return wxLANGUAGE_SPANISH; - - //variants of wxLANGUAGE_SWEDISH - case wxLANGUAGE_SWEDISH_FINLAND: - return wxLANGUAGE_SWEDISH; - - //case wxLANGUAGE_CZECH: - //case wxLANGUAGE_FINNISH: - //case wxLANGUAGE_GREEK: - //case wxLANGUAGE_JAPANESE: - //case wxLANGUAGE_POLISH: - //case wxLANGUAGE_SLOVENIAN: - //case wxLANGUAGE_HUNGARIAN: - //case wxLANGUAGE_PORTUGUESE: - //case wxLANGUAGE_PORTUGUESE_BRAZILIAN: - //case wxLANGUAGE_KOREAN: - - //variants of wxLANGUAGE_ARABIC - case wxLANGUAGE_ARABIC_ALGERIA: - case wxLANGUAGE_ARABIC_BAHRAIN: - case wxLANGUAGE_ARABIC_EGYPT: - case wxLANGUAGE_ARABIC_IRAQ: - case wxLANGUAGE_ARABIC_JORDAN: - case wxLANGUAGE_ARABIC_KUWAIT: - case wxLANGUAGE_ARABIC_LEBANON: - case wxLANGUAGE_ARABIC_LIBYA: - case wxLANGUAGE_ARABIC_MOROCCO: - case wxLANGUAGE_ARABIC_OMAN: - case wxLANGUAGE_ARABIC_QATAR: - case wxLANGUAGE_ARABIC_SAUDI_ARABIA: - case wxLANGUAGE_ARABIC_SUDAN: - case wxLANGUAGE_ARABIC_SYRIA: - case wxLANGUAGE_ARABIC_TUNISIA: - case wxLANGUAGE_ARABIC_UAE: - case wxLANGUAGE_ARABIC_YEMEN: - return wxLANGUAGE_ARABIC; - - //variants of wxLANGUAGE_ENGLISH_UK - case wxLANGUAGE_ENGLISH_AUSTRALIA: - case wxLANGUAGE_ENGLISH_NEW_ZEALAND: - case wxLANGUAGE_ENGLISH_TRINIDAD: - case wxLANGUAGE_ENGLISH_CARIBBEAN: - case wxLANGUAGE_ENGLISH_JAMAICA: - case wxLANGUAGE_ENGLISH_BELIZE: - case wxLANGUAGE_ENGLISH_EIRE: - case wxLANGUAGE_ENGLISH_SOUTH_AFRICA: - case wxLANGUAGE_ENGLISH_ZIMBABWE: - case wxLANGUAGE_ENGLISH_BOTSWANA: - case wxLANGUAGE_ENGLISH_DENMARK: - return wxLANGUAGE_ENGLISH_UK; - - default: - return language; - } -} - - -inline -void exchangeEscapeChars(wxString& data) -{ - wxString output; - - const wxChar* input = data.c_str(); - - wxChar value; - while ((value = *input) != wxChar(0)) - { - //read backslash - if (value == wxChar('\\')) - { - //read next character - ++input; - if ((value = *input) == wxChar(0)) - break; - - switch (value) - { - case wxChar('\\'): - output += wxChar('\\'); - break; - case wxChar('n'): - output += wxChar('\n'); - break; - case wxChar('t'): - output += wxChar('\t'); - break; - case wxChar('\"'): - output += wxChar('\"'); - break; - default: - output += value; - } - } - else - output += value; - - ++input; - } - data = output; -} - - -//workaround to get a FILE* from a unicode filename in a portable way -class UnicodeFileReader -{ -public: - UnicodeFileReader(const wxString& filename) : - inputFile(NULL) - { - wxFFile dummyFile(filename, wxT("rb")); - if (dummyFile.IsOpened()) - { - inputFile = dummyFile.fp(); - dummyFile.Detach(); - } - } - - ~UnicodeFileReader() - { - if (inputFile != NULL) - fclose(inputFile); - } - - bool isOkay() - { - return inputFile != NULL; - } - - bool getNextLine(wxString& line) - { - std::string output; - - while (true) - { - const int c = fgetc(inputFile); - if (c == EOF) - return false; - else if (c == 0xD) - { - //Delimiter: - //---------- - //Linux: 0xA \n - //Mac: 0xD \r - //Win: 0xD 0xA \r\n <- language files are in Windows format - - fgetc(inputFile); //discard the 0xA character - - line = wxString::FromUTF8(output.c_str(), output.length()); - return true; - } - output += static_cast<char>(c); - } - } - -private: - FILE* inputFile; -}; - - -void loadTranslation(const wxString& filename, Translation& trans) //empty translation on error -{ - trans.clear(); - - UnicodeFileReader langFile(ffs3::getResourceDir() + wxT("Languages") + ffs3::zToWx(common::FILE_NAME_SEPARATOR) + filename); - if (langFile.isOkay()) - { - int rowNumber = 0; - wxString original; - wxString tmpString; - while (langFile.getNextLine(tmpString)) - { - exchangeEscapeChars(tmpString); - - if (rowNumber++ % 2 == 0) - original = tmpString; - else - { - const wxString& translation = tmpString; - - if (!original.empty() && !translation.empty()) - trans.insert(std::make_pair(original, translation)); - } - } - } -} -} - - -void ffs3::setLanguage(int language) -{ - static class StaticInit - { - public: - StaticInit() : loc(wxLANGUAGE_DEFAULT) //wxLocale: we need deferred initialization, sigh... - { - //::setlocale (LC_ALL, ""); -> implicitly called by wxLocale - const lconv* localInfo = ::localeconv(); - - //actually these two parameters are language dependent, but we take system setting to handle all kinds of language derivations - THOUSANDS_SEPARATOR = wxString::FromUTF8(localInfo->thousands_sep); - DECIMAL_POINT = wxString::FromUTF8(localInfo->decimal_point); - - // why not working? - // THOUSANDS_SEPARATOR = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).thousands_sep(); - // DECIMAL_POINT = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).decimal_point(); - } - private: - wxLocale loc; //required for RTL language support (and nothing else) - } dummy; - - activeLanguage = language; - - //default: english - wxString languageFile; - - //(try to) retrieve language filename - const int mappedLanguage = mapLanguageDialect(language); - for (std::vector<LocInfoLine>::const_iterator i = LocalizationInfo::get().begin(); i != LocalizationInfo::get().end(); ++i) - if (i->languageID == mappedLanguage) - { - languageFile = i->languageFile; - break; - } - - //load language file into buffer - activeTranslation.clear(); - if (!languageFile.empty()) - { - loadTranslation(languageFile, activeTranslation); //empty translation on error - if (activeTranslation.empty()) - { - wxMessageBox(wxString(_("Error reading file:")) + wxT(" \"") + languageFile + wxT("\""), _("Error"), wxOK | wxICON_ERROR); - activeLanguage = wxLANGUAGE_ENGLISH; //reset to english language to show this error just once - } - } - else - ; //if languageFile is empty texts will be english per default +std::auto_ptr<TranslationHandler> globalHandler; } - -int ffs3::getLanguage() +void zen::setTranslator(TranslationHandler* newHandler) { - return activeLanguage; + globalHandler.reset(newHandler); } -int ffs3::retrieveSystemLanguage() +TranslationHandler* zen::getTranslator() { - return wxLocale::GetSystemLanguage(); -} - - - -//http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html -//http://translate.sourceforge.net/wiki/l10n/pluralforms -/* -Plural forms parser: Grammar ----------------------------- -expression: - conditional-expression - -conditional-expression: - logical-or-expression - logical-or-expression ? expression : expression - -logical-or-expression: - logical-and-expression - logical-or-expression || logical-and-expression - -logical-and-expression: - equality-expression - logical-and-expression && equality-expression - -equality-expression: - relational-expression - relational-expression == relational-expression - relational-expression != relational-expression - -relational-expression: - multiplicative-expression - multiplicative-expression > multiplicative-expression - multiplicative-expression < multiplicative-expression - multiplicative-expression >= multiplicative-expression - multiplicative-expression <= multiplicative-expression - -multiplicative-expression: - pm-expression - multiplicative-expression % pm-expression - -pm-expression: - N - Number - ( Expression ) -*/ - - - -//expression interface -struct Expression { virtual ~Expression() {} }; - -template <class T> -struct Expr : public Expression -{ - typedef T ValueType; - virtual ValueType eval() const = 0; -}; - -//specific binary expression based on STL function objects -template <class StlOp> -struct BinaryExp : public Expr<typename StlOp::result_type> -{ - typedef const Expr<typename StlOp::first_argument_type> SourceExp; - - BinaryExp(const SourceExp& lhs, const SourceExp& rhs, StlOp biop) : lhs_(lhs), rhs_(rhs), biop_(biop) {} - virtual typename StlOp::result_type eval() const { return biop_(lhs_.eval(), rhs_.eval()); } - const SourceExp& lhs_; - const SourceExp& rhs_; - StlOp biop_; -}; - -template <class StlOp> -inline -BinaryExp<StlOp> makeBiExp(const Expression& lhs, const Expression& rhs, StlOp biop) //throw (std::bad_cast) -{ - return BinaryExp<StlOp>(dynamic_cast<const Expr<typename StlOp::first_argument_type >&>(lhs), - dynamic_cast<const Expr<typename StlOp::second_argument_type>&>(rhs), biop); -} - -template <class Out> -struct TernaryExp : public Out -{ - TernaryExp(const Expr<bool>& ifExp, const Out& thenExp, const Out& elseExp) : ifExp_(ifExp), thenExp_(thenExp), elseExp_(elseExp) {} - virtual typename Out::ValueType eval() const { return ifExp_.eval() ? thenExp_.eval() : elseExp_.eval(); } - const Expr<bool>& ifExp_; - const Out& thenExp_; - const Out& elseExp_; -}; - -struct LiteralNumberEx : public Expr<int> -{ - LiteralNumberEx(int n) : n_(n) {} - virtual int eval() const { return n_; } - int n_; -}; - -struct NumberN : public Expr<int> -{ - NumberN(int& n) : n_(n) {} - virtual int eval() const { return n_; } - int& n_; -}; - - -typedef Zbase<wchar_t> Wstring; - - -class PluralForm -{ -public: - struct ParsingError {}; - - PluralForm(const Wstring& phrase) : n_(0) //.po format,e.g.: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) - { - Parser(phrase, //in - expr, //out - n_, // - count, // - dump); // - } - - int formCount() const { return count; } - - int getForm(int n) const { n_ = n ; return expr->eval(); } - -private: - typedef std::list<boost::shared_ptr<Expression> > DumpList; - - struct Token - { - enum Type - { - TK_FORM_COUNT, - TK_PHRASE_BEGIN, - TK_ASSIGN, - TK_SEMICOLON, - TK_TERNARY_QUEST, - TK_TERNARY_COLON, - TK_OR, - TK_AND, - TK_EQUAL, - TK_NOT_EQUAL, - TK_LESS, - TK_LESS_EQUAL, - TK_GREATER, - TK_GREATER_EQUAL, - TK_MODULUS, - TK_N, - TK_NUMBER, - TK_BRACKET_LEFT, - TK_BRACKET_RIGHT, - TK_END - }; - - Token(Type t) : type(t), number(0) {} - - Type type; - int number; //if type == TK_NUMBER - }; - - class Scanner - { - public: - Scanner(const Wstring& phrase) : phrase_(phrase) - { - tokens.push_back(std::make_pair(L"nplurals", Token::TK_FORM_COUNT)); - tokens.push_back(std::make_pair(L"plural" , Token::TK_PHRASE_BEGIN)); - tokens.push_back(std::make_pair(L";" , Token::TK_SEMICOLON )); - tokens.push_back(std::make_pair(L"?" , Token::TK_TERNARY_QUEST)); - tokens.push_back(std::make_pair(L":" , Token::TK_TERNARY_COLON)); - tokens.push_back(std::make_pair(L"||", Token::TK_OR )); - tokens.push_back(std::make_pair(L"&&", Token::TK_AND )); - tokens.push_back(std::make_pair(L"==", Token::TK_EQUAL )); - tokens.push_back(std::make_pair(L"=" , Token::TK_ASSIGN )); - tokens.push_back(std::make_pair(L"!=", Token::TK_NOT_EQUAL )); - tokens.push_back(std::make_pair(L"<=", Token::TK_LESS_EQUAL )); - tokens.push_back(std::make_pair(L"<" , Token::TK_LESS )); - tokens.push_back(std::make_pair(L">=", Token::TK_GREATER_EQUAL)); - tokens.push_back(std::make_pair(L">" , Token::TK_GREATER )); - tokens.push_back(std::make_pair(L"%" , Token::TK_MODULUS )); - tokens.push_back(std::make_pair(L"n" , Token::TK_N )); - tokens.push_back(std::make_pair(L"N" , Token::TK_N )); - tokens.push_back(std::make_pair(L"(" , Token::TK_BRACKET_LEFT )); - tokens.push_back(std::make_pair(L")" , Token::TK_BRACKET_RIGHT)); - } - - Token nextToken() - { - phrase_.Trim(true, false); //remove whitespace - - if (phrase_.empty()) return Token(Token::TK_END); - - for (TokenList::const_iterator i = tokens.begin(); i != tokens.end(); ++i) - if (phrase_.StartsWith(i->first)) - { - phrase_ = phrase_.substr(i->first.size()); - return Token(i->second); - } - - Wstring::iterator digitEnd = std::find_if(phrase_.begin(), phrase_.end(), std::not1(std::ptr_fun(std::iswdigit))); - int digitCount = digitEnd - phrase_.begin(); - if (digitCount != 0) - { - Token out(Token::TK_NUMBER); - out.number = Wstring(phrase_.c_str(), digitCount).toNumber<int>(); - phrase_ = phrase_.substr(digitCount); - return out; - } - - throw ParsingError(); //unknown token - } - - private: - typedef std::vector<std::pair<Wstring, Token::Type> > TokenList; - TokenList tokens; - Wstring phrase_; - }; - - - class Parser - { - public: - Parser(const Wstring& phrase, //in - const Expr<int>*& expr, int& n, int& count, PluralForm::DumpList& dump) ://out - scn(phrase), - tk(scn.nextToken()), - n_(n), - dump_(dump) - { - consumeToken(Token::TK_FORM_COUNT); - consumeToken(Token::TK_ASSIGN); - - count = token().number; - consumeToken(Token::TK_NUMBER); - - consumeToken(Token::TK_SEMICOLON); - consumeToken(Token::TK_PHRASE_BEGIN); - consumeToken(Token::TK_ASSIGN); - - try - { - const Expression& e = parse(); - expr = &dynamic_cast<const Expr<int>&>(e); - } - catch(std::bad_cast&) { throw ParsingError(); } - - consumeToken(Token::TK_END); - } - - private: - void nextToken() { tk = scn.nextToken(); } - const Token& token() const { return tk; } - - void consumeToken(Token::Type t) - { - if (token().type != t) - throw ParsingError(); - nextToken(); - } - - const Expression& parse() { return parseConditional(); }; - - const Expression& parseConditional() - { - const Expression& e = parseLogicalOr(); - - if (token().type == Token::TK_TERNARY_QUEST) - { - nextToken(); - const Expression& thenEx = parse(); //associativity: <- - consumeToken(Token::TK_TERNARY_COLON); - const Expression& elseEx = parse(); // - - return manageObj(TernaryExp<Expr<int> >(dynamic_cast<const Expr<bool>&>(e), - dynamic_cast<const Expr<int>&>(thenEx), - dynamic_cast<const Expr<int>&>(elseEx))); - } - return e; - } - - const Expression& parseLogicalOr() - { - const Expression* e = &parseLogicalAnd(); - for (;;) //associativity: -> - if (token().type == Token::TK_OR) - { - nextToken(); - const Expression& rhs = parseLogicalAnd(); - e = &manageObj(makeBiExp(*e, rhs, std::logical_or<bool>())); - } - else break; - return *e; - } - - const Expression& parseLogicalAnd() - { - const Expression* e = &parseEquality(); - for (;;) //associativity: -> - if (token().type == Token::TK_AND) - { - nextToken(); - const Expression& rhs = parseEquality(); - - e = &manageObj(makeBiExp(*e, rhs, std::logical_and<bool>())); - } - else break; - return *e; - } - - const Expression& parseEquality() - { - const Expression& e = parseRelational(); - - Token::Type t = token().type; - if (t == Token::TK_EQUAL || t == Token::TK_NOT_EQUAL) //associativity: n/a - { - nextToken(); - const Expression& rhs = parseRelational(); - - if (t == Token::TK_EQUAL) - return manageObj(makeBiExp(e, rhs, std::equal_to<int>())); - else - return manageObj(makeBiExp(e, rhs, std::not_equal_to<int>())); - } - return e; - } - - const Expression& parseRelational() - { - const Expression& e = parseMultiplicative(); - - Token::Type t = token().type; - if (t == Token::TK_LESS || //associativity: n/a - t == Token::TK_LESS_EQUAL|| - t == Token::TK_GREATER || - t == Token::TK_GREATER_EQUAL) - { - nextToken(); - const Expression& rhs = parseMultiplicative(); - - if (t == Token::TK_LESS) return manageObj(makeBiExp(e, rhs, std::less <int>())); - if (t == Token::TK_LESS_EQUAL) return manageObj(makeBiExp(e, rhs, std::less_equal <int>())); - if (t == Token::TK_GREATER) return manageObj(makeBiExp(e, rhs, std::greater <int>())); - if (t == Token::TK_GREATER_EQUAL) return manageObj(makeBiExp(e, rhs, std::greater_equal<int>())); - } - return e; - } - - const Expression& parseMultiplicative() - { - const Expression* e = &parsePrimary(); - - for (;;) //associativity: -> - if (token().type == Token::TK_MODULUS) - { - nextToken(); - const Expression& rhs = parsePrimary(); - - //"compile-time" check: n % 0 - const LiteralNumberEx* literal = dynamic_cast<const LiteralNumberEx*>(&rhs); - if (literal && literal->eval() == 0) - throw ParsingError(); - - e = &manageObj(makeBiExp(*e, rhs, std::modulus<int>())); - } - else break; - return *e; - } - - const Expression& parsePrimary() - { - if (token().type == Token::TK_N) - { - nextToken(); - return manageObj(NumberN(n_)); - } - else if (token().type == Token::TK_NUMBER) - { - const int number = token().number; - nextToken(); - return manageObj(LiteralNumberEx(number)); - } - else if (token().type == Token::TK_BRACKET_LEFT) - { - nextToken(); - const Expression& e = parse(); - - consumeToken(Token::TK_BRACKET_RIGHT); - return e; - } - else - throw ParsingError(); - } - - template <class T> - const T& manageObj(const T& obj) - { - boost::shared_ptr<Expression> newEntry(new T(obj)); - dump_.push_back(newEntry); - return static_cast<T&>(*dump_.back()); - } - - Scanner scn; - Token tk; - - int& n_; - DumpList& dump_; //manage polymorphc object lifetimes - }; - - const Expr<int>* expr; - mutable int n_; - int count; - - PluralForm::DumpList dump; //manage polymorphc object lifetimes -}; - - -const wchar_t formPol[] = L"nplurals=3; plural=n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2"; -int tstPol(int n) -{ - return n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2; -} - -const wchar_t formRu[] = L"nplurals= 3; plural=n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2"; -int tstRu(int n) -{ - return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2 ; -} - -const wchar_t formLit[] = L"nplurals =3; plural=n% 10 == 1&& n % 100 != 11 ? 0 : n % 100 != 12&& n % 10 == 2 ? 1 : 0"; -int tstLit(int n) -{ - return n % 10 == 1&& n % 100 != 11 ? 0 : n % 100 != 12&& n % 10 == 2 ? 1 : 0; -} - -const wchar_t formArab[] = L"nplurals = 6; plural = n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : (n % 100 >= 3 && n % 100 <= 10) ? 3 : (n % 100 >= 11 && n % 100 <= 99) || (n % 100 == 1) || (n % 100 ==2) ? 4 : 5"; -int tstArab(int n) -{ - return n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : (n % 100 >= 3 && n % 100 <= 10) ? 3 : (n % 100 >= 11 && n % 100 <= 99) || (n % 100 == 1) || (n % 100 ==2) ? 4 : 5; -} - -const wchar_t formGerm[] = L"nplurals=2; plural= n == 1 ? 0 : 1"; -int tstGerm(int n) -{ - return n == 1 ? 0 : 1; -} - -const wchar_t formFren[] = L"nplurals=2; plural= n <= 1 ? 0 : 1"; -int tstFren(int n) -{ - return n <= 1 ? 0 : 1; -} - -const wchar_t formJap[] = L"nplurals=1; plural=0"; -int tstJap(int n) -{ - return 0; -} - -const wchar_t formRom[] = L"nplurals=3; plural= n == 1 ? 0 : n == 0 || (n % 100 >= 1 && n % 100 <= 20) ? 1 : 2 "; -int tstRom(int n) -{ - return n == 1 ? 0 : n == 0 || (n % 100 >= 1 && n % 100 <= 20) ? 1 : 2 ; -} - -const wchar_t formCze[] = L" nplurals=3; plural= n % 100 == 1 ? 0 : n % 100 >= 2 && n % 100 <= 4 ? 1 : 2"; -int tstCze(int n) -{ - return n % 100 == 1 ? 0 : n % 100 >= 2 && n % 100 <= 4 ? 1 : 2; -} - -const wchar_t formSlov[] = L" nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3 "; -int tstSlov(int n) -{ - return n % 100 == 1 ? 0 : n % 100 == 2 ? 1 : n % 100 == 3 || n % 100 == 4 ? 2 : 3; -} - -void unitTest() -{ - typedef int (*TestFun)(int); - typedef std::vector<std::pair<const wchar_t*, TestFun> > PhraseFunList; - PhraseFunList phrases; - phrases.push_back(std::make_pair(formPol, &tstPol)); - phrases.push_back(std::make_pair(formRu, &tstRu)); - phrases.push_back(std::make_pair(formLit, &tstLit)); - phrases.push_back(std::make_pair(formArab, &tstArab)); - phrases.push_back(std::make_pair(formGerm, &tstGerm)); - phrases.push_back(std::make_pair(formFren, &tstFren)); - phrases.push_back(std::make_pair(formJap, &tstJap)); - phrases.push_back(std::make_pair(formRom, &tstRom)); - phrases.push_back(std::make_pair(formCze, &tstCze)); - phrases.push_back(std::make_pair(formSlov, &tstSlov)); - - for (PhraseFunList::const_iterator i = phrases.begin(); i != phrases.end(); ++i) - { - PluralForm pf(i->first); - for (int j = 0; j < 10000000; ++j) - assert((i->second)(j) == pf.getForm(j)); - } -} - - -wxString ffs3::translate(const wxString& original) //translate into currently selected language -{ - /* - int ba = 3; - - unitTest(); - -#ifndef _MSC_VER -#warning 3434 -#endif - - */ - - - - //look for translation in buffer table - const Translation::const_iterator i = activeTranslation.find(original); - if (i != activeTranslation.end()) - return i->second.c_str(); - - //fallback - return original; + return globalHandler.get(); } diff --git a/shared/i18n.h b/shared/i18n.h index 0026cdd5..03456ede 100644 --- a/shared/i18n.h +++ b/shared/i18n.h @@ -4,55 +4,49 @@ // * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * // ************************************************************************** // -#ifndef MISC_H_INCLUDED -#define MISC_H_INCLUDED +#ifndef I18_N_HEADER_3843489325045 +#define I18_N_HEADER_3843489325045 #include <wx/string.h> #include <vector> -namespace ffs3 +namespace zen { -struct LocInfoLine +//implement handler to enable program wide localizations +struct TranslationHandler { - int languageID; - wxString languageName; - wxString languageFile; - wxString translatorName; - wxString languageFlag; -}; - -class LocalizationInfo -{ -public: - static const std::vector<LocInfoLine>& get(); - -private: - LocalizationInfo(); - LocalizationInfo(const LocalizationInfo&); - LocalizationInfo& operator=(const LocalizationInfo&); + virtual ~TranslationHandler() {} - std::vector<LocInfoLine> locMapping; + virtual wxString thousandsSeparator() = 0; + virtual wxString translate(const wxString& text) = 0; //simple translation + virtual wxString translate(const wxString& singular, const wxString& plural, int n) = 0; }; +void setTranslator(TranslationHandler* newHandler = NULL); //takes ownership +TranslationHandler* getTranslator(); -//language independent global variables: just use operating system's default setting! -wxString getThousandsSeparator(); -wxString getDecimalPoint(); -void setLanguage(int language); -int getLanguage(); -int retrieveSystemLanguage(); +inline wxString getThousandsSeparator() { return getTranslator() ? getTranslator()->thousandsSeparator() : wxT(","); }; -wxString translate(const wxString& original); //translate into currently selected language +inline wxString translate(const wxString& text) { return getTranslator() ? getTranslator()->translate(text) : text; } -//translate plural forms: "%x day|%x days" +//translate plural forms: "%x day" "%x days" //returns "%x day" if n == 1; "%x days" else for english language -wxString translate(const wxString& original, int n); +inline wxString translate(const wxString& singular, const wxString& plural, int n) { return getTranslator() ? getTranslator()->translate(singular, plural, n) : n == 1 ? singular : plural; } + +template <class T> inline +wxString translate(const wxString& singular, const wxString& plural, T n) +{ + return translate(singular, plural, static_cast<int>(n % 1000000)); } +} + +#ifndef WXINTL_NO_GETTEXT_MACRO +#error WXINTL_NO_GETTEXT_MACRO must be defined to deactivate wxWidgets underscore macro +#endif -//WXINTL_NO_GETTEXT_MACRO must be defined to deactivate wxWidgets underscore macro -#define _(s) ffs3::translate(wxT(s)) -#define _P(s, n) ffs3::translate(wxT(s), n) +#define _(s) zen::translate(wxT(s)) +#define _P(s, p, n) zen::translate(wxT(s), wxT(p), n) -#endif // MISC_H_INCLUDED +#endif //I18_N_HEADER_3843489325045 diff --git a/shared/i18n_no_BOM.cpp b/shared/i18n_no_BOM.cpp deleted file mode 100644 index b89d3221..00000000 --- a/shared/i18n_no_BOM.cpp +++ /dev/null @@ -1,1076 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#include "i18n.h" -#include <fstream> -#include <map> -#include <wx/ffile.h> -#include <wx/intl.h> -#include <wx/msgdlg.h> -#include "../shared/standard_paths.h" -#include "../shared/string_conv.h" -#include "system_constants.h" -#include <boost/any.hpp> -#include <boost/shared_ptr.hpp> -#include <list> -#include <iterator> - -using ffs3::LocalizationInfo; - - -namespace -{ -//will receive their proper value in CustomLocale::CustomLocale() -wxString THOUSANDS_SEPARATOR = wxT(","); -wxString DECIMAL_POINT = wxT("."); - -typedef std::map<wxString, wxString> Translation; -Translation activeTranslation; //map original text |-> translation - -int activeLanguage = wxLANGUAGE_ENGLISH; -} - - -wxString ffs3::getThousandsSeparator() -{ - return THOUSANDS_SEPARATOR; -} - - -wxString ffs3::getDecimalPoint() -{ - return DECIMAL_POINT; -} - - -const std::vector<ffs3::LocInfoLine>& LocalizationInfo::get() -{ - static LocalizationInfo instance; - return instance.locMapping; -} - - -LocalizationInfo::LocalizationInfo() -{ - ffs3::LocInfoLine newEntry; - - newEntry.languageID = wxLANGUAGE_CZECH; - newEntry.languageName = wxT("ÄŒeÅ¡tina"); - newEntry.languageFile = wxT("czech.lng"); - newEntry.translatorName = wxT("ViCi"); - newEntry.languageFlag = wxT("czechRep.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_GERMAN; - newEntry.languageName = wxT("Deutsch"); - newEntry.languageFile = wxT("german.lng"); - newEntry.translatorName = wxT("ZenJu"); - newEntry.languageFlag = wxT("germany.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ENGLISH_UK; - newEntry.languageName = wxT("English (UK)"); - newEntry.languageFile = wxT("english_uk.lng"); - newEntry.translatorName = wxT("Robert Readman"); - newEntry.languageFlag = wxT("england.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ENGLISH; - newEntry.languageName = wxT("English (US)"); - newEntry.languageFile = wxT(""); - newEntry.translatorName = wxT("ZenJu"); - newEntry.languageFlag = wxT("usa.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_SPANISH; - newEntry.languageName = wxT("Español"); - newEntry.languageFile = wxT("spanish.lng"); - newEntry.translatorName = wxT("Alexis MartÃnez"); - newEntry.languageFlag = wxT("spain.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_GREEK; - newEntry.languageName = wxT("Ελληνικά"); - newEntry.languageFile = wxT("greek.lng"); - newEntry.translatorName = wxT("ΓιώÏγος Γιαγλής"); - newEntry.languageFlag = wxT("greece.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_FRENCH; - newEntry.languageName = wxT("Français"); - newEntry.languageFile = wxT("french.lng"); - newEntry.translatorName = wxT("Jean-François Hartmann"); - newEntry.languageFlag = wxT("france.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ITALIAN; - newEntry.languageName = wxT("Italiano"); - newEntry.languageFile = wxT("italian.lng"); - newEntry.translatorName = wxT("Emmo"); - newEntry.languageFlag = wxT("italy.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_HUNGARIAN; - newEntry.languageName = wxT("Magyar"); - newEntry.languageFile = wxT("hungarian.lng"); - newEntry.translatorName = wxT("Demon"); - newEntry.languageFlag = wxT("hungary.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_DUTCH; - newEntry.languageName = wxT("Nederlands"); - newEntry.languageFile = wxT("dutch.lng"); - newEntry.translatorName = wxT("Dion van Lieshout"); - newEntry.languageFlag = wxT("holland.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_POLISH; - newEntry.languageName = wxT("Polski"); - newEntry.languageFile = wxT("polish.lng"); - newEntry.translatorName = wxT("Wojtek Pietruszewski"); - newEntry.languageFlag = wxT("poland.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_PORTUGUESE; - newEntry.languageName = wxT("Português"); - newEntry.languageFile = wxT("portuguese.lng"); - newEntry.translatorName = wxT("QuestMark"); - newEntry.languageFlag = wxT("portugal.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_PORTUGUESE_BRAZILIAN; - newEntry.languageName = wxT("Português do Brasil"); - newEntry.languageFile = wxT("portuguese_br.lng"); - newEntry.translatorName = wxT("Edison Aranha"); - newEntry.languageFlag = wxT("brazil.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_RUSSIAN; - newEntry.languageName = wxT("PуÑÑкий"); - newEntry.languageFile = wxT("russian.lng"); - newEntry.translatorName = wxT("Fayzullin T.N. aka Svobodniy"); - newEntry.languageFlag = wxT("russia.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_ROMANIAN; - newEntry.languageName = wxT("Română"); - newEntry.languageFile = wxT("romanian.lng"); - newEntry.translatorName = wxT("Alexandru Bogdan Munteanu"); - newEntry.languageFlag = wxT("romania.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_SLOVENIAN; - newEntry.languageName = wxT("SlovenÅ¡Äina"); - newEntry.languageFile = wxT("slovenian.lng"); - newEntry.translatorName = wxT("Matej Badalic"); - newEntry.languageFlag = wxT("slovakia.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_FINNISH; - newEntry.languageName = wxT("Suomi"); - newEntry.languageFile = wxT("finnish.lng"); - newEntry.translatorName = wxT("Nalle Juslén"); - newEntry.languageFlag = wxT("finland.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_SWEDISH; - newEntry.languageName = wxT("Svenska"); - newEntry.languageFile = wxT("swedish.lng"); - newEntry.translatorName = wxT("Ã…ke Engelbrektson"); - newEntry.languageFlag = wxT("sweden.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_TURKISH; - newEntry.languageName = wxT("Türkçe"); - newEntry.languageFile = wxT("turkish.lng"); - newEntry.translatorName = wxT("Kaya Zeren"); - newEntry.languageFlag = wxT("turkey.png"); - locMapping.push_back(newEntry); - - // newEntry.languageID = wxLANGUAGE_HEBREW; - // newEntry.languageName = wxT("עִבְרִית"); - // newEntry.languageFile = wxT("hebrew.lng"); - // newEntry.translatorName = wxT("Moshe Olshevsky"); - // newEntry.languageFlag = wxT("isreal.png"); - // locMapping.push_back(newEntry); - - // newEntry.languageID = wxLANGUAGE_ARABIC; - // newEntry.languageName = wxT("العربية"); - // newEntry.languageFile = wxT("arabic.lng"); - // newEntry.translatorName = wxT("Yousef Shamshoum"); - // newEntry.languageFlag = wxT("arabic-language.png"); - // locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_JAPANESE; - newEntry.languageName = wxT("日本語"); - newEntry.languageFile = wxT("japanese.lng"); - newEntry.translatorName = wxT("Tilt"); - newEntry.languageFlag = wxT("japan.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_CHINESE_TRADITIONAL; - newEntry.languageName = wxT("æ£é«”ä¸æ–‡"); - newEntry.languageFile = wxT("chinese_traditional.lng"); - newEntry.translatorName = wxT("Carlos"); - newEntry.languageFlag = wxT("taiwan.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_CHINESE_SIMPLIFIED; - newEntry.languageName = wxT("简体ä¸æ–‡"); - newEntry.languageFile = wxT("chinese_simple.lng"); - newEntry.translatorName = wxT("CyberCowBoy"); - newEntry.languageFlag = wxT("china.png"); - locMapping.push_back(newEntry); - - newEntry.languageID = wxLANGUAGE_KOREAN; - newEntry.languageName = wxT("í•œêµì–´"); - newEntry.languageFile = wxT("korean.lng"); - newEntry.translatorName = wxT("Simon Park"); - newEntry.languageFlag = wxT("south_korea.png"); - locMapping.push_back(newEntry); -} - - -namespace -{ -int mapLanguageDialect(int language) -{ - switch (language) //map language dialects - { - //variants of wxLANGUAGE_GERMAN - case wxLANGUAGE_GERMAN_AUSTRIAN: - case wxLANGUAGE_GERMAN_BELGIUM: - case wxLANGUAGE_GERMAN_LIECHTENSTEIN: - case wxLANGUAGE_GERMAN_LUXEMBOURG: - case wxLANGUAGE_GERMAN_SWISS: - return wxLANGUAGE_GERMAN; - - //variants of wxLANGUAGE_FRENCH - case wxLANGUAGE_FRENCH_BELGIAN: - case wxLANGUAGE_FRENCH_CANADIAN: - case wxLANGUAGE_FRENCH_LUXEMBOURG: - case wxLANGUAGE_FRENCH_MONACO: - case wxLANGUAGE_FRENCH_SWISS: - return wxLANGUAGE_FRENCH; - - //variants of wxLANGUAGE_DUTCH - case wxLANGUAGE_DUTCH_BELGIAN: - return wxLANGUAGE_DUTCH; - - //variants of wxLANGUAGE_ITALIAN - case wxLANGUAGE_ITALIAN_SWISS: - return wxLANGUAGE_ITALIAN; - - //variants of wxLANGUAGE_CHINESE_SIMPLIFIED - case wxLANGUAGE_CHINESE: - case wxLANGUAGE_CHINESE_SINGAPORE: - return wxLANGUAGE_CHINESE_SIMPLIFIED; - - //variants of wxLANGUAGE_CHINESE_TRADITIONAL - case wxLANGUAGE_CHINESE_TAIWAN: - case wxLANGUAGE_CHINESE_HONGKONG: - case wxLANGUAGE_CHINESE_MACAU: - return wxLANGUAGE_CHINESE_TRADITIONAL; - - //variants of wxLANGUAGE_RUSSIAN - case wxLANGUAGE_RUSSIAN_UKRAINE: - return wxLANGUAGE_RUSSIAN; - - //variants of wxLANGUAGE_SPANISH - case wxLANGUAGE_SPANISH_ARGENTINA: - case wxLANGUAGE_SPANISH_BOLIVIA: - case wxLANGUAGE_SPANISH_CHILE: - case wxLANGUAGE_SPANISH_COLOMBIA: - case wxLANGUAGE_SPANISH_COSTA_RICA: - case wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC: - case wxLANGUAGE_SPANISH_ECUADOR: - case wxLANGUAGE_SPANISH_EL_SALVADOR: - case wxLANGUAGE_SPANISH_GUATEMALA: - case wxLANGUAGE_SPANISH_HONDURAS: - case wxLANGUAGE_SPANISH_MEXICAN: - case wxLANGUAGE_SPANISH_MODERN: - case wxLANGUAGE_SPANISH_NICARAGUA: - case wxLANGUAGE_SPANISH_PANAMA: - case wxLANGUAGE_SPANISH_PARAGUAY: - case wxLANGUAGE_SPANISH_PERU: - case wxLANGUAGE_SPANISH_PUERTO_RICO: - case wxLANGUAGE_SPANISH_URUGUAY: - case wxLANGUAGE_SPANISH_US: - case wxLANGUAGE_SPANISH_VENEZUELA: - return wxLANGUAGE_SPANISH; - - //variants of wxLANGUAGE_SWEDISH - case wxLANGUAGE_SWEDISH_FINLAND: - return wxLANGUAGE_SWEDISH; - - //case wxLANGUAGE_CZECH: - //case wxLANGUAGE_FINNISH: - //case wxLANGUAGE_GREEK: - //case wxLANGUAGE_JAPANESE: - //case wxLANGUAGE_POLISH: - //case wxLANGUAGE_SLOVENIAN: - //case wxLANGUAGE_HUNGARIAN: - //case wxLANGUAGE_PORTUGUESE: - //case wxLANGUAGE_PORTUGUESE_BRAZILIAN: - //case wxLANGUAGE_KOREAN: - - //variants of wxLANGUAGE_ARABIC - case wxLANGUAGE_ARABIC_ALGERIA: - case wxLANGUAGE_ARABIC_BAHRAIN: - case wxLANGUAGE_ARABIC_EGYPT: - case wxLANGUAGE_ARABIC_IRAQ: - case wxLANGUAGE_ARABIC_JORDAN: - case wxLANGUAGE_ARABIC_KUWAIT: - case wxLANGUAGE_ARABIC_LEBANON: - case wxLANGUAGE_ARABIC_LIBYA: - case wxLANGUAGE_ARABIC_MOROCCO: - case wxLANGUAGE_ARABIC_OMAN: - case wxLANGUAGE_ARABIC_QATAR: - case wxLANGUAGE_ARABIC_SAUDI_ARABIA: - case wxLANGUAGE_ARABIC_SUDAN: - case wxLANGUAGE_ARABIC_SYRIA: - case wxLANGUAGE_ARABIC_TUNISIA: - case wxLANGUAGE_ARABIC_UAE: - case wxLANGUAGE_ARABIC_YEMEN: - return wxLANGUAGE_ARABIC; - - //variants of wxLANGUAGE_ENGLISH_UK - case wxLANGUAGE_ENGLISH_AUSTRALIA: - case wxLANGUAGE_ENGLISH_NEW_ZEALAND: - case wxLANGUAGE_ENGLISH_TRINIDAD: - case wxLANGUAGE_ENGLISH_CARIBBEAN: - case wxLANGUAGE_ENGLISH_JAMAICA: - case wxLANGUAGE_ENGLISH_BELIZE: - case wxLANGUAGE_ENGLISH_EIRE: - case wxLANGUAGE_ENGLISH_SOUTH_AFRICA: - case wxLANGUAGE_ENGLISH_ZIMBABWE: - case wxLANGUAGE_ENGLISH_BOTSWANA: - case wxLANGUAGE_ENGLISH_DENMARK: - return wxLANGUAGE_ENGLISH_UK; - - default: - return language; - } -} - - -inline -void exchangeEscapeChars(wxString& data) -{ - wxString output; - - const wxChar* input = data.c_str(); - - wxChar value; - while ((value = *input) != wxChar(0)) - { - //read backslash - if (value == wxChar('\\')) - { - //read next character - ++input; - if ((value = *input) == wxChar(0)) - break; - - switch (value) - { - case wxChar('\\'): - output += wxChar('\\'); - break; - case wxChar('n'): - output += wxChar('\n'); - break; - case wxChar('t'): - output += wxChar('\t'); - break; - case wxChar('\"'): - output += wxChar('\"'); - break; - default: - output += value; - } - } - else - output += value; - - ++input; - } - data = output; -} - - -//workaround to get a FILE* from a unicode filename in a portable way -class UnicodeFileReader -{ -public: - UnicodeFileReader(const wxString& filename) : - inputFile(NULL) - { - wxFFile dummyFile(filename, wxT("rb")); - if (dummyFile.IsOpened()) - { - inputFile = dummyFile.fp(); - dummyFile.Detach(); - } - } - - ~UnicodeFileReader() - { - if (inputFile != NULL) - fclose(inputFile); - } - - bool isOkay() - { - return inputFile != NULL; - } - - bool getNextLine(wxString& line) - { - std::string output; - - while (true) - { - const int c = fgetc(inputFile); - if (c == EOF) - return false; - else if (c == 0xD) - { - //Delimiter: - //---------- - //Linux: 0xA \n - //Mac: 0xD \r - //Win: 0xD 0xA \r\n <- language files are in Windows format - - fgetc(inputFile); //discard the 0xA character - - line = wxString::FromUTF8(output.c_str(), output.length()); - return true; - } - output += static_cast<char>(c); - } - } - -private: - FILE* inputFile; -}; - - -void loadTranslation(const wxString& filename, Translation& trans) //empty translation on error -{ - trans.clear(); - - UnicodeFileReader langFile(ffs3::getResourceDir() + wxT("Languages") + ffs3::zToWx(common::FILE_NAME_SEPARATOR) + filename); - if (langFile.isOkay()) - { - int rowNumber = 0; - wxString original; - wxString tmpString; - while (langFile.getNextLine(tmpString)) - { - exchangeEscapeChars(tmpString); - - if (rowNumber++ % 2 == 0) - original = tmpString; - else - { - const wxString& translation = tmpString; - - if (!original.empty() && !translation.empty()) - trans.insert(std::make_pair(original, translation)); - } - } - } -} -} - - -void ffs3::setLanguage(int language) -{ - static class StaticInit - { - public: - StaticInit() : loc(wxLANGUAGE_DEFAULT) //wxLocale: we need deferred initialization, sigh... - { - //::setlocale (LC_ALL, ""); -> implicitly called by wxLocale - const lconv* localInfo = ::localeconv(); - - //actually these two parameters are language dependent, but we take system setting to handle all kinds of language derivations - THOUSANDS_SEPARATOR = wxString::FromUTF8(localInfo->thousands_sep); - DECIMAL_POINT = wxString::FromUTF8(localInfo->decimal_point); - - // why not working? - // THOUSANDS_SEPARATOR = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).thousands_sep(); - // DECIMAL_POINT = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).decimal_point(); - } - private: - wxLocale loc; //required for RTL language support (and nothing else) - } dummy; - - activeLanguage = language; - - //default: english - wxString languageFile; - - //(try to) retrieve language filename - const int mappedLanguage = mapLanguageDialect(language); - for (std::vector<LocInfoLine>::const_iterator i = LocalizationInfo::get().begin(); i != LocalizationInfo::get().end(); ++i) - if (i->languageID == mappedLanguage) - { - languageFile = i->languageFile; - break; - } - - //load language file into buffer - activeTranslation.clear(); - if (!languageFile.empty()) - { - loadTranslation(languageFile, activeTranslation); //empty translation on error - if (activeTranslation.empty()) - { - wxMessageBox(wxString(_("Error reading file:")) + wxT(" \"") + languageFile + wxT("\""), _("Error"), wxOK | wxICON_ERROR); - activeLanguage = wxLANGUAGE_ENGLISH; //reset to english language to show this error just once - } - } - else - ; //if languageFile is empty texts will be english per default -} - - -int ffs3::getLanguage() -{ - return activeLanguage; -} - - -int ffs3::retrieveSystemLanguage() -{ - return wxLocale::GetSystemLanguage(); -} - - - -//http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html -//http://translate.sourceforge.net/wiki/l10n/pluralforms -/* -Plural forms parser: Grammar ----------------------------- -expression: - conditional-expression - -conditional-expression: - logical-or-expression - logical-or-expression ? expression : expression - -logical-or-expression: - logical-and-expression - logical-or-expression || logical-and-expression - -logical-and-expression: - equality-expression - logical-and-expression && equality-expression - -equality-expression: - relational-expression - relational-expression == relational-expression - relational-expression != relational-expression - -relational-expression: - multiplicative-expression - multiplicative-expression > multiplicative-expression - multiplicative-expression < multiplicative-expression - multiplicative-expression >= multiplicative-expression - multiplicative-expression <= multiplicative-expression - -multiplicative-expression: - pm-expression - multiplicative-expression % pm-expression - -pm-expression: - N - Number - ( Expression ) -*/ - - - -//expression interface -struct Expression { virtual ~Expression() {} }; - -template <class T> -struct Expr : public Expression -{ - typedef T ValueType; - virtual ValueType eval() const = 0; -}; - -//specific binary expression based on STL function objects -template <class StlOp> -struct BinaryExp : public Expr<typename StlOp::result_type> -{ - typedef const Expr<typename StlOp::first_argument_type> SourceExp; - - BinaryExp(const SourceExp& lhs, const SourceExp& rhs, StlOp biop) : lhs_(lhs), rhs_(rhs), biop_(biop) {} - virtual typename StlOp::result_type eval() const { return biop_(lhs_.eval(), rhs_.eval()); } - const SourceExp& lhs_; - const SourceExp& rhs_; - StlOp biop_; -}; - -template <class StlOp> -inline -BinaryExp<StlOp> makeBiExp(const Expression& lhs, const Expression& rhs, StlOp biop) //throw (std::bad_cast) -{ - return BinaryExp<StlOp>(dynamic_cast<const Expr<typename StlOp::first_argument_type >&>(lhs), - dynamic_cast<const Expr<typename StlOp::second_argument_type>&>(rhs), biop); -} - -template <class Out> -struct TernaryExp : public Out -{ - TernaryExp(const Expr<bool>& ifExp, const Out& thenExp, const Out& elseExp) : ifExp_(ifExp), thenExp_(thenExp), elseExp_(elseExp) {} - virtual typename Out::ValueType eval() const { return ifExp_.eval() ? thenExp_.eval() : elseExp_.eval(); } - const Expr<bool>& ifExp_; - const Out& thenExp_; - const Out& elseExp_; -}; - -struct LiteralNumberEx : public Expr<int> -{ - LiteralNumberEx(int n) : n_(n) {} - virtual int eval() const { return n_; } - int n_; -}; - -struct NumberN : public Expr<int> -{ - NumberN(int& n) : n_(n) {} - virtual int eval() const { return n_; } - int& n_; -}; - - -typedef Zbase<wchar_t> Wstring; - - -class PluralForm -{ -public: - struct ParsingError {}; - - PluralForm(const Wstring& phrase) : n_(0) //.po format,e.g.: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) - { - Parser(phrase, //in - expr, //out - n_, // - count, // - dump); // - } - - int formCount() const { return count; } - - int getForm(int n) const { n_ = n ; return expr->eval(); } - -private: - typedef std::list<boost::shared_ptr<Expression> > DumpList; - - struct Token - { - enum Type - { - TK_FORM_COUNT, - TK_PHRASE_BEGIN, - TK_ASSIGN, - TK_SEMICOLON, - TK_TERNARY_QUEST, - TK_TERNARY_COLON, - TK_OR, - TK_AND, - TK_EQUAL, - TK_NOT_EQUAL, - TK_LESS, - TK_LESS_EQUAL, - TK_GREATER, - TK_GREATER_EQUAL, - TK_MODULUS, - TK_N, - TK_NUMBER, - TK_BRACKET_LEFT, - TK_BRACKET_RIGHT, - TK_END - }; - - Token(Type t) : type(t), number(0) {} - - Type type; - int number; //if type == TK_NUMBER - }; - - class Scanner - { - public: - Scanner(const Wstring& phrase) : phrase_(phrase) - { - tokens.push_back(std::make_pair(L"nplurals", Token::TK_FORM_COUNT)); - tokens.push_back(std::make_pair(L"plural" , Token::TK_PHRASE_BEGIN)); - tokens.push_back(std::make_pair(L";" , Token::TK_SEMICOLON )); - tokens.push_back(std::make_pair(L"?" , Token::TK_TERNARY_QUEST)); - tokens.push_back(std::make_pair(L":" , Token::TK_TERNARY_COLON)); - tokens.push_back(std::make_pair(L"||", Token::TK_OR )); - tokens.push_back(std::make_pair(L"&&", Token::TK_AND )); - tokens.push_back(std::make_pair(L"==", Token::TK_EQUAL )); - tokens.push_back(std::make_pair(L"=" , Token::TK_ASSIGN )); - tokens.push_back(std::make_pair(L"!=", Token::TK_NOT_EQUAL )); - tokens.push_back(std::make_pair(L"<=", Token::TK_LESS_EQUAL )); - tokens.push_back(std::make_pair(L"<" , Token::TK_LESS )); - tokens.push_back(std::make_pair(L">=", Token::TK_GREATER_EQUAL)); - tokens.push_back(std::make_pair(L">" , Token::TK_GREATER )); - tokens.push_back(std::make_pair(L"%" , Token::TK_MODULUS )); - tokens.push_back(std::make_pair(L"n" , Token::TK_N )); - tokens.push_back(std::make_pair(L"N" , Token::TK_N )); - tokens.push_back(std::make_pair(L"(" , Token::TK_BRACKET_LEFT )); - tokens.push_back(std::make_pair(L")" , Token::TK_BRACKET_RIGHT)); - } - - Token nextToken() - { - phrase_.Trim(true, false); //remove whitespace - - if (phrase_.empty()) return Token(Token::TK_END); - - for (TokenList::const_iterator i = tokens.begin(); i != tokens.end(); ++i) - if (phrase_.StartsWith(i->first)) - { - phrase_ = phrase_.substr(i->first.size()); - return Token(i->second); - } - - Wstring::iterator digitEnd = std::find_if(phrase_.begin(), phrase_.end(), std::not1(std::ptr_fun(std::iswdigit))); - int digitCount = digitEnd - phrase_.begin(); - if (digitCount != 0) - { - Token out(Token::TK_NUMBER); - out.number = Wstring(phrase_.c_str(), digitCount).toNumber<int>(); - phrase_ = phrase_.substr(digitCount); - return out; - } - - throw ParsingError(); //unknown token - } - - private: - typedef std::vector<std::pair<Wstring, Token::Type> > TokenList; - TokenList tokens; - Wstring phrase_; - }; - - - class Parser - { - public: - Parser(const Wstring& phrase, //in - const Expr<int>*& expr, int& n, int& count, PluralForm::DumpList& dump) ://out - scn(phrase), - tk(scn.nextToken()), - n_(n), - dump_(dump) - { - consumeToken(Token::TK_FORM_COUNT); - consumeToken(Token::TK_ASSIGN); - - count = token().number; - consumeToken(Token::TK_NUMBER); - - consumeToken(Token::TK_SEMICOLON); - consumeToken(Token::TK_PHRASE_BEGIN); - consumeToken(Token::TK_ASSIGN); - - try - { - const Expression& e = parse(); - expr = &dynamic_cast<const Expr<int>&>(e); - } - catch(std::bad_cast&) { throw ParsingError(); } - - consumeToken(Token::TK_END); - } - - private: - void nextToken() { tk = scn.nextToken(); } - const Token& token() const { return tk; } - - void consumeToken(Token::Type t) - { - if (token().type != t) - throw ParsingError(); - nextToken(); - } - - const Expression& parse() { return parseConditional(); }; - - const Expression& parseConditional() - { - const Expression& e = parseLogicalOr(); - - if (token().type == Token::TK_TERNARY_QUEST) - { - nextToken(); - const Expression& thenEx = parse(); //associativity: <- - consumeToken(Token::TK_TERNARY_COLON); - const Expression& elseEx = parse(); // - - return manageObj(TernaryExp<Expr<int> >(dynamic_cast<const Expr<bool>&>(e), - dynamic_cast<const Expr<int>&>(thenEx), - dynamic_cast<const Expr<int>&>(elseEx))); - } - return e; - } - - const Expression& parseLogicalOr() - { - const Expression* e = &parseLogicalAnd(); - for (;;) //associativity: -> - if (token().type == Token::TK_OR) - { - nextToken(); - const Expression& rhs = parseLogicalAnd(); - e = &manageObj(makeBiExp(*e, rhs, std::logical_or<bool>())); - } - else break; - return *e; - } - - const Expression& parseLogicalAnd() - { - const Expression* e = &parseEquality(); - for (;;) //associativity: -> - if (token().type == Token::TK_AND) - { - nextToken(); - const Expression& rhs = parseEquality(); - - e = &manageObj(makeBiExp(*e, rhs, std::logical_and<bool>())); - } - else break; - return *e; - } - - const Expression& parseEquality() - { - const Expression& e = parseRelational(); - - Token::Type t = token().type; - if (t == Token::TK_EQUAL || t == Token::TK_NOT_EQUAL) //associativity: n/a - { - nextToken(); - const Expression& rhs = parseRelational(); - - if (t == Token::TK_EQUAL) - return manageObj(makeBiExp(e, rhs, std::equal_to<int>())); - else - return manageObj(makeBiExp(e, rhs, std::not_equal_to<int>())); - } - return e; - } - - const Expression& parseRelational() - { - const Expression& e = parseMultiplicative(); - - Token::Type t = token().type; - if (t == Token::TK_LESS || //associativity: n/a - t == Token::TK_LESS_EQUAL|| - t == Token::TK_GREATER || - t == Token::TK_GREATER_EQUAL) - { - nextToken(); - const Expression& rhs = parseMultiplicative(); - - if (t == Token::TK_LESS) return manageObj(makeBiExp(e, rhs, std::less <int>())); - if (t == Token::TK_LESS_EQUAL) return manageObj(makeBiExp(e, rhs, std::less_equal <int>())); - if (t == Token::TK_GREATER) return manageObj(makeBiExp(e, rhs, std::greater <int>())); - if (t == Token::TK_GREATER_EQUAL) return manageObj(makeBiExp(e, rhs, std::greater_equal<int>())); - } - return e; - } - - const Expression& parseMultiplicative() - { - const Expression* e = &parsePrimary(); - - for (;;) //associativity: -> - if (token().type == Token::TK_MODULUS) - { - nextToken(); - const Expression& rhs = parsePrimary(); - - //"compile-time" check: n % 0 - const LiteralNumberEx* literal = dynamic_cast<const LiteralNumberEx*>(&rhs); - if (literal && literal->eval() == 0) - throw ParsingError(); - - e = &manageObj(makeBiExp(*e, rhs, std::modulus<int>())); - } - else break; - return *e; - } - - const Expression& parsePrimary() - { - if (token().type == Token::TK_N) - { - nextToken(); - return manageObj(NumberN(n_)); - } - else if (token().type == Token::TK_NUMBER) - { - const int number = token().number; - nextToken(); - return manageObj(LiteralNumberEx(number)); - } - else if (token().type == Token::TK_BRACKET_LEFT) - { - nextToken(); - const Expression& e = parse(); - - consumeToken(Token::TK_BRACKET_RIGHT); - return e; - } - else - throw ParsingError(); - } - - template <class T> - const T& manageObj(const T& obj) - { - boost::shared_ptr<Expression> newEntry(new T(obj)); - dump_.push_back(newEntry); - return static_cast<T&>(*dump_.back()); - } - - Scanner scn; - Token tk; - - int& n_; - DumpList& dump_; //manage polymorphc object lifetimes - }; - - const Expr<int>* expr; - mutable int n_; - int count; - - PluralForm::DumpList dump; //manage polymorphc object lifetimes -}; - - -const wchar_t formPol[] = L"nplurals=3; plural=n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2"; -int tstPol(int n) -{ - return n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2; -} - -const wchar_t formRu[] = L"nplurals= 3; plural=n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2"; -int tstRu(int n) -{ - return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 > 20) ? 1 : 2 ; -} - -const wchar_t formLit[] = L"nplurals =3; plural=n% 10 == 1&& n % 100 != 11 ? 0 : n % 100 != 12&& n % 10 == 2 ? 1 : 0"; -int tstLit(int n) -{ - return n % 10 == 1&& n % 100 != 11 ? 0 : n % 100 != 12&& n % 10 == 2 ? 1 : 0; -} - -const wchar_t formArab[] = L"nplurals = 6; plural = n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : (n % 100 >= 3 && n % 100 <= 10) ? 3 : (n % 100 >= 11 && n % 100 <= 99) || (n % 100 == 1) || (n % 100 ==2) ? 4 : 5"; -int tstArab(int n) -{ - return n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : (n % 100 >= 3 && n % 100 <= 10) ? 3 : (n % 100 >= 11 && n % 100 <= 99) || (n % 100 == 1) || (n % 100 ==2) ? 4 : 5; -} - -const wchar_t formGerm[] = L"nplurals=2; plural= n == 1 ? 0 : 1"; -int tstGerm(int n) -{ - return n == 1 ? 0 : 1; -} - -const wchar_t formFren[] = L"nplurals=2; plural= n <= 1 ? 0 : 1"; -int tstFren(int n) -{ - return n <= 1 ? 0 : 1; -} - -const wchar_t formJap[] = L"nplurals=1; plural=0"; -int tstJap(int n) -{ - return 0; -} - -const wchar_t formRom[] = L"nplurals=3; plural= n == 1 ? 0 : n == 0 || (n % 100 >= 1 && n % 100 <= 20) ? 1 : 2 "; -int tstRom(int n) -{ - return n == 1 ? 0 : n == 0 || (n % 100 >= 1 && n % 100 <= 20) ? 1 : 2 ; -} - -const wchar_t formCze[] = L" nplurals=3; plural= n % 100 == 1 ? 0 : n % 100 >= 2 && n % 100 <= 4 ? 1 : 2"; -int tstCze(int n) -{ - return n % 100 == 1 ? 0 : n % 100 >= 2 && n % 100 <= 4 ? 1 : 2; -} - -const wchar_t formSlov[] = L" nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3 "; -int tstSlov(int n) -{ - return n % 100 == 1 ? 0 : n % 100 == 2 ? 1 : n % 100 == 3 || n % 100 == 4 ? 2 : 3; -} - -void unitTest() -{ - typedef int (*TestFun)(int); - typedef std::vector<std::pair<const wchar_t*, TestFun> > PhraseFunList; - PhraseFunList phrases; - phrases.push_back(std::make_pair(formPol, &tstPol)); - phrases.push_back(std::make_pair(formRu, &tstRu)); - phrases.push_back(std::make_pair(formLit, &tstLit)); - phrases.push_back(std::make_pair(formArab, &tstArab)); - phrases.push_back(std::make_pair(formGerm, &tstGerm)); - phrases.push_back(std::make_pair(formFren, &tstFren)); - phrases.push_back(std::make_pair(formJap, &tstJap)); - phrases.push_back(std::make_pair(formRom, &tstRom)); - phrases.push_back(std::make_pair(formCze, &tstCze)); - phrases.push_back(std::make_pair(formSlov, &tstSlov)); - - for (PhraseFunList::const_iterator i = phrases.begin(); i != phrases.end(); ++i) - { - PluralForm pf(i->first); - for (int j = 0; j < 10000000; ++j) - assert((i->second)(j) == pf.getForm(j)); - } -} - - -wxString ffs3::translate(const wxString& original) //translate into currently selected language -{ - /* - int ba = 3; - - unitTest(); - -#ifndef _MSC_VER -#warning 3434 -#endif - - */ - - - - //look for translation in buffer table - const Translation::const_iterator i = activeTranslation.find(original); - if (i != activeTranslation.end()) - return i->second.c_str(); - - //fallback - return original; -} diff --git a/shared/int64.h b/shared/int64.h new file mode 100644 index 00000000..15900fde --- /dev/null +++ b/shared/int64.h @@ -0,0 +1,227 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef FFS_LARGE_64_BIT_INTEGER_H_INCLUDED +#define FFS_LARGE_64_BIT_INTEGER_H_INCLUDED + +#include <cassert> +#include <ostream> +#include <limits> +#include <boost/cstdint.hpp> +#include <boost/numeric/conversion/bounds.hpp> +#include "assert_static.h" +#include "loki/TypeManip.h" + +#ifdef FFS_WIN +#include <wx/msw/wrapwin.h> +#endif + + +/* +zen::Int64/zen::UInt64: wrapper classes around boost::int64_t/boost::uint64_t + + - default initialization with 0 + - debug runtime overflow/underflow checks + - safe and explicit semantics: no unsafe type conversions + - safe conversion to and from Windows 64-bit integers + - specializes std::numeric_limits + - support stream operator<< and operator>> +*/ + +namespace zen +{ +template <class T, class U> inline void checkRange(U value) +{ + //caveat: std::numeric_limits<T>::min returns minimum positive(!) number for T = double, while behaving correctly for integer types... sigh + //std::numeric_limits<T>::lowest() not available before C++11 + assert(double(boost::numeric::bounds<T>::lowest ()) <= double(value) && + double(boost::numeric::bounds<T>::highest()) >= double(value)); +} + +class Int64 +{ + struct DummyClass { operator int() { return 0; } }; +public: + //safe implicit conversions + Int64() : value(0) {} + Int64(const Int64& rhs) : value(rhs.value) {} + Int64(int rhs) : value(rhs) {} //ambiguity intentional for types other than these + Int64(long rhs) : value(rhs) {} + Int64(Loki::Select<Loki::IsSameType<boost::int64_t, long>::value, DummyClass, boost::int64_t>::Result rhs) : + value(rhs) {} //-> boost::int64_t equals long int on x64 Linux! Still we want implicit behavior for all other systems! + + //unsafe explicit but checked conversion from arbitrary integer type + template <class T> explicit Int64(T rhs) : value(rhs) { checkRange<boost::int64_t>(rhs); } + + Int64& operator=(const Int64& rhs) { value = rhs.value; return *this; } + +#ifdef FFS_WIN + Int64(DWORD low, LONG high) + { + assert_static(sizeof(low) + sizeof(high) == sizeof(value)); + + LARGE_INTEGER cvt = {}; + cvt.LowPart = low; + cvt.HighPart = high; + value = cvt.QuadPart; + } + LONG getHi() const + { + LARGE_INTEGER cvt = {}; + cvt.QuadPart = value; + return cvt.HighPart; + } + DWORD getLo() const + { + LARGE_INTEGER cvt = {}; + cvt.QuadPart = value; + return cvt.LowPart; + } +#endif + + Int64& operator+=(const Int64& rhs) { checkRange<boost::int64_t>(double(value) + rhs.value); value += rhs.value; return *this; } + Int64& operator-=(const Int64& rhs) { checkRange<boost::int64_t>(double(value) - rhs.value); value -= rhs.value; return *this; } + Int64& operator*=(const Int64& rhs) { checkRange<boost::int64_t>(double(value) * rhs.value); value *= rhs.value; return *this; } + Int64& operator/=(const Int64& rhs) { assert(rhs.value != 0); value /= rhs.value; return *this; } + Int64& operator%=(const Int64& rhs) { assert(rhs.value != 0); value %= rhs.value; return *this; } + Int64& operator&=(const Int64& rhs) { value &= rhs.value; return *this;} + Int64& operator|=(const Int64& rhs) { value |= rhs.value; return *this;} + Int64& operator<<=(int rhs) { assert(rhs < 0 || (value << rhs) >> rhs == value); value <<= rhs; return *this; } + Int64& operator>>=(int rhs) { assert(rhs > 0 || (value >> rhs) << rhs == value); value >>= rhs; return *this; } + + inline friend bool operator==(const Int64& lhs, const Int64& rhs) { return lhs.value == rhs.value; } + inline friend bool operator!=(const Int64& lhs, const Int64& rhs) { return lhs.value != rhs.value; } + inline friend bool operator< (const Int64& lhs, const Int64& rhs) { return lhs.value < rhs.value; } + inline friend bool operator> (const Int64& lhs, const Int64& rhs) { return lhs.value > rhs.value; } + inline friend bool operator<=(const Int64& lhs, const Int64& rhs) { return lhs.value <= rhs.value; } + inline friend bool operator>=(const Int64& lhs, const Int64& rhs) { return lhs.value >= rhs.value; } + + //checked conversion to arbitrary target integer type + template <class T> inline friend T to(Int64 number) { checkRange<T>(number.value); return static_cast<T>(number.value); } + + template <class T> inline friend std::basic_istream<T>& operator>>(std::basic_istream<T>& lhs, Int64& rhs) { lhs >> rhs.value; return lhs; } + template <class T> inline friend std::basic_ostream<T>& operator<<(std::basic_ostream<T>& lhs, const Int64& rhs) { lhs << rhs.value; return lhs; } + +private: + boost::int64_t value; +}; + +inline Int64 operator+(const Int64& lhs, const Int64& rhs) { return Int64(lhs) += rhs; } +inline Int64 operator-(const Int64& lhs, const Int64& rhs) { return Int64(lhs) -= rhs; } +inline Int64 operator*(const Int64& lhs, const Int64& rhs) { return Int64(lhs) *= rhs; } +inline Int64 operator/(const Int64& lhs, const Int64& rhs) { return Int64(lhs) /= rhs; } +inline Int64 operator%(const Int64& lhs, const Int64& rhs) { return Int64(lhs) %= rhs; } +inline Int64 operator&(const Int64& lhs, const Int64& rhs) { return Int64(lhs) &= rhs; } +inline Int64 operator|(const Int64& lhs, const Int64& rhs) { return Int64(lhs) |= rhs; } +inline Int64 operator<<(const Int64& lhs, int rhs) { return Int64(lhs) <<= rhs; } +inline Int64 operator>>(const Int64& lhs, int rhs) { return Int64(lhs) >>= rhs; } + + + +class UInt64 +{ + struct DummyClass { operator size_t() { return 0U; } }; +public: + //safe implicit conversions + UInt64() : value(0) {} + UInt64(const UInt64& rhs) : value(rhs.value) {} + UInt64(unsigned int rhs) : value(rhs) {} //ambiguity intentional for types other than these + UInt64(unsigned long rhs) : value(rhs) {} + UInt64(Loki::Select<Loki::IsSameType<boost::uint64_t, unsigned long>::value, DummyClass, boost::uint64_t>::Result rhs) : + value(rhs) {} //-> boost::uint64_t equals unsigned long int on x64 Linux! Still we want implicit behavior for all other systems! + + //unsafe explicit but checked conversion from arbitrary integer type + template <class T> explicit UInt64(T rhs) : value(rhs) { checkRange<boost::uint64_t>(rhs); } + + UInt64& operator=(const UInt64& rhs) { value = rhs.value; return *this; } + +#ifdef FFS_WIN + UInt64(DWORD low, DWORD high) + { + assert_static(sizeof(low) + sizeof(high) == sizeof(value)); + + ULARGE_INTEGER cvt = {}; + cvt.LowPart = low; + cvt.HighPart = high; + value = cvt.QuadPart; + } + DWORD getHi() const + { + ULARGE_INTEGER cvt = {}; + cvt.QuadPart = value; + return cvt.HighPart; + } + DWORD getLo() const + { + ULARGE_INTEGER cvt = {}; + cvt.QuadPart = value; + return cvt.LowPart; + } +#endif + + UInt64& operator+=(const UInt64& rhs) { checkRange<boost::uint64_t>(double(value) + rhs.value); value += rhs.value; return *this; } + UInt64& operator-=(const UInt64& rhs) { checkRange<boost::uint64_t>(double(value) - rhs.value); value -= rhs.value; return *this; } + UInt64& operator*=(const UInt64& rhs) { checkRange<boost::uint64_t>(double(value) * rhs.value); value *= rhs.value; return *this; } + UInt64& operator/=(const UInt64& rhs) { assert(rhs.value != 0); value /= rhs.value; return *this; } + UInt64& operator%=(const UInt64& rhs) { assert(rhs.value != 0); value %= rhs.value; return *this; } + UInt64& operator&=(const UInt64& rhs) { value &= rhs.value; return *this;} + UInt64& operator|=(const UInt64& rhs) { value |= rhs.value; return *this;} + UInt64& operator<<=(int rhs) { assert(rhs < 0 || (value << rhs) >> rhs == value); value <<= rhs; return *this; } + UInt64& operator>>=(int rhs) { assert(rhs > 0 || (value >> rhs) << rhs == value); value >>= rhs; return *this; } + + inline friend bool operator==(const UInt64& lhs, const UInt64& rhs) { return lhs.value == rhs.value; } + inline friend bool operator!=(const UInt64& lhs, const UInt64& rhs) { return lhs.value != rhs.value; } + inline friend bool operator< (const UInt64& lhs, const UInt64& rhs) { return lhs.value < rhs.value; } + inline friend bool operator> (const UInt64& lhs, const UInt64& rhs) { return lhs.value > rhs.value; } + inline friend bool operator<=(const UInt64& lhs, const UInt64& rhs) { return lhs.value <= rhs.value; } + inline friend bool operator>=(const UInt64& lhs, const UInt64& rhs) { return lhs.value >= rhs.value; } + + //checked conversion to arbitrary target integer type + template <class T> inline friend T to(UInt64 number) { checkRange<T>(number.value); return static_cast<T>(number.value); } + + template <class T> inline friend std::basic_istream<T>& operator>>(std::basic_istream<T>& lhs, UInt64& rhs) { lhs >> rhs.value; return lhs; } + template <class T> inline friend std::basic_ostream<T>& operator<<(std::basic_ostream<T>& lhs, const UInt64& rhs) { lhs << rhs.value; return lhs; } + +private: + boost::uint64_t value; +}; + +inline UInt64 operator+(const UInt64& lhs, const UInt64& rhs) { return UInt64(lhs) += rhs; } +inline UInt64 operator-(const UInt64& lhs, const UInt64& rhs) { return UInt64(lhs) -= rhs; } +inline UInt64 operator*(const UInt64& lhs, const UInt64& rhs) { return UInt64(lhs) *= rhs; } +inline UInt64 operator/(const UInt64& lhs, const UInt64& rhs) { return UInt64(lhs) /= rhs; } +inline UInt64 operator%(const UInt64& lhs, const UInt64& rhs) { return UInt64(lhs) %= rhs; } +inline UInt64 operator&(const UInt64& lhs, const UInt64& rhs) { return UInt64(lhs) &= rhs; } +inline UInt64 operator|(const UInt64& lhs, const UInt64& rhs) { return UInt64(lhs) |= rhs; } +inline UInt64 operator<<(const UInt64& lhs, int rhs) { return UInt64(lhs) <<= rhs; } +inline UInt64 operator>>(const UInt64& lhs, int rhs) { return UInt64(lhs) >>= rhs; } + +template <> inline UInt64 to(Int64 number) { checkRange<boost::uint64_t>(number.value); return UInt64(number.value); } +template <> inline Int64 to(UInt64 number) { checkRange<boost:: int64_t>(number.value); return Int64(number.value); } +} + + +namespace std +{ +assert_static(std::numeric_limits<boost:: int64_t>::is_specialized); +assert_static(std::numeric_limits<boost::uint64_t>::is_specialized); + +template <> class numeric_limits<zen::Int64> : public numeric_limits<boost::int64_t> +{ +public: + static zen::Int64 min() throw() { return numeric_limits<boost::int64_t>::min(); } + static zen::Int64 max() throw() { return numeric_limits<boost::int64_t>::max(); } +}; + +template <> class numeric_limits<zen::UInt64> : public numeric_limits<boost::uint64_t> +{ +public: + static zen::UInt64 min() throw() { return numeric_limits<boost::uint64_t>::min(); } + static zen::UInt64 max() throw() { return numeric_limits<boost::uint64_t>::max(); } +}; +} + +#endif //FFS_LARGE_64_BIT_INTEGER_H_INCLUDED diff --git a/shared/system_func.cpp b/shared/last_error.cpp index 430451e5..8109b669 100644 --- a/shared/system_func.cpp +++ b/shared/last_error.cpp @@ -4,7 +4,9 @@ // * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * // ************************************************************************** // -#include "system_func.h" +#include "last_error.h" +#include "string_tools.h" +#include "i18n.h" #ifdef FFS_WIN #include <wx/msw/wrapwin.h> //includes "windows.h" @@ -17,13 +19,14 @@ #ifdef FFS_WIN -wxString ffs3::getLastErrorFormatted(unsigned long lastError) //try to get additional Windows error information +wxString zen::getLastErrorFormatted(unsigned long lastError) //try to get additional Windows error information { //determine error code if none was specified if (lastError == 0) lastError = ::GetLastError(); - wxString output = wxString(wxT("Windows Error Code ")) + wxString::Format(wxT("%u"), lastError); + wxString output = _("Windows Error Code %x:"); + output.Replace(wxT("%x"), zen::toString<wxString>(lastError)); LPWSTR buffer = NULL; if (::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | @@ -33,24 +36,26 @@ wxString ffs3::getLastErrorFormatted(unsigned long lastError) //try to get addit { if (buffer) //just to be sure { - output += wxString(wxT(": ")) + buffer; + output += wxT(" "); + output += buffer; ::LocalFree(buffer); } } ::SetLastError(lastError); //restore last error - return output; } #elif defined FFS_LINUX -wxString ffs3::getLastErrorFormatted(int lastError) //try to get additional Linux error information +wxString zen::getLastErrorFormatted(int lastError) //try to get additional Linux error information { //determine error code if none was specified if (lastError == 0) lastError = errno; //don't use "::", errno is a macro! - wxString output = wxString(wxT("Linux Error Code ")) + wxString::Format(wxT("%i"), lastError); - output += wxString(wxT(": ")) + wxString::FromUTF8(::strerror(lastError)); + wxString output = _("Linux Error Code %x:"); + output.Replace(wxT("%x"), zen::toString<wxString>(lastError)); + + output += wxT(" ") + wxString::FromUTF8(::strerror(lastError)); errno = lastError; //restore errno return output; diff --git a/shared/system_func.h b/shared/last_error.h index 0bbd25d0..9db41222 100644 --- a/shared/system_func.h +++ b/shared/last_error.h @@ -10,7 +10,7 @@ #include <wx/string.h> -namespace ffs3 +namespace zen { //evaluate GetLastError()/errno and assemble specific error message #ifdef FFS_WIN diff --git a/shared/localization.cpp b/shared/localization.cpp new file mode 100644 index 00000000..825773d9 --- /dev/null +++ b/shared/localization.cpp @@ -0,0 +1,431 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#include "localization.h" +#include <fstream> +#include <map> +#include <list> +#include <iterator> +#include <wx/ffile.h> +#include <wx/intl.h> +#include <wx/msgdlg.h> +#include "system_constants.h" +#include "parse_plural.h" +#include "parse_lng.h" +#include "util.h" +#include "string_tools.h" +#include "file_traverser.h" +#include "../shared/standard_paths.h" +#include "../shared/string_conv.h" +#include "i18n.h" + +using namespace zen; + + +namespace +{ +//global objects +wxString THOUSANDS_SEPARATOR = wxT(","); + + +class FFSLocale : public TranslationHandler +{ +public: + FFSLocale(const wxString& filename, wxLanguage languageId); //throw (lngfile::ParsingError, PluralForm::ParsingError) + + wxLanguage langId() const { return langId_; } + + virtual wxString thousandsSeparator() { return THOUSANDS_SEPARATOR; }; + + virtual wxString translate(const wxString& text) + { + //look for translation in buffer table + const Translation::const_iterator iter = transMapping.find(text); + if (iter != transMapping.end()) + return iter->second; + + return text; //fallback + } + + virtual wxString translate(const wxString& singular, const wxString& plural, int n) + { + TranslationPlural::const_iterator iter = transMappingPl.find(std::make_pair(singular, plural)); + if (iter != transMappingPl.end()) + { + const int formNo = pluralParser->getForm(n); + if (0 <= formNo && formNo < static_cast<int>(iter->second.size())) + return iter->second[formNo]; + } + + return n == 1 ? singular : plural; //fallback + } + +private: + typedef std::map<wxString, wxString> Translation; + typedef std::map<std::pair<wxString, wxString>, std::vector<wxString> > TranslationPlural; + + Translation transMapping; //map original text |-> translation + TranslationPlural transMappingPl; + std::auto_ptr<PluralForm> pluralParser; + wxLanguage langId_; +}; + + + +std::string getFileStream(const wxString& filename) //return empty string on error throw() +{ + std::string inputStream; + + //workaround to get a FILE* from a unicode filename in a portable way + wxFFile langFile(filename, wxT("rb")); + if (langFile.IsOpened()) + { + FILE* fpInput = langFile.fp(); + + std::vector<char> buffer(50 * 1024); + size_t bytesRead = 0; + do + { + bytesRead = ::fread(&buffer[0], 1, buffer.size(), fpInput); + inputStream.append(&buffer[0], bytesRead); + } + while (bytesRead == buffer.size()); + } + return inputStream; +} + + +FFSLocale::FFSLocale(const wxString& filename, wxLanguage languageId) : langId_(languageId) //throw (lngfile::ParsingError, PluralForm::ParsingError) +{ + static class StaticInit + { + public: + StaticInit() : loc(wxLANGUAGE_DEFAULT) //wxLocale: we need deferred initialization, sigh... + { + //::setlocale (LC_ALL, ""); -> implicitly called by wxLocale + const lconv* localInfo = ::localeconv(); + + //actually these two parameters are language dependent, but we take system setting to handle all kinds of language derivations + THOUSANDS_SEPARATOR = wxString::FromUTF8(localInfo->thousands_sep); + + // why not working? + // THOUSANDS_SEPARATOR = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).thousands_sep(); + // DECIMAL_POINT = std::use_facet<std::numpunct<wchar_t> >(std::locale("")).decimal_point(); + } + private: + wxLocale loc; //required for RTL language support (and nothing else) + } dummy; + + + const std::string inputStream = getFileStream(filename); + if (inputStream.empty()) + throw lngfile::ParsingError(0, 0); + + lngfile::TransHeader header; + lngfile::TranslationMap transInput; + lngfile::TranslationPluralMap transPluralInput; + lngfile::parseLng(inputStream, header, transInput, transPluralInput); //throw ParsingError + + for (lngfile::TranslationMap::const_iterator i = transInput.begin(); i != transInput.end(); ++i) + { + const wxString original = wxString::FromUTF8(i->first.c_str()); + const wxString translation = wxString::FromUTF8(i->second.c_str()); + assert(!translation.empty()); + transMapping.insert(std::make_pair(original , translation)); + } + + for (lngfile::TranslationPluralMap::const_iterator i = transPluralInput.begin(); i != transPluralInput.end(); ++i) + { + const wxString singular = wxString::FromUTF8(i->first.first.c_str()); + const wxString plural = wxString::FromUTF8(i->first.second.c_str()); + const lngfile::PluralForms& plForms = i->second; + + std::vector<wxString> plFormsWide; + for (lngfile::PluralForms::const_iterator j = plForms.begin(); j != plForms.end(); ++j) + plFormsWide.push_back(wxString::FromUTF8(j->c_str())); + + assert(!plFormsWide.empty()); + + transMappingPl.insert(std::make_pair(std::make_pair(singular, plural), plFormsWide)); + } + + pluralParser.reset(new PluralForm(header.pluralDefinition.c_str())); //throw PluralForm::ParsingError +} +} + + +class FindLngfiles : public zen::TraverseCallback +{ +public: + FindLngfiles(std::vector<Zstring>& lngFiles) : lngFiles_(lngFiles) {} + + virtual void onFile(const Zchar* shortName, const Zstring& fullName, const FileInfo& details) + { + if (Zstring(shortName).EndsWith(Zstr(".lng"))) + lngFiles_.push_back(fullName); + } + + virtual void onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details) {} + virtual ReturnValDir onDir(const Zchar* shortName, const Zstring& fullName) { return Loki::Int2Type<ReturnValDir::TRAVERSING_DIR_IGNORE>(); } + virtual void onError(const wxString& errorText) {} //errors are not really critical in this context + +private: + std::vector<Zstring>& lngFiles_; +}; + + +struct LessTranslation : public std::binary_function<ExistingTranslations::Entry, ExistingTranslations::Entry, bool> +{ + bool operator()(const ExistingTranslations::Entry& lhs, const ExistingTranslations::Entry& rhs) const + { +#ifdef FFS_WIN + //use a more "natural" sort, that is ignore case and diacritics + const int rv = ::CompareString(LOCALE_USER_DEFAULT, //__in LCID Locale, + NORM_IGNORECASE, //__in DWORD dwCmpFlags, + lhs.languageName.c_str(), //__in LPCTSTR lpString1, + static_cast<int>(lhs.languageName.size()), //__in int cchCount1, + rhs.languageName.c_str(), //__in LPCTSTR lpString2, + static_cast<int>(rhs.languageName.size())); //__in int cchCount2 + if (rv == 0) + throw std::runtime_error("Error comparing strings!"); + else + return rv == CSTR_LESS_THAN; //convert to C-style string compare result +#else + return lhs.languageName < rhs.languageName; +#endif + } +}; + + +ExistingTranslations::ExistingTranslations() +{ + { + //default entry: + ExistingTranslations::Entry newEntry; + newEntry.languageID = wxLANGUAGE_ENGLISH_US; + newEntry.languageName = wxT("English (US)"); + newEntry.languageFile = wxT(""); + newEntry.translatorName = wxT("ZenJu"); + newEntry.languageFlag = wxT("usa.png"); + locMapping.push_back(newEntry); + } + + //search language files available + std::vector<Zstring> lngFiles; + FindLngfiles traverseCallback(lngFiles); + + traverseFolder(wxToZ(zen::getResourceDir() + wxT("Languages")), //throw(); + false, //don't follow symlinks + traverseCallback); + + for (std::vector<Zstring>::const_iterator i = lngFiles.begin(); i != lngFiles.end(); ++i) + { + const std::string stream = getFileStream(zToWx(*i)); + if (!stream.empty()) + try + { + lngfile::TransHeader lngHeader; + lngfile::parseHeader(stream, lngHeader); //throw ParsingError + + const wxLanguageInfo* locInfo = wxLocale::FindLanguageInfo(wxString::FromUTF8(lngHeader.localeName.c_str())); + if (locInfo) + { + ExistingTranslations::Entry newEntry; + newEntry.languageID = locInfo->Language; + newEntry.languageName = wxString::FromUTF8(lngHeader.languageName.c_str()); + newEntry.languageFile = zToWx(*i); + newEntry.translatorName = wxString::FromUTF8(lngHeader.translatorName.c_str()); + newEntry.languageFlag = wxString::FromUTF8(lngHeader.flagFile.c_str()); + locMapping.push_back(newEntry); + } + } + catch (lngfile::ParsingError&) {} + } + + std::sort(locMapping.begin(), locMapping.end(), LessTranslation()); +} + + +namespace +{ +wxLanguage mapLanguageDialect(wxLanguage language) +{ + switch (static_cast<int>(language)) //map language dialects + { + //variants of wxLANGUAGE_GERMAN + case wxLANGUAGE_GERMAN_AUSTRIAN: + case wxLANGUAGE_GERMAN_BELGIUM: + case wxLANGUAGE_GERMAN_LIECHTENSTEIN: + case wxLANGUAGE_GERMAN_LUXEMBOURG: + case wxLANGUAGE_GERMAN_SWISS: + return wxLANGUAGE_GERMAN; + + //variants of wxLANGUAGE_FRENCH + case wxLANGUAGE_FRENCH_BELGIAN: + case wxLANGUAGE_FRENCH_CANADIAN: + case wxLANGUAGE_FRENCH_LUXEMBOURG: + case wxLANGUAGE_FRENCH_MONACO: + case wxLANGUAGE_FRENCH_SWISS: + return wxLANGUAGE_FRENCH; + + //variants of wxLANGUAGE_DUTCH + case wxLANGUAGE_DUTCH_BELGIAN: + return wxLANGUAGE_DUTCH; + + //variants of wxLANGUAGE_ITALIAN + case wxLANGUAGE_ITALIAN_SWISS: + return wxLANGUAGE_ITALIAN; + + //variants of wxLANGUAGE_CHINESE_SIMPLIFIED + case wxLANGUAGE_CHINESE: + case wxLANGUAGE_CHINESE_SINGAPORE: + return wxLANGUAGE_CHINESE_SIMPLIFIED; + + //variants of wxLANGUAGE_CHINESE_TRADITIONAL + case wxLANGUAGE_CHINESE_TAIWAN: + case wxLANGUAGE_CHINESE_HONGKONG: + case wxLANGUAGE_CHINESE_MACAU: + return wxLANGUAGE_CHINESE_TRADITIONAL; + + //variants of wxLANGUAGE_RUSSIAN + case wxLANGUAGE_RUSSIAN_UKRAINE: + return wxLANGUAGE_RUSSIAN; + + //variants of wxLANGUAGE_SPANISH + case wxLANGUAGE_SPANISH_ARGENTINA: + case wxLANGUAGE_SPANISH_BOLIVIA: + case wxLANGUAGE_SPANISH_CHILE: + case wxLANGUAGE_SPANISH_COLOMBIA: + case wxLANGUAGE_SPANISH_COSTA_RICA: + case wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC: + case wxLANGUAGE_SPANISH_ECUADOR: + case wxLANGUAGE_SPANISH_EL_SALVADOR: + case wxLANGUAGE_SPANISH_GUATEMALA: + case wxLANGUAGE_SPANISH_HONDURAS: + case wxLANGUAGE_SPANISH_MEXICAN: + case wxLANGUAGE_SPANISH_MODERN: + case wxLANGUAGE_SPANISH_NICARAGUA: + case wxLANGUAGE_SPANISH_PANAMA: + case wxLANGUAGE_SPANISH_PARAGUAY: + case wxLANGUAGE_SPANISH_PERU: + case wxLANGUAGE_SPANISH_PUERTO_RICO: + case wxLANGUAGE_SPANISH_URUGUAY: + case wxLANGUAGE_SPANISH_US: + case wxLANGUAGE_SPANISH_VENEZUELA: + return wxLANGUAGE_SPANISH; + + //variants of wxLANGUAGE_SWEDISH + case wxLANGUAGE_SWEDISH_FINLAND: + return wxLANGUAGE_SWEDISH; + + //case wxLANGUAGE_CZECH: + //case wxLANGUAGE_FINNISH: + //case wxLANGUAGE_GREEK: + //case wxLANGUAGE_JAPANESE: + //case wxLANGUAGE_POLISH: + //case wxLANGUAGE_SLOVENIAN: + //case wxLANGUAGE_HUNGARIAN: + //case wxLANGUAGE_PORTUGUESE: + //case wxLANGUAGE_PORTUGUESE_BRAZILIAN: + //case wxLANGUAGE_KOREAN: + //case wxLANGUAGE_UKRAINIAN: + + //variants of wxLANGUAGE_ARABIC + case wxLANGUAGE_ARABIC_ALGERIA: + case wxLANGUAGE_ARABIC_BAHRAIN: + case wxLANGUAGE_ARABIC_EGYPT: + case wxLANGUAGE_ARABIC_IRAQ: + case wxLANGUAGE_ARABIC_JORDAN: + case wxLANGUAGE_ARABIC_KUWAIT: + case wxLANGUAGE_ARABIC_LEBANON: + case wxLANGUAGE_ARABIC_LIBYA: + case wxLANGUAGE_ARABIC_MOROCCO: + case wxLANGUAGE_ARABIC_OMAN: + case wxLANGUAGE_ARABIC_QATAR: + case wxLANGUAGE_ARABIC_SAUDI_ARABIA: + case wxLANGUAGE_ARABIC_SUDAN: + case wxLANGUAGE_ARABIC_SYRIA: + case wxLANGUAGE_ARABIC_TUNISIA: + case wxLANGUAGE_ARABIC_UAE: + case wxLANGUAGE_ARABIC_YEMEN: + return wxLANGUAGE_ARABIC; + + //variants of wxLANGUAGE_ENGLISH_UK + case wxLANGUAGE_ENGLISH_AUSTRALIA: + case wxLANGUAGE_ENGLISH_NEW_ZEALAND: + case wxLANGUAGE_ENGLISH_TRINIDAD: + case wxLANGUAGE_ENGLISH_CARIBBEAN: + case wxLANGUAGE_ENGLISH_JAMAICA: + case wxLANGUAGE_ENGLISH_BELIZE: + case wxLANGUAGE_ENGLISH_EIRE: + case wxLANGUAGE_ENGLISH_SOUTH_AFRICA: + case wxLANGUAGE_ENGLISH_ZIMBABWE: + case wxLANGUAGE_ENGLISH_BOTSWANA: + case wxLANGUAGE_ENGLISH_DENMARK: + return wxLANGUAGE_ENGLISH_UK; + + default: + return language; + } +} +} + + +void zen::setLanguage(int language) +{ + //(try to) retrieve language file + wxString languageFile; + for (std::vector<ExistingTranslations::Entry>::const_iterator i = ExistingTranslations::get().begin(); i != ExistingTranslations::get().end(); ++i) + if (i->languageID == language) + { + languageFile = i->languageFile; + break; + } + + + //reset to english language; in case of error show error message just once + zen::setTranslator(); + + //load language file into buffer + if (!languageFile.empty()) //if languageFile is empty texts will be english per default + { + try + { + zen::setTranslator(new FFSLocale(languageFile, static_cast<wxLanguage>(language))); //throw (lngfile::ParsingError, PluralForm::ParsingError) + } + catch (lngfile::ParsingError& e) + { + wxMessageBox(wxString(_("Error reading file:")) + wxT(" \"") + languageFile + wxT("\"") + wxT("\n\n") + + wxT("Row: ") + zen::toStringSep(e.row) + wxT("\n") + + wxT("Column: ") + zen::toStringSep(e.col) + wxT("\n"), _("Error"), wxOK | wxICON_ERROR); + } + catch (PluralForm::ParsingError&) + { + wxMessageBox(wxT("Invalid Plural Form"), _("Error"), wxOK | wxICON_ERROR); + } + } +} + + + +int zen::getLanguage() +{ + FFSLocale* loc = dynamic_cast<FFSLocale*>(zen::getTranslator()); + return loc ? loc->langId() : wxLANGUAGE_ENGLISH_US; +} + + +int zen::retrieveSystemLanguage() +{ + return mapLanguageDialect(static_cast<wxLanguage>(wxLocale::GetSystemLanguage())); +} + + +const std::vector<ExistingTranslations::Entry>& ExistingTranslations::get() +{ + static ExistingTranslations instance; + return instance.locMapping; +} diff --git a/shared/localization.h b/shared/localization.h new file mode 100644 index 00000000..07ac2a69 --- /dev/null +++ b/shared/localization.h @@ -0,0 +1,41 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef MISC_H_INCLUDED +#define MISC_H_INCLUDED + +#include <wx/string.h> +#include <vector> + +namespace zen +{ +class ExistingTranslations +{ +public: + struct Entry + { + int languageID; + wxString languageName; + wxString languageFile; + wxString translatorName; + wxString languageFlag; + }; + static const std::vector<Entry>& get(); + +private: + ExistingTranslations(); + ExistingTranslations(const ExistingTranslations&); + ExistingTranslations& operator=(const ExistingTranslations&); + + std::vector<Entry> locMapping; +}; + +void setLanguage(int language); +int getLanguage(); +int retrieveSystemLanguage(); +} + +#endif // MISC_H_INCLUDED diff --git a/shared/loki/Factory.h b/shared/loki/Factory.h index 6a1ac6b7..abf4ab3b 100644 --- a/shared/loki/Factory.h +++ b/shared/loki/Factory.h @@ -210,7 +210,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6> > virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6 ) - = 0; + = 0; }; template<typename AP, typename Id, @@ -229,7 +229,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7> > virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7 ) - = 0; + = 0; }; template<typename AP, typename Id, @@ -249,7 +249,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8> > virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8) - = 0; + = 0; }; template<typename AP, typename Id, @@ -270,7 +270,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9> > virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9) - = 0; + = 0; }; template<typename AP, typename Id, @@ -292,7 +292,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> > virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10) - = 0; + = 0; }; template<typename AP, typename Id, @@ -317,7 +317,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> > virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11) - = 0; + = 0; }; template<typename AP, typename Id, @@ -343,7 +343,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11,Parm12) - = 0; + = 0; }; template<typename AP, typename Id, @@ -370,7 +370,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11,Parm12,Parm13) - = 0; + = 0; }; template<typename AP, typename Id, @@ -398,7 +398,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm8,Parm10, Parm11,Parm12,Parm13,Parm14) - = 0; + = 0; }; template<typename AP, typename Id, @@ -427,7 +427,7 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11,Parm12,Parm13,Parm14,Parm15 ) - = 0; + = 0; }; #ifndef LOKI_DISABLE_TYPELIST_MACROS @@ -503,7 +503,7 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_6( P1, P2, P3, P4, P5, P6 )> virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6 ) -= 0; + = 0; }; template<typename AP, typename Id, @@ -522,7 +522,7 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_7( P1, P2, P3, P4, P5, P6, P7 )> virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7 ) -= 0; + = 0; }; template<typename AP, typename Id, @@ -542,7 +542,7 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_8( P1, P2, P3, P4, P5, P6, P7, P8 )> virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8) -= 0; + = 0; }; template<typename AP, typename Id, @@ -563,7 +563,7 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_9( P1, P2, P3, P4, P5, P6, P7, P8, P9 ) virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9) -= 0; + = 0; }; template<typename AP, typename Id, @@ -585,7 +585,7 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_10( P1, P2, P3, P4, P5, P6, P7, P8, P9, virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10) -= 0; + = 0; }; template<typename AP, typename Id, @@ -610,7 +610,7 @@ virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11) -= 0; + = 0; }; template<typename AP, typename Id, @@ -636,7 +636,7 @@ virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11,Parm12) -= 0; + = 0; }; template<typename AP, typename Id, @@ -663,7 +663,7 @@ virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11,Parm12,Parm13) -= 0; + = 0; }; template<typename AP, typename Id, @@ -691,7 +691,7 @@ virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm8,Parm10, Parm11,Parm12,Parm13,Parm14) -= 0; + = 0; }; template<typename AP, typename Id, @@ -720,7 +720,7 @@ virtual ~FactoryImpl() {} virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9,Parm10, Parm11,Parm12,Parm13,Parm14,Parm15 ) -= 0; + = 0; }; #endif //LOKI_DISABLE_TYPELIST_MACROS diff --git a/shared/loki/Register.h b/shared/loki/Register.h index 0edf4a37..32409f4b 100644 --- a/shared/loki/Register.h +++ b/shared/loki/Register.h @@ -81,7 +81,7 @@ struct UnRegisterOnDeleteElement template<typename ElementList> struct RegisterOnCreateSet : GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement> - {}; +{}; //////////////////////////////////////////////////////////////////////////////// /// \class UnRegisterOnDeleteSet @@ -95,7 +95,7 @@ struct RegisterOnCreateSet template<typename ElementList> struct UnRegisterOnDeleteSet : GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement> - {}; +{}; //////////////////////////////////////////////////////////////////////////////// diff --git a/shared/loki/ScopeGuard.h b/shared/loki/ScopeGuard.h index 0b5445f5..46e4d892 100644 --- a/shared/loki/ScopeGuard.h +++ b/shared/loki/ScopeGuard.h @@ -66,7 +66,7 @@ protected: j.Execute(); } catch(...) - {} + {} } mutable bool dismissed_; diff --git a/shared/loki/Singleton.h b/shared/loki/Singleton.h index 40cc7550..c5f1f567 100644 --- a/shared/loki/Singleton.h +++ b/shared/loki/Singleton.h @@ -567,21 +567,21 @@ public: /// \brief Longest possible SingletonWithLongevity lifetime: 0xFFFFFFFF template <class T> struct DieLast : SingletonFixedLongevity<0xFFFFFFFF ,T> - {}; +{}; /// \struct DieDirectlyBeforeLast /// \ingroup LongevityLifetimeGroup /// \brief Lifetime is a one less than DieLast: 0xFFFFFFFF-1 template <class T> struct DieDirectlyBeforeLast : SingletonFixedLongevity<0xFFFFFFFF-1 ,T> - {}; +{}; /// \struct DieFirst /// \ingroup LongevityLifetimeGroup /// \brief Shortest possible SingletonWithLongevity lifetime: 0 template <class T> struct DieFirst : SingletonFixedLongevity<0,T> - {}; +{}; }//namespace LongevityLifetime diff --git a/shared/loki/TypeTraits.h b/shared/loki/TypeTraits.h index 00ef069e..2d5af757 100644 --- a/shared/loki/TypeTraits.h +++ b/shared/loki/TypeTraits.h @@ -154,7 +154,7 @@ template <> struct AddParameterType<void> template <typename T> struct IsFunctionPointerRaw - {enum {result = 0};}; +{enum {result = 0};}; template <typename T> struct IsFunctionPointerRaw<T(*)()> @@ -531,7 +531,7 @@ struct IsFunctionPointerRaw<T(*)( template <typename T> struct IsMemberFunctionPointerRaw - {enum {result = 0};}; +{enum {result = 0};}; template <typename T, typename S> struct IsMemberFunctionPointerRaw<T (S::*)()> diff --git a/shared/long_path_prefix.cpp b/shared/long_path_prefix.cpp deleted file mode 100644 index dc249283..00000000 --- a/shared/long_path_prefix.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#include "long_path_prefix.h" -#include <wx/msw/wrapwin.h> //includes "windows.h" - - -//there are two flavors of long path prefix: one for UNC paths, one for regular paths -const Zstring LONG_PATH_PREFIX = Zstr("\\\\?\\"); -const Zstring LONG_PATH_PREFIX_UNC = Zstr("\\\\?\\UNC"); - -template <size_t max_path> -inline -Zstring applyLongPathPrefixImpl(const Zstring& path) -{ - if (path.length() >= max_path && //maximum allowed path length without prefix is (MAX_PATH - 1) - !path.StartsWith(LONG_PATH_PREFIX)) - { - if (path.StartsWith(Zstr("\\\\"))) //UNC-name, e.g. \\zenju-pc\Users - return LONG_PATH_PREFIX_UNC + path.AfterFirst(Zchar('\\')); //convert to \\?\UNC\zenju-pc\Users - else - return LONG_PATH_PREFIX + path; //prepend \\?\ prefix - } - - //fallback - return path; -} - - -Zstring ffs3::applyLongPathPrefix(const Zstring& path) -{ - return applyLongPathPrefixImpl<MAX_PATH>(path); -} - - -Zstring ffs3::applyLongPathPrefixCreateDir(const Zstring& path) //throw() -{ - //special rule for ::CreateDirectoryEx(): MAX_PATH - 12(=^ 8.3 filename) is threshold - return applyLongPathPrefixImpl<MAX_PATH - 12>(path); -} - - -Zstring ffs3::removeLongPathPrefix(const Zstring& path) //throw() -{ - if (path.StartsWith(LONG_PATH_PREFIX)) - { - if (path.StartsWith(LONG_PATH_PREFIX_UNC)) //UNC-name - return Zstring(path).Replace(LONG_PATH_PREFIX_UNC, Zstr("\\"), false); - else - return Zstring(path).Replace(LONG_PATH_PREFIX, Zstr(""), false); - } - - //fallback - return path; -} - diff --git a/shared/long_path_prefix.h b/shared/long_path_prefix.h index df4c31ab..b6da9168 100644 --- a/shared/long_path_prefix.h +++ b/shared/long_path_prefix.h @@ -7,13 +7,13 @@ #ifndef LONGPATHPREFIX_H_INCLUDED #define LONGPATHPREFIX_H_INCLUDED +#include "zstring.h" + #ifndef FFS_WIN -use in windows build only! +#error use in windows build only! #endif -#include "zstring.h" - -namespace ffs3 +namespace zen { //handle filenames longer-equal 260 (== MAX_PATH) characters by applying \\?\-prefix (Reference: http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath) /* @@ -27,4 +27,78 @@ Zstring applyLongPathPrefixCreateDir(const Zstring& path); //throw() -> special Zstring removeLongPathPrefix(const Zstring& path); //throw() } -#endif // LONGPATHPREFIX_H_INCLUDED + + + + + + + + + + + + + + + + + + + + + +//################## implementation ################## + +//there are two flavors of long path prefix: one for UNC paths, one for regular paths +const Zstring LONG_PATH_PREFIX = Zstr("\\\\?\\"); +const Zstring LONG_PATH_PREFIX_UNC = Zstr("\\\\?\\UNC"); + +template <size_t max_path> +inline +Zstring applyLongPathPrefixImpl(const Zstring& path) +{ + assert(!path.empty()); //nicely check almost all WinAPI accesses! + if (path.length() >= max_path && //maximum allowed path length without prefix is (MAX_PATH - 1) + !path.StartsWith(LONG_PATH_PREFIX)) + { + if (path.StartsWith(Zstr("\\\\"))) //UNC-name, e.g. \\zenju-pc\Users + return LONG_PATH_PREFIX_UNC + path.AfterFirst(Zchar('\\')); //convert to \\?\UNC\zenju-pc\Users + else + return LONG_PATH_PREFIX + path; //prepend \\?\ prefix + } + + return path; //fallback +} + + +inline +Zstring zen::applyLongPathPrefix(const Zstring& path) +{ + return applyLongPathPrefixImpl<MAX_PATH>(path); +} + + +inline +Zstring zen::applyLongPathPrefixCreateDir(const Zstring& path) //throw() +{ + //special rule for ::CreateDirectoryEx(): MAX_PATH - 12(=^ 8.3 filename) is threshold + return applyLongPathPrefixImpl<MAX_PATH - 12>(path); +} + + +inline +Zstring zen::removeLongPathPrefix(const Zstring& path) //throw() +{ + if (path.StartsWith(LONG_PATH_PREFIX)) + { + if (path.StartsWith(LONG_PATH_PREFIX_UNC)) //UNC-name + return Zstring(path).Replace(LONG_PATH_PREFIX_UNC, Zstr("\\"), false); + else + return Zstring(path).Replace(LONG_PATH_PREFIX, Zstr(""), false); + } + + return path; //fallback +} + +#endif //LONGPATHPREFIX_H_INCLUDED diff --git a/shared/mouse_move_dlg.cpp b/shared/mouse_move_dlg.cpp index abaa7ead..95074b55 100644 --- a/shared/mouse_move_dlg.cpp +++ b/shared/mouse_move_dlg.cpp @@ -7,26 +7,42 @@ #include "mouse_move_dlg.h" #include <vector> #include <wx/msw/wrapwin.h> //includes "windows.h" +#include <wx/stattext.h> +#include <wx/statbmp.h> +#include <wx/statline.h> +#include <wx/animate.h> +#include <wx/panel.h> +#include <wx/gauge.h> +#include <wx/statusbr.h> -using namespace ffs3; +using namespace zen; +namespace +{ +void getAllChildren(wxWindow& parent, std::vector<wxWindow*>& out) +{ + wxWindowList& wl = parent.GetChildren(); + for (wxWindowList::iterator i = wl.begin(); i != wl.end(); ++i) + { + if (dynamic_cast<wxStaticText*> (*i) || //redirect clicks on these "dead" controls to move dialog instead + dynamic_cast<wxStaticBitmap*> (*i) || + dynamic_cast<wxAnimationCtrl*>(*i) || + dynamic_cast<wxGauge*> (*i) || + dynamic_cast<wxStaticLine*> (*i) || + dynamic_cast<wxStatusBar*> (*i) || + dynamic_cast<wxPanel*> (*i)) + out.push_back(*i); + getAllChildren(**i, out); + } +} +} -MouseMoveWindow::MouseMoveWindow(wxWindow& parent, - wxWindow* child1, - wxWindow* child2, - wxWindow* child3, - wxWindow* child4, - wxWindow* child5, - wxWindow* child6) : wxWindow(&parent, wxID_ANY) +MouseMoveWindow::MouseMoveWindow(wxWindow& parent, bool includeParent) : wxWindow(&parent, wxID_ANY) { std::vector<wxWindow*> windList; - - if (child1) windList.push_back(child1); - if (child2) windList.push_back(child2); - if (child3) windList.push_back(child3); - if (child4) windList.push_back(child4); - if (child5) windList.push_back(child5); - if (child6) windList.push_back(child6); + if (includeParent) + windList.push_back(&parent); + getAllChildren(parent, windList); for (std::vector<wxWindow*>::const_iterator i = windList.begin(); i != windList.end(); ++i) (*i)->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(MouseMoveWindow::LeftButtonDown), NULL, this); @@ -36,9 +52,6 @@ MouseMoveWindow::MouseMoveWindow(wxWindow& parent, } -MouseMoveWindow::~MouseMoveWindow() {} - - void MouseMoveWindow::LeftButtonDown(wxMouseEvent& event) { if (GetParent() && allowMove(event)) diff --git a/shared/mouse_move_dlg.h b/shared/mouse_move_dlg.h index ccdf6c01..2e23c089 100644 --- a/shared/mouse_move_dlg.h +++ b/shared/mouse_move_dlg.h @@ -9,32 +9,23 @@ #include <wx/window.h> -namespace ffs3 +namespace zen { -//move main dialog by mouse-dragging contained sub-windows: just attach to parent via new in constructor: ownership passed! +/* +move dialog by mouse-dragging contained sub-windows: just attach to parent via new in constructor: + new MouseMoveWindow(parent); //ownership passed to parent +*/ class MouseMoveWindow : public wxWindow //private wxEvtHandler { public: - MouseMoveWindow(wxWindow& parent, - wxWindow* child1, - wxWindow* child2 = NULL, - wxWindow* child3 = NULL, - wxWindow* child4 = NULL, - wxWindow* child5 = NULL, - wxWindow* child6 = NULL); + MouseMoveWindow(wxWindow& parent, bool includeParent = true); //parent including all relevant child elements - virtual ~MouseMoveWindow(); - - virtual bool allowMove(const wxMouseEvent& event) - { - return true; - } + virtual bool allowMove(const wxMouseEvent& event) { return true; } private: void LeftButtonDown(wxMouseEvent& event); }; } - #endif // MOUSEMOVEWINDOW_H_INCLUDED diff --git a/shared/parse_lng.h b/shared/parse_lng.h new file mode 100644 index 00000000..fcf20d28 --- /dev/null +++ b/shared/parse_lng.h @@ -0,0 +1,618 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef PARSE_LNG_HEADER_INCLUDED +#define PARSE_LNG_HEADER_INCLUDED + +#include <string> +#include <sstream> +#include <map> +#include <set> +#include <vector> +#include <algorithm> +#include <functional> +#include <cctype> +#include <list> +#include <stdexcept> + + +namespace lngfile +{ +//singular forms +typedef std::map <std::string, std::string> +TranslationMap; //orig |-> translation + +//plural forms +typedef std::pair<std::string, std::string> +SingularPluralPair; //1 house| n houses + +typedef std::vector<std::string> +PluralForms; //1 dom | 2 domy | 5 domów + +typedef std::map <SingularPluralPair, PluralForms> +TranslationPluralMap; //(sing/plu) |-> pluralforms + +struct TransHeader +{ + std::string languageName; //display name: "English (UK)" + std::string translatorName; //"ZenJu" + std::string localeName; //ISO 639 language code + ISO 3166 country code, e.g. "en_GB", or "en_US" + std::string flagFile; //"england.png" + int pluralCount; + std::string pluralDefinition; //"nplurals=2; plural= n == 1 ? 0 : 1" +}; + + +struct ParsingError +{ + ParsingError(size_t rowNo, size_t colNo) : row(rowNo), col(colNo) {} + size_t row; + size_t col; +}; +void parseLng(const std::string& fileStream, TransHeader& header, TranslationMap& out, TranslationPluralMap& pluralOut); //throw ParsingError +void parseHeader(const std::string& fileStream, TransHeader& header); //throw ParsingError + +class TranslationList; //unordered list of unique translation items +void generateLng(const TranslationList& in, const TransHeader& header, std::string& fileStream); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +//--------------------------- implementation --------------------------- +class TranslationList //unordered list of unique translation items +{ +public: + void addItem(const std::string& orig, const std::string& trans) + { + if (!transUnique.insert(orig).second) return; + + dump.push_back(RegularItem(std::make_pair(orig, trans))); + sequence.push_back(&dump.back()); + } + void addPluralItem(const SingularPluralPair& orig, const PluralForms& trans) + { + if (!pluralUnique.insert(orig).second) return; + + dumpPlural.push_back(PluralItem(std::make_pair(orig, trans))); + sequence.push_back(&dumpPlural.back()); + } + + bool untranslatedTextExists() const + { + for (std::list<RegularItem>::const_iterator i = dump.begin(); i != dump.end(); ++i) + if (i->value.second.empty()) + return true; + for (std::list<PluralItem>::const_iterator i = dumpPlural.begin(); i != dumpPlural.end(); ++i) + if (i->value.second.empty()) + return true; + return false; + } + +private: + friend void generateLng(const TranslationList& in, const TransHeader& header, std::string& fileStream); + + struct Item {virtual ~Item() {} }; + struct RegularItem : public Item { RegularItem(const TranslationMap ::value_type& val) : value(val) {} TranslationMap ::value_type value; }; + struct PluralItem : public Item { PluralItem (const TranslationPluralMap::value_type& val) : value(val) {} TranslationPluralMap::value_type value; }; + + std::vector<Item*> sequence; //dynamic list of translation elements + std::list<RegularItem> dump; //manage memory + std::list<PluralItem> dumpPlural; //manage memory + + std::set<TranslationMap ::key_type> transUnique; //check uniqueness + std::set<TranslationPluralMap::key_type> pluralUnique; // +}; + + +struct Token +{ + enum Type + { + //header information + TK_HEADER_BEGIN, + TK_HEADER_END, + TK_LANG_NAME_BEGIN, + TK_LANG_NAME_END, + TK_TRANS_NAME_BEGIN, + TK_TRANS_NAME_END, + TK_LOCALE_NAME_BEGIN, + TK_LOCALE_NAME_END, + TK_FLAG_FILE_BEGIN, + TK_FLAG_FILE_END, + TK_PLURAL_COUNT_BEGIN, + TK_PLURAL_COUNT_END, + TK_PLURAL_DEF_BEGIN, + TK_PLURAL_DEF_END, + + //item level + TK_SRC_BEGIN, + TK_SRC_END, + TK_TRG_BEGIN, + TK_TRG_END, + TK_TEXT, + TK_PLURAL_BEGIN, + TK_PLURAL_END, + TK_END + }; + + Token(Type t) : type(t) {} + Type type; + + std::string text; +}; + + +class KnownTokens +{ +public: + typedef std::map<Token::Type, std::string> TokenMap; + + static const TokenMap& asList() + { + static KnownTokens inst; + return inst.tokens; + } + + static std::string text(Token::Type t) + { + TokenMap::const_iterator iter = asList().find(t); + return iter != asList().end() ? iter->second : std::string(); + } + +private: + KnownTokens() + { + //header information + tokens.insert(std::make_pair(Token::TK_HEADER_BEGIN, "<header>")); + tokens.insert(std::make_pair(Token::TK_HEADER_END, "</header>")); + tokens.insert(std::make_pair(Token::TK_LANG_NAME_BEGIN, "<language name>")); + tokens.insert(std::make_pair(Token::TK_LANG_NAME_END, "</language name>")); + tokens.insert(std::make_pair(Token::TK_TRANS_NAME_BEGIN, "<translator>")); + tokens.insert(std::make_pair(Token::TK_TRANS_NAME_END, "</translator>")); + tokens.insert(std::make_pair(Token::TK_LOCALE_NAME_BEGIN, "<locale>")); + tokens.insert(std::make_pair(Token::TK_LOCALE_NAME_END, "</locale>")); + tokens.insert(std::make_pair(Token::TK_FLAG_FILE_BEGIN, "<flag file>")); + tokens.insert(std::make_pair(Token::TK_FLAG_FILE_END, "</flag file>")); + tokens.insert(std::make_pair(Token::TK_PLURAL_COUNT_BEGIN, "<plural forms>")); + tokens.insert(std::make_pair(Token::TK_PLURAL_COUNT_END, "</plural forms>")); + tokens.insert(std::make_pair(Token::TK_PLURAL_DEF_BEGIN, "<plural definition>")); + tokens.insert(std::make_pair(Token::TK_PLURAL_DEF_END, "</plural definition>")); + + //item level + tokens.insert(std::make_pair(Token::TK_SRC_BEGIN, "<source>")); + tokens.insert(std::make_pair(Token::TK_SRC_END, "</source>")); + tokens.insert(std::make_pair(Token::TK_TRG_BEGIN, "<target>")); + tokens.insert(std::make_pair(Token::TK_TRG_END, "</target>")); + tokens.insert(std::make_pair(Token::TK_PLURAL_BEGIN, "<pluralform>")); + tokens.insert(std::make_pair(Token::TK_PLURAL_END, "</pluralform>")); + } + TokenMap tokens; +}; + +struct IsWhiteSpace : public std::unary_function<char, bool> +{ + bool operator()(char c) const + { + const unsigned char usc = c; //caveat 1: std::isspace() takes an int, but expects an unsigned char + return usc < 128 && //caveat 2: some parts of UTF-8 chars are erroneously seen as whitespace, e.g. the a0 from "\xec\x8b\a0" (MSVC) + std::isspace(usc) != 0; //[!] + } +}; + +class Scanner +{ +public: + Scanner(const std::string& fileStream) : stream(fileStream), pos(stream.begin()) {} + + Token nextToken() + { + //skip whitespace + pos = std::find_if(pos, stream.end(), std::not1(IsWhiteSpace())); + + if (pos == stream.end()) + return Token(Token::TK_END); + + for (KnownTokens::TokenMap::const_iterator i = KnownTokens::asList().begin(); i != KnownTokens::asList().end(); ++i) + if (startsWith(i->second)) + { + pos += i->second.size(); + return Token(i->first); + } + + //rest must be "text" + std::string::const_iterator textBegin = pos; + while (pos != stream.end() && !startsWithKnownTag()) + pos = std::find(pos + 1, stream.end(), '<'); + + std::string text(textBegin, pos); + + normalize(text); //remove whitespace from end ect. + + if (text.empty() && pos == stream.end()) + return Token(Token::TK_END); + + Token out(Token::TK_TEXT); + out.text = text; + return out; + } + + std::pair<size_t, size_t> position() const //current (row/col) beginning with 1 + { + //seek last line break + std::string::const_iterator iter = pos; + while (iter != stream.begin() && *iter != '\n') + --iter; + + return std::make_pair(std::count(stream.begin(), pos, '\n') + 1, pos - iter); + } + +private: + bool startsWithKnownTag() const + { + for (KnownTokens::TokenMap::const_iterator i = KnownTokens::asList().begin(); i != KnownTokens::asList().end(); ++i) + if (startsWith(i->second)) + return true; + return false; + } + + bool startsWith(const std::string& prefix) const + { + if (stream.end() - pos < static_cast<int>(prefix.size())) + return false; + return std::equal(prefix.begin(), prefix.end(), pos); + } + + static void normalize(std::string& text) + { + //remmove whitespace from end + while (!text.empty() && IsWhiteSpace()(*text.rbegin())) + text.resize(text.size() - 1); + + //ensure c-style line breaks + + //Delimiter: + //---------- + //Linux: 0xA \n + //Mac: 0xD \r + //Win: 0xD 0xA \r\n <- language files are in Windows format + if (text.find('\r') != std::string::npos) + { + std::string tmp; + for (std::string::const_iterator i = text.begin(); i != text.end(); ++i) + if(*i == '\r') + { + std::string::const_iterator next = i + 1; + if (next != text.end() && *next == '\n') + ++i; + tmp += '\n'; + } + else + tmp += *i; + text = tmp; + } + } + + const std::string stream; + std::string::const_iterator pos; +}; + +template <class C, class T> +inline +std::basic_string<C> numberToString(const T& number) //convert number to string the C++ way +{ + std::basic_ostringstream<C> ss; + ss << number; + return ss.str(); +} + +template <class T, class C> +inline +T stringToNumber(const std::basic_string<C>& str) //convert string to number the C++ way +{ + T number = 0; + std::basic_istringstream<C>(str) >> number; + return number; +} + + +class LngParser +{ +public: + LngParser(const std::string& fileStream) : scn(fileStream), tk(scn.nextToken()) {} + + void parse(TranslationMap& out, TranslationPluralMap& pluralOut, TransHeader& header) + { + //header + parseHeader(header); + + //items + while (token().type != Token::TK_END) + parseRegular(out, pluralOut, header.pluralCount); + } + + void parseHeader(TransHeader& header) + { + consumeToken(Token::TK_HEADER_BEGIN); + + consumeToken(Token::TK_LANG_NAME_BEGIN); + header.languageName = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_LANG_NAME_END); + + consumeToken(Token::TK_TRANS_NAME_BEGIN); + header.translatorName = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_TRANS_NAME_END); + + consumeToken(Token::TK_LOCALE_NAME_BEGIN); + header.localeName = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_LOCALE_NAME_END); + + consumeToken(Token::TK_FLAG_FILE_BEGIN); + header.flagFile = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_FLAG_FILE_END); + + consumeToken(Token::TK_PLURAL_COUNT_BEGIN); + header.pluralCount = stringToNumber<int>(tk.text); + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_PLURAL_COUNT_END); + + consumeToken(Token::TK_PLURAL_DEF_BEGIN); + header.pluralDefinition = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_PLURAL_DEF_END); + + consumeToken(Token::TK_HEADER_END); + } + +private: + void parseRegular(TranslationMap& out, TranslationPluralMap& pluralOut, int formCount) + { + consumeToken(Token::TK_SRC_BEGIN); + + if (token().type == Token::TK_PLURAL_BEGIN) + return parsePlural(pluralOut, formCount); + + std::string original = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_SRC_END); + + consumeToken(Token::TK_TRG_BEGIN); + std::string translation; + if (token().type == Token::TK_TEXT) + { + translation = token().text; + nextToken(); + } + consumeToken(Token::TK_TRG_END); + + if (!translation.empty()) //only add if translation is existing + out.insert(std::make_pair(original, translation)); + } + + void parsePlural(TranslationPluralMap& pluralOut, int formCount) + { + //Token::TK_SRC_BEGIN already consumed + + consumeToken(Token::TK_PLURAL_BEGIN); + std::string engSingular = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_PLURAL_END); + + consumeToken(Token::TK_PLURAL_BEGIN); + std::string engPlural = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_PLURAL_END); + + consumeToken(Token::TK_SRC_END); + + consumeToken(Token::TK_TRG_BEGIN); + + PluralForms pluralList; + while (token().type == Token::TK_PLURAL_BEGIN) + { + consumeToken(Token::TK_PLURAL_BEGIN); + std::string pluralForm = tk.text; + consumeToken(Token::TK_TEXT); + consumeToken(Token::TK_PLURAL_END); + pluralList.push_back(pluralForm); + + } + + if (!pluralList.empty()&& static_cast<int>(pluralList.size()) != formCount) //invalid number of plural forms + throw ParsingError(scn.position().first, scn.position().second); + + consumeToken(Token::TK_TRG_END); + + if (!pluralList.empty()) //only add if translation is existing + pluralOut.insert(std::make_pair(SingularPluralPair(engSingular, engPlural), pluralList)); + } + + + void nextToken() { tk = scn.nextToken(); } + const Token& token() const { return tk; } + + void consumeToken(Token::Type t) + { + if (token().type != t) + throw ParsingError(scn.position().first, scn.position().second); + nextToken(); + } + + Scanner scn; + Token tk; +}; + + +inline +void parseLng(const std::string& fileStream, TransHeader& header, TranslationMap& out, TranslationPluralMap& pluralOut) //throw ParsingError +{ + out.clear(); + pluralOut.clear(); + + //skip UTF-8 Byte Ordering Mark + const bool hasBOM = fileStream.size() >= 3 && fileStream.substr(0, 3) == "\xef\xbb\xbf"; + + LngParser prs(hasBOM ? fileStream.substr(3) : fileStream); + prs.parse(out, pluralOut, header); +} + + +inline +void parseHeader(const std::string& fileStream, TransHeader& header) //throw ParsingError +{ + //skip UTF-8 Byte Ordering Mark + const bool hasBOM = fileStream.size() >= 3 && fileStream.substr(0, 3) == "\xef\xbb\xbf"; + + LngParser prs(hasBOM ? fileStream.substr(3) : fileStream); + prs.parseHeader(header); +} + + +inline +void formatMultiLineText(std::string& text) +{ + if (text.find('\n') != std::string::npos) //multiple lines + { + if (*text.begin() != '\n') + text = '\n' + text; + if (*text.rbegin() != '\n') + text += '\n'; + } +} + + +const std::string LB = "\n"; +const std::string TAB = "\t"; + + +void generateLng(const TranslationList& in, const TransHeader& header, std::string& fileStream) +{ + //header + fileStream += KnownTokens::text(Token::TK_HEADER_BEGIN) + LB; + + fileStream += TAB + KnownTokens::text(Token::TK_LANG_NAME_BEGIN); + fileStream += header.languageName; + fileStream += KnownTokens::text(Token::TK_LANG_NAME_END) + LB; + + fileStream += TAB + KnownTokens::text(Token::TK_TRANS_NAME_BEGIN); + fileStream += header.translatorName; + fileStream += KnownTokens::text(Token::TK_TRANS_NAME_END) + LB; + + fileStream += TAB + KnownTokens::text(Token::TK_LOCALE_NAME_BEGIN); + fileStream += header.localeName; + fileStream += KnownTokens::text(Token::TK_LOCALE_NAME_END) + LB; + + fileStream += TAB + KnownTokens::text(Token::TK_FLAG_FILE_BEGIN); + fileStream += header.flagFile; + fileStream += KnownTokens::text(Token::TK_FLAG_FILE_END) + LB; + + fileStream += TAB + KnownTokens::text(Token::TK_PLURAL_COUNT_BEGIN); + fileStream += numberToString<char>(header.pluralCount); + fileStream += KnownTokens::text(Token::TK_PLURAL_COUNT_END) + LB; + + fileStream += TAB + KnownTokens::text(Token::TK_PLURAL_DEF_BEGIN); + fileStream += header.pluralDefinition; + fileStream += KnownTokens::text(Token::TK_PLURAL_DEF_END) + LB; + + fileStream += KnownTokens::text(Token::TK_HEADER_END) + LB; + + fileStream += LB; + + + //items + for (std::vector<TranslationList::Item*>::const_iterator i = in.sequence.begin(); i != in.sequence.end(); ++i) + { + const TranslationList::RegularItem* regular = dynamic_cast<const TranslationList::RegularItem*>(*i); + const TranslationList::PluralItem* plural = dynamic_cast<const TranslationList::PluralItem*>(*i); + + if (regular) + { + std::string original = regular->value.first; + std::string translation = regular->value.second; + + formatMultiLineText(original); + formatMultiLineText(translation); + + fileStream += KnownTokens::text(Token::TK_SRC_BEGIN); + fileStream += original; + fileStream += KnownTokens::text(Token::TK_SRC_END) + LB; + + fileStream += KnownTokens::text(Token::TK_TRG_BEGIN); + fileStream += translation; + fileStream += KnownTokens::text(Token::TK_TRG_END) + LB; + + } + else if (plural) + { + std::string engSingular = plural->value.first.first; + std::string engPlural = plural->value.first.second; + const PluralForms& forms = plural->value.second; + + formatMultiLineText(engSingular); + formatMultiLineText(engPlural); + + fileStream += KnownTokens::text(Token::TK_SRC_BEGIN) + LB; + fileStream += KnownTokens::text(Token::TK_PLURAL_BEGIN); + fileStream += engSingular; + fileStream += KnownTokens::text(Token::TK_PLURAL_END) + LB; + fileStream += KnownTokens::text(Token::TK_PLURAL_BEGIN); + fileStream += engPlural; + fileStream += KnownTokens::text(Token::TK_PLURAL_END)+ LB; + fileStream += KnownTokens::text(Token::TK_SRC_END) + LB; + + fileStream += KnownTokens::text(Token::TK_TRG_BEGIN); + if (!forms.empty()) fileStream += LB; + + for (PluralForms::const_iterator j = forms.begin(); j != forms.end(); ++j) + { + std::string plForm = *j; + formatMultiLineText(plForm); + + fileStream += KnownTokens::text(Token::TK_PLURAL_BEGIN); + fileStream += plForm; + fileStream += KnownTokens::text(Token::TK_PLURAL_END) + LB; + } + fileStream += KnownTokens::text(Token::TK_TRG_END) + LB; + } + else + { + throw std::logic_error("that's what you get for brittle design ;)"); + } + } +} +} + +#endif //PARSE_LNG_HEADER_INCLUDED diff --git a/shared/parse_plural.h b/shared/parse_plural.h new file mode 100644 index 00000000..0a0e7545 --- /dev/null +++ b/shared/parse_plural.h @@ -0,0 +1,412 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef PARSE_PLURAL_H_INCLUDED +#define PARSE_PLURAL_H_INCLUDED + +#include <list> +#include <boost/shared_ptr.hpp> +#include "zbase.h" + + +//http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html +//http://translate.sourceforge.net/wiki/l10n/pluralforms +/* +Grammar for Plural forms parser +------------------------------- +expression: + conditional-expression + +conditional-expression: + logical-or-expression + logical-or-expression ? expression : expression + +logical-or-expression: + logical-and-expression + logical-or-expression || logical-and-expression + +logical-and-expression: + equality-expression + logical-and-expression && equality-expression + +equality-expression: + relational-expression + relational-expression == relational-expression + relational-expression != relational-expression + +relational-expression: + multiplicative-expression + multiplicative-expression > multiplicative-expression + multiplicative-expression < multiplicative-expression + multiplicative-expression >= multiplicative-expression + multiplicative-expression <= multiplicative-expression + +multiplicative-expression: + pm-expression + multiplicative-expression % pm-expression + +pm-expression: + N + Number + ( Expression ) +*/ + + + +//expression interface +struct Expression { virtual ~Expression() {} }; + +template <class T> +struct Expr : public Expression +{ + typedef T ValueType; + virtual ValueType eval() const = 0; +}; + +//specific binary expression based on STL function objects +template <class StlOp> +struct BinaryExp : public Expr<typename StlOp::result_type> +{ + typedef const Expr<typename StlOp::first_argument_type> SourceExp; + + BinaryExp(const SourceExp& lhs, const SourceExp& rhs, StlOp biop) : lhs_(lhs), rhs_(rhs), biop_(biop) {} + virtual typename StlOp::result_type eval() const { return biop_(lhs_.eval(), rhs_.eval()); } + const SourceExp& lhs_; + const SourceExp& rhs_; + StlOp biop_; +}; + +template <class StlOp> +inline +BinaryExp<StlOp> makeBiExp(const Expression& lhs, const Expression& rhs, StlOp biop) //throw (std::bad_cast) +{ + return BinaryExp<StlOp>(dynamic_cast<const Expr<typename StlOp::first_argument_type >&>(lhs), + dynamic_cast<const Expr<typename StlOp::second_argument_type>&>(rhs), biop); +} + +template <class Out> +struct TernaryExp : public Out +{ + TernaryExp(const Expr<bool>& ifExp, const Out& thenExp, const Out& elseExp) : ifExp_(ifExp), thenExp_(thenExp), elseExp_(elseExp) {} + virtual typename Out::ValueType eval() const { return ifExp_.eval() ? thenExp_.eval() : elseExp_.eval(); } + const Expr<bool>& ifExp_; + const Out& thenExp_; + const Out& elseExp_; +}; + +struct LiteralNumberEx : public Expr<int> +{ + LiteralNumberEx(int n) : n_(n) {} + virtual int eval() const { return n_; } + int n_; +}; + +struct NumberN : public Expr<int> +{ + NumberN(int& n) : n_(n) {} + virtual int eval() const { return n_; } + int& n_; +}; + + +typedef Zbase<char> Wstring; + + +class PluralForm +{ +public: + struct ParsingError {}; + + //.po format,e.g.: (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) + PluralForm(const Wstring& phrase) : n_(0) + { + Parser(phrase, //in + expr, n_, dump); //out + } + + int getForm(int n) const { n_ = n ; return expr->eval(); } + +private: + typedef std::list<boost::shared_ptr<Expression> > DumpList; + + struct Token + { + enum Type + { + TK_TERNARY_QUEST, + TK_TERNARY_COLON, + TK_OR, + TK_AND, + TK_EQUAL, + TK_NOT_EQUAL, + TK_LESS, + TK_LESS_EQUAL, + TK_GREATER, + TK_GREATER_EQUAL, + TK_MODULUS, + TK_N, + TK_NUMBER, + TK_BRACKET_LEFT, + TK_BRACKET_RIGHT, + TK_END + }; + + Token(Type t) : type(t), number(0) {} + + Type type; + int number; //if type == TK_NUMBER + }; + + class Scanner + { + public: + Scanner(const Wstring& phrase) : stream(phrase), pos(stream.begin()) + { + tokens.push_back(std::make_pair("?" , Token::TK_TERNARY_QUEST)); + tokens.push_back(std::make_pair(":" , Token::TK_TERNARY_COLON)); + tokens.push_back(std::make_pair("||", Token::TK_OR )); + tokens.push_back(std::make_pair("&&", Token::TK_AND )); + tokens.push_back(std::make_pair("==", Token::TK_EQUAL )); + tokens.push_back(std::make_pair("!=", Token::TK_NOT_EQUAL )); + tokens.push_back(std::make_pair("<=", Token::TK_LESS_EQUAL )); + tokens.push_back(std::make_pair("<" , Token::TK_LESS )); + tokens.push_back(std::make_pair(">=", Token::TK_GREATER_EQUAL)); + tokens.push_back(std::make_pair(">" , Token::TK_GREATER )); + tokens.push_back(std::make_pair("%" , Token::TK_MODULUS )); + tokens.push_back(std::make_pair("n" , Token::TK_N )); + tokens.push_back(std::make_pair("N" , Token::TK_N )); + tokens.push_back(std::make_pair("(" , Token::TK_BRACKET_LEFT )); + tokens.push_back(std::make_pair(")" , Token::TK_BRACKET_RIGHT)); + } + + Token nextToken() + { + //skip whitespace + pos = std::find_if(pos, stream.end(), std::not1(std::ptr_fun(std::iswspace))); + + if (pos == stream.end()) return Token(Token::TK_END); + + for (TokenList::const_iterator i = tokens.begin(); i != tokens.end(); ++i) + if (startsWith(i->first)) + { + pos += i->first.size(); + return Token(i->second); + } + + Wstring::const_iterator digitEnd = std::find_if(pos, stream.end(), std::not1(std::ptr_fun(std::iswdigit))); + int digitCount = digitEnd - pos; + if (digitCount != 0) + { + Token out(Token::TK_NUMBER); + out.number = Wstring(&*pos, digitCount).toNumber<int>(); + pos += digitCount; + return out; + } + + throw ParsingError(); //unknown token + } + + private: + bool startsWith(const Wstring& prefix) const + { + if (stream.end() - pos < static_cast<int>(prefix.size())) + return false; + return std::equal(prefix.begin(), prefix.end(), pos); + } + + typedef std::vector<std::pair<Wstring, Token::Type> > TokenList; + TokenList tokens; + + const Wstring stream; + Wstring::const_iterator pos; + }; + + + class Parser + { + public: + Parser(const Wstring& phrase, //in + const Expr<int>*& expr, int& n, PluralForm::DumpList& dump) ://out + scn(phrase), + tk(scn.nextToken()), + n_(n), + dump_(dump) + { + try + { + const Expression& e = parse(); + expr = &dynamic_cast<const Expr<int>&>(e); + } + catch(std::bad_cast&) { throw ParsingError(); } + + consumeToken(Token::TK_END); + } + + private: + void nextToken() { tk = scn.nextToken(); } + const Token& token() const { return tk; } + + void consumeToken(Token::Type t) + { + if (token().type != t) + throw ParsingError(); + nextToken(); + } + + const Expression& parse() { return parseConditional(); }; + + const Expression& parseConditional() + { + const Expression& e = parseLogicalOr(); + + if (token().type == Token::TK_TERNARY_QUEST) + { + nextToken(); + const Expression& thenEx = parse(); //associativity: <- + consumeToken(Token::TK_TERNARY_COLON); + const Expression& elseEx = parse(); // + + return manageObj(TernaryExp<Expr<int> >(dynamic_cast<const Expr<bool>&>(e), + dynamic_cast<const Expr<int>&>(thenEx), + dynamic_cast<const Expr<int>&>(elseEx))); + } + return e; + } + + const Expression& parseLogicalOr() + { + const Expression* e = &parseLogicalAnd(); + for (;;) //associativity: -> + if (token().type == Token::TK_OR) + { + nextToken(); + const Expression& rhs = parseLogicalAnd(); + e = &manageObj(makeBiExp(*e, rhs, std::logical_or<bool>())); + } + else break; + return *e; + } + + const Expression& parseLogicalAnd() + { + const Expression* e = &parseEquality(); + for (;;) //associativity: -> + if (token().type == Token::TK_AND) + { + nextToken(); + const Expression& rhs = parseEquality(); + + e = &manageObj(makeBiExp(*e, rhs, std::logical_and<bool>())); + } + else break; + return *e; + } + + const Expression& parseEquality() + { + const Expression& e = parseRelational(); + + Token::Type t = token().type; + if (t == Token::TK_EQUAL || t == Token::TK_NOT_EQUAL) //associativity: n/a + { + nextToken(); + const Expression& rhs = parseRelational(); + + if (t == Token::TK_EQUAL) return manageObj(makeBiExp(e, rhs, std::equal_to <int>())); + if (t == Token::TK_NOT_EQUAL) return manageObj(makeBiExp(e, rhs, std::not_equal_to<int>())); + } + return e; + } + + const Expression& parseRelational() + { + const Expression& e = parseMultiplicative(); + + Token::Type t = token().type; + if (t == Token::TK_LESS || //associativity: n/a + t == Token::TK_LESS_EQUAL|| + t == Token::TK_GREATER || + t == Token::TK_GREATER_EQUAL) + { + nextToken(); + const Expression& rhs = parseMultiplicative(); + + if (t == Token::TK_LESS) return manageObj(makeBiExp(e, rhs, std::less <int>())); + if (t == Token::TK_LESS_EQUAL) return manageObj(makeBiExp(e, rhs, std::less_equal <int>())); + if (t == Token::TK_GREATER) return manageObj(makeBiExp(e, rhs, std::greater <int>())); + if (t == Token::TK_GREATER_EQUAL) return manageObj(makeBiExp(e, rhs, std::greater_equal<int>())); + } + return e; + } + + const Expression& parseMultiplicative() + { + const Expression* e = &parsePrimary(); + + for (;;) //associativity: -> + if (token().type == Token::TK_MODULUS) + { + nextToken(); + const Expression& rhs = parsePrimary(); + + //"compile-time" check: n % 0 + const LiteralNumberEx* literal = dynamic_cast<const LiteralNumberEx*>(&rhs); + if (literal && literal->eval() == 0) + throw ParsingError(); + + e = &manageObj(makeBiExp(*e, rhs, std::modulus<int>())); + } + else break; + return *e; + } + + const Expression& parsePrimary() + { + if (token().type == Token::TK_N) + { + nextToken(); + return manageObj(NumberN(n_)); + } + else if (token().type == Token::TK_NUMBER) + { + const int number = token().number; + nextToken(); + return manageObj(LiteralNumberEx(number)); + } + else if (token().type == Token::TK_BRACKET_LEFT) + { + nextToken(); + const Expression& e = parse(); + + consumeToken(Token::TK_BRACKET_RIGHT); + return e; + } + else + throw ParsingError(); + } + + template <class T> + const T& manageObj(const T& obj) + { + boost::shared_ptr<Expression> newEntry(new T(obj)); + dump_.push_back(newEntry); + return static_cast<T&>(*dump_.back()); + } + + Scanner scn; + Token tk; + + int& n_; + DumpList& dump_; //manage polymorphc object lifetimes + }; + + const Expr<int>* expr; + mutable int n_; + + PluralForm::DumpList dump; //manage polymorphc object lifetimes +}; + +#endif // PARSE_PLURAL_H_INCLUDED diff --git a/shared/parse_txt.cpp b/shared/parse_txt.cpp new file mode 100644 index 00000000..56da3bdd --- /dev/null +++ b/shared/parse_txt.cpp @@ -0,0 +1,93 @@ +#include "parse_txt.h" + +using namespace zen; + + +namespace +{ +std::string detectLineBreak(const Zstring& filename) //throw (FileError) +{ + //read a (hopefully) significant portion of data + zen::FileInput input(filename); + + std::vector<char> buffer(64 * 1024); + size_t bytesRead = input.read(&buffer[0], buffer.size()); //throw (FileError); + buffer.resize(bytesRead); + + //detect line break + std::string linebreakChars = "\r\n"; + std::vector<char>::iterator iter = std::find_first_of(buffer.begin(), buffer.end(), + linebreakChars.begin(), linebreakChars.end()); + if (iter != buffer.end()) + { + wxString firstRow = wxString::FromUTF8(&buffer[0], iter - buffer.begin()); + + if (*iter == '\r') + { + ++iter; + if (iter != buffer.end()) + { + + if (*iter == '\n') + return "\r\n"; //Windows + else + return "\r"; //Mac + } + } + else if (*iter == '\n') + return "\n"; //Linux + } + //fallback + return "\n"; +} +} + + +ExtractLines::ExtractLines(const Zstring& filename, const std::string& lineBreak) : //throw (FileError) + inputStream(filename), bufferLogBegin(buffer.begin()), lineBreak_(lineBreak) +{ + if (lineBreak.empty()) + lineBreak_ = detectLineBreak(filename); //throw (FileError) +} + + +bool ExtractLines::getLine(std::string& output) //throw (FileError) +{ + for (;;) + { + //check if full line is in buffer + std::vector<char>::iterator iter = std::search(bufferLogBegin, buffer.end(), lineBreak_.begin(), lineBreak_.end()); + if (iter != buffer.end()) + { + output.assign(bufferLogBegin, iter); + bufferLogBegin = iter + lineBreak_.size(); + return true; + } + + buffer.erase(buffer.begin(), bufferLogBegin); + bufferLogBegin = buffer.begin(); + + //if done: cleanup + if (inputStream.eof()) + { + if (buffer.empty()) + return false; + + output.assign(buffer.begin(), buffer.end()); + buffer.clear(); + return true; + } + + //read next block + const size_t BLOCK_SIZE = 512 * 1024; + buffer.resize(buffer.size() + BLOCK_SIZE); + + size_t bytesRead = inputStream.read(&buffer[0] + buffer.size() - BLOCK_SIZE, BLOCK_SIZE); //throw (FileError); + assert(bytesRead <= BLOCK_SIZE); //promised by FileInput() + + if (bytesRead < BLOCK_SIZE) + buffer.resize(buffer.size() - (BLOCK_SIZE - bytesRead)); + + bufferLogBegin = buffer.begin(); + } +} diff --git a/shared/parse_txt.h b/shared/parse_txt.h new file mode 100644 index 00000000..56147425 --- /dev/null +++ b/shared/parse_txt.h @@ -0,0 +1,32 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef PARSE_TXT_H_INCLUDED +#define PARSE_TXT_H_INCLUDED + +#include "file_io.h" +#include <vector> +#include <string> + +namespace zen +{ +class ExtractLines +{ +public: + ExtractLines(const Zstring& filename, const std::string& lineBreak = std::string()); //throw (FileError) + bool getLine(std::string& output); //throw (FileError) + +private: + zen::FileInput inputStream; + std::vector<char> buffer; + std::vector<char>::iterator bufferLogBegin; + std::string lineBreak_; +}; + +} + + +#endif // PARSE_TXT_H_INCLUDED diff --git a/shared/pch.h b/shared/pch.h index eb95fd50..71a09899 100644 --- a/shared/pch.h +++ b/shared/pch.h @@ -23,30 +23,7 @@ #endif #include <wx/wxprec.h> - -//##################################################### -// #include other rarely changing headers here - -//STL headers -#include <string> -#include <vector> -#include <set> -#include <map> -#include <queue> -#include <deque> -#include <stack> -#include <list> -#include <algorithm> -#include <functional> -#include <iterator> -#include <numeric> -#include <memory> -#include <utility> -#include <fstream> -#include <iostream> -#include <sstream> -#include <new> -#include <stdexcept> +//#include <wx/msw/wrapwin.h> -> already included via wxprec.h //other wxWidgets headers #include <wx/log.h> @@ -104,16 +81,32 @@ #include <wx/help.h> #include <wx/event.h> -//other -#include "../shared/tinyxml/tinyxml.h" -#include <sys/stat.h> +//##################################################### +// #include other rarely changing headers here + +//STL headers +#include <string> +#include <vector> +#include <set> +#include <map> +#include <queue> +#include <deque> +#include <stack> +#include <list> +#include <algorithm> +#include <functional> +#include <iterator> +#include <numeric> +#include <memory> +#include <utility> +#include <fstream> +#include <iostream> +#include <sstream> +#include <new> +#include <stdexcept> //Boost #include <boost/shared_ptr.hpp> #include <boost/scoped_array.hpp> -#ifdef __WXMSW__ -#include <wx/msw/wrapwin.h> //includes "windows.h" -#endif //__WXMSW__ - #endif //FFS_PRECOMPILED_HEADER diff --git a/shared/perf.h b/shared/perf.h index 641eee2b..8bd89643 100644 --- a/shared/perf.h +++ b/shared/perf.h @@ -9,7 +9,7 @@ #include <sstream> -#ifdef __WXWINDOWS__ +#ifdef __WXMSW__ //we have wxWidgets #include <wx/msw/wrapwin.h> //includes "windows.h" #else //#define WIN32_LEAN_AND_MEAN -> not in a header diff --git a/shared/privilege.cpp b/shared/privilege.cpp index 5cb664e1..c854ad4e 100644 --- a/shared/privilege.cpp +++ b/shared/privilege.cpp @@ -1,9 +1,9 @@ #include "privilege.h" -#include "system_func.h" +#include "last_error.h" #include "i18n.h" #include "loki/ScopeGuard.h" -using namespace ffs3; +using namespace zen; Privileges& Privileges::getInstance() @@ -20,8 +20,8 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) TOKEN_QUERY, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); (void)dummy; //silence warning "unused variable" @@ -33,8 +33,8 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) privilege, //__in LPCTSTR lpName, &luid )) //__out PLUID lpLuid { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } PRIVILEGE_SET priv = {}; @@ -49,8 +49,8 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) &priv, //__inout PPRIVILEGE_SET RequiredPrivileges, &alreadyGranted)) //__out LPBOOL pfResult { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } return alreadyGranted == TRUE; @@ -64,8 +64,8 @@ void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError TOKEN_ADJUST_PRIVILEGES, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); (void)dummy; //silence warning "unused variable" @@ -76,8 +76,8 @@ void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError privilege, //__in LPCTSTR lpName, &luid )) //__out PLUID lpLuid { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } TOKEN_PRIVILEGES tp = {}; @@ -93,13 +93,13 @@ void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError NULL, //__out_opt PTOKEN_PRIVILEGES PreviousState, NULL)) //__out_opt PDWORD ReturnLength { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } if (::GetLastError() == ERROR_NOT_ALL_ASSIGNED) //check although previous function returned with success! { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\"") + wxT("\n\n"); - throw FileError(errorMessage + ffs3::getLastErrorFormatted()); + const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } } diff --git a/shared/privilege.h b/shared/privilege.h index 0c5d5f0c..4775fcef 100644 --- a/shared/privilege.h +++ b/shared/privilege.h @@ -7,7 +7,7 @@ #include <wx/msw/wrapwin.h> //includes "windows.h" -namespace ffs3 +namespace zen { #ifdef FFS_WIN class Privileges diff --git a/shared/recycler.cpp b/shared/recycler.cpp index 4fedf01f..32de3f33 100644 --- a/shared/recycler.cpp +++ b/shared/recycler.cpp @@ -73,7 +73,7 @@ Nevertheless, let's use IFileOperation for better error reporting! void moveToWindowsRecycler(const std::vector<Zstring>& filesToDelete) //throw (FileError) { - using ffs3::FileError; + using zen::FileError; if (filesToDelete.empty()) return; @@ -97,21 +97,21 @@ void moveToWindowsRecycler(const std::vector<Zstring>& filesToDelete) //throw ( getLastError = util::getDllFun<GetLastErrorFct>(getRecyclerDllName().c_str(), getLastErrorFctName); if (moveToRecycler == NULL || getLastError == NULL) - throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + fileNames[0] + wxT("\"\n\n") + //report first file only... better than nothing - wxString(_("Could not load a required DLL:")) + wxT(" \"") + getRecyclerDllName().c_str() + wxT("\"")); + throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + fileNames[0] + wxT("\"") + //report first file only... better than nothing + wxT("\n\n") + wxString(_("Could not load a required DLL:")) + wxT(" \"") + getRecyclerDllName().c_str() + wxT("\"")); //#warning moving long file paths to recycler does not work! clarify! // std::vector<Zstring> temp; // std::transform(filesToDelete.begin(), filesToDelete.end(), - // std::back_inserter(temp), std::ptr_fun(ffs3::removeLongPathPrefix)); //::IFileOperation() can't handle \\?\-prefix! + // std::back_inserter(temp), std::ptr_fun(zen::removeLongPathPrefix)); //::IFileOperation() can't handle \\?\-prefix! if (!moveToRecycler(&fileNames[0], //array must not be empty fileNames.size())) { wchar_t errorMessage[2000]; getLastError(errorMessage, 2000); - throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + fileNames[0] + wxT("\"\n\n") + //report first file only... better than nothing - wxT("(") + errorMessage + wxT(")")); + throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + fileNames[0] + wxT("\"") + //report first file only... better than nothing + wxT("\n\n") + wxT("(") + errorMessage + wxT(")")); } } else //regular recycle bin usage: available since XP @@ -146,19 +146,24 @@ void moveToWindowsRecycler(const std::vector<Zstring>& filesToDelete) //throw ( } -bool ffs3::moveToRecycleBin(const Zstring& fileToDelete) //throw (FileError) +bool zen::moveToRecycleBin(const Zstring& fileToDelete) //throw (FileError) { #ifdef FFS_WIN const Zstring filenameFmt = applyLongPathPrefix(fileToDelete); - if (::GetFileAttributes(filenameFmt.c_str()) == INVALID_FILE_ATTRIBUTES) + + const DWORD attr = ::GetFileAttributes(filenameFmt.c_str()); + if (attr == INVALID_FILE_ATTRIBUTES) return false; //neither file nor any other object with that name existing: no error situation, manual deletion relies on it! + //::SetFileAttributes(filenameFmt.c_str(), FILE_ATTRIBUTE_NORMAL); + + //both SHFileOperation and useIFileOperation are not able to delete a folder named "System Volume Information" with normal attributes but shamelessly report success std::vector<Zstring> fileNames; fileNames.push_back(fileToDelete); ::moveToWindowsRecycler(fileNames); //throw (FileError) #elif defined FFS_LINUX - struct stat fileInfo; + struct stat fileInfo = {}; if (::lstat(fileToDelete.c_str(), &fileInfo) != 0) return false; //neither file nor any other object with that name existing: no error situation, manual deletion relies on it! @@ -168,8 +173,8 @@ bool ffs3::moveToRecycleBin(const Zstring& fileToDelete) //throw (FileError) try { if (!fileObj->trash()) - throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + zToWx(fileToDelete) + wxT("\"\n\n") + - wxT("(") + wxT("unknown error") + wxT(")")); + throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + zToWx(fileToDelete) + wxT("\"") + + wxT("\n\n") + wxT("(") + wxT("unknown error") + wxT(")")); } catch (const Glib::Error& errorObj) { @@ -177,15 +182,15 @@ bool ffs3::moveToRecycleBin(const Zstring& fileToDelete) //throw (FileError) const wxString errorMessage = wxString(wxT("Glib Error Code ")) + wxString::Format(wxT("%i"), errorObj.code()) + wxT(", ") + wxString::FromUTF8(g_quark_to_string(errorObj.domain())) + wxT(": ") + wxString::FromUTF8(errorObj.what().c_str()); - throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + zToWx(fileToDelete) + wxT("\"\n\n") + - wxT("(") + errorMessage + wxT(")")); + throw FileError(wxString(_("Error moving to Recycle Bin:")) + wxT("\n\"") + zToWx(fileToDelete) + wxT("\"") + + wxT("\n\n") + wxT("(") + errorMessage + wxT(")")); } #endif -return true; + return true; } -bool ffs3::recycleBinExists() +bool zen::recycleBinExists() { #ifdef FFS_WIN return true; diff --git a/shared/recycler.h b/shared/recycler.h index 404d6f06..85df6f41 100644 --- a/shared/recycler.h +++ b/shared/recycler.h @@ -10,7 +10,7 @@ #include "file_error.h" #include "zstring.h" -namespace ffs3 +namespace zen { /* -------------------- @@ -19,7 +19,7 @@ namespace ffs3 Windows ------- -Recycler always available: during runtime dynamically either SHFileOperation or (since Vista) IFileOperation will be selected +Recycler always available: during runtime either SHFileOperation or (since Vista) IFileOperation will be dynamically selected Linux ----- diff --git a/shared/resolve_path.cpp b/shared/resolve_path.cpp index b17c3fb5..1fdc2430 100644 --- a/shared/resolve_path.cpp +++ b/shared/resolve_path.cpp @@ -1,5 +1,4 @@ #include "resolve_path.h" -#include <boost/scoped_array.hpp> #include <wx/utils.h> #include <wx/datetime.h> #include "string_conv.h" @@ -17,7 +16,7 @@ #include "stdlib.h" #endif -using namespace ffs3; +using namespace zen; using namespace common; @@ -26,11 +25,12 @@ namespace #ifdef FFS_WIN Zstring resolveRelativePath(const Zstring& relativeName, DWORD proposedBufferSize = 1000) { - boost::scoped_array<Zchar> fullPath(new Zchar[proposedBufferSize]); + std::vector<Zchar> fullPath(proposedBufferSize); + const DWORD rv = ::GetFullPathName( applyLongPathPrefix(relativeName).c_str(), //__in LPCTSTR lpFileName, proposedBufferSize, //__in DWORD nBufferLength, - fullPath.get(), //__out LPTSTR lpBuffer, + &fullPath[0], //__out LPTSTR lpBuffer, NULL); //__out LPTSTR *lpFilePart if (rv == 0 || rv == proposedBufferSize) //ERROR! Don't do anything @@ -38,7 +38,7 @@ Zstring resolveRelativePath(const Zstring& relativeName, DWORD proposedBufferSiz if (rv > proposedBufferSize) return resolveRelativePath(relativeName, rv); - return fullPath.get(); + return &fullPath[0]; } #elif defined FFS_LINUX @@ -149,7 +149,7 @@ void expandMacros(wxString& text) #ifdef FFS_LINUX -class TraverseMedia : public ffs3::TraverseCallback +class TraverseMedia : public zen::TraverseCallback { public: typedef std::map<Zstring, Zstring> DeviceList; //device name -> device path mapping @@ -174,10 +174,9 @@ private: Zstring getVolumePath(const Zstring& volumeName) //empty string on error { #ifdef FFS_WIN - const size_t volGuidSize = 10000; - boost::scoped_array<wchar_t> volGuid(new wchar_t[volGuidSize]); + std::vector<wchar_t> volGuid(10000); - HANDLE hVol = ::FindFirstVolume(volGuid.get(), volGuidSize); + HANDLE hVol = ::FindFirstVolume(&volGuid[0], static_cast<DWORD>(volGuid.size())); if (hVol != INVALID_HANDLE_VALUE) { Loki::ScopeGuard dummy = Loki::MakeGuard(::FindVolumeClose, hVol); @@ -185,19 +184,18 @@ Zstring getVolumePath(const Zstring& volumeName) //empty string on error do { - const size_t volNameSize = MAX_PATH + 1; - boost::scoped_array<wchar_t> volName(new wchar_t[volNameSize]); - - if (::GetVolumeInformation(volGuid.get(), //__in_opt LPCTSTR lpRootPathName, - volName.get(), //__out LPTSTR lpVolumeNameBuffer, - volNameSize, //__in DWORD nVolumeNameSize, - NULL, //__out_opt LPDWORD lpVolumeSerialNumber, - NULL, //__out_opt LPDWORD lpMaximumComponentLength, - NULL, //__out_opt LPDWORD lpFileSystemFlags, - NULL, //__out LPTSTR lpFileSystemNameBuffer, - 0)) //__in DWORD nFileSystemNameSize + std::vector<wchar_t> volName(MAX_PATH + 1); + + if (::GetVolumeInformation(&volGuid[0], //__in_opt LPCTSTR lpRootPathName, + &volName[0], //__out LPTSTR lpVolumeNameBuffer, + static_cast<DWORD>(volName.size()), //__in DWORD nVolumeNameSize, + NULL, //__out_opt LPDWORD lpVolumeSerialNumber, + NULL, //__out_opt LPDWORD lpMaximumComponentLength, + NULL, //__out_opt LPDWORD lpFileSystemFlags, + NULL, //__out LPTSTR lpFileSystemNameBuffer, + 0)) //__in DWORD nFileSystemNameSize { - if (EqualFilename()(volumeName, Zstring(volName.get()))) + if (EqualFilename()(volumeName, Zstring(&volName[0]))) { //GetVolumePathNamesForVolumeName is not available for Windows 2000! typedef BOOL (WINAPI *GetVolumePathNamesForVolumeNameWFunc)(LPCWSTR lpszVolumeName, @@ -210,23 +208,22 @@ Zstring getVolumePath(const Zstring& volumeName) //empty string on error if (getVolumePathNamesForVolumeName != NULL) { - const DWORD volPathSize = 10000; - boost::scoped_array<wchar_t> volPath(new wchar_t[volPathSize]); + std::vector<wchar_t> volPath(10000); DWORD returnedLen = 0; - if (getVolumePathNamesForVolumeName(volGuid.get(), //__in LPCTSTR lpszVolumeName, - volPath.get(), //__out LPTSTR lpszVolumePathNames, - volPathSize, //__in DWORD cchBufferLength, - &returnedLen)) //__out PDWORD lpcchReturnLength + if (getVolumePathNamesForVolumeName(&volGuid[0], //__in LPCTSTR lpszVolumeName, + &volPath[0], //__out LPTSTR lpszVolumePathNames, + static_cast<DWORD>(volPath.size()), //__in DWORD cchBufferLength, + &returnedLen)) //__out PDWORD lpcchReturnLength { - return volPath.get(); //return first path name in double-null terminated list! + return &volPath[0]; //return first path name in double-null terminated list! } } - return volGuid.get(); //GUID looks ugly, but should be working correctly + return &volGuid[0]; //GUID looks ugly, but should be working correctly } } } - while (::FindNextVolume(hVol, volGuid.get(), volGuidSize)); + while (::FindNextVolume(hVol, &volGuid[0], static_cast<DWORD>(volGuid.size()))); } #elif defined FFS_LINUX @@ -283,7 +280,7 @@ void expandVolumeName(Zstring& text) // [volname]:\folder [volname]\folde } -Zstring ffs3::getFormattedDirectoryName(const Zstring& dirname) +Zstring zen::getFormattedDirectoryName(const Zstring& dirname) { //Formatting is needed since functions expect the directory to end with '\' to be able to split the relative names. //note: don't combine directory formatting with wxFileName, as it doesn't respect //?/ - prefix! @@ -295,7 +292,10 @@ Zstring ffs3::getFormattedDirectoryName(const Zstring& dirname) expandVolumeName(output); - output.Trim(); + //remove leading/trailing whitespace + trim(output, true, false); + while (endsWith(output, Zstr(" "))) //don't remove all whitespace from right, e.g. 0xa0 may be used as part of dir name + output.resize(output.size() - 1); if (output.empty()) //an empty string will later be returned as "\"; this is not desired return Zstring(); diff --git a/shared/resolve_path.h b/shared/resolve_path.h index 0bd4b0d2..4ee1a90f 100644 --- a/shared/resolve_path.h +++ b/shared/resolve_path.h @@ -10,7 +10,7 @@ #include "zstring.h" -namespace ffs3 +namespace zen { Zstring getFormattedDirectoryName(const Zstring& dirname); } diff --git a/shared/serialize.cpp b/shared/serialize.cpp index 719d0861..634b830b 100644 --- a/shared/serialize.cpp +++ b/shared/serialize.cpp @@ -7,13 +7,13 @@ #include "serialize.h" #include "i18n.h" -using namespace util; +using namespace zen; void ReadInputStream::throwReadError() const //throw (FileError) { - throw ffs3::FileError(wxString(_("Error reading from synchronization database:")) + wxT(" \n") + - wxT("\"") + errorObjName_ + wxT("\"")); + throw zen::FileError(wxString(_("Error reading from synchronization database:")) + wxT(" \n") + + wxT("\"") + errorObjName_ + wxT("\"")); } @@ -35,8 +35,8 @@ ReadInputStream::CharArray ReadInputStream::readArrayC() const //-------------------------------------------------------------------------------------------------------- void WriteOutputStream::throwWriteError() const //throw (FileError) { - throw ffs3::FileError(wxString(_("Error writing to synchronization database:")) + wxT(" \n") + - wxT("\"") + errorObjName_ + wxT("\"")); + throw zen::FileError(wxString(_("Error writing to synchronization database:")) + wxT(" \n") + + wxT("\"") + errorObjName_ + wxT("\"")); } diff --git a/shared/serialize.h b/shared/serialize.h index db1848d5..0f2f398f 100644 --- a/shared/serialize.h +++ b/shared/serialize.h @@ -7,24 +7,58 @@ #ifndef SERIALIZE_H_INCLUDED #define SERIALIZE_H_INCLUDED -#include "zstring.h" -#include <wx/stream.h> +#include <vector> #include "file_error.h" -#include <boost/scoped_array.hpp> +#include <wx/stream.h> #include <boost/shared_ptr.hpp> #include <boost/cstdint.hpp> +#include "file_io.h" -namespace util + +namespace zen { -template <class T> -T readNumber(wxInputStream& stream); +//unchecked, unformatted serialization +template <class T> T readPOD (wxInputStream& stream); +template <class T> void writePOD(wxOutputStream& stream, const T& pod); + +template <class S> S readString (wxInputStream& stream); +template <class S> void writeString(wxOutputStream& stream, const S& str); + + +//############# wxWidgets stream adapter ############# +// can be used as base classes (have virtual destructors) +class FileInputStream : public wxInputStream +{ +public: + FileInputStream(const Zstring& filename) : //throw (FileError) + fileObj(filename) {} + +private: + virtual size_t OnSysRead(void* buffer, size_t bufsize) + { + return fileObj.read(buffer, bufsize); //throw (FileError) + } + + zen::FileInput fileObj; +}; -template <class T> -void writeNumber(wxOutputStream& stream, T number); +class FileOutputStream : public wxOutputStream +{ +public: + FileOutputStream(const Zstring& filename) : //throw (FileError) + fileObj(filename, zen::FileOutput::ACC_OVERWRITE) {} + +private: + virtual size_t OnSysWrite(const void* buffer, size_t bufsize) + { + fileObj.write(buffer, bufsize); //throw (FileError) + return bufsize; + } + + zen::FileOutput fileObj; +}; -Zstring readString(wxInputStream& stream); -void writeString(wxOutputStream& stream, const Zstring& str); class ReadInputStream //throw (FileError) @@ -35,7 +69,8 @@ protected: template <class T> T readNumberC() const; //throw (FileError), checked read operation - Zstring readStringC() const; //throw (FileError), checked read operation + template <class S> + S readStringC() const; //throw (FileError), checked read operation typedef boost::shared_ptr<std::vector<char> > CharArray; //there's no guarantee std::string has a ref-counted implementation... so use this "thing" CharArray readArrayC() const; //throw (FileError) @@ -62,7 +97,8 @@ protected: template <class T> void writeNumberC(T number) const; //throw (FileError), checked write operation - void writeStringC(const Zstring& str) const; //throw (FileError), checked write operation + template <class S> + void writeStringC(const S& str) const; //throw (FileError), checked write operation void writeArrayC(const std::vector<char>& buffer) const; //throw (FileError) @@ -110,46 +146,50 @@ private: //---------------Inline Implementation--------------------------------------------------- template <class T> inline -T readNumber(wxInputStream& stream) +T readPOD(wxInputStream& stream) { - T result = 0; - stream.Read(&result, sizeof(T)); - return result; + T pod = 0; + stream.Read(reinterpret_cast<char*>(&pod), sizeof(T)); + return pod; } template <class T> inline -void writeNumber(wxOutputStream& stream, T number) +void writePOD(wxOutputStream& stream, const T& pod) { - stream.Write(&number, sizeof(T)); + stream.Write(reinterpret_cast<const char*>(&pod), sizeof(T)); } +template <class S> inline -Zstring readString(wxInputStream& stream) +S readString(wxInputStream& stream) { - const boost::uint32_t strLength = readNumber<boost::uint32_t>(stream); + typedef typename S::value_type CharType; + + const boost::uint32_t strLength = readPOD<boost::uint32_t>(stream); if (strLength <= 1000) { - Zchar buffer[1000]; - stream.Read(buffer, sizeof(Zchar) * strLength); - return Zstring(buffer, strLength); + CharType buffer[1000]; + stream.Read(buffer, sizeof(CharType) * strLength); + return S(buffer, strLength); } else { - boost::scoped_array<Zchar> buffer(new Zchar[strLength]); - stream.Read(buffer.get(), sizeof(Zchar) * strLength); - return Zstring(buffer.get(), strLength); + std::vector<CharType> buffer(strLength); //throw (std::bad_alloc) + stream.Read(&buffer[0], sizeof(CharType) * strLength); + return S(&buffer[0], strLength); } } +template <class S> inline -void writeString(wxOutputStream& stream, const Zstring& str) +void writeString(wxOutputStream& stream, const S& str) { - writeNumber<boost::uint32_t>(stream, static_cast<boost::uint32_t>(str.length())); - stream.Write(str.c_str(), sizeof(Zchar) * str.length()); + writePOD(stream, static_cast<boost::uint32_t>(str.length())); + stream.Write(str.c_str(), sizeof(typename S::value_type) * str.length()); } @@ -165,17 +205,26 @@ template <class T> inline T ReadInputStream::readNumberC() const //checked read operation { - T output = readNumber<T>(stream_); + T output = readPOD<T>(stream_); check(); return output; } +template <class S> inline -Zstring ReadInputStream::readStringC() const //checked read operation +S ReadInputStream::readStringC() const //checked read operation { - Zstring output = readString(stream_); - check(); + S output; + try + { + output = readString<S>(stream_); //throw (std::bad_alloc) + check(); + } + catch (std::exception&) + { + throwReadError(); + } return output; } @@ -184,13 +233,14 @@ template <class T> inline void WriteOutputStream::writeNumberC(T number) const //checked write operation { - writeNumber<T>(stream_, number); + writePOD<T>(stream_, number); check(); } +template <class S> inline -void WriteOutputStream::writeStringC(const Zstring& str) const //checked write operation +void WriteOutputStream::writeStringC(const S& str) const //checked write operation { writeString(stream_, str); check(); @@ -205,7 +255,6 @@ void WriteOutputStream::check() const throwWriteError(); } - } -#endif // SERIALIZE_H_INCLUDED +#endif //SERIALIZE_H_INCLUDED diff --git a/shared/shadow.cpp b/shared/shadow.cpp index 150a8bbf..52ffefc7 100644 --- a/shared/shadow.cpp +++ b/shared/shadow.cpp @@ -18,7 +18,7 @@ using shadow::ShadowCopy; using shadow::WaitingForShadow; -using ffs3::FileError; +using zen::FileError; namespace @@ -165,7 +165,7 @@ shadow::ReleaseShadowCopyFct ShadowCopy::ShadowVolume::releaseShadowCopy; Zstring ShadowCopy::makeShadowCopy(const Zstring& inputFile) { - using namespace ffs3; + using namespace zen; wchar_t volumeNameRaw[1000]; diff --git a/shared/shell_execute.h b/shared/shell_execute.h new file mode 100644 index 00000000..d3605a09 --- /dev/null +++ b/shared/shell_execute.h @@ -0,0 +1,97 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef EXECUTE_HEADER_23482134578134134 +#define EXECUTE_HEADER_23482134578134134 + +#include <wx/string.h> +#include <wx/msgdlg.h> + +#ifdef FFS_WIN +#include "string_tools.h" +#include "last_error.h" +#include "i18n.h" +#include <wx/msw/wrapwin.h> //includes "windows.h" + +#elif defined FFS_LINUX +#include <wx/utils.h> +#endif + + +namespace zen +{ +//launch commandline and report errors via popup dialog +//windows: COM needs to be initialized before calling this function! +namespace +{ +enum ExecutionType +{ + EXEC_TYPE_SYNC, + EXEC_TYPE_ASYNC +}; + +void shellExecute(const wxString& command, ExecutionType type = EXEC_TYPE_ASYNC) +{ +#ifdef FFS_WIN + //parse commandline + std::vector<std::wstring> argv; + { + int argc = 0; + LPWSTR* tmp = ::CommandLineToArgvW(command.c_str(), &argc); + for (int i = 0; i < argc; ++i) + argv.push_back(tmp[i]); + ::LocalFree(tmp); + } + + wxString filename; + wxString arguments; + if (!argv.empty()) + { + filename = argv[0]; + for (std::vector<std::wstring>::const_iterator i = argv.begin() + 1; i != argv.end(); ++i) + arguments += (i != argv.begin() ? L" " : L"") + + (i->empty() || std::find_if(i->begin(), i->end(), &cStringIsWhiteSpace<wchar_t>) != i->end() ? L"\"" + *i + L"\"" : *i); + } + + SHELLEXECUTEINFO execInfo = {}; + execInfo.cbSize = sizeof(execInfo); + + //SEE_MASK_NOASYNC is equal to SEE_MASK_FLAG_DDEWAIT, but former is defined not before Win SDK 6.0 + execInfo.fMask = type == EXEC_TYPE_SYNC ? (SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT) : 0; //don't use SEE_MASK_ASYNCOK -> returns successful despite errors! + execInfo.fMask |= SEE_MASK_UNICODE | SEE_MASK_FLAG_NO_UI; //::ShellExecuteEx() shows a non-blocking pop-up dialog on errors -> we want a blocking one + execInfo.lpVerb = L"open"; + execInfo.lpFile = filename.c_str(); + execInfo.lpParameters = arguments.c_str(); + execInfo.nShow = SW_SHOWNORMAL; + + if (!::ShellExecuteEx(&execInfo)) //__inout LPSHELLEXECUTEINFO lpExecInfo + { + wxString errorMsg = _("Invalid commandline: \"%x\""); + errorMsg.Replace(L"%x", filename + L" " + arguments); + wxMessageBox(errorMsg + L"\n\n" + getLastErrorFormatted()); + return; + } + + if (type == EXEC_TYPE_SYNC) + { + if (execInfo.hProcess != 0) + { + ::WaitForSingleObject(execInfo.hProcess, INFINITE); + ::CloseHandle(execInfo.hProcess); + } + } + +#elif defined FFS_LINUX + //by default wxExecute uses a zero sized dummy window as a hack to keep focus which leaves a useless empty icon in ALT-TAB list + //=> use wxEXEC_NODISABLE and roll our own window disabler! (see comment in app.cpp: void *wxGUIAppTraits::BeforeChildWaitLoop()) + wxWindowDisabler dummy; //disables all top level windows + wxExecute(command, (type == EXEC_TYPE_ASYNC ? wxEXEC_ASYNC : wxEXEC_SYNC) | wxEXEC_NODISABLE); +#endif +} +} +} + +#endif //EXECUTE_HEADER_23482134578134134 diff --git a/shared/standard_paths.cpp b/shared/standard_paths.cpp index e4f87dd6..44deafff 100644 --- a/shared/standard_paths.cpp +++ b/shared/standard_paths.cpp @@ -9,78 +9,87 @@ #include "system_constants.h" #include "string_conv.h" -using namespace ffs3; +using namespace zen; -bool ffs3::isPortableVersion() +namespace { +const wxString& getBinaryDir() //directory containing executable WITH path separator at end +{ + static wxString instance = zToWx(wxToZ(wxStandardPaths::Get().GetExecutablePath()).BeforeLast(common::FILE_NAME_SEPARATOR) + common::FILE_NAME_SEPARATOR); + return instance; +} + #ifdef FFS_WIN - static const bool isPortable = !wxFileExists(ffs3::getBinaryDir() + wxT("uninstall.exe")); //this check is a bit lame... -#elif defined FFS_LINUX - static const bool isPortable = !ffs3::getBinaryDir().EndsWith(wxT("/bin/")); //this check is a bit lame... +wxString getInstallDir() //root install directory WITH path separator at end +{ + return getBinaryDir().BeforeLast(common::FILE_NAME_SEPARATOR).BeforeLast(common::FILE_NAME_SEPARATOR) + common::FILE_NAME_SEPARATOR; +} #endif - return isPortable; } -const wxString& ffs3::getBinaryDir() +bool zen::isPortableVersion() { - static wxString instance = zToWx(wxToZ(wxStandardPaths::Get().GetExecutablePath()).BeforeLast(common::FILE_NAME_SEPARATOR) + common::FILE_NAME_SEPARATOR); - return instance; +#ifdef FFS_WIN + static const bool isPortable = !wxFileExists(getInstallDir() + wxT("uninstall.exe")); //this check is a bit lame... +#elif defined FFS_LINUX + static const bool isPortable = !::getBinaryDir().EndsWith(wxT("/bin/")); //this check is a bit lame... +#endif + return isPortable; } -const wxString& ffs3::getResourceDir() +wxString zen::getResourceDir() { #ifdef FFS_WIN - return getBinaryDir(); + return getInstallDir(); #elif defined FFS_LINUX - static wxString resourceDir; - - static bool isInitalized = false; //poor man's singleton... - if (!isInitalized) + if (isPortableVersion()) + return getBinaryDir(); + else //use OS' standard paths { - isInitalized = true; + wxString resourceDir = wxStandardPathsBase::Get().GetResourcesDir(); - if (isPortableVersion()) - resourceDir = getBinaryDir(); - else //use OS' standard paths - { - resourceDir = wxStandardPathsBase::Get().GetResourcesDir(); + if (!resourceDir.EndsWith(zToWx(common::FILE_NAME_SEPARATOR))) + resourceDir += zToWx(common::FILE_NAME_SEPARATOR); - if (!resourceDir.EndsWith(zToWx(common::FILE_NAME_SEPARATOR))) - resourceDir += zToWx(common::FILE_NAME_SEPARATOR); - } + return resourceDir; } - - return resourceDir; #endif } -const wxString& ffs3::getConfigDir() +wxString zen::getConfigDir() { - static wxString userDirectory; - - static bool isInitalized = false; //poor man's singleton... - if (!isInitalized) + if (isPortableVersion()) +#ifdef FFS_WIN + return getInstallDir(); +#elif defined FFS_LINUX + //wxString(wxT(".")) + zToWx(common::FILE_NAME_SEPARATOR) -> don't use current working directory + //avoid surprises with GlobalSettings.xml being newly created in each working directory + return getBinaryDir(); +#endif + else //use OS' standard paths { - isInitalized = true; + wxString userDirectory = wxStandardPathsBase::Get().GetUserDataDir(); - if (isPortableVersion()) - //userDirectory = wxString(wxT(".")) + zToWx(common::FILE_NAME_SEPARATOR); //use current working directory - userDirectory = getBinaryDir(); //avoid surprises with GlobalSettings.xml being newly created in each working directory - else //use OS' standard paths - { - userDirectory = wxStandardPathsBase::Get().GetUserDataDir(); + if (!wxDirExists(userDirectory)) + ::wxMkdir(userDirectory); //only top directory needs to be created: no recursion necessary - if (!wxDirExists(userDirectory)) - ::wxMkdir(userDirectory); //only top directory needs to be created: no recursion necessary + if (!userDirectory.EndsWith(zToWx(common::FILE_NAME_SEPARATOR))) + userDirectory += zToWx(common::FILE_NAME_SEPARATOR); - if (!userDirectory.EndsWith(zToWx(common::FILE_NAME_SEPARATOR))) - userDirectory += zToWx(common::FILE_NAME_SEPARATOR); - } + return userDirectory; } +} + - return userDirectory; +wxString zen::getLauncher() +{ +#ifdef FFS_WIN + return getInstallDir() + wxT("FreeFileSync.exe"); +#elif defined FFS_LINUX + return getBinaryDir() + wxT("FreeFileSync"); +#endif } diff --git a/shared/standard_paths.h b/shared/standard_paths.h index 5ecae9a7..faafe263 100644 --- a/shared/standard_paths.h +++ b/shared/standard_paths.h @@ -10,16 +10,16 @@ #include <wx/string.h> -namespace ffs3 +namespace zen { //------------------------------------------------------------------------------ //global program directories //------------------------------------------------------------------------------ -const wxString& getBinaryDir(); //directory containing executable WITH path separator at end -const wxString& getResourceDir(); //resource directory WITH path separator at end -const wxString& getConfigDir(); //config directory WITH path separator at end +wxString getResourceDir(); //resource directory WITH path separator at end +wxString getConfigDir(); //config directory WITH path separator at end //------------------------------------------------------------------------------ +wxString getLauncher(); //full path to application launcher C:\...\FreeFileSync.exe bool isPortableVersion(); } diff --git a/shared/string_conv.h b/shared/string_conv.h index 24cb521e..248605f6 100644 --- a/shared/string_conv.h +++ b/shared/string_conv.h @@ -10,7 +10,7 @@ #include <wx/string.h> #include "zstring.h" -namespace ffs3 +namespace zen { //conversion from Zstring to wxString wxString zToWx(const Zstring& str); @@ -74,7 +74,7 @@ wxString zToWx(const Zchar* str) inline wxString zToWx(Zchar ch) { - return zToWx(Zstring(ch)); + return zToWx(Zstring() + ch); } //----------------------------------------------------------------- diff --git a/shared/string_tools.h b/shared/string_tools.h new file mode 100644 index 00000000..53365f71 --- /dev/null +++ b/shared/string_tools.h @@ -0,0 +1,444 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef STRING_TOOLS_HEADER_213458973046 +#define STRING_TOOLS_HEADER_213458973046 + +#include <cstddef> //size_t +#include <cctype> //isspace +#include <cwctype> //iswspace +#include <algorithm> +#include <cassert> +#include <sstream> +#include <functional> +#include <vector> +#include "loki/TypeTraits.h" + + +//enhance arbitray string class with useful non-member functions: +namespace zen +{ +template <class C> size_t cStringLength(const C* input); //strlen() +template <class C> bool cStringIsWhiteSpace(C ch); +template <class C> bool cStringIsDigit(C ch); + +template <class S> bool startsWith(const S& str, typename S::value_type prefix); +template <class S> bool startsWith(const S& str, const typename S::value_type* prefix); +template <class S, class T> bool startsWith(const S& str, const T& prefix, typename T::value_type dummy = 0); //SFINAE: T must be a "string" +template <class S> bool endsWith(const S& str, typename S::value_type postfix); +template <class S> bool endsWith(const S& str, const typename S::value_type* postfix); +template <class S, class T> bool endsWith(const S& str, const T& postfix, typename T::value_type dummy = 0); //SFINAE: T must be a "string" + +template <class S> S afterLast (const S& str, typename S::value_type ch); //returns the whole string if ch not found +template <class S> S beforeLast (const S& str, typename S::value_type ch); //returns empty string if ch not found +template <class S> S afterFirst (const S& str, typename S::value_type ch); //returns empty string if ch not found +template <class S> S beforeFirst(const S& str, typename S::value_type ch); //returns the whole string if ch not found + +template <class S, class T> std::vector<S> split(const S& str, const T& delimiter); +template <class S> void truncate(S& str, size_t newLen); +template <class S> void replace(S& str, const typename S::value_type* old, const typename S::value_type* replacement, bool replaceAll); +template <class S> void trim(S& str, bool fromLeft = true, bool fromRight = true); + +//formatted number conversion the C++ way +template <class S, class Num> S toString(const Num& number); +template <class Num, class S> Num toNumber(const S& str); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +//---------------------- implementation ---------------------- + +template <class C> +inline +size_t cStringLength(const C* input) //strlen() +{ + const C* iter = input; + while (*iter != 0) + ++iter; + return iter - input; +} + + +template <> +inline +bool cStringIsWhiteSpace(char ch) +{ + const unsigned char usc = ch; //caveat 1: std::isspace() takes an int, but expects an unsigned char + return usc < 128 && //caveat 2: some parts of UTF-8 chars are erroneously seen as whitespace, e.g. the a0 from "\xec\x8b\xa0" (MSVC) + std::isspace(usc) != 0; +} + +template <> +inline +bool cStringIsWhiteSpace(wchar_t ch) +{ + return std::iswspace(ch) != 0; //some compilers (e.g. VC++ 6.0) return true for a call to isspace('\xEA'); but no issue with newer versions of MSVC +} + + +template <> +inline +bool cStringIsDigit(char ch) +{ + return std::isdigit(static_cast<unsigned char>(ch)) != 0; //caveat: takes an int, but expects an unsigned char +} + + +template <> +inline +bool cStringIsDigit(wchar_t ch) +{ + return std::iswdigit(ch) != 0; +} + + +template <class S> +inline +bool startsWith(const S& str, typename S::value_type prefix) +{ + return str.length() != 0 && str.operator[](0) == prefix; +} + + +template <class S> +inline +bool startsWith(const S& str, const typename S::value_type* prefix) +{ + const size_t pfLength = cStringLength(prefix); + if (str.length() < pfLength) + return false; + + return std::equal(str.c_str(), str.c_str() + pfLength, + prefix); +} + + +template <class S, class T> +inline +bool startsWith(const S& str, const T& prefix, typename T::value_type) +{ + if (str.length() < prefix.length()) + return false; + + return std::equal(str.c_str(), str.c_str() + prefix.length(), + prefix.c_str()); +} + + +template <class S> +inline +bool endsWith(const S& str, typename S::value_type postfix) +{ + const size_t len = str.length(); + return len != 0 && str.operator[](len - 1) == postfix; +} + + +template <class S> +inline +bool endsWith(const S& str, const typename S::value_type* postfix) +{ + const size_t pfLength = cStringLength(postfix); + if (str.length() < pfLength) + return false; + + const typename S::value_type* cmpBegin = str.c_str() + str.length() - pfLength; + return std::equal(cmpBegin, cmpBegin + pfLength, + postfix); +} + + +template <class S, class T> +inline +bool endsWith(const S& str, const T& postfix, typename T::value_type) +{ + if (str.length() < postfix.length()) + return false; + + const typename S::value_type* cmpBegin = str.c_str() + str.length() - postfix.length(); + return std::equal(cmpBegin, cmpBegin + postfix.length(), + postfix.c_str()); +} + + +// get all characters after the last occurence of ch +// (returns the whole string if ch not found) +template <class S> +inline +S afterLast(const S& str, typename S::value_type ch) +{ + const size_t pos = str.rfind(ch); + if (pos != S::npos) + return S(str.c_str() + pos + 1, str.length() - pos - 1); + else + return str; +} + + +// get all characters before the last occurence of ch +// (returns empty string if ch not found) +template <class S> +inline +S beforeLast(const S& str, typename S::value_type ch) +{ + const size_t pos = str.rfind(ch); + if (pos != S::npos) + return S(str.c_str(), pos); //data is non-empty string in this context: else ch would not have been found! + else + return S(); +} + + +//returns empty string if ch not found +template <class S> +inline +S afterFirst(const S& str, typename S::value_type ch) +{ + const size_t pos = str.find(ch); + if (pos != S::npos) + return S(str.c_str() + pos + 1, str.length() - pos - 1); + else + return S(); + +} + + +//returns the whole string if ch not found +template <class S> +inline +S beforeFirst(const S& str, typename S::value_type ch) +{ + const size_t pos = str.find(ch, 0); + if (pos != S::npos) + return S(str.c_str(), pos); //data is non-empty string in this context: else ch would not have been found! + else + return str; +} + + +template <class S, class T> +inline +std::vector<S> split(const S& str, const T& delimiter) +{ + const S delim = S() + delimiter; //handle char, char* and string + std::vector<S> output; + size_t bockStart = 0; + if (!delim.empty()) + { + for (size_t blockEnd = str.find(delim, bockStart); + blockEnd != S::npos; + bockStart = blockEnd + delim.size(), blockEnd = str.find(delim, bockStart)) + { + output.push_back(S(str.c_str() + bockStart, blockEnd - bockStart)); + } + } + output.push_back(S(str.c_str() + bockStart, str.length() - bockStart)); + return output; +} + + +template <class S> +inline +void truncate(S& str, size_t newLen) +{ + if (newLen < str.length()) + str.resize(newLen); +} + + +template <class S> +inline +void replace(S& str, const typename S::value_type* old, const typename S::value_type* replacement, bool replaceAll) +{ + const size_t oldLen = cStringLength(old); + const size_t replacementLen = cStringLength(replacement); + + size_t pos = 0; + while ((pos = str.find(old, pos)) != S::npos) + { + str.replace(pos, oldLen, replacement, replacementLen); + pos += replacementLen; //move past the string that was replaced + + if (!replaceAll) + break; + } +} + + +template <class S> +inline +void trim(S& str, bool fromLeft, bool fromRight) +{ + assert(fromLeft || fromRight); + + typedef typename S::value_type CharType; + + const CharType* newBegin = str.c_str(); + const CharType* newEnd = str.c_str() + str.length(); + + if (fromRight) + while (newBegin != newEnd && cStringIsWhiteSpace(newEnd[-1])) + --newEnd; + + if (fromLeft) + while (newBegin != newEnd && cStringIsWhiteSpace(*newBegin)) + ++newBegin; + + const size_t newLength = newEnd - newBegin; + if (newLength != str.length()) + { + if (newBegin != str.c_str()) + str = S(newBegin, newLength); //minor inefficiency: in case "str" is not shared, we could save an allocation and do a memory move only + else + str.resize(newLength); + } +} + + +namespace +{ +template <class S, class T> +struct CnvtStringToString +{ + T convert(const S& src) const { return T(src.c_str(), src.size()); } +}; + +template <class S> +struct CnvtStringToString<S, S> //optimization: for "basic_string -> basic_string" we don't need a deep copy +{ + S convert(const S& src) const { return src; } +}; + + +template <class S, class Num> +struct CvrtNumberToString +{ + S convert(const Num& number) const //convert string to number using streams: convenient, but SLOW + { + typedef typename S::value_type CharType; + + std::basic_ostringstream<CharType> ss; + ss << number; + return CnvtStringToString<std::basic_string<CharType>, S>().convert(ss.str()); + } +}; + + +template <class S, class Num, bool isIntegral> +struct CvrtStringToNumber +{ + Num convert(const S& str) const //convert number to string using streams: convenient, but SLOW + { + typedef typename S::value_type CharType; + + Num number = 0; + std::basic_istringstream<CharType>(CnvtStringToString<S, std::basic_string<CharType> >().convert(str)) >> number; + return number; + } +}; + + +template <class S, class Num> +struct CvrtStringToNumber<S, Num, true> +{ + Num convert(const S& str) const //very fast conversion to integers: slightly faster than std::atoi, but more importantly: generic + { + typedef typename S::value_type CharType; + + const CharType* first = str.c_str(); + const CharType* last = first + str.size(); + + while (first != last && cStringIsWhiteSpace(*first)) //skip leading whitespace + ++first; + + bool hasMinusSign = false; //handle minus sign + if (first != last) + { + if (*first == '-') + { + hasMinusSign = true; + ++first; + } + else if (*first == '+') + ++first; + } + + Num number = 0; + for (const CharType* iter = first; iter != last; ++iter) + { + const CharType c = *iter; + if ('0' <= c && c <= '9') + { + number *= 10; + number += c - '0'; + } + else + { + assert(std::find_if(iter, last, std::not1(std::ptr_fun(&cStringIsWhiteSpace<CharType>))) == last); //rest of string should contain whitespace only + break; + } + } + + return hasMinusSign ? -number : number; + } +}; +} + + +template <class S, class Num> +inline +S toString(const Num& number) //convert number to string the C++ way +{ + return CvrtNumberToString<S, Num>().convert(number); +} + + +template <class Num, class S> +inline +Num toNumber(const S& str) //convert number to string the C++ way +{ + return CvrtStringToNumber<S, Num, Loki::TypeTraits<Num>::isIntegral>().convert(str); +} + +} + +#endif //STRING_TOOLS_HEADER_213458973046 diff --git a/shared/symlink_target.h b/shared/symlink_target.h index 200c76d8..0e98b951 100644 --- a/shared/symlink_target.h +++ b/shared/symlink_target.h @@ -8,8 +8,7 @@ #define SYMLINK_WIN_H_INCLUDED #include "loki/ScopeGuard.h" -#include <boost/scoped_array.hpp> -#include "system_func.h" +#include "last_error.h" #include "string_conv.h" #include "file_error.h" #include "i18n.h" @@ -64,19 +63,19 @@ namespace //retrieve raw target data of symlink or junction Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) { - using ffs3::zToWx; - using ffs3::FileError; + using zen::zToWx; + using zen::FileError; #ifdef FFS_WIN //FSCTL_GET_REPARSE_POINT: http://msdn.microsoft.com/en-us/library/aa364571(VS.85).aspx try //reading certain symlinks requires admin rights! This shall not cause an error in user mode! { //allow access to certain symbolic links/junctions - ffs3::Privileges::getInstance().ensureActive(SE_BACKUP_NAME); //throw (FileError) + zen::Privileges::getInstance().ensureActive(SE_BACKUP_NAME); //throw (FileError) } catch (...) {} - const HANDLE hLink = ::CreateFile(ffs3::applyLongPathPrefix(linkPath).c_str(), + const HANDLE hLink = ::CreateFile(zen::applyLongPathPrefix(linkPath).c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, @@ -85,31 +84,30 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) NULL); if (hLink == INVALID_HANDLE_VALUE) { - wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(linkPath) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(linkPath) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hLink); (void)dummy; //silence warning "unused variable" //respect alignment issues... - const size_t bufferSize = REPARSE_DATA_BUFFER_HEADER_SIZE + MAXIMUM_REPARSE_DATA_BUFFER_SIZE; - boost::scoped_array<char> buffer(new char[bufferSize]); + std::vector<char> buffer(REPARSE_DATA_BUFFER_HEADER_SIZE + MAXIMUM_REPARSE_DATA_BUFFER_SIZE); DWORD bytesReturned; //dummy value required by FSCTL_GET_REPARSE_POINT! if (!::DeviceIoControl(hLink, //__in HANDLE hDevice, FSCTL_GET_REPARSE_POINT, //__in DWORD dwIoControlCode, NULL, //__in_opt LPVOID lpInBuffer, 0, //__in DWORD nInBufferSize, - buffer.get(), //__out_opt LPVOID lpOutBuffer, - bufferSize, //__in DWORD nOutBufferSize, + &buffer[0], //__out_opt LPVOID lpOutBuffer, + static_cast<DWORD>(buffer.size()), //__in DWORD nOutBufferSize, &bytesReturned, //__out_opt LPDWORD lpBytesReturned, NULL)) //__inout_opt LPOVERLAPPED lpOverlapped { - wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(linkPath) + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); + wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(linkPath) + wxT("\""); + throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); } - REPARSE_DATA_BUFFER& reparseData = *reinterpret_cast<REPARSE_DATA_BUFFER*>(buffer.get()); //REPARSE_DATA_BUFFER needs to be artificially enlarged! + REPARSE_DATA_BUFFER& reparseData = *reinterpret_cast<REPARSE_DATA_BUFFER*>(&buffer[0]); //REPARSE_DATA_BUFFER needs to be artificially enlarged! Zstring output; if (reparseData.ReparseTag == IO_REPARSE_TAG_SYMLINK) @@ -124,7 +122,7 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) } else { - wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(linkPath) + wxT("\""); + wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(linkPath) + wxT("\""); throw FileError(errorMessage + wxT("\n\n") + wxT("Not a symbolic link or junction!")); } @@ -142,7 +140,7 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) if (bytesWritten < 0 || bytesWritten >= BUFFER_SIZE) { wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zToWx(linkPath) + wxT("\""); - if (bytesWritten < 0) errorMessage += wxString(wxT("\n\n")) + ffs3::getLastErrorFormatted(); + if (bytesWritten < 0) errorMessage += wxString(wxT("\n\n")) + zen::getLastErrorFormatted(); throw FileError(errorMessage); } buffer[bytesWritten] = 0; //set null-terminating char diff --git a/shared/tinyxml/changes.txt b/shared/tinyxml/changes.txt index 1ea21ad0..15b51bd9 100644 --- a/shared/tinyxml/changes.txt +++ b/shared/tinyxml/changes.txt @@ -286,5 +286,14 @@ Changes in version 2.1.5 - tibur found a bug in end tag parsing - +2.6.2 +- Switched over to VC 2010 +- Fixed up all the build issues arising from that. (Lots of latent build problems.) +- Removed the old, now unmaintained and likely not working, build files. +- Fixed some static analysis issues reported by orbitcowboy from cppcheck. +- Bayard 95 sent in analysis from a different analyzer - fixes applied from that as well. +- Tim Kosse sent a patch fixing an infinite loop. +- Ma Anguo identified a doc issue. +- Eddie Cohen identified a missing qualifier resulting in a compilation error on some systems. +- Fixed a line ending bug. (What year is this? Can we all agree on a format for text files? Please? ...oh well.) diff --git a/shared/tinyxml/docs/classTiXmlDocument.html b/shared/tinyxml/docs/classTiXmlDocument.html index 107101cb..b46bb27c 100644 --- a/shared/tinyxml/docs/classTiXmlDocument.html +++ b/shared/tinyxml/docs/classTiXmlDocument.html @@ -309,7 +309,7 @@ virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" hr <p>Load a file using the current document value. </p> <p>Returns true if successful. Will delete any existing document data before loading. </p> -<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01425">LoadFile()</a>.</p> +<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01432">LoadFile()</a>.</p> </div> </div> @@ -368,9 +368,9 @@ virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" hr <p>Write the document to standard out using formatted printing ("pretty print"). </p> -<p>References <a class="el" href="tinyxml_8h_source.html#l01512">Print()</a>.</p> +<p>References <a class="el" href="tinyxml_8h_source.html#l01519">Print()</a>.</p> -<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01512">Print()</a>.</p> +<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01519">Print()</a>.</p> </div> </div> diff --git a/shared/tinyxml/docs/classTiXmlElement-members.html b/shared/tinyxml/docs/classTiXmlElement-members.html index dff303a8..dc8a33be 100644 --- a/shared/tinyxml/docs/classTiXmlElement-members.html +++ b/shared/tinyxml/docs/classTiXmlElement-members.html @@ -82,10 +82,12 @@ <tr class="memlist"><td><a class="el" href="classTiXmlNode.html#a658276f57d35d5d4256d1dc1a2c398ab">PreviousSibling</a>(const std::string &_value) const </td><td><a class="el" href="classTiXmlNode.html">TiXmlNode</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlNode.html#acc8a0434c7f401d4a3b6dee77c1a5912">PreviousSibling</a>(const std::string &_value)</td><td><a class="el" href="classTiXmlNode.html">TiXmlNode</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#afbf52736e70fc91ec9d760721d6f4fd2">Print</a>(FILE *cfile, int depth) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td><code> [virtual]</code></td></tr> + <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#af4a1d3f88c28eb0f3115dc39ebd83fff">QueryBoolAttribute</a>(const char *name, bool *_value) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7">QueryDoubleAttribute</a>(const char *name, double *_value) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#aa04d3af11601ef5a5f88295203a843be">QueryFloatAttribute</a>(const char *name, float *_value) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#aea0bfe471380f281c5945770ddbf52b9">QueryIntAttribute</a>(const char *name, int *_value) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#a14321ac360efe906ed449d9db3fd9961">QueryStringAttribute</a>(const char *name, std::string *_value) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td><code> [inline]</code></td></tr> + <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#ae48df644f890ab86fa19839ac401f00d">QueryUnsignedAttribute</a>(const char *name, unsigned *_value) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#ae3b9a03b0a56663a40801c7256683576">QueryValueAttribute</a>(const std::string &name, T *outValue) const </td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td><code> [inline]</code></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#a56979767deca794376b1dfa69a525b2a">RemoveAttribute</a>(const char *name)</td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td></td></tr> <tr class="memlist"><td><a class="el" href="classTiXmlElement.html#a1afa6aea716511326a608e4c05df4f3a">RemoveAttribute</a>(const std::string &name)</td><td><a class="el" href="classTiXmlElement.html">TiXmlElement</a></td><td><code> [inline]</code></td></tr> diff --git a/shared/tinyxml/docs/classTiXmlElement.html b/shared/tinyxml/docs/classTiXmlElement.html index ac1b3d7a..4d6a5e93 100644 --- a/shared/tinyxml/docs/classTiXmlElement.html +++ b/shared/tinyxml/docs/classTiXmlElement.html @@ -61,6 +61,11 @@ const char * </td><td class="memItemRight" valign="bottom"><a class="el" hr <tr><td class="mdescLeft"> </td><td class="mdescRight">Given an attribute name, <a class="el" href="classTiXmlElement.html#ae419a442a9701a62b0c3d8fd1cbdd12d" title="Given an attribute name, Attribute() returns the value for the attribute of that...">Attribute()</a> returns the value for the attribute of that name, or null if none exists. <a href="#aeaff99d4f0ea5b34f7aee202aad457ba"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#aea0bfe471380f281c5945770ddbf52b9">QueryIntAttribute</a> (const char *name, int *_value) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">QueryIntAttribute examines the attribute - it is an alternative to the <a class="el" href="classTiXmlElement.html#ae419a442a9701a62b0c3d8fd1cbdd12d" title="Given an attribute name, Attribute() returns the value for the attribute of that...">Attribute()</a> method with richer error checking. <a href="#aea0bfe471380f281c5945770ddbf52b9"></a><br/></td></tr> +<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae48df644f890ab86fa19839ac401f00d"></a><!-- doxytag: member="TiXmlElement::QueryUnsignedAttribute" ref="ae48df644f890ab86fa19839ac401f00d" args="(const char *name, unsigned *_value) const " --> +int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#ae48df644f890ab86fa19839ac401f00d">QueryUnsignedAttribute</a> (const char *name, unsigned *_value) const </td></tr> +<tr><td class="mdescLeft"> </td><td class="mdescRight">QueryUnsignedAttribute examines the attribute - see <a class="el" href="classTiXmlElement.html#aea0bfe471380f281c5945770ddbf52b9" title="QueryIntAttribute examines the attribute - it is an alternative to the Attribute()...">QueryIntAttribute()</a>. <br/></td></tr> +<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#af4a1d3f88c28eb0f3115dc39ebd83fff">QueryBoolAttribute</a> (const char *name, bool *_value) const </td></tr> +<tr><td class="mdescLeft"> </td><td class="mdescRight">QueryBoolAttribute examines the attribute - see <a class="el" href="classTiXmlElement.html#aea0bfe471380f281c5945770ddbf52b9" title="QueryIntAttribute examines the attribute - it is an alternative to the Attribute()...">QueryIntAttribute()</a>. <a href="#af4a1d3f88c28eb0f3115dc39ebd83fff"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a898d7730ecc341f0bffc7a9dadbf1ce7"></a><!-- doxytag: member="TiXmlElement::QueryDoubleAttribute" ref="a898d7730ecc341f0bffc7a9dadbf1ce7" args="(const char *name, double *_value) const " --> int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7">QueryDoubleAttribute</a> (const char *name, double *_value) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">QueryDoubleAttribute examines the attribute - see <a class="el" href="classTiXmlElement.html#aea0bfe471380f281c5945770ddbf52b9" title="QueryIntAttribute examines the attribute - it is an alternative to the Attribute()...">QueryIntAttribute()</a>. <br/></td></tr> @@ -244,6 +249,36 @@ virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" hr </div> </div> +<a class="anchor" id="af4a1d3f88c28eb0f3115dc39ebd83fff"></a><!-- doxytag: member="TiXmlElement::QueryBoolAttribute" ref="af4a1d3f88c28eb0f3115dc39ebd83fff" args="(const char *name, bool *_value) const " --> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname">int TiXmlElement::QueryBoolAttribute </td> + <td>(</td> + <td class="paramtype">const char * </td> + <td class="paramname"> <em>name</em>, </td> + </tr> + <tr> + <td class="paramkey"></td> + <td></td> + <td class="paramtype">bool * </td> + <td class="paramname"> <em>_value</em></td><td> </td> + </tr> + <tr> + <td></td> + <td>)</td> + <td></td><td></td><td> const</td> + </tr> + </table> +</div> +<div class="memdoc"> + +<p>QueryBoolAttribute examines the attribute - see <a class="el" href="classTiXmlElement.html#aea0bfe471380f281c5945770ddbf52b9" title="QueryIntAttribute examines the attribute - it is an alternative to the Attribute()...">QueryIntAttribute()</a>. </p> +<p>Note that '1', 'true', or 'yes' are considered true, while '0', 'false' and 'no' are considered false. </p> + +</div> +</div> <a class="anchor" id="aea0bfe471380f281c5945770ddbf52b9"></a><!-- doxytag: member="TiXmlElement::QueryIntAttribute" ref="aea0bfe471380f281c5945770ddbf52b9" args="(const char *name, int *_value) const " --> <div class="memitem"> <div class="memproto"> diff --git a/shared/tinyxml/docs/classTiXmlHandle.html b/shared/tinyxml/docs/classTiXmlHandle.html index 0e0d45e3..59ee217c 100644 --- a/shared/tinyxml/docs/classTiXmlHandle.html +++ b/shared/tinyxml/docs/classTiXmlHandle.html @@ -249,7 +249,7 @@ <div class="memdoc"> <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000002">Deprecated:</a></b></dt><dd>use ToElement. Return the handle as a <a class="el" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>. This may return null. </dd></dl> -<p>References <a class="el" href="tinyxml_8h_source.html#l01681">ToElement()</a>.</p> +<p>References <a class="el" href="tinyxml_8h_source.html#l01688">ToElement()</a>.</p> </div> </div> @@ -269,7 +269,7 @@ <div class="memdoc"> <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000001">Deprecated:</a></b></dt><dd>use ToNode. Return the handle as a <a class="el" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>. This may return null. </dd></dl> -<p>References <a class="el" href="tinyxml_8h_source.html#l01678">ToNode()</a>.</p> +<p>References <a class="el" href="tinyxml_8h_source.html#l01685">ToNode()</a>.</p> </div> </div> @@ -289,7 +289,7 @@ <div class="memdoc"> <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000003">Deprecated:</a></b></dt><dd>use <a class="el" href="classTiXmlHandle.html#a4ac53a652296203a5b5e13854d923586" title="Return the handle as a TiXmlText.">ToText()</a> Return the handle as a <a class="el" href="classTiXmlText.html" title="XML text.">TiXmlText</a>. This may return null. </dd></dl> -<p>References <a class="el" href="tinyxml_8h_source.html#l01684">ToText()</a>.</p> +<p>References <a class="el" href="tinyxml_8h_source.html#l01691">ToText()</a>.</p> </div> </div> @@ -311,7 +311,7 @@ <p>Return the handle as a <a class="el" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>. </p> <p>This may return null. </p> -<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01696">Element()</a>.</p> +<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01703">Element()</a>.</p> </div> </div> @@ -333,7 +333,7 @@ <p>Return the handle as a <a class="el" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>. </p> <p>This may return null. </p> -<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01692">Node()</a>.</p> +<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01699">Node()</a>.</p> </div> </div> @@ -355,7 +355,7 @@ <p>Return the handle as a <a class="el" href="classTiXmlText.html" title="XML text.">TiXmlText</a>. </p> <p>This may return null. </p> -<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01700">Text()</a>.</p> +<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01707">Text()</a>.</p> </div> </div> @@ -377,7 +377,7 @@ <p>Return the handle as a <a class="el" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn't recognize is saved as an unknown.">TiXmlUnknown</a>. </p> <p>This may return null. </p> -<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01704">Unknown()</a>.</p> +<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01711">Unknown()</a>.</p> </div> </div> @@ -397,7 +397,7 @@ <div class="memdoc"> <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000004">Deprecated:</a></b></dt><dd>use <a class="el" href="classTiXmlHandle.html#a1381c17507a130767b1e23afc93b3674" title="Return the handle as a TiXmlUnknown.">ToUnknown()</a> Return the handle as a <a class="el" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn't recognize is saved as an unknown.">TiXmlUnknown</a>. This may return null. </dd></dl> -<p>References <a class="el" href="tinyxml_8h_source.html#l01687">ToUnknown()</a>.</p> +<p>References <a class="el" href="tinyxml_8h_source.html#l01694">ToUnknown()</a>.</p> </div> </div> diff --git a/shared/tinyxml/docs/classTiXmlNode.html b/shared/tinyxml/docs/classTiXmlNode.html index 50b3464a..5ba4bcf3 100644 --- a/shared/tinyxml/docs/classTiXmlNode.html +++ b/shared/tinyxml/docs/classTiXmlNode.html @@ -573,7 +573,7 @@ std::string & </td><td class="memItemRight" valign="bottom"><a class="e Unknown: the tag contents Text: the text string </pre></div> -<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01161">TiXmlComment::TiXmlComment()</a>, and <a class="el" href="tinyxml_8h_source.html#l01213">TiXmlText::TiXmlText()</a>.</p> +<p>Referenced by <a class="el" href="tinyxml_8h_source.html#l01168">TiXmlComment::TiXmlComment()</a>, and <a class="el" href="tinyxml_8h_source.html#l01220">TiXmlText::TiXmlText()</a>.</p> </div> </div> @@ -593,7 +593,7 @@ std::string & </td><td class="memItemRight" valign="bottom"><a class="e <div class="memdoc"> <p>Query the type (as an enumerated value, above) of this node. </p> -<p>The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION. </p> +<p>The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION. </p> </div> </div> diff --git a/shared/tinyxml/docs/classTiXmlPrinter.html b/shared/tinyxml/docs/classTiXmlPrinter.html index bfbf4187..28be1e88 100644 --- a/shared/tinyxml/docs/classTiXmlPrinter.html +++ b/shared/tinyxml/docs/classTiXmlPrinter.html @@ -68,7 +68,7 @@ virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" hr <tr><td class="mdescLeft"> </td><td class="mdescRight">Visit a comment node. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad2dca6dd106e8982fd3c7db1f3330970"></a><!-- doxytag: member="TiXmlPrinter::Visit" ref="ad2dca6dd106e8982fd3c7db1f3330970" args="(const TiXmlUnknown &unknown)" --> virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlPrinter.html#ad2dca6dd106e8982fd3c7db1f3330970">Visit</a> (const <a class="el" href="classTiXmlUnknown.html">TiXmlUnknown</a> &unknown)</td></tr> -<tr><td class="mdescLeft"> </td><td class="mdescRight">Visit an unknow node. <br/></td></tr> +<tr><td class="mdescLeft"> </td><td class="mdescRight">Visit an unknown node. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlPrinter.html#a213377a4070c7e625bae59716b089e5e">SetIndent</a> (const char *_indent)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Set the indent characters for printing. <a href="#a213377a4070c7e625bae59716b089e5e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abb33ec7d4bad6aaeb57f4304394b133d"></a><!-- doxytag: member="TiXmlPrinter::Indent" ref="abb33ec7d4bad6aaeb57f4304394b133d" args="()" --> diff --git a/shared/tinyxml/docs/classTiXmlVisitor.html b/shared/tinyxml/docs/classTiXmlVisitor.html index 404ae0dc..60c6a27d 100644 --- a/shared/tinyxml/docs/classTiXmlVisitor.html +++ b/shared/tinyxml/docs/classTiXmlVisitor.html @@ -68,7 +68,7 @@ virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" hr <tr><td class="mdescLeft"> </td><td class="mdescRight">Visit a comment node. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7e284d607d275c51dac1adb58159ce28"></a><!-- doxytag: member="TiXmlVisitor::Visit" ref="a7e284d607d275c51dac1adb58159ce28" args="(const TiXmlUnknown &)" --> virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlVisitor.html#a7e284d607d275c51dac1adb58159ce28">Visit</a> (const <a class="el" href="classTiXmlUnknown.html">TiXmlUnknown</a> &)</td></tr> -<tr><td class="mdescLeft"> </td><td class="mdescRight">Visit an unknow node. <br/></td></tr> +<tr><td class="mdescLeft"> </td><td class="mdescRight">Visit an unknown node. <br/></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Implements the interface to the "Visitor pattern" (see the Accept() method. </p> diff --git a/shared/tinyxml/docs/functions_0x71.html b/shared/tinyxml/docs/functions_0x71.html index c7882b83..d2fd5c60 100644 --- a/shared/tinyxml/docs/functions_0x71.html +++ b/shared/tinyxml/docs/functions_0x71.html @@ -59,6 +59,9 @@ Here is a list of all documented class members with links to the class documentation for each member: <h3><a class="anchor" id="index_q">- q -</a></h3><ul> +<li>QueryBoolAttribute() +: <a class="el" href="classTiXmlElement.html#af4a1d3f88c28eb0f3115dc39ebd83fff">TiXmlElement</a> +</li> <li>QueryDoubleAttribute() : <a class="el" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7">TiXmlElement</a> </li> @@ -77,6 +80,9 @@ Here is a list of all documented class members with links to the class documenta <li>QueryStringAttribute() : <a class="el" href="classTiXmlElement.html#a14321ac360efe906ed449d9db3fd9961">TiXmlElement</a> </li> +<li>QueryUnsignedAttribute() +: <a class="el" href="classTiXmlElement.html#ae48df644f890ab86fa19839ac401f00d">TiXmlElement</a> +</li> <li>QueryValueAttribute() : <a class="el" href="classTiXmlElement.html#ae3b9a03b0a56663a40801c7256683576">TiXmlElement</a> </li> diff --git a/shared/tinyxml/docs/functions_func_0x71.html b/shared/tinyxml/docs/functions_func_0x71.html index 27402292..4d236d2a 100644 --- a/shared/tinyxml/docs/functions_func_0x71.html +++ b/shared/tinyxml/docs/functions_func_0x71.html @@ -58,6 +58,9 @@ <h3><a class="anchor" id="index_q">- q -</a></h3><ul> +<li>QueryBoolAttribute() +: <a class="el" href="classTiXmlElement.html#af4a1d3f88c28eb0f3115dc39ebd83fff">TiXmlElement</a> +</li> <li>QueryDoubleAttribute() : <a class="el" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7">TiXmlElement</a> </li> @@ -76,6 +79,9 @@ <li>QueryStringAttribute() : <a class="el" href="classTiXmlElement.html#a14321ac360efe906ed449d9db3fd9961">TiXmlElement</a> </li> +<li>QueryUnsignedAttribute() +: <a class="el" href="classTiXmlElement.html#ae48df644f890ab86fa19839ac401f00d">TiXmlElement</a> +</li> <li>QueryValueAttribute() : <a class="el" href="classTiXmlElement.html#ae3b9a03b0a56663a40801c7256683576">TiXmlElement</a> </li> diff --git a/shared/tinyxml/docs/index.html b/shared/tinyxml/docs/index.html index 1cb925ba..d89b21a7 100644 --- a/shared/tinyxml/docs/index.html +++ b/shared/tinyxml/docs/index.html @@ -19,7 +19,7 @@ </div> </div> <div class="contents"> -<h1>TinyXml Documentation</h1><h3 class="version">2.6.1 </h3><h1>TinyXML </h1> +<h1>TinyXml Documentation</h1><h3 class="version">2.6.2 </h3><h1>TinyXML </h1> <p>TinyXML is a simple, small, C++ XML parser that can be easily integrated into other programs.</p> <h2>What it does. </h2> <p>In brief, TinyXML parses an XML document, and builds from that a Document Object Model (DOM) that can be read, modified, and saved.</p> diff --git a/shared/tinyxml/docs/tinystr_8h_source.html b/shared/tinyxml/docs/tinystr_8h_source.html index eddeda87..579a90e0 100644 --- a/shared/tinyxml/docs/tinystr_8h_source.html +++ b/shared/tinyxml/docs/tinystr_8h_source.html @@ -24,323 +24,309 @@ </div> <h1>tinystr.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment">www.sourceforge.net/projects/tinyxml</span> -<a name="l00003"></a>00003 <span class="comment">Original file by Yves Berquin.</span> -<a name="l00004"></a>00004 <span class="comment"></span> -<a name="l00005"></a>00005 <span class="comment">This software is provided 'as-is', without any express or implied</span> -<a name="l00006"></a>00006 <span class="comment">warranty. In no event will the authors be held liable for any</span> -<a name="l00007"></a>00007 <span class="comment">damages arising from the use of this software.</span> -<a name="l00008"></a>00008 <span class="comment"></span> -<a name="l00009"></a>00009 <span class="comment">Permission is granted to anyone to use this software for any</span> -<a name="l00010"></a>00010 <span class="comment">purpose, including commercial applications, and to alter it and</span> -<a name="l00011"></a>00011 <span class="comment">redistribute it freely, subject to the following restrictions:</span> -<a name="l00012"></a>00012 <span class="comment"></span> -<a name="l00013"></a>00013 <span class="comment">1. The origin of this software must not be misrepresented; you must</span> -<a name="l00014"></a>00014 <span class="comment">not claim that you wrote the original software. If you use this</span> -<a name="l00015"></a>00015 <span class="comment">software in a product, an acknowledgment in the product documentation</span> -<a name="l00016"></a>00016 <span class="comment">would be appreciated but is not required.</span> -<a name="l00017"></a>00017 <span class="comment"></span> -<a name="l00018"></a>00018 <span class="comment">2. Altered source versions must be plainly marked as such, and</span> -<a name="l00019"></a>00019 <span class="comment">must not be misrepresented as being the original software.</span> -<a name="l00020"></a>00020 <span class="comment"></span> -<a name="l00021"></a>00021 <span class="comment">3. This notice may not be removed or altered from any source</span> -<a name="l00022"></a>00022 <span class="comment">distribution.</span> -<a name="l00023"></a>00023 <span class="comment">*/</span> +<a name="l00003"></a>00003 <span class="comment"></span> +<a name="l00004"></a>00004 <span class="comment">This software is provided 'as-is', without any express or implied</span> +<a name="l00005"></a>00005 <span class="comment">warranty. In no event will the authors be held liable for any</span> +<a name="l00006"></a>00006 <span class="comment">damages arising from the use of this software.</span> +<a name="l00007"></a>00007 <span class="comment"></span> +<a name="l00008"></a>00008 <span class="comment">Permission is granted to anyone to use this software for any</span> +<a name="l00009"></a>00009 <span class="comment">purpose, including commercial applications, and to alter it and</span> +<a name="l00010"></a>00010 <span class="comment">redistribute it freely, subject to the following restrictions:</span> +<a name="l00011"></a>00011 <span class="comment"></span> +<a name="l00012"></a>00012 <span class="comment">1. The origin of this software must not be misrepresented; you must</span> +<a name="l00013"></a>00013 <span class="comment">not claim that you wrote the original software. If you use this</span> +<a name="l00014"></a>00014 <span class="comment">software in a product, an acknowledgment in the product documentation</span> +<a name="l00015"></a>00015 <span class="comment">would be appreciated but is not required.</span> +<a name="l00016"></a>00016 <span class="comment"></span> +<a name="l00017"></a>00017 <span class="comment">2. Altered source versions must be plainly marked as such, and</span> +<a name="l00018"></a>00018 <span class="comment">must not be misrepresented as being the original software.</span> +<a name="l00019"></a>00019 <span class="comment"></span> +<a name="l00020"></a>00020 <span class="comment">3. This notice may not be removed or altered from any source</span> +<a name="l00021"></a>00021 <span class="comment">distribution.</span> +<a name="l00022"></a>00022 <span class="comment">*/</span> +<a name="l00023"></a>00023 <a name="l00024"></a>00024 -<a name="l00025"></a>00025 <span class="comment">/*</span> -<a name="l00026"></a>00026 <span class="comment"> * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.</span> -<a name="l00027"></a>00027 <span class="comment"> *</span> -<a name="l00028"></a>00028 <span class="comment"> * - completely rewritten. compact, clean, and fast implementation.</span> -<a name="l00029"></a>00029 <span class="comment"> * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)</span> -<a name="l00030"></a>00030 <span class="comment"> * - fixed reserve() to work as per specification.</span> -<a name="l00031"></a>00031 <span class="comment"> * - fixed buggy compares operator==(), operator<(), and operator>()</span> -<a name="l00032"></a>00032 <span class="comment"> * - fixed operator+=() to take a const ref argument, following spec.</span> -<a name="l00033"></a>00033 <span class="comment"> * - added "copy" constructor with length, and most compare operators.</span> -<a name="l00034"></a>00034 <span class="comment"> * - added swap(), clear(), size(), capacity(), operator+().</span> -<a name="l00035"></a>00035 <span class="comment"> */</span> -<a name="l00036"></a>00036 -<a name="l00037"></a>00037 <span class="preprocessor">#ifndef TIXML_USE_STL</span> -<a name="l00038"></a>00038 <span class="preprocessor"></span> -<a name="l00039"></a>00039 <span class="preprocessor">#ifndef TIXML_STRING_INCLUDED</span> -<a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor">#define TIXML_STRING_INCLUDED</span> -<a name="l00041"></a>00041 <span class="preprocessor"></span> -<a name="l00042"></a>00042 <span class="preprocessor">#include <assert.h></span> -<a name="l00043"></a>00043 <span class="preprocessor">#include <string.h></span> -<a name="l00044"></a>00044 -<a name="l00045"></a>00045 <span class="comment">/* The support for explicit isn't that universal, and it isn't really</span> -<a name="l00046"></a>00046 <span class="comment"> required - it is used to check that the TiXmlString class isn't incorrectly</span> -<a name="l00047"></a>00047 <span class="comment"> used. Be nice to old compilers and macro it here:</span> -<a name="l00048"></a>00048 <span class="comment">*/</span> -<a name="l00049"></a>00049 <span class="preprocessor">#if defined(_MSC_VER) && (_MSC_VER >= 1200 )</span> -<a name="l00050"></a>00050 <span class="preprocessor"></span> <span class="comment">// Microsoft visual studio, version 6 and higher.</span> -<a name="l00051"></a>00051 <span class="preprocessor"> #define TIXML_EXPLICIT explicit</span> -<a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__GNUC__) && (__GNUC__ >= 3 )</span> -<a name="l00053"></a>00053 <span class="preprocessor"></span> <span class="comment">// GCC version 3 and higher.s</span> -<a name="l00054"></a>00054 <span class="preprocessor"> #define TIXML_EXPLICIT explicit</span> -<a name="l00055"></a>00055 <span class="preprocessor"></span><span class="preprocessor">#else</span> -<a name="l00056"></a>00056 <span class="preprocessor"></span><span class="preprocessor"> #define TIXML_EXPLICIT</span> -<a name="l00057"></a>00057 <span class="preprocessor"></span><span class="preprocessor">#endif</span> -<a name="l00058"></a>00058 <span class="preprocessor"></span> -<a name="l00059"></a>00059 -<a name="l00060"></a>00060 <span class="comment">/*</span> -<a name="l00061"></a>00061 <span class="comment"> TiXmlString is an emulation of a subset of the std::string template.</span> -<a name="l00062"></a>00062 <span class="comment"> Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.</span> -<a name="l00063"></a>00063 <span class="comment"> Only the member functions relevant to the TinyXML project have been implemented.</span> -<a name="l00064"></a>00064 <span class="comment"> The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase</span> -<a name="l00065"></a>00065 <span class="comment"> a string and there's no more room, we allocate a buffer twice as big as we need.</span> -<a name="l00066"></a>00066 <span class="comment">*/</span> -<a name="l00067"></a>00067 <span class="keyword">class </span>TiXmlString -<a name="l00068"></a>00068 { -<a name="l00069"></a>00069 <span class="keyword">public</span> : -<a name="l00070"></a>00070 <span class="comment">// The size type used</span> -<a name="l00071"></a>00071 <span class="keyword">typedef</span> <span class="keywordtype">size_t</span> size_type; -<a name="l00072"></a>00072 -<a name="l00073"></a>00073 <span class="comment">// Error value for find primitive</span> -<a name="l00074"></a>00074 <span class="keyword">static</span> <span class="keyword">const</span> size_type npos; <span class="comment">// = -1;</span> -<a name="l00075"></a>00075 +<a name="l00025"></a>00025 <span class="preprocessor">#ifndef TIXML_USE_STL</span> +<a name="l00026"></a>00026 <span class="preprocessor"></span> +<a name="l00027"></a>00027 <span class="preprocessor">#ifndef TIXML_STRING_INCLUDED</span> +<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#define TIXML_STRING_INCLUDED</span> +<a name="l00029"></a>00029 <span class="preprocessor"></span> +<a name="l00030"></a>00030 <span class="preprocessor">#include <assert.h></span> +<a name="l00031"></a>00031 <span class="preprocessor">#include <string.h></span> +<a name="l00032"></a>00032 +<a name="l00033"></a>00033 <span class="comment">/* The support for explicit isn't that universal, and it isn't really</span> +<a name="l00034"></a>00034 <span class="comment"> required - it is used to check that the TiXmlString class isn't incorrectly</span> +<a name="l00035"></a>00035 <span class="comment"> used. Be nice to old compilers and macro it here:</span> +<a name="l00036"></a>00036 <span class="comment">*/</span> +<a name="l00037"></a>00037 <span class="preprocessor">#if defined(_MSC_VER) && (_MSC_VER >= 1200 )</span> +<a name="l00038"></a>00038 <span class="preprocessor"></span> <span class="comment">// Microsoft visual studio, version 6 and higher.</span> +<a name="l00039"></a>00039 <span class="preprocessor"> #define TIXML_EXPLICIT explicit</span> +<a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__GNUC__) && (__GNUC__ >= 3 )</span> +<a name="l00041"></a>00041 <span class="preprocessor"></span> <span class="comment">// GCC version 3 and higher.s</span> +<a name="l00042"></a>00042 <span class="preprocessor"> #define TIXML_EXPLICIT explicit</span> +<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#else</span> +<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor"> #define TIXML_EXPLICIT</span> +<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#endif</span> +<a name="l00046"></a>00046 <span class="preprocessor"></span> +<a name="l00047"></a>00047 +<a name="l00048"></a>00048 <span class="comment">/*</span> +<a name="l00049"></a>00049 <span class="comment"> TiXmlString is an emulation of a subset of the std::string template.</span> +<a name="l00050"></a>00050 <span class="comment"> Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.</span> +<a name="l00051"></a>00051 <span class="comment"> Only the member functions relevant to the TinyXML project have been implemented.</span> +<a name="l00052"></a>00052 <span class="comment"> The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase</span> +<a name="l00053"></a>00053 <span class="comment"> a string and there's no more room, we allocate a buffer twice as big as we need.</span> +<a name="l00054"></a>00054 <span class="comment">*/</span> +<a name="l00055"></a>00055 <span class="keyword">class </span>TiXmlString +<a name="l00056"></a>00056 { +<a name="l00057"></a>00057 <span class="keyword">public</span> : +<a name="l00058"></a>00058 <span class="comment">// The size type used</span> +<a name="l00059"></a>00059 <span class="keyword">typedef</span> <span class="keywordtype">size_t</span> size_type; +<a name="l00060"></a>00060 +<a name="l00061"></a>00061 <span class="comment">// Error value for find primitive</span> +<a name="l00062"></a>00062 <span class="keyword">static</span> <span class="keyword">const</span> size_type npos; <span class="comment">// = -1;</span> +<a name="l00063"></a>00063 +<a name="l00064"></a>00064 +<a name="l00065"></a>00065 <span class="comment">// TiXmlString empty constructor</span> +<a name="l00066"></a>00066 TiXmlString () : rep_(&nullrep_) +<a name="l00067"></a>00067 { +<a name="l00068"></a>00068 } +<a name="l00069"></a>00069 +<a name="l00070"></a>00070 <span class="comment">// TiXmlString copy constructor</span> +<a name="l00071"></a>00071 TiXmlString ( <span class="keyword">const</span> TiXmlString & copy) : rep_(0) +<a name="l00072"></a>00072 { +<a name="l00073"></a>00073 init(copy.length()); +<a name="l00074"></a>00074 memcpy(start(), copy.data(), length()); +<a name="l00075"></a>00075 } <a name="l00076"></a>00076 -<a name="l00077"></a>00077 <span class="comment">// TiXmlString empty constructor</span> -<a name="l00078"></a>00078 TiXmlString () : rep_(&nullrep_) +<a name="l00077"></a>00077 <span class="comment">// TiXmlString constructor, based on a string</span> +<a name="l00078"></a>00078 TIXML_EXPLICIT TiXmlString ( <span class="keyword">const</span> <span class="keywordtype">char</span> * copy) : rep_(0) <a name="l00079"></a>00079 { -<a name="l00080"></a>00080 } -<a name="l00081"></a>00081 -<a name="l00082"></a>00082 <span class="comment">// TiXmlString copy constructor</span> -<a name="l00083"></a>00083 TiXmlString ( <span class="keyword">const</span> TiXmlString & copy) : rep_(0) -<a name="l00084"></a>00084 { -<a name="l00085"></a>00085 init(copy.length()); -<a name="l00086"></a>00086 memcpy(start(), copy.data(), length()); -<a name="l00087"></a>00087 } -<a name="l00088"></a>00088 -<a name="l00089"></a>00089 <span class="comment">// TiXmlString constructor, based on a string</span> -<a name="l00090"></a>00090 TIXML_EXPLICIT TiXmlString ( <span class="keyword">const</span> <span class="keywordtype">char</span> * copy) : rep_(0) -<a name="l00091"></a>00091 { -<a name="l00092"></a>00092 init( static_cast<size_type>( strlen(copy) )); -<a name="l00093"></a>00093 memcpy(start(), copy, length()); -<a name="l00094"></a>00094 } -<a name="l00095"></a>00095 -<a name="l00096"></a>00096 <span class="comment">// TiXmlString constructor, based on a string</span> -<a name="l00097"></a>00097 TIXML_EXPLICIT TiXmlString ( <span class="keyword">const</span> <span class="keywordtype">char</span> * str, size_type len) : rep_(0) +<a name="l00080"></a>00080 init( static_cast<size_type>( strlen(copy) )); +<a name="l00081"></a>00081 memcpy(start(), copy, length()); +<a name="l00082"></a>00082 } +<a name="l00083"></a>00083 +<a name="l00084"></a>00084 <span class="comment">// TiXmlString constructor, based on a string</span> +<a name="l00085"></a>00085 TIXML_EXPLICIT TiXmlString ( <span class="keyword">const</span> <span class="keywordtype">char</span> * str, size_type len) : rep_(0) +<a name="l00086"></a>00086 { +<a name="l00087"></a>00087 init(len); +<a name="l00088"></a>00088 memcpy(start(), str, len); +<a name="l00089"></a>00089 } +<a name="l00090"></a>00090 +<a name="l00091"></a>00091 <span class="comment">// TiXmlString destructor</span> +<a name="l00092"></a>00092 ~TiXmlString () +<a name="l00093"></a>00093 { +<a name="l00094"></a>00094 quit(); +<a name="l00095"></a>00095 } +<a name="l00096"></a>00096 +<a name="l00097"></a>00097 TiXmlString& operator = (<span class="keyword">const</span> <span class="keywordtype">char</span> * copy) <a name="l00098"></a>00098 { -<a name="l00099"></a>00099 init(len); -<a name="l00100"></a>00100 memcpy(start(), str, len); -<a name="l00101"></a>00101 } -<a name="l00102"></a>00102 -<a name="l00103"></a>00103 <span class="comment">// TiXmlString destructor</span> -<a name="l00104"></a>00104 ~TiXmlString () -<a name="l00105"></a>00105 { -<a name="l00106"></a>00106 quit(); -<a name="l00107"></a>00107 } -<a name="l00108"></a>00108 -<a name="l00109"></a>00109 <span class="comment">// = operator</span> -<a name="l00110"></a>00110 TiXmlString& operator = (<span class="keyword">const</span> <span class="keywordtype">char</span> * copy) -<a name="l00111"></a>00111 { -<a name="l00112"></a>00112 <span class="keywordflow">return</span> assign( copy, (size_type)strlen(copy)); -<a name="l00113"></a>00113 } -<a name="l00114"></a>00114 -<a name="l00115"></a>00115 <span class="comment">// = operator</span> -<a name="l00116"></a>00116 TiXmlString& operator = (<span class="keyword">const</span> TiXmlString & copy) -<a name="l00117"></a>00117 { -<a name="l00118"></a>00118 <span class="keywordflow">return</span> assign(copy.start(), copy.length()); -<a name="l00119"></a>00119 } -<a name="l00120"></a>00120 -<a name="l00121"></a>00121 -<a name="l00122"></a>00122 <span class="comment">// += operator. Maps to append</span> -<a name="l00123"></a>00123 TiXmlString& operator += (<span class="keyword">const</span> <span class="keywordtype">char</span> * suffix) -<a name="l00124"></a>00124 { -<a name="l00125"></a>00125 <span class="keywordflow">return</span> append(suffix, static_cast<size_type>( strlen(suffix) )); -<a name="l00126"></a>00126 } -<a name="l00127"></a>00127 -<a name="l00128"></a>00128 <span class="comment">// += operator. Maps to append</span> -<a name="l00129"></a>00129 TiXmlString& operator += (<span class="keywordtype">char</span> single) -<a name="l00130"></a>00130 { -<a name="l00131"></a>00131 <span class="keywordflow">return</span> append(&single, 1); -<a name="l00132"></a>00132 } -<a name="l00133"></a>00133 -<a name="l00134"></a>00134 <span class="comment">// += operator. Maps to append</span> -<a name="l00135"></a>00135 TiXmlString& operator += (<span class="keyword">const</span> TiXmlString & suffix) -<a name="l00136"></a>00136 { -<a name="l00137"></a>00137 <span class="keywordflow">return</span> append(suffix.data(), suffix.length()); -<a name="l00138"></a>00138 } -<a name="l00139"></a>00139 -<a name="l00140"></a>00140 -<a name="l00141"></a>00141 <span class="comment">// Convert a TiXmlString into a null-terminated char *</span> -<a name="l00142"></a>00142 <span class="keyword">const</span> <span class="keywordtype">char</span> * c_str ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str; } -<a name="l00143"></a>00143 -<a name="l00144"></a>00144 <span class="comment">// Convert a TiXmlString into a char * (need not be null terminated).</span> -<a name="l00145"></a>00145 <span class="keyword">const</span> <span class="keywordtype">char</span> * data ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str; } -<a name="l00146"></a>00146 -<a name="l00147"></a>00147 <span class="comment">// Return the length of a TiXmlString</span> -<a name="l00148"></a>00148 size_type length ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->size; } -<a name="l00149"></a>00149 -<a name="l00150"></a>00150 <span class="comment">// Alias for length()</span> -<a name="l00151"></a>00151 size_type size ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->size; } +<a name="l00099"></a>00099 <span class="keywordflow">return</span> assign( copy, (size_type)strlen(copy)); +<a name="l00100"></a>00100 } +<a name="l00101"></a>00101 +<a name="l00102"></a>00102 TiXmlString& operator = (<span class="keyword">const</span> TiXmlString & copy) +<a name="l00103"></a>00103 { +<a name="l00104"></a>00104 <span class="keywordflow">return</span> assign(copy.start(), copy.length()); +<a name="l00105"></a>00105 } +<a name="l00106"></a>00106 +<a name="l00107"></a>00107 +<a name="l00108"></a>00108 <span class="comment">// += operator. Maps to append</span> +<a name="l00109"></a>00109 TiXmlString& operator += (<span class="keyword">const</span> <span class="keywordtype">char</span> * suffix) +<a name="l00110"></a>00110 { +<a name="l00111"></a>00111 <span class="keywordflow">return</span> append(suffix, static_cast<size_type>( strlen(suffix) )); +<a name="l00112"></a>00112 } +<a name="l00113"></a>00113 +<a name="l00114"></a>00114 <span class="comment">// += operator. Maps to append</span> +<a name="l00115"></a>00115 TiXmlString& operator += (<span class="keywordtype">char</span> single) +<a name="l00116"></a>00116 { +<a name="l00117"></a>00117 <span class="keywordflow">return</span> append(&single, 1); +<a name="l00118"></a>00118 } +<a name="l00119"></a>00119 +<a name="l00120"></a>00120 <span class="comment">// += operator. Maps to append</span> +<a name="l00121"></a>00121 TiXmlString& operator += (<span class="keyword">const</span> TiXmlString & suffix) +<a name="l00122"></a>00122 { +<a name="l00123"></a>00123 <span class="keywordflow">return</span> append(suffix.data(), suffix.length()); +<a name="l00124"></a>00124 } +<a name="l00125"></a>00125 +<a name="l00126"></a>00126 +<a name="l00127"></a>00127 <span class="comment">// Convert a TiXmlString into a null-terminated char *</span> +<a name="l00128"></a>00128 <span class="keyword">const</span> <span class="keywordtype">char</span> * c_str ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str; } +<a name="l00129"></a>00129 +<a name="l00130"></a>00130 <span class="comment">// Convert a TiXmlString into a char * (need not be null terminated).</span> +<a name="l00131"></a>00131 <span class="keyword">const</span> <span class="keywordtype">char</span> * data ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str; } +<a name="l00132"></a>00132 +<a name="l00133"></a>00133 <span class="comment">// Return the length of a TiXmlString</span> +<a name="l00134"></a>00134 size_type length ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->size; } +<a name="l00135"></a>00135 +<a name="l00136"></a>00136 <span class="comment">// Alias for length()</span> +<a name="l00137"></a>00137 size_type size ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->size; } +<a name="l00138"></a>00138 +<a name="l00139"></a>00139 <span class="comment">// Checks if a TiXmlString is empty</span> +<a name="l00140"></a>00140 <span class="keywordtype">bool</span> empty ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->size == 0; } +<a name="l00141"></a>00141 +<a name="l00142"></a>00142 <span class="comment">// Return capacity of string</span> +<a name="l00143"></a>00143 size_type capacity ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->capacity; } +<a name="l00144"></a>00144 +<a name="l00145"></a>00145 +<a name="l00146"></a>00146 <span class="comment">// single char extraction</span> +<a name="l00147"></a>00147 <span class="keyword">const</span> <span class="keywordtype">char</span>& at (size_type index)<span class="keyword"> const</span> +<a name="l00148"></a>00148 <span class="keyword"> </span>{ +<a name="l00149"></a>00149 assert( index < length() ); +<a name="l00150"></a>00150 <span class="keywordflow">return</span> rep_->str[ index ]; +<a name="l00151"></a>00151 } <a name="l00152"></a>00152 -<a name="l00153"></a>00153 <span class="comment">// Checks if a TiXmlString is empty</span> -<a name="l00154"></a>00154 <span class="keywordtype">bool</span> empty ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->size == 0; } -<a name="l00155"></a>00155 -<a name="l00156"></a>00156 <span class="comment">// Return capacity of string</span> -<a name="l00157"></a>00157 size_type capacity ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->capacity; } -<a name="l00158"></a>00158 +<a name="l00153"></a>00153 <span class="comment">// [] operator</span> +<a name="l00154"></a>00154 <span class="keywordtype">char</span>& operator [] (size_type index)<span class="keyword"> const</span> +<a name="l00155"></a>00155 <span class="keyword"> </span>{ +<a name="l00156"></a>00156 assert( index < length() ); +<a name="l00157"></a>00157 <span class="keywordflow">return</span> rep_->str[ index ]; +<a name="l00158"></a>00158 } <a name="l00159"></a>00159 -<a name="l00160"></a>00160 <span class="comment">// single char extraction</span> -<a name="l00161"></a>00161 <span class="keyword">const</span> <span class="keywordtype">char</span>& at (size_type index)<span class="keyword"> const</span> +<a name="l00160"></a>00160 <span class="comment">// find a char in a string. Return TiXmlString::npos if not found</span> +<a name="l00161"></a>00161 size_type find (<span class="keywordtype">char</span> lookup)<span class="keyword"> const</span> <a name="l00162"></a>00162 <span class="keyword"> </span>{ -<a name="l00163"></a>00163 assert( index < length() ); -<a name="l00164"></a>00164 <span class="keywordflow">return</span> rep_->str[ index ]; -<a name="l00165"></a>00165 } -<a name="l00166"></a>00166 -<a name="l00167"></a>00167 <span class="comment">// [] operator</span> -<a name="l00168"></a>00168 <span class="keywordtype">char</span>& operator [] (size_type index)<span class="keyword"> const</span> -<a name="l00169"></a>00169 <span class="keyword"> </span>{ -<a name="l00170"></a>00170 assert( index < length() ); -<a name="l00171"></a>00171 <span class="keywordflow">return</span> rep_->str[ index ]; -<a name="l00172"></a>00172 } -<a name="l00173"></a>00173 -<a name="l00174"></a>00174 <span class="comment">// find a char in a string. Return TiXmlString::npos if not found</span> -<a name="l00175"></a>00175 size_type find (<span class="keywordtype">char</span> lookup)<span class="keyword"> const</span> -<a name="l00176"></a>00176 <span class="keyword"> </span>{ -<a name="l00177"></a>00177 <span class="keywordflow">return</span> find(lookup, 0); -<a name="l00178"></a>00178 } -<a name="l00179"></a>00179 -<a name="l00180"></a>00180 <span class="comment">// find a char in a string from an offset. Return TiXmlString::npos if not found</span> -<a name="l00181"></a>00181 size_type find (<span class="keywordtype">char</span> tofind, size_type offset)<span class="keyword"> const</span> -<a name="l00182"></a>00182 <span class="keyword"> </span>{ -<a name="l00183"></a>00183 <span class="keywordflow">if</span> (offset >= length()) <span class="keywordflow">return</span> npos; -<a name="l00184"></a>00184 -<a name="l00185"></a>00185 <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">char</span>* p = c_str() + offset; *p != <span class="charliteral">'\0'</span>; ++p) -<a name="l00186"></a>00186 { -<a name="l00187"></a>00187 <span class="keywordflow">if</span> (*p == tofind) <span class="keywordflow">return</span> <span class="keyword">static_cast<</span> size_type <span class="keyword">></span>( p - c_str() ); -<a name="l00188"></a>00188 } -<a name="l00189"></a>00189 <span class="keywordflow">return</span> npos; -<a name="l00190"></a>00190 } -<a name="l00191"></a>00191 -<a name="l00192"></a>00192 <span class="keywordtype">void</span> clear () -<a name="l00193"></a>00193 { -<a name="l00194"></a>00194 <span class="comment">//Lee:</span> -<a name="l00195"></a>00195 <span class="comment">//The original was just too strange, though correct:</span> -<a name="l00196"></a>00196 <span class="comment">// TiXmlString().swap(*this);</span> -<a name="l00197"></a>00197 <span class="comment">//Instead use the quit & re-init:</span> -<a name="l00198"></a>00198 quit(); -<a name="l00199"></a>00199 init(0,0); -<a name="l00200"></a>00200 } -<a name="l00201"></a>00201 -<a name="l00202"></a>00202 <span class="comment">/* Function to reserve a big amount of data when we know we'll need it. Be aware that this</span> -<a name="l00203"></a>00203 <span class="comment"> function DOES NOT clear the content of the TiXmlString if any exists.</span> -<a name="l00204"></a>00204 <span class="comment"> */</span> -<a name="l00205"></a>00205 <span class="keywordtype">void</span> reserve (size_type cap); -<a name="l00206"></a>00206 -<a name="l00207"></a>00207 TiXmlString& assign (<span class="keyword">const</span> <span class="keywordtype">char</span>* str, size_type len); -<a name="l00208"></a>00208 -<a name="l00209"></a>00209 TiXmlString& append (<span class="keyword">const</span> <span class="keywordtype">char</span>* str, size_type len); +<a name="l00163"></a>00163 <span class="keywordflow">return</span> find(lookup, 0); +<a name="l00164"></a>00164 } +<a name="l00165"></a>00165 +<a name="l00166"></a>00166 <span class="comment">// find a char in a string from an offset. Return TiXmlString::npos if not found</span> +<a name="l00167"></a>00167 size_type find (<span class="keywordtype">char</span> tofind, size_type offset)<span class="keyword"> const</span> +<a name="l00168"></a>00168 <span class="keyword"> </span>{ +<a name="l00169"></a>00169 <span class="keywordflow">if</span> (offset >= length()) <span class="keywordflow">return</span> npos; +<a name="l00170"></a>00170 +<a name="l00171"></a>00171 <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">char</span>* p = c_str() + offset; *p != <span class="charliteral">'\0'</span>; ++p) +<a name="l00172"></a>00172 { +<a name="l00173"></a>00173 <span class="keywordflow">if</span> (*p == tofind) <span class="keywordflow">return</span> <span class="keyword">static_cast<</span> size_type <span class="keyword">></span>( p - c_str() ); +<a name="l00174"></a>00174 } +<a name="l00175"></a>00175 <span class="keywordflow">return</span> npos; +<a name="l00176"></a>00176 } +<a name="l00177"></a>00177 +<a name="l00178"></a>00178 <span class="keywordtype">void</span> clear () +<a name="l00179"></a>00179 { +<a name="l00180"></a>00180 <span class="comment">//Lee:</span> +<a name="l00181"></a>00181 <span class="comment">//The original was just too strange, though correct:</span> +<a name="l00182"></a>00182 <span class="comment">// TiXmlString().swap(*this);</span> +<a name="l00183"></a>00183 <span class="comment">//Instead use the quit & re-init:</span> +<a name="l00184"></a>00184 quit(); +<a name="l00185"></a>00185 init(0,0); +<a name="l00186"></a>00186 } +<a name="l00187"></a>00187 +<a name="l00188"></a>00188 <span class="comment">/* Function to reserve a big amount of data when we know we'll need it. Be aware that this</span> +<a name="l00189"></a>00189 <span class="comment"> function DOES NOT clear the content of the TiXmlString if any exists.</span> +<a name="l00190"></a>00190 <span class="comment"> */</span> +<a name="l00191"></a>00191 <span class="keywordtype">void</span> reserve (size_type cap); +<a name="l00192"></a>00192 +<a name="l00193"></a>00193 TiXmlString& assign (<span class="keyword">const</span> <span class="keywordtype">char</span>* str, size_type len); +<a name="l00194"></a>00194 +<a name="l00195"></a>00195 TiXmlString& append (<span class="keyword">const</span> <span class="keywordtype">char</span>* str, size_type len); +<a name="l00196"></a>00196 +<a name="l00197"></a>00197 <span class="keywordtype">void</span> swap (TiXmlString& other) +<a name="l00198"></a>00198 { +<a name="l00199"></a>00199 Rep* r = rep_; +<a name="l00200"></a>00200 rep_ = other.rep_; +<a name="l00201"></a>00201 other.rep_ = r; +<a name="l00202"></a>00202 } +<a name="l00203"></a>00203 +<a name="l00204"></a>00204 <span class="keyword">private</span>: +<a name="l00205"></a>00205 +<a name="l00206"></a>00206 <span class="keywordtype">void</span> init(size_type sz) { init(sz, sz); } +<a name="l00207"></a>00207 <span class="keywordtype">void</span> set_size(size_type sz) { rep_->str[ rep_->size = sz ] = <span class="charliteral">'\0'</span>; } +<a name="l00208"></a>00208 <span class="keywordtype">char</span>* start()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str; } +<a name="l00209"></a>00209 <span class="keywordtype">char</span>* finish()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str + rep_->size; } <a name="l00210"></a>00210 -<a name="l00211"></a>00211 <span class="keywordtype">void</span> swap (TiXmlString& other) +<a name="l00211"></a>00211 <span class="keyword">struct </span>Rep <a name="l00212"></a>00212 { -<a name="l00213"></a>00213 Rep* r = rep_; -<a name="l00214"></a>00214 rep_ = other.rep_; -<a name="l00215"></a>00215 other.rep_ = r; -<a name="l00216"></a>00216 } -<a name="l00217"></a>00217 -<a name="l00218"></a>00218 <span class="keyword">private</span>: -<a name="l00219"></a>00219 -<a name="l00220"></a>00220 <span class="keywordtype">void</span> init(size_type sz) { init(sz, sz); } -<a name="l00221"></a>00221 <span class="keywordtype">void</span> set_size(size_type sz) { rep_->str[ rep_->size = sz ] = <span class="charliteral">'\0'</span>; } -<a name="l00222"></a>00222 <span class="keywordtype">char</span>* start()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str; } -<a name="l00223"></a>00223 <span class="keywordtype">char</span>* finish()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep_->str + rep_->size; } -<a name="l00224"></a>00224 -<a name="l00225"></a>00225 <span class="keyword">struct </span>Rep -<a name="l00226"></a>00226 { -<a name="l00227"></a>00227 size_type size, capacity; -<a name="l00228"></a>00228 <span class="keywordtype">char</span> str[1]; -<a name="l00229"></a>00229 }; -<a name="l00230"></a>00230 -<a name="l00231"></a>00231 <span class="keywordtype">void</span> init(size_type sz, size_type cap) -<a name="l00232"></a>00232 { -<a name="l00233"></a>00233 <span class="keywordflow">if</span> (cap) +<a name="l00213"></a>00213 size_type size, capacity; +<a name="l00214"></a>00214 <span class="keywordtype">char</span> str[1]; +<a name="l00215"></a>00215 }; +<a name="l00216"></a>00216 +<a name="l00217"></a>00217 <span class="keywordtype">void</span> init(size_type sz, size_type cap) +<a name="l00218"></a>00218 { +<a name="l00219"></a>00219 <span class="keywordflow">if</span> (cap) +<a name="l00220"></a>00220 { +<a name="l00221"></a>00221 <span class="comment">// Lee: the original form:</span> +<a name="l00222"></a>00222 <span class="comment">// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));</span> +<a name="l00223"></a>00223 <span class="comment">// doesn't work in some cases of new being overloaded. Switching</span> +<a name="l00224"></a>00224 <span class="comment">// to the normal allocation, although use an 'int' for systems</span> +<a name="l00225"></a>00225 <span class="comment">// that are overly picky about structure alignment.</span> +<a name="l00226"></a>00226 <span class="keyword">const</span> size_type bytesNeeded = <span class="keyword">sizeof</span>(Rep) + cap; +<a name="l00227"></a>00227 <span class="keyword">const</span> size_type intsNeeded = ( bytesNeeded + <span class="keyword">sizeof</span>(int) - 1 ) / <span class="keyword">sizeof</span>( int ); +<a name="l00228"></a>00228 rep_ = <span class="keyword">reinterpret_cast<</span>Rep*<span class="keyword">></span>( <span class="keyword">new</span> <span class="keywordtype">int</span>[ intsNeeded ] ); +<a name="l00229"></a>00229 +<a name="l00230"></a>00230 rep_->str[ rep_->size = sz ] = <span class="charliteral">'\0'</span>; +<a name="l00231"></a>00231 rep_->capacity = cap; +<a name="l00232"></a>00232 } +<a name="l00233"></a>00233 <span class="keywordflow">else</span> <a name="l00234"></a>00234 { -<a name="l00235"></a>00235 <span class="comment">// Lee: the original form:</span> -<a name="l00236"></a>00236 <span class="comment">// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));</span> -<a name="l00237"></a>00237 <span class="comment">// doesn't work in some cases of new being overloaded. Switching</span> -<a name="l00238"></a>00238 <span class="comment">// to the normal allocation, although use an 'int' for systems</span> -<a name="l00239"></a>00239 <span class="comment">// that are overly picky about structure alignment.</span> -<a name="l00240"></a>00240 <span class="keyword">const</span> size_type bytesNeeded = <span class="keyword">sizeof</span>(Rep) + cap; -<a name="l00241"></a>00241 <span class="keyword">const</span> size_type intsNeeded = ( bytesNeeded + <span class="keyword">sizeof</span>(int) - 1 ) / <span class="keyword">sizeof</span>( int ); -<a name="l00242"></a>00242 rep_ = <span class="keyword">reinterpret_cast<</span>Rep*<span class="keyword">></span>( <span class="keyword">new</span> <span class="keywordtype">int</span>[ intsNeeded ] ); -<a name="l00243"></a>00243 -<a name="l00244"></a>00244 rep_->str[ rep_->size = sz ] = <span class="charliteral">'\0'</span>; -<a name="l00245"></a>00245 rep_->capacity = cap; +<a name="l00235"></a>00235 rep_ = &nullrep_; +<a name="l00236"></a>00236 } +<a name="l00237"></a>00237 } +<a name="l00238"></a>00238 +<a name="l00239"></a>00239 <span class="keywordtype">void</span> quit() +<a name="l00240"></a>00240 { +<a name="l00241"></a>00241 <span class="keywordflow">if</span> (rep_ != &nullrep_) +<a name="l00242"></a>00242 { +<a name="l00243"></a>00243 <span class="comment">// The rep_ is really an array of ints. (see the allocator, above).</span> +<a name="l00244"></a>00244 <span class="comment">// Cast it back before delete, so the compiler won't incorrectly call destructors.</span> +<a name="l00245"></a>00245 <span class="keyword">delete</span> [] ( <span class="keyword">reinterpret_cast<</span><span class="keywordtype">int</span>*<span class="keyword">></span>( rep_ ) ); <a name="l00246"></a>00246 } -<a name="l00247"></a>00247 <span class="keywordflow">else</span> -<a name="l00248"></a>00248 { -<a name="l00249"></a>00249 rep_ = &nullrep_; -<a name="l00250"></a>00250 } -<a name="l00251"></a>00251 } -<a name="l00252"></a>00252 -<a name="l00253"></a>00253 <span class="keywordtype">void</span> quit() -<a name="l00254"></a>00254 { -<a name="l00255"></a>00255 <span class="keywordflow">if</span> (rep_ != &nullrep_) -<a name="l00256"></a>00256 { -<a name="l00257"></a>00257 <span class="comment">// The rep_ is really an array of ints. (see the allocator, above).</span> -<a name="l00258"></a>00258 <span class="comment">// Cast it back before delete, so the compiler won't incorrectly call destructors.</span> -<a name="l00259"></a>00259 <span class="keyword">delete</span> [] ( <span class="keyword">reinterpret_cast<</span><span class="keywordtype">int</span>*<span class="keyword">></span>( rep_ ) ); -<a name="l00260"></a>00260 } -<a name="l00261"></a>00261 } -<a name="l00262"></a>00262 -<a name="l00263"></a>00263 Rep * rep_; -<a name="l00264"></a>00264 <span class="keyword">static</span> Rep nullrep_; -<a name="l00265"></a>00265 -<a name="l00266"></a>00266 } ; -<a name="l00267"></a>00267 -<a name="l00268"></a>00268 -<a name="l00269"></a>00269 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator == (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) -<a name="l00270"></a>00270 { -<a name="l00271"></a>00271 <span class="keywordflow">return</span> ( a.length() == b.length() ) <span class="comment">// optimization on some platforms</span> -<a name="l00272"></a>00272 && ( strcmp(a.c_str(), b.c_str()) == 0 ); <span class="comment">// actual compare</span> -<a name="l00273"></a>00273 } -<a name="l00274"></a>00274 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator < (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) -<a name="l00275"></a>00275 { -<a name="l00276"></a>00276 <span class="keywordflow">return</span> strcmp(a.c_str(), b.c_str()) < 0; -<a name="l00277"></a>00277 } +<a name="l00247"></a>00247 } +<a name="l00248"></a>00248 +<a name="l00249"></a>00249 Rep * rep_; +<a name="l00250"></a>00250 <span class="keyword">static</span> Rep nullrep_; +<a name="l00251"></a>00251 +<a name="l00252"></a>00252 } ; +<a name="l00253"></a>00253 +<a name="l00254"></a>00254 +<a name="l00255"></a>00255 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator == (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) +<a name="l00256"></a>00256 { +<a name="l00257"></a>00257 <span class="keywordflow">return</span> ( a.length() == b.length() ) <span class="comment">// optimization on some platforms</span> +<a name="l00258"></a>00258 && ( strcmp(a.c_str(), b.c_str()) == 0 ); <span class="comment">// actual compare</span> +<a name="l00259"></a>00259 } +<a name="l00260"></a>00260 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator < (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) +<a name="l00261"></a>00261 { +<a name="l00262"></a>00262 <span class="keywordflow">return</span> strcmp(a.c_str(), b.c_str()) < 0; +<a name="l00263"></a>00263 } +<a name="l00264"></a>00264 +<a name="l00265"></a>00265 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator != (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(a == b); } +<a name="l00266"></a>00266 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator > (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> b < a; } +<a name="l00267"></a>00267 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator <= (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(b < a); } +<a name="l00268"></a>00268 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator >= (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(a < b); } +<a name="l00269"></a>00269 +<a name="l00270"></a>00270 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator == (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> <span class="keywordtype">char</span>* b) { <span class="keywordflow">return</span> strcmp(a.c_str(), b) == 0; } +<a name="l00271"></a>00271 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator == (<span class="keyword">const</span> <span class="keywordtype">char</span>* a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> b == a; } +<a name="l00272"></a>00272 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator != (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> <span class="keywordtype">char</span>* b) { <span class="keywordflow">return</span> !(a == b); } +<a name="l00273"></a>00273 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator != (<span class="keyword">const</span> <span class="keywordtype">char</span>* a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(b == a); } +<a name="l00274"></a>00274 +<a name="l00275"></a>00275 TiXmlString operator + (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b); +<a name="l00276"></a>00276 TiXmlString operator + (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> <span class="keywordtype">char</span>* b); +<a name="l00277"></a>00277 TiXmlString operator + (<span class="keyword">const</span> <span class="keywordtype">char</span>* a, <span class="keyword">const</span> TiXmlString & b); <a name="l00278"></a>00278 -<a name="l00279"></a>00279 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator != (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(a == b); } -<a name="l00280"></a>00280 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator > (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> b < a; } -<a name="l00281"></a>00281 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator <= (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(b < a); } -<a name="l00282"></a>00282 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator >= (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(a < b); } -<a name="l00283"></a>00283 -<a name="l00284"></a>00284 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator == (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> <span class="keywordtype">char</span>* b) { <span class="keywordflow">return</span> strcmp(a.c_str(), b) == 0; } -<a name="l00285"></a>00285 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator == (<span class="keyword">const</span> <span class="keywordtype">char</span>* a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> b == a; } -<a name="l00286"></a>00286 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator != (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> <span class="keywordtype">char</span>* b) { <span class="keywordflow">return</span> !(a == b); } -<a name="l00287"></a>00287 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator != (<span class="keyword">const</span> <span class="keywordtype">char</span>* a, <span class="keyword">const</span> TiXmlString & b) { <span class="keywordflow">return</span> !(b == a); } -<a name="l00288"></a>00288 -<a name="l00289"></a>00289 TiXmlString operator + (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> TiXmlString & b); -<a name="l00290"></a>00290 TiXmlString operator + (<span class="keyword">const</span> TiXmlString & a, <span class="keyword">const</span> <span class="keywordtype">char</span>* b); -<a name="l00291"></a>00291 TiXmlString operator + (<span class="keyword">const</span> <span class="keywordtype">char</span>* a, <span class="keyword">const</span> TiXmlString & b); -<a name="l00292"></a>00292 -<a name="l00293"></a>00293 -<a name="l00294"></a>00294 <span class="comment">/*</span> -<a name="l00295"></a>00295 <span class="comment"> TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.</span> -<a name="l00296"></a>00296 <span class="comment"> Only the operators that we need for TinyXML have been developped.</span> -<a name="l00297"></a>00297 <span class="comment">*/</span> -<a name="l00298"></a>00298 <span class="keyword">class </span>TiXmlOutStream : <span class="keyword">public</span> TiXmlString -<a name="l00299"></a>00299 { -<a name="l00300"></a>00300 <span class="keyword">public</span> : +<a name="l00279"></a>00279 +<a name="l00280"></a>00280 <span class="comment">/*</span> +<a name="l00281"></a>00281 <span class="comment"> TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.</span> +<a name="l00282"></a>00282 <span class="comment"> Only the operators that we need for TinyXML have been developped.</span> +<a name="l00283"></a>00283 <span class="comment">*/</span> +<a name="l00284"></a>00284 <span class="keyword">class </span>TiXmlOutStream : <span class="keyword">public</span> TiXmlString +<a name="l00285"></a>00285 { +<a name="l00286"></a>00286 <span class="keyword">public</span> : +<a name="l00287"></a>00287 +<a name="l00288"></a>00288 <span class="comment">// TiXmlOutStream << operator.</span> +<a name="l00289"></a>00289 TiXmlOutStream & operator << (<span class="keyword">const</span> TiXmlString & in) +<a name="l00290"></a>00290 { +<a name="l00291"></a>00291 *<span class="keyword">this</span> += in; +<a name="l00292"></a>00292 <span class="keywordflow">return</span> *<span class="keyword">this</span>; +<a name="l00293"></a>00293 } +<a name="l00294"></a>00294 +<a name="l00295"></a>00295 <span class="comment">// TiXmlOutStream << operator.</span> +<a name="l00296"></a>00296 TiXmlOutStream & operator << (<span class="keyword">const</span> <span class="keywordtype">char</span> * in) +<a name="l00297"></a>00297 { +<a name="l00298"></a>00298 *<span class="keyword">this</span> += in; +<a name="l00299"></a>00299 <span class="keywordflow">return</span> *<span class="keyword">this</span>; +<a name="l00300"></a>00300 } <a name="l00301"></a>00301 -<a name="l00302"></a>00302 <span class="comment">// TiXmlOutStream << operator.</span> -<a name="l00303"></a>00303 TiXmlOutStream & operator << (<span class="keyword">const</span> TiXmlString & in) -<a name="l00304"></a>00304 { -<a name="l00305"></a>00305 *<span class="keyword">this</span> += in; -<a name="l00306"></a>00306 <span class="keywordflow">return</span> *<span class="keyword">this</span>; -<a name="l00307"></a>00307 } -<a name="l00308"></a>00308 -<a name="l00309"></a>00309 <span class="comment">// TiXmlOutStream << operator.</span> -<a name="l00310"></a>00310 TiXmlOutStream & operator << (<span class="keyword">const</span> <span class="keywordtype">char</span> * in) -<a name="l00311"></a>00311 { -<a name="l00312"></a>00312 *<span class="keyword">this</span> += in; -<a name="l00313"></a>00313 <span class="keywordflow">return</span> *<span class="keyword">this</span>; -<a name="l00314"></a>00314 } -<a name="l00315"></a>00315 -<a name="l00316"></a>00316 } ; -<a name="l00317"></a>00317 -<a name="l00318"></a>00318 <span class="preprocessor">#endif // TIXML_STRING_INCLUDED</span> -<a name="l00319"></a>00319 <span class="preprocessor"></span><span class="preprocessor">#endif // TIXML_USE_STL</span> +<a name="l00302"></a>00302 } ; +<a name="l00303"></a>00303 +<a name="l00304"></a>00304 <span class="preprocessor">#endif // TIXML_STRING_INCLUDED</span> +<a name="l00305"></a>00305 <span class="preprocessor"></span><span class="preprocessor">#endif // TIXML_USE_STL</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> diff --git a/shared/tinyxml/docs/tinyxml_8h_source.html b/shared/tinyxml/docs/tinyxml_8h_source.html index e991e035..566e3960 100644 --- a/shared/tinyxml/docs/tinyxml_8h_source.html +++ b/shared/tinyxml/docs/tinyxml_8h_source.html @@ -24,7 +24,7 @@ </div> <h1>tinyxml.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment">www.sourceforge.net/projects/tinyxml</span> -<a name="l00003"></a>00003 <span class="comment">Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)</span> +<a name="l00003"></a>00003 <span class="comment">Original code by Lee Thomason (www.grinninglizard.com)</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment">This software is provided 'as-is', without any express or implied</span> <a name="l00006"></a>00006 <span class="comment">warranty. In no event will the authors be held liable for any</span> @@ -115,7 +115,7 @@ <a name="l00091"></a>00091 <a name="l00092"></a>00092 <span class="keyword">const</span> <span class="keywordtype">int</span> TIXML_MAJOR_VERSION = 2; <a name="l00093"></a>00093 <span class="keyword">const</span> <span class="keywordtype">int</span> TIXML_MINOR_VERSION = 6; -<a name="l00094"></a>00094 <span class="keyword">const</span> <span class="keywordtype">int</span> TIXML_PATCH_VERSION = 1; +<a name="l00094"></a>00094 <span class="keyword">const</span> <span class="keywordtype">int</span> TIXML_PATCH_VERSION = 2; <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="comment">/* Internal structure for tracking location of items </span> <a name="l00097"></a>00097 <span class="comment"> in the XML file.</span> @@ -144,7 +144,7 @@ <a name="l00144"></a><a class="code" href="classTiXmlVisitor.html#afad71c71ce6473fb9b4b64cd92de4a19">00144</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlVisitor.html#afad71c71ce6473fb9b4b64cd92de4a19" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& <span class="comment">/*declaration*/</span> ) { <span class="keywordflow">return</span> <span class="keyword">true</span>; } <a name="l00146"></a><a class="code" href="classTiXmlVisitor.html#a399b8ebca5cd14664974a32d2ce029e5">00146</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlVisitor.html#a399b8ebca5cd14664974a32d2ce029e5" title="Visit a text node.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& <span class="comment">/*text*/</span> ) { <span class="keywordflow">return</span> <span class="keyword">true</span>; } <a name="l00148"></a><a class="code" href="classTiXmlVisitor.html#a53a60e7a528627b31af3161972cc7fa2">00148</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlVisitor.html#a53a60e7a528627b31af3161972cc7fa2" title="Visit a comment node.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& <span class="comment">/*comment*/</span> ) { <span class="keywordflow">return</span> <span class="keyword">true</span>; } -<a name="l00150"></a><a class="code" href="classTiXmlVisitor.html#a7e284d607d275c51dac1adb58159ce28">00150</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlVisitor.html#a7e284d607d275c51dac1adb58159ce28" title="Visit an unknow node.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& <span class="comment">/*unknown*/</span> ) { <span class="keywordflow">return</span> <span class="keyword">true</span>; } +<a name="l00150"></a><a class="code" href="classTiXmlVisitor.html#a7e284d607d275c51dac1adb58159ce28">00150</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlVisitor.html#a7e284d607d275c51dac1adb58159ce28" title="Visit an unknown node.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& <span class="comment">/*unknown*/</span> ) { <span class="keywordflow">return</span> <span class="keyword">true</span>; } <a name="l00151"></a>00151 }; <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="comment">// Only used by Attribute::Query functions</span> @@ -715,7 +715,7 @@ <a name="l00950"></a>00950 <span class="preprocessor"></span> <a name="l00951"></a>00951 <a class="code" href="classTiXmlElement.html#a01bc3ab372d35da08efcbbe65ad90c60" title="Construct an element.">TiXmlElement</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& ); <a name="l00952"></a>00952 -<a name="l00953"></a>00953 <span class="keywordtype">void</span> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& base ); +<a name="l00953"></a>00953 <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& base ); <a name="l00954"></a>00954 <a name="l00955"></a>00955 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>(); <a name="l00956"></a>00956 @@ -726,477 +726,478 @@ <a name="l00976"></a>00976 <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlElement.html#ae419a442a9701a62b0c3d8fd1cbdd12d" title="Given an attribute name, Attribute() returns the value for the attribute of that...">Attribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">double</span>* d ) <span class="keyword">const</span>; <a name="l00977"></a>00977 <a name="l00985"></a>00985 <span class="keywordtype">int</span> <a class="code" href="classTiXmlElement.html#aea0bfe471380f281c5945770ddbf52b9" title="QueryIntAttribute examines the attribute - it is an alternative to the Attribute()...">QueryIntAttribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">int</span>* _value ) <span class="keyword">const</span>; -<a name="l00987"></a>00987 <span class="keywordtype">int</span> <a class="code" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7" title="QueryDoubleAttribute examines the attribute - see QueryIntAttribute().">QueryDoubleAttribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">double</span>* _value ) <span class="keyword">const</span>; -<a name="l00989"></a><a class="code" href="classTiXmlElement.html#aa04d3af11601ef5a5f88295203a843be">00989</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlElement.html#aa04d3af11601ef5a5f88295203a843be" title="QueryFloatAttribute examines the attribute - see QueryIntAttribute().">QueryFloatAttribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">float</span>* _value )<span class="keyword"> const </span>{ -<a name="l00990"></a>00990 <span class="keywordtype">double</span> d; -<a name="l00991"></a>00991 <span class="keywordtype">int</span> result = <a class="code" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7" title="QueryDoubleAttribute examines the attribute - see QueryIntAttribute().">QueryDoubleAttribute</a>( name, &d ); -<a name="l00992"></a>00992 <span class="keywordflow">if</span> ( result == TIXML_SUCCESS ) { -<a name="l00993"></a>00993 *_value = (float)d; -<a name="l00994"></a>00994 } -<a name="l00995"></a>00995 <span class="keywordflow">return</span> result; -<a name="l00996"></a>00996 } -<a name="l00997"></a>00997 -<a name="l00998"></a>00998 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01000"></a><a class="code" href="classTiXmlElement.html#a14321ac360efe906ed449d9db3fd9961">01000</a> <span class="preprocessor"> int QueryStringAttribute( const char* name, std::string* _value ) const {</span> -<a name="l01001"></a>01001 <span class="preprocessor"></span> <span class="keyword">const</span> <span class="keywordtype">char</span>* cstr = <a class="code" href="classTiXmlElement.html#ae419a442a9701a62b0c3d8fd1cbdd12d" title="Given an attribute name, Attribute() returns the value for the attribute of that...">Attribute</a>( name ); -<a name="l01002"></a>01002 <span class="keywordflow">if</span> ( cstr ) { -<a name="l01003"></a>01003 *_value = std::string( cstr ); -<a name="l01004"></a>01004 <span class="keywordflow">return</span> TIXML_SUCCESS; -<a name="l01005"></a>01005 } -<a name="l01006"></a>01006 <span class="keywordflow">return</span> TIXML_NO_ATTRIBUTE; -<a name="l01007"></a>01007 } -<a name="l01008"></a>01008 -<a name="l01017"></a><a class="code" href="classTiXmlElement.html#ae3b9a03b0a56663a40801c7256683576">01017</a> <span class="keyword">template</span>< <span class="keyword">typename</span> T > <span class="keywordtype">int</span> QueryValueAttribute( <span class="keyword">const</span> std::string& name, T* outValue )<span class="keyword"> const</span> -<a name="l01018"></a>01018 <span class="keyword"> </span>{ -<a name="l01019"></a>01019 <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* node = attributeSet.Find( name ); -<a name="l01020"></a>01020 <span class="keywordflow">if</span> ( !node ) -<a name="l01021"></a>01021 <span class="keywordflow">return</span> TIXML_NO_ATTRIBUTE; -<a name="l01022"></a>01022 -<a name="l01023"></a>01023 std::stringstream sstream( node-><a class="code" href="classTiXmlAttribute.html#a87705c3ccf9ee9417beb4f7cbacd4d33" title="Return the value of this attribute.">ValueStr</a>() ); -<a name="l01024"></a>01024 sstream >> *outValue; -<a name="l01025"></a>01025 <span class="keywordflow">if</span> ( !sstream.fail() ) -<a name="l01026"></a>01026 <span class="keywordflow">return</span> TIXML_SUCCESS; -<a name="l01027"></a>01027 <span class="keywordflow">return</span> TIXML_WRONG_TYPE; -<a name="l01028"></a>01028 } +<a name="l00987"></a>00987 <span class="keywordtype">int</span> <a class="code" href="classTiXmlElement.html#ae48df644f890ab86fa19839ac401f00d" title="QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().">QueryUnsignedAttribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">unsigned</span>* _value ) <span class="keyword">const</span>; +<a name="l00992"></a>00992 <span class="keywordtype">int</span> <a class="code" href="classTiXmlElement.html#af4a1d3f88c28eb0f3115dc39ebd83fff" title="QueryBoolAttribute examines the attribute - see QueryIntAttribute().">QueryBoolAttribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">bool</span>* _value ) <span class="keyword">const</span>; +<a name="l00994"></a>00994 <span class="keywordtype">int</span> <a class="code" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7" title="QueryDoubleAttribute examines the attribute - see QueryIntAttribute().">QueryDoubleAttribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">double</span>* _value ) <span class="keyword">const</span>; +<a name="l00996"></a><a class="code" href="classTiXmlElement.html#aa04d3af11601ef5a5f88295203a843be">00996</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlElement.html#aa04d3af11601ef5a5f88295203a843be" title="QueryFloatAttribute examines the attribute - see QueryIntAttribute().">QueryFloatAttribute</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">float</span>* _value )<span class="keyword"> const </span>{ +<a name="l00997"></a>00997 <span class="keywordtype">double</span> d; +<a name="l00998"></a>00998 <span class="keywordtype">int</span> result = <a class="code" href="classTiXmlElement.html#a898d7730ecc341f0bffc7a9dadbf1ce7" title="QueryDoubleAttribute examines the attribute - see QueryIntAttribute().">QueryDoubleAttribute</a>( name, &d ); +<a name="l00999"></a>00999 <span class="keywordflow">if</span> ( result == TIXML_SUCCESS ) { +<a name="l01000"></a>01000 *_value = (float)d; +<a name="l01001"></a>01001 } +<a name="l01002"></a>01002 <span class="keywordflow">return</span> result; +<a name="l01003"></a>01003 } +<a name="l01004"></a>01004 +<a name="l01005"></a>01005 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01007"></a><a class="code" href="classTiXmlElement.html#a14321ac360efe906ed449d9db3fd9961">01007</a> <span class="preprocessor"> int QueryStringAttribute( const char* name, std::string* _value ) const {</span> +<a name="l01008"></a>01008 <span class="preprocessor"></span> <span class="keyword">const</span> <span class="keywordtype">char</span>* cstr = <a class="code" href="classTiXmlElement.html#ae419a442a9701a62b0c3d8fd1cbdd12d" title="Given an attribute name, Attribute() returns the value for the attribute of that...">Attribute</a>( name ); +<a name="l01009"></a>01009 <span class="keywordflow">if</span> ( cstr ) { +<a name="l01010"></a>01010 *_value = std::string( cstr ); +<a name="l01011"></a>01011 <span class="keywordflow">return</span> TIXML_SUCCESS; +<a name="l01012"></a>01012 } +<a name="l01013"></a>01013 <span class="keywordflow">return</span> TIXML_NO_ATTRIBUTE; +<a name="l01014"></a>01014 } +<a name="l01015"></a>01015 +<a name="l01024"></a><a class="code" href="classTiXmlElement.html#ae3b9a03b0a56663a40801c7256683576">01024</a> <span class="keyword">template</span>< <span class="keyword">typename</span> T > <span class="keywordtype">int</span> QueryValueAttribute( <span class="keyword">const</span> std::string& name, T* outValue )<span class="keyword"> const</span> +<a name="l01025"></a>01025 <span class="keyword"> </span>{ +<a name="l01026"></a>01026 <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* node = attributeSet.Find( name ); +<a name="l01027"></a>01027 <span class="keywordflow">if</span> ( !node ) +<a name="l01028"></a>01028 <span class="keywordflow">return</span> TIXML_NO_ATTRIBUTE; <a name="l01029"></a>01029 -<a name="l01030"></a>01030 <span class="keywordtype">int</span> QueryValueAttribute( <span class="keyword">const</span> std::string& name, std::string* outValue )<span class="keyword"> const</span> -<a name="l01031"></a>01031 <span class="keyword"> </span>{ -<a name="l01032"></a>01032 <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* node = attributeSet.Find( name ); -<a name="l01033"></a>01033 <span class="keywordflow">if</span> ( !node ) -<a name="l01034"></a>01034 <span class="keywordflow">return</span> TIXML_NO_ATTRIBUTE; -<a name="l01035"></a>01035 *outValue = node-><a class="code" href="classTiXmlAttribute.html#a87705c3ccf9ee9417beb4f7cbacd4d33" title="Return the value of this attribute.">ValueStr</a>(); -<a name="l01036"></a>01036 <span class="keywordflow">return</span> TIXML_SUCCESS; -<a name="l01037"></a>01037 } -<a name="l01038"></a>01038 <span class="preprocessor"> #endif</span> -<a name="l01039"></a>01039 <span class="preprocessor"></span> -<a name="l01043"></a>01043 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keyword">const</span> <span class="keywordtype">char</span> * _value ); -<a name="l01044"></a>01044 -<a name="l01045"></a>01045 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01046"></a>01046 <span class="preprocessor"></span> <span class="keyword">const</span> std::string* Attribute( <span class="keyword">const</span> std::string& name ) <span class="keyword">const</span>; -<a name="l01047"></a>01047 <span class="keyword">const</span> std::string* Attribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">int</span>* i ) <span class="keyword">const</span>; -<a name="l01048"></a>01048 <span class="keyword">const</span> std::string* Attribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">double</span>* d ) <span class="keyword">const</span>; -<a name="l01049"></a>01049 <span class="keywordtype">int</span> QueryIntAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">int</span>* _value ) <span class="keyword">const</span>; -<a name="l01050"></a>01050 <span class="keywordtype">int</span> QueryDoubleAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">double</span>* _value ) <span class="keyword">const</span>; +<a name="l01030"></a>01030 std::stringstream sstream( node-><a class="code" href="classTiXmlAttribute.html#a87705c3ccf9ee9417beb4f7cbacd4d33" title="Return the value of this attribute.">ValueStr</a>() ); +<a name="l01031"></a>01031 sstream >> *outValue; +<a name="l01032"></a>01032 <span class="keywordflow">if</span> ( !sstream.fail() ) +<a name="l01033"></a>01033 <span class="keywordflow">return</span> TIXML_SUCCESS; +<a name="l01034"></a>01034 <span class="keywordflow">return</span> TIXML_WRONG_TYPE; +<a name="l01035"></a>01035 } +<a name="l01036"></a>01036 +<a name="l01037"></a>01037 <span class="keywordtype">int</span> QueryValueAttribute( <span class="keyword">const</span> std::string& name, std::string* outValue )<span class="keyword"> const</span> +<a name="l01038"></a>01038 <span class="keyword"> </span>{ +<a name="l01039"></a>01039 <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* node = attributeSet.Find( name ); +<a name="l01040"></a>01040 <span class="keywordflow">if</span> ( !node ) +<a name="l01041"></a>01041 <span class="keywordflow">return</span> TIXML_NO_ATTRIBUTE; +<a name="l01042"></a>01042 *outValue = node-><a class="code" href="classTiXmlAttribute.html#a87705c3ccf9ee9417beb4f7cbacd4d33" title="Return the value of this attribute.">ValueStr</a>(); +<a name="l01043"></a>01043 <span class="keywordflow">return</span> TIXML_SUCCESS; +<a name="l01044"></a>01044 } +<a name="l01045"></a>01045 <span class="preprocessor"> #endif</span> +<a name="l01046"></a>01046 <span class="preprocessor"></span> +<a name="l01050"></a>01050 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keyword">const</span> <span class="keywordtype">char</span> * _value ); <a name="l01051"></a>01051 -<a name="l01053"></a>01053 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> std::string& name, <span class="keyword">const</span> std::string& _value ); -<a name="l01055"></a>01055 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">int</span> _value ); -<a name="l01057"></a>01057 <span class="keywordtype">void</span> SetDoubleAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">double</span> value ); -<a name="l01058"></a>01058 <span class="preprocessor"> #endif</span> -<a name="l01059"></a>01059 <span class="preprocessor"></span> -<a name="l01063"></a>01063 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span> * name, <span class="keywordtype">int</span> value ); -<a name="l01064"></a>01064 -<a name="l01068"></a>01068 <span class="keywordtype">void</span> SetDoubleAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span> * name, <span class="keywordtype">double</span> value ); -<a name="l01069"></a>01069 -<a name="l01072"></a>01072 <span class="keywordtype">void</span> RemoveAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span> * name ); -<a name="l01073"></a>01073 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01074"></a><a class="code" href="classTiXmlElement.html#a1afa6aea716511326a608e4c05df4f3a">01074</a> <span class="preprocessor"></span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlElement.html#a1afa6aea716511326a608e4c05df4f3a" title="STL std::string form.">RemoveAttribute</a>( <span class="keyword">const</span> std::string& name ) { <a class="code" href="classTiXmlElement.html#a1afa6aea716511326a608e4c05df4f3a" title="STL std::string form.">RemoveAttribute</a> (name.c_str ()); } -<a name="l01075"></a>01075 <span class="preprocessor"> #endif</span> -<a name="l01076"></a>01076 <span class="preprocessor"></span> -<a name="l01077"></a><a class="code" href="classTiXmlElement.html#a516054c9073647d6cb29b6abe9fa0592">01077</a> <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* <a class="code" href="classTiXmlElement.html#a516054c9073647d6cb29b6abe9fa0592" title="Access the first attribute in this element.">FirstAttribute</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> attributeSet.First(); } -<a name="l01078"></a>01078 <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* FirstAttribute() { <span class="keywordflow">return</span> attributeSet.First(); } -<a name="l01079"></a><a class="code" href="classTiXmlElement.html#a86191b49f9177be132b85b14655f1381">01079</a> <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* <a class="code" href="classTiXmlElement.html#a86191b49f9177be132b85b14655f1381" title="Access the last attribute in this element.">LastAttribute</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> attributeSet.Last(); } -<a name="l01080"></a>01080 <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* LastAttribute() { <span class="keywordflow">return</span> attributeSet.Last(); } -<a name="l01081"></a>01081 -<a name="l01114"></a>01114 <span class="keyword">const</span> <span class="keywordtype">char</span>* GetText() <span class="keyword">const</span>; -<a name="l01115"></a>01115 -<a name="l01117"></a>01117 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* Clone() <span class="keyword">const</span>; -<a name="l01118"></a>01118 <span class="comment">// Print the Element to a FILE stream.</span> -<a name="l01119"></a>01119 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Print( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; -<a name="l01120"></a>01120 -<a name="l01121"></a>01121 <span class="comment">/* Attribtue parsing starts: next char past '<'</span> -<a name="l01122"></a>01122 <span class="comment"> returns: next char past '>'</span> -<a name="l01123"></a>01123 <span class="comment"> */</span> -<a name="l01124"></a>01124 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); -<a name="l01125"></a>01125 -<a name="l01126"></a><a class="code" href="classTiXmlElement.html#ac5b8d0e25fa23fd9acbb6d146082901c">01126</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlElement.html#ac5b8d0e25fa23fd9acbb6d146082901c" title="Cast to a more defined type. Will return null not of the requested type.">ToElement</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01127"></a><a class="code" href="classTiXmlElement.html#a9def86337ea7a755eb41cac980f60c7a">01127</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlElement.html#a9def86337ea7a755eb41cac980f60c7a" title="Cast to a more defined type. Will return null not of the requested type.">ToElement</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01128"></a>01128 -<a name="l01131"></a>01131 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> Accept( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* visitor ) <span class="keyword">const</span>; +<a name="l01052"></a>01052 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01053"></a>01053 <span class="preprocessor"></span> <span class="keyword">const</span> std::string* Attribute( <span class="keyword">const</span> std::string& name ) <span class="keyword">const</span>; +<a name="l01054"></a>01054 <span class="keyword">const</span> std::string* Attribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">int</span>* i ) <span class="keyword">const</span>; +<a name="l01055"></a>01055 <span class="keyword">const</span> std::string* Attribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">double</span>* d ) <span class="keyword">const</span>; +<a name="l01056"></a>01056 <span class="keywordtype">int</span> QueryIntAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">int</span>* _value ) <span class="keyword">const</span>; +<a name="l01057"></a>01057 <span class="keywordtype">int</span> QueryDoubleAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">double</span>* _value ) <span class="keyword">const</span>; +<a name="l01058"></a>01058 +<a name="l01060"></a>01060 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> std::string& name, <span class="keyword">const</span> std::string& _value ); +<a name="l01062"></a>01062 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">int</span> _value ); +<a name="l01064"></a>01064 <span class="keywordtype">void</span> SetDoubleAttribute( <span class="keyword">const</span> std::string& name, <span class="keywordtype">double</span> value ); +<a name="l01065"></a>01065 <span class="preprocessor"> #endif</span> +<a name="l01066"></a>01066 <span class="preprocessor"></span> +<a name="l01070"></a>01070 <span class="keywordtype">void</span> SetAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span> * name, <span class="keywordtype">int</span> value ); +<a name="l01071"></a>01071 +<a name="l01075"></a>01075 <span class="keywordtype">void</span> SetDoubleAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span> * name, <span class="keywordtype">double</span> value ); +<a name="l01076"></a>01076 +<a name="l01079"></a>01079 <span class="keywordtype">void</span> RemoveAttribute( <span class="keyword">const</span> <span class="keywordtype">char</span> * name ); +<a name="l01080"></a>01080 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01081"></a><a class="code" href="classTiXmlElement.html#a1afa6aea716511326a608e4c05df4f3a">01081</a> <span class="preprocessor"></span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlElement.html#a1afa6aea716511326a608e4c05df4f3a" title="STL std::string form.">RemoveAttribute</a>( <span class="keyword">const</span> std::string& name ) { <a class="code" href="classTiXmlElement.html#a1afa6aea716511326a608e4c05df4f3a" title="STL std::string form.">RemoveAttribute</a> (name.c_str ()); } +<a name="l01082"></a>01082 <span class="preprocessor"> #endif</span> +<a name="l01083"></a>01083 <span class="preprocessor"></span> +<a name="l01084"></a><a class="code" href="classTiXmlElement.html#a516054c9073647d6cb29b6abe9fa0592">01084</a> <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* <a class="code" href="classTiXmlElement.html#a516054c9073647d6cb29b6abe9fa0592" title="Access the first attribute in this element.">FirstAttribute</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> attributeSet.First(); } +<a name="l01085"></a>01085 <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* FirstAttribute() { <span class="keywordflow">return</span> attributeSet.First(); } +<a name="l01086"></a><a class="code" href="classTiXmlElement.html#a86191b49f9177be132b85b14655f1381">01086</a> <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* <a class="code" href="classTiXmlElement.html#a86191b49f9177be132b85b14655f1381" title="Access the last attribute in this element.">LastAttribute</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> attributeSet.Last(); } +<a name="l01087"></a>01087 <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* LastAttribute() { <span class="keywordflow">return</span> attributeSet.Last(); } +<a name="l01088"></a>01088 +<a name="l01121"></a>01121 <span class="keyword">const</span> <span class="keywordtype">char</span>* GetText() <span class="keyword">const</span>; +<a name="l01122"></a>01122 +<a name="l01124"></a>01124 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* Clone() <span class="keyword">const</span>; +<a name="l01125"></a>01125 <span class="comment">// Print the Element to a FILE stream.</span> +<a name="l01126"></a>01126 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Print( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; +<a name="l01127"></a>01127 +<a name="l01128"></a>01128 <span class="comment">/* Attribtue parsing starts: next char past '<'</span> +<a name="l01129"></a>01129 <span class="comment"> returns: next char past '>'</span> +<a name="l01130"></a>01130 <span class="comment"> */</span> +<a name="l01131"></a>01131 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); <a name="l01132"></a>01132 -<a name="l01133"></a>01133 <span class="keyword">protected</span>: -<a name="l01134"></a>01134 -<a name="l01135"></a>01135 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* target ) <span class="keyword">const</span>; -<a name="l01136"></a>01136 <span class="keywordtype">void</span> ClearThis(); <span class="comment">// like clear, but initializes 'this' object as well</span> -<a name="l01137"></a>01137 -<a name="l01138"></a>01138 <span class="comment">// Used to be public [internal use]</span> -<a name="l01139"></a>01139 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01140"></a>01140 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); -<a name="l01141"></a>01141 <span class="preprocessor"> #endif</span> -<a name="l01142"></a>01142 <span class="preprocessor"></span> <span class="comment">/* [internal use]</span> -<a name="l01143"></a>01143 <span class="comment"> Reads the "value" of the element -- another element, or text.</span> -<a name="l01144"></a>01144 <span class="comment"> This should terminate with the current end tag.</span> -<a name="l01145"></a>01145 <span class="comment"> */</span> -<a name="l01146"></a>01146 <span class="keyword">const</span> <span class="keywordtype">char</span>* ReadValue( <span class="keyword">const</span> <span class="keywordtype">char</span>* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); -<a name="l01147"></a>01147 -<a name="l01148"></a>01148 <span class="keyword">private</span>: -<a name="l01149"></a>01149 TiXmlAttributeSet attributeSet; -<a name="l01150"></a>01150 }; -<a name="l01151"></a>01151 -<a name="l01152"></a>01152 -<a name="l01155"></a><a class="code" href="classTiXmlComment.html">01155</a> <span class="keyword">class </span><a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> -<a name="l01156"></a>01156 { -<a name="l01157"></a>01157 <span class="keyword">public</span>: -<a name="l01159"></a><a class="code" href="classTiXmlComment.html#aaa3252031d3e8bd3a2bf51a1c61201b7">01159</a> <a class="code" href="classTiXmlComment.html#aaa3252031d3e8bd3a2bf51a1c61201b7" title="Constructs an empty comment.">TiXmlComment</a>() : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_COMMENT ) {} -<a name="l01161"></a><a class="code" href="classTiXmlComment.html#a37e7802ef17bc03ebe5ae79bf0713d47">01161</a> <a class="code" href="classTiXmlComment.html#a37e7802ef17bc03ebe5ae79bf0713d47" title="Construct a comment from text.">TiXmlComment</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _value ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_COMMENT ) { -<a name="l01162"></a>01162 <a class="code" href="classTiXmlNode.html#a2a38329ca5d3f28f98ce932b8299ae90" title="Changes the value of the node.">SetValue</a>( _value ); -<a name="l01163"></a>01163 } -<a name="l01164"></a>01164 <a class="code" href="classTiXmlComment.html#aaa3252031d3e8bd3a2bf51a1c61201b7" title="Constructs an empty comment.">TiXmlComment</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& ); -<a name="l01165"></a>01165 <span class="keywordtype">void</span> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& base ); -<a name="l01166"></a>01166 -<a name="l01167"></a>01167 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>() {} -<a name="l01168"></a>01168 -<a name="l01170"></a>01170 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlComment.html#a0d6662bdc52488b9e12b3c7a0453d028" title="Returns a copy of this Comment.">Clone</a>() <span class="keyword">const</span>; -<a name="l01171"></a>01171 <span class="comment">// Write this Comment to a FILE stream.</span> -<a name="l01172"></a>01172 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlComment.html#a6b316527aaa8da0370cd68c22a5a0f5f" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; +<a name="l01133"></a><a class="code" href="classTiXmlElement.html#ac5b8d0e25fa23fd9acbb6d146082901c">01133</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlElement.html#ac5b8d0e25fa23fd9acbb6d146082901c" title="Cast to a more defined type. Will return null not of the requested type.">ToElement</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01134"></a><a class="code" href="classTiXmlElement.html#a9def86337ea7a755eb41cac980f60c7a">01134</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlElement.html#a9def86337ea7a755eb41cac980f60c7a" title="Cast to a more defined type. Will return null not of the requested type.">ToElement</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01135"></a>01135 +<a name="l01138"></a>01138 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> Accept( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* visitor ) <span class="keyword">const</span>; +<a name="l01139"></a>01139 +<a name="l01140"></a>01140 <span class="keyword">protected</span>: +<a name="l01141"></a>01141 +<a name="l01142"></a>01142 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* target ) <span class="keyword">const</span>; +<a name="l01143"></a>01143 <span class="keywordtype">void</span> ClearThis(); <span class="comment">// like clear, but initializes 'this' object as well</span> +<a name="l01144"></a>01144 +<a name="l01145"></a>01145 <span class="comment">// Used to be public [internal use]</span> +<a name="l01146"></a>01146 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01147"></a>01147 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); +<a name="l01148"></a>01148 <span class="preprocessor"> #endif</span> +<a name="l01149"></a>01149 <span class="preprocessor"></span> <span class="comment">/* [internal use]</span> +<a name="l01150"></a>01150 <span class="comment"> Reads the "value" of the element -- another element, or text.</span> +<a name="l01151"></a>01151 <span class="comment"> This should terminate with the current end tag.</span> +<a name="l01152"></a>01152 <span class="comment"> */</span> +<a name="l01153"></a>01153 <span class="keyword">const</span> <span class="keywordtype">char</span>* ReadValue( <span class="keyword">const</span> <span class="keywordtype">char</span>* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); +<a name="l01154"></a>01154 +<a name="l01155"></a>01155 <span class="keyword">private</span>: +<a name="l01156"></a>01156 TiXmlAttributeSet attributeSet; +<a name="l01157"></a>01157 }; +<a name="l01158"></a>01158 +<a name="l01159"></a>01159 +<a name="l01162"></a><a class="code" href="classTiXmlComment.html">01162</a> <span class="keyword">class </span><a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> +<a name="l01163"></a>01163 { +<a name="l01164"></a>01164 <span class="keyword">public</span>: +<a name="l01166"></a><a class="code" href="classTiXmlComment.html#aaa3252031d3e8bd3a2bf51a1c61201b7">01166</a> <a class="code" href="classTiXmlComment.html#aaa3252031d3e8bd3a2bf51a1c61201b7" title="Constructs an empty comment.">TiXmlComment</a>() : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_COMMENT ) {} +<a name="l01168"></a><a class="code" href="classTiXmlComment.html#a37e7802ef17bc03ebe5ae79bf0713d47">01168</a> <a class="code" href="classTiXmlComment.html#a37e7802ef17bc03ebe5ae79bf0713d47" title="Construct a comment from text.">TiXmlComment</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _value ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_COMMENT ) { +<a name="l01169"></a>01169 <a class="code" href="classTiXmlNode.html#a2a38329ca5d3f28f98ce932b8299ae90" title="Changes the value of the node.">SetValue</a>( _value ); +<a name="l01170"></a>01170 } +<a name="l01171"></a>01171 <a class="code" href="classTiXmlComment.html#aaa3252031d3e8bd3a2bf51a1c61201b7" title="Constructs an empty comment.">TiXmlComment</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& ); +<a name="l01172"></a>01172 <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& base ); <a name="l01173"></a>01173 -<a name="l01174"></a>01174 <span class="comment">/* Attribtue parsing starts: at the ! of the !--</span> -<a name="l01175"></a>01175 <span class="comment"> returns: next char past '>'</span> -<a name="l01176"></a>01176 <span class="comment"> */</span> -<a name="l01177"></a>01177 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); -<a name="l01178"></a>01178 -<a name="l01179"></a><a class="code" href="classTiXmlComment.html#a00fb4215c20a2399ea05ac9b9e7e68a0">01179</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>* <a class="code" href="classTiXmlComment.html#a00fb4215c20a2399ea05ac9b9e7e68a0" title="Cast to a more defined type. Will return null not of the requested type.">ToComment</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01180"></a><a class="code" href="classTiXmlComment.html#acc7c7e07e13c23f17797d642981511df">01180</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>* <a class="code" href="classTiXmlComment.html#acc7c7e07e13c23f17797d642981511df" title="Cast to a more defined type. Will return null not of the requested type.">ToComment</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01181"></a>01181 -<a name="l01184"></a>01184 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlComment.html#af3ac1b99fbbe9ea4fb6e14146156e43e" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* visitor ) <span class="keyword">const</span>; +<a name="l01174"></a>01174 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>() {} +<a name="l01175"></a>01175 +<a name="l01177"></a>01177 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlComment.html#a0d6662bdc52488b9e12b3c7a0453d028" title="Returns a copy of this Comment.">Clone</a>() <span class="keyword">const</span>; +<a name="l01178"></a>01178 <span class="comment">// Write this Comment to a FILE stream.</span> +<a name="l01179"></a>01179 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlComment.html#a6b316527aaa8da0370cd68c22a5a0f5f" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; +<a name="l01180"></a>01180 +<a name="l01181"></a>01181 <span class="comment">/* Attribtue parsing starts: at the ! of the !--</span> +<a name="l01182"></a>01182 <span class="comment"> returns: next char past '>'</span> +<a name="l01183"></a>01183 <span class="comment"> */</span> +<a name="l01184"></a>01184 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); <a name="l01185"></a>01185 -<a name="l01186"></a>01186 <span class="keyword">protected</span>: -<a name="l01187"></a>01187 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>* target ) <span class="keyword">const</span>; +<a name="l01186"></a><a class="code" href="classTiXmlComment.html#a00fb4215c20a2399ea05ac9b9e7e68a0">01186</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>* <a class="code" href="classTiXmlComment.html#a00fb4215c20a2399ea05ac9b9e7e68a0" title="Cast to a more defined type. Will return null not of the requested type.">ToComment</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01187"></a><a class="code" href="classTiXmlComment.html#acc7c7e07e13c23f17797d642981511df">01187</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>* <a class="code" href="classTiXmlComment.html#acc7c7e07e13c23f17797d642981511df" title="Cast to a more defined type. Will return null not of the requested type.">ToComment</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } <a name="l01188"></a>01188 -<a name="l01189"></a>01189 <span class="comment">// used to be public</span> -<a name="l01190"></a>01190 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01191"></a>01191 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); -<a name="l01192"></a>01192 <span class="preprocessor"> #endif</span> -<a name="l01193"></a>01193 <span class="preprocessor"></span><span class="comment">// virtual void StreamOut( TIXML_OSTREAM * out ) const;</span> -<a name="l01194"></a>01194 -<a name="l01195"></a>01195 <span class="keyword">private</span>: -<a name="l01196"></a>01196 -<a name="l01197"></a>01197 }; -<a name="l01198"></a>01198 -<a name="l01199"></a>01199 -<a name="l01205"></a><a class="code" href="classTiXmlText.html">01205</a> <span class="keyword">class </span><a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> -<a name="l01206"></a>01206 { -<a name="l01207"></a>01207 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>; -<a name="l01208"></a>01208 <span class="keyword">public</span>: -<a name="l01213"></a><a class="code" href="classTiXmlText.html#af659e77c6b87d684827f35a8f4895960">01213</a> <a class="code" href="classTiXmlText.html#af659e77c6b87d684827f35a8f4895960" title="Constructor for text element.">TiXmlText</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> * initValue ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> (<a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_TEXT) -<a name="l01214"></a>01214 { -<a name="l01215"></a>01215 <a class="code" href="classTiXmlNode.html#a2a38329ca5d3f28f98ce932b8299ae90" title="Changes the value of the node.">SetValue</a>( initValue ); -<a name="l01216"></a>01216 cdata = <span class="keyword">false</span>; -<a name="l01217"></a>01217 } -<a name="l01218"></a>01218 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>() {} -<a name="l01219"></a>01219 -<a name="l01220"></a>01220 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01222"></a><a class="code" href="classTiXmlText.html#a439792f6183a3d3fb6f2bc2b16fa5691">01222</a> <span class="preprocessor"> TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)</span> -<a name="l01223"></a>01223 <span class="preprocessor"></span> { -<a name="l01224"></a>01224 <a class="code" href="classTiXmlNode.html#a2a38329ca5d3f28f98ce932b8299ae90" title="Changes the value of the node.">SetValue</a>( initValue ); -<a name="l01225"></a>01225 cdata = <span class="keyword">false</span>; -<a name="l01226"></a>01226 } -<a name="l01227"></a>01227 <span class="preprocessor"> #endif</span> -<a name="l01228"></a>01228 <span class="preprocessor"></span> -<a name="l01229"></a>01229 <a class="code" href="classTiXmlText.html#af659e77c6b87d684827f35a8f4895960" title="Constructor for text element.">TiXmlText</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& copy ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_TEXT ) { copy.CopyTo( <span class="keyword">this</span> ); } -<a name="l01230"></a>01230 <span class="keywordtype">void</span> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& base ) { base.CopyTo( <span class="keyword">this</span> ); } -<a name="l01231"></a>01231 -<a name="l01232"></a>01232 <span class="comment">// Write this text object to a FILE stream.</span> -<a name="l01233"></a>01233 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlText.html#a0cafbf6f236c7f02d12b2bffc2b7976b" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; -<a name="l01234"></a>01234 -<a name="l01236"></a><a class="code" href="classTiXmlText.html#ad1a6a6b83fa2271022dd97c072a2b586">01236</a> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlText.html#ad1a6a6b83fa2271022dd97c072a2b586" title="Queries whether this represents text using a CDATA section.">CDATA</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> cdata; } -<a name="l01238"></a><a class="code" href="classTiXmlText.html#acb17ff7c5d09b2c839393445a3de5ea9">01238</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlText.html#acb17ff7c5d09b2c839393445a3de5ea9" title="Turns on or off a CDATA representation of text.">SetCDATA</a>( <span class="keywordtype">bool</span> _cdata ) { cdata = _cdata; } -<a name="l01239"></a>01239 -<a name="l01240"></a>01240 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); +<a name="l01191"></a>01191 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlComment.html#af3ac1b99fbbe9ea4fb6e14146156e43e" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* visitor ) <span class="keyword">const</span>; +<a name="l01192"></a>01192 +<a name="l01193"></a>01193 <span class="keyword">protected</span>: +<a name="l01194"></a>01194 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>* target ) <span class="keyword">const</span>; +<a name="l01195"></a>01195 +<a name="l01196"></a>01196 <span class="comment">// used to be public</span> +<a name="l01197"></a>01197 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01198"></a>01198 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); +<a name="l01199"></a>01199 <span class="preprocessor"> #endif</span> +<a name="l01200"></a>01200 <span class="preprocessor"></span><span class="comment">// virtual void StreamOut( TIXML_OSTREAM * out ) const;</span> +<a name="l01201"></a>01201 +<a name="l01202"></a>01202 <span class="keyword">private</span>: +<a name="l01203"></a>01203 +<a name="l01204"></a>01204 }; +<a name="l01205"></a>01205 +<a name="l01206"></a>01206 +<a name="l01212"></a><a class="code" href="classTiXmlText.html">01212</a> <span class="keyword">class </span><a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> +<a name="l01213"></a>01213 { +<a name="l01214"></a>01214 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>; +<a name="l01215"></a>01215 <span class="keyword">public</span>: +<a name="l01220"></a><a class="code" href="classTiXmlText.html#af659e77c6b87d684827f35a8f4895960">01220</a> <a class="code" href="classTiXmlText.html#af659e77c6b87d684827f35a8f4895960" title="Constructor for text element.">TiXmlText</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> * initValue ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> (<a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_TEXT) +<a name="l01221"></a>01221 { +<a name="l01222"></a>01222 <a class="code" href="classTiXmlNode.html#a2a38329ca5d3f28f98ce932b8299ae90" title="Changes the value of the node.">SetValue</a>( initValue ); +<a name="l01223"></a>01223 cdata = <span class="keyword">false</span>; +<a name="l01224"></a>01224 } +<a name="l01225"></a>01225 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>() {} +<a name="l01226"></a>01226 +<a name="l01227"></a>01227 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01229"></a><a class="code" href="classTiXmlText.html#a439792f6183a3d3fb6f2bc2b16fa5691">01229</a> <span class="preprocessor"> TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)</span> +<a name="l01230"></a>01230 <span class="preprocessor"></span> { +<a name="l01231"></a>01231 <a class="code" href="classTiXmlNode.html#a2a38329ca5d3f28f98ce932b8299ae90" title="Changes the value of the node.">SetValue</a>( initValue ); +<a name="l01232"></a>01232 cdata = <span class="keyword">false</span>; +<a name="l01233"></a>01233 } +<a name="l01234"></a>01234 <span class="preprocessor"> #endif</span> +<a name="l01235"></a>01235 <span class="preprocessor"></span> +<a name="l01236"></a>01236 <a class="code" href="classTiXmlText.html#af659e77c6b87d684827f35a8f4895960" title="Constructor for text element.">TiXmlText</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& copy ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_TEXT ) { copy.CopyTo( <span class="keyword">this</span> ); } +<a name="l01237"></a>01237 <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& base ) { base.CopyTo( <span class="keyword">this</span> ); <span class="keywordflow">return</span> *<span class="keyword">this</span>; } +<a name="l01238"></a>01238 +<a name="l01239"></a>01239 <span class="comment">// Write this text object to a FILE stream.</span> +<a name="l01240"></a>01240 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlText.html#a0cafbf6f236c7f02d12b2bffc2b7976b" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; <a name="l01241"></a>01241 -<a name="l01242"></a><a class="code" href="classTiXmlText.html#a895bf34ffad17f7439ab2a52b9651648">01242</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlText.html#a895bf34ffad17f7439ab2a52b9651648" title="Cast to a more defined type. Will return null not of the requested type.">ToText</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01243"></a><a class="code" href="classTiXmlText.html#ae7c3a8fd3e4dbf6c0c4363a943d72f5b">01243</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlText.html#ae7c3a8fd3e4dbf6c0c4363a943d72f5b" title="Cast to a more defined type. Will return null not of the requested type.">ToText</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01244"></a>01244 -<a name="l01247"></a>01247 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlText.html#a8483d4415ce9de6c4fa8f63d067d5de6" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* content ) <span class="keyword">const</span>; +<a name="l01243"></a><a class="code" href="classTiXmlText.html#ad1a6a6b83fa2271022dd97c072a2b586">01243</a> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlText.html#ad1a6a6b83fa2271022dd97c072a2b586" title="Queries whether this represents text using a CDATA section.">CDATA</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> cdata; } +<a name="l01245"></a><a class="code" href="classTiXmlText.html#acb17ff7c5d09b2c839393445a3de5ea9">01245</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlText.html#acb17ff7c5d09b2c839393445a3de5ea9" title="Turns on or off a CDATA representation of text.">SetCDATA</a>( <span class="keywordtype">bool</span> _cdata ) { cdata = _cdata; } +<a name="l01246"></a>01246 +<a name="l01247"></a>01247 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); <a name="l01248"></a>01248 -<a name="l01249"></a>01249 <span class="keyword">protected</span> : -<a name="l01251"></a>01251 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlText.html#a0c411e93a27537369479d034cc82da3b" title="[internal use] Creates a new Element and returns it.">Clone</a>() <span class="keyword">const</span>; -<a name="l01252"></a>01252 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* target ) <span class="keyword">const</span>; -<a name="l01253"></a>01253 -<a name="l01254"></a>01254 <span class="keywordtype">bool</span> Blank() <span class="keyword">const</span>; <span class="comment">// returns true if all white space and new lines</span> -<a name="l01255"></a>01255 <span class="comment">// [internal use]</span> -<a name="l01256"></a>01256 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01257"></a>01257 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); -<a name="l01258"></a>01258 <span class="preprocessor"> #endif</span> -<a name="l01259"></a>01259 <span class="preprocessor"></span> -<a name="l01260"></a>01260 <span class="keyword">private</span>: -<a name="l01261"></a>01261 <span class="keywordtype">bool</span> cdata; <span class="comment">// true if this should be input and output as a CDATA style text element</span> -<a name="l01262"></a>01262 }; -<a name="l01263"></a>01263 -<a name="l01264"></a>01264 -<a name="l01278"></a><a class="code" href="classTiXmlDeclaration.html">01278</a> <span class="keyword">class </span><a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> -<a name="l01279"></a>01279 { -<a name="l01280"></a>01280 <span class="keyword">public</span>: -<a name="l01282"></a><a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79">01282</a> <a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79" title="Construct an empty declaration.">TiXmlDeclaration</a>() : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_DECLARATION ) {} -<a name="l01283"></a>01283 -<a name="l01284"></a>01284 <span class="preprocessor">#ifdef TIXML_USE_STL</span> -<a name="l01286"></a>01286 <span class="preprocessor"> TiXmlDeclaration( const std::string& _version,</span> -<a name="l01287"></a>01287 <span class="preprocessor"></span> <span class="keyword">const</span> std::string& _encoding, -<a name="l01288"></a>01288 <span class="keyword">const</span> std::string& _standalone ); -<a name="l01289"></a>01289 <span class="preprocessor">#endif</span> -<a name="l01290"></a>01290 <span class="preprocessor"></span> -<a name="l01292"></a>01292 <a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79" title="Construct an empty declaration.">TiXmlDeclaration</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _version, -<a name="l01293"></a>01293 <span class="keyword">const</span> <span class="keywordtype">char</span>* _encoding, -<a name="l01294"></a>01294 <span class="keyword">const</span> <span class="keywordtype">char</span>* _standalone ); -<a name="l01295"></a>01295 -<a name="l01296"></a>01296 <a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79" title="Construct an empty declaration.">TiXmlDeclaration</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& copy ); -<a name="l01297"></a>01297 <span class="keywordtype">void</span> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& copy ); -<a name="l01298"></a>01298 -<a name="l01299"></a>01299 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>() {} -<a name="l01300"></a>01300 -<a name="l01302"></a><a class="code" href="classTiXmlDeclaration.html#a02ee557b1a4545c3219ed377c103ec76">01302</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classTiXmlDeclaration.html#a02ee557b1a4545c3219ed377c103ec76" title="Version. Will return an empty string if none was found.">Version</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> version.c_str (); } -<a name="l01304"></a><a class="code" href="classTiXmlDeclaration.html#a5d974231f9e9a2f0542f15f3a46cdb76">01304</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classTiXmlDeclaration.html#a5d974231f9e9a2f0542f15f3a46cdb76" title="Encoding. Will return an empty string if none was found.">Encoding</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> encoding.c_str (); } -<a name="l01306"></a><a class="code" href="classTiXmlDeclaration.html#a9ff06afc033d7ef730ec7c6825b97ad9">01306</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classTiXmlDeclaration.html#a9ff06afc033d7ef730ec7c6825b97ad9" title="Is this a standalone document?">Standalone</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> standalone.c_str (); } +<a name="l01249"></a><a class="code" href="classTiXmlText.html#a895bf34ffad17f7439ab2a52b9651648">01249</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlText.html#a895bf34ffad17f7439ab2a52b9651648" title="Cast to a more defined type. Will return null not of the requested type.">ToText</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01250"></a><a class="code" href="classTiXmlText.html#ae7c3a8fd3e4dbf6c0c4363a943d72f5b">01250</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlText.html#ae7c3a8fd3e4dbf6c0c4363a943d72f5b" title="Cast to a more defined type. Will return null not of the requested type.">ToText</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01251"></a>01251 +<a name="l01254"></a>01254 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlText.html#a8483d4415ce9de6c4fa8f63d067d5de6" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* content ) <span class="keyword">const</span>; +<a name="l01255"></a>01255 +<a name="l01256"></a>01256 <span class="keyword">protected</span> : +<a name="l01258"></a>01258 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlText.html#a0c411e93a27537369479d034cc82da3b" title="[internal use] Creates a new Element and returns it.">Clone</a>() <span class="keyword">const</span>; +<a name="l01259"></a>01259 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* target ) <span class="keyword">const</span>; +<a name="l01260"></a>01260 +<a name="l01261"></a>01261 <span class="keywordtype">bool</span> Blank() <span class="keyword">const</span>; <span class="comment">// returns true if all white space and new lines</span> +<a name="l01262"></a>01262 <span class="comment">// [internal use]</span> +<a name="l01263"></a>01263 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01264"></a>01264 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); +<a name="l01265"></a>01265 <span class="preprocessor"> #endif</span> +<a name="l01266"></a>01266 <span class="preprocessor"></span> +<a name="l01267"></a>01267 <span class="keyword">private</span>: +<a name="l01268"></a>01268 <span class="keywordtype">bool</span> cdata; <span class="comment">// true if this should be input and output as a CDATA style text element</span> +<a name="l01269"></a>01269 }; +<a name="l01270"></a>01270 +<a name="l01271"></a>01271 +<a name="l01285"></a><a class="code" href="classTiXmlDeclaration.html">01285</a> <span class="keyword">class </span><a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> +<a name="l01286"></a>01286 { +<a name="l01287"></a>01287 <span class="keyword">public</span>: +<a name="l01289"></a><a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79">01289</a> <a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79" title="Construct an empty declaration.">TiXmlDeclaration</a>() : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>::TINYXML_DECLARATION ) {} +<a name="l01290"></a>01290 +<a name="l01291"></a>01291 <span class="preprocessor">#ifdef TIXML_USE_STL</span> +<a name="l01293"></a>01293 <span class="preprocessor"> TiXmlDeclaration( const std::string& _version,</span> +<a name="l01294"></a>01294 <span class="preprocessor"></span> <span class="keyword">const</span> std::string& _encoding, +<a name="l01295"></a>01295 <span class="keyword">const</span> std::string& _standalone ); +<a name="l01296"></a>01296 <span class="preprocessor">#endif</span> +<a name="l01297"></a>01297 <span class="preprocessor"></span> +<a name="l01299"></a>01299 <a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79" title="Construct an empty declaration.">TiXmlDeclaration</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _version, +<a name="l01300"></a>01300 <span class="keyword">const</span> <span class="keywordtype">char</span>* _encoding, +<a name="l01301"></a>01301 <span class="keyword">const</span> <span class="keywordtype">char</span>* _standalone ); +<a name="l01302"></a>01302 +<a name="l01303"></a>01303 <a class="code" href="classTiXmlDeclaration.html#aa0484d059bea0ea1acb47c9094382d79" title="Construct an empty declaration.">TiXmlDeclaration</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& copy ); +<a name="l01304"></a>01304 <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& copy ); +<a name="l01305"></a>01305 +<a name="l01306"></a>01306 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>() {} <a name="l01307"></a>01307 -<a name="l01309"></a>01309 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlDeclaration.html#a7cf459186040141cda7a180a6585ce2e" title="Creates a copy of this Declaration and returns it.">Clone</a>() <span class="keyword">const</span>; -<a name="l01310"></a>01310 <span class="comment">// Print this declaration to a FILE stream.</span> -<a name="l01311"></a>01311 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Print( FILE* cfile, <span class="keywordtype">int</span> depth, TIXML_STRING* str ) <span class="keyword">const</span>; -<a name="l01312"></a><a class="code" href="classTiXmlDeclaration.html#abf6303db4bd05b5be554036817ff1cb4">01312</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDeclaration.html#abf6303db4bd05b5be554036817ff1cb4" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth )<span class="keyword"> const </span>{ -<a name="l01313"></a>01313 Print( cfile, depth, 0 ); -<a name="l01314"></a>01314 } -<a name="l01315"></a>01315 -<a name="l01316"></a>01316 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); -<a name="l01317"></a>01317 -<a name="l01318"></a><a class="code" href="classTiXmlDeclaration.html#a1e085d3fefd1dbf5ccdbff729931a967">01318</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>* <a class="code" href="classTiXmlDeclaration.html#a1e085d3fefd1dbf5ccdbff729931a967" title="Cast to a more defined type. Will return null not of the requested type.">ToDeclaration</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01319"></a><a class="code" href="classTiXmlDeclaration.html#a6bd3d1daddcaeb9543c24bfd090969ce">01319</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>* <a class="code" href="classTiXmlDeclaration.html#a6bd3d1daddcaeb9543c24bfd090969ce" title="Cast to a more defined type. Will return null not of the requested type.">ToDeclaration</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01320"></a>01320 -<a name="l01323"></a>01323 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDeclaration.html#a22315a535983b86535cdba3458669e3e" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* visitor ) <span class="keyword">const</span>; +<a name="l01309"></a><a class="code" href="classTiXmlDeclaration.html#a02ee557b1a4545c3219ed377c103ec76">01309</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classTiXmlDeclaration.html#a02ee557b1a4545c3219ed377c103ec76" title="Version. Will return an empty string if none was found.">Version</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> version.c_str (); } +<a name="l01311"></a><a class="code" href="classTiXmlDeclaration.html#a5d974231f9e9a2f0542f15f3a46cdb76">01311</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classTiXmlDeclaration.html#a5d974231f9e9a2f0542f15f3a46cdb76" title="Encoding. Will return an empty string if none was found.">Encoding</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> encoding.c_str (); } +<a name="l01313"></a><a class="code" href="classTiXmlDeclaration.html#a9ff06afc033d7ef730ec7c6825b97ad9">01313</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classTiXmlDeclaration.html#a9ff06afc033d7ef730ec7c6825b97ad9" title="Is this a standalone document?">Standalone</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> standalone.c_str (); } +<a name="l01314"></a>01314 +<a name="l01316"></a>01316 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlDeclaration.html#a7cf459186040141cda7a180a6585ce2e" title="Creates a copy of this Declaration and returns it.">Clone</a>() <span class="keyword">const</span>; +<a name="l01317"></a>01317 <span class="comment">// Print this declaration to a FILE stream.</span> +<a name="l01318"></a>01318 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Print( FILE* cfile, <span class="keywordtype">int</span> depth, TIXML_STRING* str ) <span class="keyword">const</span>; +<a name="l01319"></a><a class="code" href="classTiXmlDeclaration.html#abf6303db4bd05b5be554036817ff1cb4">01319</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDeclaration.html#abf6303db4bd05b5be554036817ff1cb4" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth )<span class="keyword"> const </span>{ +<a name="l01320"></a>01320 Print( cfile, depth, 0 ); +<a name="l01321"></a>01321 } +<a name="l01322"></a>01322 +<a name="l01323"></a>01323 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); <a name="l01324"></a>01324 -<a name="l01325"></a>01325 <span class="keyword">protected</span>: -<a name="l01326"></a>01326 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>* target ) <span class="keyword">const</span>; -<a name="l01327"></a>01327 <span class="comment">// used to be public</span> -<a name="l01328"></a>01328 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01329"></a>01329 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); -<a name="l01330"></a>01330 <span class="preprocessor"> #endif</span> -<a name="l01331"></a>01331 <span class="preprocessor"></span> -<a name="l01332"></a>01332 <span class="keyword">private</span>: -<a name="l01333"></a>01333 -<a name="l01334"></a>01334 TIXML_STRING version; -<a name="l01335"></a>01335 TIXML_STRING encoding; -<a name="l01336"></a>01336 TIXML_STRING standalone; -<a name="l01337"></a>01337 }; -<a name="l01338"></a>01338 -<a name="l01339"></a>01339 -<a name="l01347"></a><a class="code" href="classTiXmlUnknown.html">01347</a> <span class="keyword">class </span><a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> -<a name="l01348"></a>01348 { -<a name="l01349"></a>01349 <span class="keyword">public</span>: -<a name="l01350"></a>01350 <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>() : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( TiXmlNode::TINYXML_UNKNOWN ) {} -<a name="l01351"></a>01351 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>() {} -<a name="l01352"></a>01352 -<a name="l01353"></a>01353 <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& copy ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( <span class="keyword">this</span> ); } -<a name="l01354"></a>01354 <span class="keywordtype">void</span> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& copy ) { copy.CopyTo( <span class="keyword">this</span> ); } -<a name="l01355"></a>01355 -<a name="l01357"></a>01357 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlUnknown.html#a0960bb7428b3f341da46244229604d73" title="Creates a copy of this Unknown and returns it.">Clone</a>() <span class="keyword">const</span>; -<a name="l01358"></a>01358 <span class="comment">// Print this Unknown to a FILE stream.</span> -<a name="l01359"></a>01359 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlUnknown.html#a31ba089a40fb5a1869750fce09b0bacb" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; -<a name="l01360"></a>01360 -<a name="l01361"></a>01361 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); +<a name="l01325"></a><a class="code" href="classTiXmlDeclaration.html#a1e085d3fefd1dbf5ccdbff729931a967">01325</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>* <a class="code" href="classTiXmlDeclaration.html#a1e085d3fefd1dbf5ccdbff729931a967" title="Cast to a more defined type. Will return null not of the requested type.">ToDeclaration</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01326"></a><a class="code" href="classTiXmlDeclaration.html#a6bd3d1daddcaeb9543c24bfd090969ce">01326</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>* <a class="code" href="classTiXmlDeclaration.html#a6bd3d1daddcaeb9543c24bfd090969ce" title="Cast to a more defined type. Will return null not of the requested type.">ToDeclaration</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01327"></a>01327 +<a name="l01330"></a>01330 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDeclaration.html#a22315a535983b86535cdba3458669e3e" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* visitor ) <span class="keyword">const</span>; +<a name="l01331"></a>01331 +<a name="l01332"></a>01332 <span class="keyword">protected</span>: +<a name="l01333"></a>01333 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>* target ) <span class="keyword">const</span>; +<a name="l01334"></a>01334 <span class="comment">// used to be public</span> +<a name="l01335"></a>01335 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01336"></a>01336 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); +<a name="l01337"></a>01337 <span class="preprocessor"> #endif</span> +<a name="l01338"></a>01338 <span class="preprocessor"></span> +<a name="l01339"></a>01339 <span class="keyword">private</span>: +<a name="l01340"></a>01340 +<a name="l01341"></a>01341 TIXML_STRING version; +<a name="l01342"></a>01342 TIXML_STRING encoding; +<a name="l01343"></a>01343 TIXML_STRING standalone; +<a name="l01344"></a>01344 }; +<a name="l01345"></a>01345 +<a name="l01346"></a>01346 +<a name="l01354"></a><a class="code" href="classTiXmlUnknown.html">01354</a> <span class="keyword">class </span><a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> +<a name="l01355"></a>01355 { +<a name="l01356"></a>01356 <span class="keyword">public</span>: +<a name="l01357"></a>01357 <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>() : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( TiXmlNode::TINYXML_UNKNOWN ) {} +<a name="l01358"></a>01358 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>() {} +<a name="l01359"></a>01359 +<a name="l01360"></a>01360 <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& copy ) : <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( <span class="keyword">this</span> ); } +<a name="l01361"></a>01361 <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& copy ) { copy.CopyTo( <span class="keyword">this</span> ); <span class="keywordflow">return</span> *<span class="keyword">this</span>; } <a name="l01362"></a>01362 -<a name="l01363"></a><a class="code" href="classTiXmlUnknown.html#ab0313e5fe77987d746ac1a97a254419d">01363</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlUnknown.html#ab0313e5fe77987d746ac1a97a254419d" title="Cast to a more defined type. Will return null not of the requested type.">ToUnknown</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01364"></a><a class="code" href="classTiXmlUnknown.html#a67c9fd22940e8c47f706a72cdd2e332c">01364</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlUnknown.html#a67c9fd22940e8c47f706a72cdd2e332c" title="Cast to a more defined type. Will return null not of the requested type.">ToUnknown</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01365"></a>01365 -<a name="l01368"></a>01368 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlUnknown.html#ad7122e5135581b3c832a1a3217760a93" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* content ) <span class="keyword">const</span>; +<a name="l01364"></a>01364 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlUnknown.html#a0960bb7428b3f341da46244229604d73" title="Creates a copy of this Unknown and returns it.">Clone</a>() <span class="keyword">const</span>; +<a name="l01365"></a>01365 <span class="comment">// Print this Unknown to a FILE stream.</span> +<a name="l01366"></a>01366 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlUnknown.html#a31ba089a40fb5a1869750fce09b0bacb" title="All TinyXml classes can print themselves to a filestream or the string class (TiXmlString...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth ) <span class="keyword">const</span>; +<a name="l01367"></a>01367 +<a name="l01368"></a>01368 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* Parse( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data, TiXmlEncoding encoding ); <a name="l01369"></a>01369 -<a name="l01370"></a>01370 <span class="keyword">protected</span>: -<a name="l01371"></a>01371 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* target ) <span class="keyword">const</span>; +<a name="l01370"></a><a class="code" href="classTiXmlUnknown.html#ab0313e5fe77987d746ac1a97a254419d">01370</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlUnknown.html#ab0313e5fe77987d746ac1a97a254419d" title="Cast to a more defined type. Will return null not of the requested type.">ToUnknown</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01371"></a><a class="code" href="classTiXmlUnknown.html#a67c9fd22940e8c47f706a72cdd2e332c">01371</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlUnknown.html#a67c9fd22940e8c47f706a72cdd2e332c" title="Cast to a more defined type. Will return null not of the requested type.">ToUnknown</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } <a name="l01372"></a>01372 -<a name="l01373"></a>01373 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01374"></a>01374 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); -<a name="l01375"></a>01375 <span class="preprocessor"> #endif</span> -<a name="l01376"></a>01376 <span class="preprocessor"></span> -<a name="l01377"></a>01377 <span class="keyword">private</span>: -<a name="l01378"></a>01378 -<a name="l01379"></a>01379 }; -<a name="l01380"></a>01380 -<a name="l01381"></a>01381 -<a name="l01386"></a><a class="code" href="classTiXmlDocument.html">01386</a> <span class="keyword">class </span><a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> -<a name="l01387"></a>01387 { -<a name="l01388"></a>01388 <span class="keyword">public</span>: -<a name="l01390"></a>01390 <a class="code" href="classTiXmlDocument.html#a9f5e84335708fde98400230f9f12659c" title="Create an empty document, that has no name.">TiXmlDocument</a>(); -<a name="l01392"></a>01392 <a class="code" href="classTiXmlDocument.html#a9f5e84335708fde98400230f9f12659c" title="Create an empty document, that has no name.">TiXmlDocument</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * documentName ); -<a name="l01393"></a>01393 -<a name="l01394"></a>01394 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01396"></a>01396 <span class="preprocessor"> TiXmlDocument( const std::string& documentName );</span> -<a name="l01397"></a>01397 <span class="preprocessor"></span><span class="preprocessor"> #endif</span> -<a name="l01398"></a>01398 <span class="preprocessor"></span> -<a name="l01399"></a>01399 <a class="code" href="classTiXmlDocument.html#a9f5e84335708fde98400230f9f12659c" title="Create an empty document, that has no name.">TiXmlDocument</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& copy ); -<a name="l01400"></a>01400 <span class="keywordtype">void</span> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& copy ); -<a name="l01401"></a>01401 -<a name="l01402"></a>01402 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>() {} -<a name="l01403"></a>01403 -<a name="l01408"></a>01408 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); -<a name="l01410"></a>01410 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>() <span class="keyword">const</span>; -<a name="l01412"></a>01412 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); -<a name="l01414"></a>01414 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * filename ) <span class="keyword">const</span>; -<a name="l01420"></a>01420 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); -<a name="l01422"></a>01422 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( FILE* ) <span class="keyword">const</span>; -<a name="l01423"></a>01423 -<a name="l01424"></a>01424 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01425"></a><a class="code" href="classTiXmlDocument.html#a18ae6ed34fed7991ebc220862dfac884">01425</a> <span class="preprocessor"></span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( <span class="keyword">const</span> std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) -<a name="l01426"></a>01426 { -<a name="l01427"></a>01427 <span class="keywordflow">return</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( filename.c_str(), encoding ); -<a name="l01428"></a>01428 } -<a name="l01429"></a><a class="code" href="classTiXmlDocument.html#a3d4fae0463f3f03679ba0b7cf6f2df52">01429</a> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( <span class="keyword">const</span> std::string& filename ) <span class="keyword">const</span> -<a name="l01430"></a>01430 { -<a name="l01431"></a>01431 <span class="keywordflow">return</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( filename.c_str() ); -<a name="l01432"></a>01432 } -<a name="l01433"></a>01433 <span class="preprocessor"> #endif</span> -<a name="l01434"></a>01434 <span class="preprocessor"></span> -<a name="l01439"></a>01439 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlDocument.html#a17ebabe36926ef398e78dec0d0ad0378" title="Parse the given null terminated block of xml data.">Parse</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); -<a name="l01440"></a>01440 -<a name="l01445"></a><a class="code" href="classTiXmlDocument.html#ad09d17927f908f40efb406af2fb873be">01445</a> <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlDocument.html#ad09d17927f908f40efb406af2fb873be" title="Get the root element -- the only top level element -- of the document.">RootElement</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlNode.html#af4fb652f6bd79ae0d5ce7d0f7d3c0fba" title="Convenience function to get through elements.">FirstChildElement</a>(); } -<a name="l01446"></a>01446 <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlDocument.html#ad09d17927f908f40efb406af2fb873be" title="Get the root element -- the only top level element -- of the document.">RootElement</a>() { <span class="keywordflow">return</span> <a class="code" href="classTiXmlNode.html#af4fb652f6bd79ae0d5ce7d0f7d3c0fba" title="Convenience function to get through elements.">FirstChildElement</a>(); } +<a name="l01375"></a>01375 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlUnknown.html#ad7122e5135581b3c832a1a3217760a93" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* content ) <span class="keyword">const</span>; +<a name="l01376"></a>01376 +<a name="l01377"></a>01377 <span class="keyword">protected</span>: +<a name="l01378"></a>01378 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* target ) <span class="keyword">const</span>; +<a name="l01379"></a>01379 +<a name="l01380"></a>01380 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01381"></a>01381 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); +<a name="l01382"></a>01382 <span class="preprocessor"> #endif</span> +<a name="l01383"></a>01383 <span class="preprocessor"></span> +<a name="l01384"></a>01384 <span class="keyword">private</span>: +<a name="l01385"></a>01385 +<a name="l01386"></a>01386 }; +<a name="l01387"></a>01387 +<a name="l01388"></a>01388 +<a name="l01393"></a><a class="code" href="classTiXmlDocument.html">01393</a> <span class="keyword">class </span><a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a> +<a name="l01394"></a>01394 { +<a name="l01395"></a>01395 <span class="keyword">public</span>: +<a name="l01397"></a>01397 <a class="code" href="classTiXmlDocument.html#a9f5e84335708fde98400230f9f12659c" title="Create an empty document, that has no name.">TiXmlDocument</a>(); +<a name="l01399"></a>01399 <a class="code" href="classTiXmlDocument.html#a9f5e84335708fde98400230f9f12659c" title="Create an empty document, that has no name.">TiXmlDocument</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * documentName ); +<a name="l01400"></a>01400 +<a name="l01401"></a>01401 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01403"></a>01403 <span class="preprocessor"> TiXmlDocument( const std::string& documentName );</span> +<a name="l01404"></a>01404 <span class="preprocessor"></span><span class="preprocessor"> #endif</span> +<a name="l01405"></a>01405 <span class="preprocessor"></span> +<a name="l01406"></a>01406 <a class="code" href="classTiXmlDocument.html#a9f5e84335708fde98400230f9f12659c" title="Create an empty document, that has no name.">TiXmlDocument</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& copy ); +<a name="l01407"></a>01407 <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& copy ); +<a name="l01408"></a>01408 +<a name="l01409"></a>01409 <span class="keyword">virtual</span> ~<a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>() {} +<a name="l01410"></a>01410 +<a name="l01415"></a>01415 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); +<a name="l01417"></a>01417 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>() <span class="keyword">const</span>; +<a name="l01419"></a>01419 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); +<a name="l01421"></a>01421 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * filename ) <span class="keyword">const</span>; +<a name="l01427"></a>01427 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); +<a name="l01429"></a>01429 <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( FILE* ) <span class="keyword">const</span>; +<a name="l01430"></a>01430 +<a name="l01431"></a>01431 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01432"></a><a class="code" href="classTiXmlDocument.html#a18ae6ed34fed7991ebc220862dfac884">01432</a> <span class="preprocessor"></span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( <span class="keyword">const</span> std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) +<a name="l01433"></a>01433 { +<a name="l01434"></a>01434 <span class="keywordflow">return</span> <a class="code" href="classTiXmlDocument.html#a4c852a889c02cf251117fd1d9fe1845f" title="Load a file using the current document value.">LoadFile</a>( filename.c_str(), encoding ); +<a name="l01435"></a>01435 } +<a name="l01436"></a><a class="code" href="classTiXmlDocument.html#a3d4fae0463f3f03679ba0b7cf6f2df52">01436</a> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( <span class="keyword">const</span> std::string& filename ) <span class="keyword">const</span> +<a name="l01437"></a>01437 { +<a name="l01438"></a>01438 <span class="keywordflow">return</span> <a class="code" href="classTiXmlDocument.html#a21c0aeb0d0a720169ad4ac89523ebe93" title="Save a file using the current document value. Returns true if successful.">SaveFile</a>( filename.c_str() ); +<a name="l01439"></a>01439 } +<a name="l01440"></a>01440 <span class="preprocessor"> #endif</span> +<a name="l01441"></a>01441 <span class="preprocessor"></span> +<a name="l01446"></a>01446 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlDocument.html#a17ebabe36926ef398e78dec0d0ad0378" title="Parse the given null terminated block of xml data.">Parse</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); <a name="l01447"></a>01447 -<a name="l01453"></a><a class="code" href="classTiXmlDocument.html#a6dfc01a6e5d58e56acd537dfd3bdeb29">01453</a> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a6dfc01a6e5d58e56acd537dfd3bdeb29" title="If an error occurs, Error will be set to true.">Error</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> error; } +<a name="l01452"></a><a class="code" href="classTiXmlDocument.html#ad09d17927f908f40efb406af2fb873be">01452</a> <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlDocument.html#ad09d17927f908f40efb406af2fb873be" title="Get the root element -- the only top level element -- of the document.">RootElement</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlNode.html#af4fb652f6bd79ae0d5ce7d0f7d3c0fba" title="Convenience function to get through elements.">FirstChildElement</a>(); } +<a name="l01453"></a>01453 <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlDocument.html#ad09d17927f908f40efb406af2fb873be" title="Get the root element -- the only top level element -- of the document.">RootElement</a>() { <span class="keywordflow">return</span> <a class="code" href="classTiXmlNode.html#af4fb652f6bd79ae0d5ce7d0f7d3c0fba" title="Convenience function to get through elements.">FirstChildElement</a>(); } <a name="l01454"></a>01454 -<a name="l01456"></a><a class="code" href="classTiXmlDocument.html#a9d0f689f6e09ea494ea547be8d79c25e">01456</a> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="classTiXmlDocument.html#a9d0f689f6e09ea494ea547be8d79c25e" title="Contains a textual (english) description of the error if one occurs.">ErrorDesc</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorDesc.c_str (); } -<a name="l01457"></a>01457 -<a name="l01461"></a><a class="code" href="classTiXmlDocument.html#af96fc2f3f9ec6422782bfe916c9e778f">01461</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlDocument.html#af96fc2f3f9ec6422782bfe916c9e778f" title="Generally, you probably want the error string ( ErrorDesc() ).">ErrorId</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorId; } -<a name="l01462"></a>01462 -<a name="l01470"></a><a class="code" href="classTiXmlDocument.html#af30efc75e804aa2e92fb8be3a8cb676e">01470</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlDocument.html#af30efc75e804aa2e92fb8be3a8cb676e" title="Returns the location (if known) of the error.">ErrorRow</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorLocation.row+1; } -<a name="l01471"></a><a class="code" href="classTiXmlDocument.html#aa90bc630ee5203c6109ca5fad3323649">01471</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlDocument.html#aa90bc630ee5203c6109ca5fad3323649" title="The column where the error occured. See ErrorRow().">ErrorCol</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorLocation.col+1; } -<a name="l01472"></a>01472 -<a name="l01497"></a><a class="code" href="classTiXmlDocument.html#a51dac56316f89b35bdb7d0d433ba988e">01497</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#a51dac56316f89b35bdb7d0d433ba988e" title="SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to...">SetTabSize</a>( <span class="keywordtype">int</span> _tabsize ) { tabsize = _tabsize; } -<a name="l01498"></a>01498 -<a name="l01499"></a>01499 <span class="keywordtype">int</span> TabSize()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> tabsize; } -<a name="l01500"></a>01500 -<a name="l01504"></a><a class="code" href="classTiXmlDocument.html#ac66b8c28db86363315712a3574e87c35">01504</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#ac66b8c28db86363315712a3574e87c35" title="If you have handled the error, it can be reset with this call.">ClearError</a>() { error = <span class="keyword">false</span>; -<a name="l01505"></a>01505 errorId = 0; -<a name="l01506"></a>01506 errorDesc = <span class="stringliteral">""</span>; -<a name="l01507"></a>01507 errorLocation.row = errorLocation.col = 0; -<a name="l01508"></a>01508 <span class="comment">//errorLocation.last = 0; </span> -<a name="l01509"></a>01509 } -<a name="l01510"></a>01510 -<a name="l01512"></a><a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510">01512</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510" title="Write the document to standard out using formatted printing (&quot;pretty print&quot;)...">Print</a>()<span class="keyword"> const </span>{ <a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510" title="Write the document to standard out using formatted printing (&quot;pretty print&quot;)...">Print</a>( stdout, 0 ); } -<a name="l01513"></a>01513 -<a name="l01514"></a>01514 <span class="comment">/* Write the document to a string using formatted printing ("pretty print"). This</span> -<a name="l01515"></a>01515 <span class="comment"> will allocate a character array (new char[]) and return it as a pointer. The</span> -<a name="l01516"></a>01516 <span class="comment"> calling code pust call delete[] on the return char* to avoid a memory leak.</span> -<a name="l01517"></a>01517 <span class="comment"> */</span> -<a name="l01518"></a>01518 <span class="comment">//char* PrintToMemory() const; </span> -<a name="l01519"></a>01519 -<a name="l01521"></a>01521 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510" title="Write the document to standard out using formatted printing (&quot;pretty print&quot;)...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth = 0 ) <span class="keyword">const</span>; -<a name="l01522"></a>01522 <span class="comment">// [internal use]</span> -<a name="l01523"></a>01523 <span class="keywordtype">void</span> SetError( <span class="keywordtype">int</span> err, <span class="keyword">const</span> <span class="keywordtype">char</span>* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); -<a name="l01524"></a>01524 -<a name="l01525"></a><a class="code" href="classTiXmlDocument.html#a1dc977bde3e4fe85a8eb9d88a35ef5a4">01525</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>* <a class="code" href="classTiXmlDocument.html#a1dc977bde3e4fe85a8eb9d88a35ef5a4" title="Cast to a more defined type. Will return null not of the requested type.">ToDocument</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01526"></a><a class="code" href="classTiXmlDocument.html#a1025d942a1f328fd742d545e37efdd42">01526</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>* <a class="code" href="classTiXmlDocument.html#a1025d942a1f328fd742d545e37efdd42" title="Cast to a more defined type. Will return null not of the requested type.">ToDocument</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } -<a name="l01527"></a>01527 -<a name="l01530"></a>01530 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#aa545aae325d9752ad64120bc4ecf939a" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* content ) <span class="keyword">const</span>; +<a name="l01460"></a><a class="code" href="classTiXmlDocument.html#a6dfc01a6e5d58e56acd537dfd3bdeb29">01460</a> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#a6dfc01a6e5d58e56acd537dfd3bdeb29" title="If an error occurs, Error will be set to true.">Error</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> error; } +<a name="l01461"></a>01461 +<a name="l01463"></a><a class="code" href="classTiXmlDocument.html#a9d0f689f6e09ea494ea547be8d79c25e">01463</a> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="classTiXmlDocument.html#a9d0f689f6e09ea494ea547be8d79c25e" title="Contains a textual (english) description of the error if one occurs.">ErrorDesc</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorDesc.c_str (); } +<a name="l01464"></a>01464 +<a name="l01468"></a><a class="code" href="classTiXmlDocument.html#af96fc2f3f9ec6422782bfe916c9e778f">01468</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlDocument.html#af96fc2f3f9ec6422782bfe916c9e778f" title="Generally, you probably want the error string ( ErrorDesc() ).">ErrorId</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorId; } +<a name="l01469"></a>01469 +<a name="l01477"></a><a class="code" href="classTiXmlDocument.html#af30efc75e804aa2e92fb8be3a8cb676e">01477</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlDocument.html#af30efc75e804aa2e92fb8be3a8cb676e" title="Returns the location (if known) of the error.">ErrorRow</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorLocation.row+1; } +<a name="l01478"></a><a class="code" href="classTiXmlDocument.html#aa90bc630ee5203c6109ca5fad3323649">01478</a> <span class="keywordtype">int</span> <a class="code" href="classTiXmlDocument.html#aa90bc630ee5203c6109ca5fad3323649" title="The column where the error occured. See ErrorRow().">ErrorCol</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> errorLocation.col+1; } +<a name="l01479"></a>01479 +<a name="l01504"></a><a class="code" href="classTiXmlDocument.html#a51dac56316f89b35bdb7d0d433ba988e">01504</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#a51dac56316f89b35bdb7d0d433ba988e" title="SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to...">SetTabSize</a>( <span class="keywordtype">int</span> _tabsize ) { tabsize = _tabsize; } +<a name="l01505"></a>01505 +<a name="l01506"></a>01506 <span class="keywordtype">int</span> TabSize()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> tabsize; } +<a name="l01507"></a>01507 +<a name="l01511"></a><a class="code" href="classTiXmlDocument.html#ac66b8c28db86363315712a3574e87c35">01511</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#ac66b8c28db86363315712a3574e87c35" title="If you have handled the error, it can be reset with this call.">ClearError</a>() { error = <span class="keyword">false</span>; +<a name="l01512"></a>01512 errorId = 0; +<a name="l01513"></a>01513 errorDesc = <span class="stringliteral">""</span>; +<a name="l01514"></a>01514 errorLocation.row = errorLocation.col = 0; +<a name="l01515"></a>01515 <span class="comment">//errorLocation.last = 0; </span> +<a name="l01516"></a>01516 } +<a name="l01517"></a>01517 +<a name="l01519"></a><a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510">01519</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510" title="Write the document to standard out using formatted printing (&quot;pretty print&quot;)...">Print</a>()<span class="keyword"> const </span>{ <a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510" title="Write the document to standard out using formatted printing (&quot;pretty print&quot;)...">Print</a>( stdout, 0 ); } +<a name="l01520"></a>01520 +<a name="l01521"></a>01521 <span class="comment">/* Write the document to a string using formatted printing ("pretty print"). This</span> +<a name="l01522"></a>01522 <span class="comment"> will allocate a character array (new char[]) and return it as a pointer. The</span> +<a name="l01523"></a>01523 <span class="comment"> calling code pust call delete[] on the return char* to avoid a memory leak.</span> +<a name="l01524"></a>01524 <span class="comment"> */</span> +<a name="l01525"></a>01525 <span class="comment">//char* PrintToMemory() const; </span> +<a name="l01526"></a>01526 +<a name="l01528"></a>01528 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classTiXmlDocument.html#af08389ec70ee9b2de7f800e206a18510" title="Write the document to standard out using formatted printing (&quot;pretty print&quot;)...">Print</a>( FILE* cfile, <span class="keywordtype">int</span> depth = 0 ) <span class="keyword">const</span>; +<a name="l01529"></a>01529 <span class="comment">// [internal use]</span> +<a name="l01530"></a>01530 <span class="keywordtype">void</span> SetError( <span class="keywordtype">int</span> err, <span class="keyword">const</span> <span class="keywordtype">char</span>* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); <a name="l01531"></a>01531 -<a name="l01532"></a>01532 <span class="keyword">protected</span> : -<a name="l01533"></a>01533 <span class="comment">// [internal use]</span> -<a name="l01534"></a>01534 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlDocument.html#a4968661cab4a1f44a23329c6f8db1907" title="Create an exact duplicate of this node and return it.">Clone</a>() <span class="keyword">const</span>; -<a name="l01535"></a>01535 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01536"></a>01536 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); -<a name="l01537"></a>01537 <span class="preprocessor"> #endif</span> -<a name="l01538"></a>01538 <span class="preprocessor"></span> -<a name="l01539"></a>01539 <span class="keyword">private</span>: -<a name="l01540"></a>01540 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>* target ) <span class="keyword">const</span>; -<a name="l01541"></a>01541 -<a name="l01542"></a>01542 <span class="keywordtype">bool</span> error; -<a name="l01543"></a>01543 <span class="keywordtype">int</span> errorId; -<a name="l01544"></a>01544 TIXML_STRING errorDesc; -<a name="l01545"></a>01545 <span class="keywordtype">int</span> tabsize; -<a name="l01546"></a>01546 TiXmlCursor errorLocation; -<a name="l01547"></a>01547 <span class="keywordtype">bool</span> useMicrosoftBOM; <span class="comment">// the UTF-8 BOM were found when read. Note this, and try to write.</span> -<a name="l01548"></a>01548 }; -<a name="l01549"></a>01549 -<a name="l01550"></a>01550 -<a name="l01631"></a><a class="code" href="classTiXmlHandle.html">01631</a> <span class="keyword">class </span><a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> -<a name="l01632"></a>01632 { -<a name="l01633"></a>01633 <span class="keyword">public</span>: -<a name="l01635"></a><a class="code" href="classTiXmlHandle.html#aba18fd7bdefb942ecdea4bf4b8e29ec8">01635</a> <a class="code" href="classTiXmlHandle.html#aba18fd7bdefb942ecdea4bf4b8e29ec8" title="Create a handle from any node (at any depth of the tree.) This can be a null pointer...">TiXmlHandle</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* _node ) { this->node = _node; } -<a name="l01637"></a><a class="code" href="classTiXmlHandle.html#a236d7855e1e56ccc7b980630c48c7fd7">01637</a> <a class="code" href="classTiXmlHandle.html#a236d7855e1e56ccc7b980630c48c7fd7" title="Copy constructor.">TiXmlHandle</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a>& ref ) { this->node = ref.node; } -<a name="l01638"></a>01638 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a>& ref ) { this->node = ref.node; <span class="keywordflow">return</span> *<span class="keyword">this</span>; } -<a name="l01639"></a>01639 -<a name="l01641"></a>01641 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>() <span class="keyword">const</span>; -<a name="l01643"></a>01643 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * value ) <span class="keyword">const</span>; -<a name="l01645"></a>01645 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>() <span class="keyword">const</span>; -<a name="l01647"></a>01647 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * value ) <span class="keyword">const</span>; -<a name="l01648"></a>01648 -<a name="l01652"></a>01652 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* value, <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; -<a name="l01656"></a>01656 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; -<a name="l01661"></a>01661 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* value, <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; -<a name="l01666"></a>01666 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; -<a name="l01667"></a>01667 -<a name="l01668"></a>01668 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01669"></a>01669 <span class="preprocessor"></span> <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>( <span class="keyword">const</span> std::string& _value )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>( _value.c_str() ); } -<a name="l01670"></a>01670 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>( <span class="keyword">const</span> std::string& _value )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>( _value.c_str() ); } -<a name="l01671"></a>01671 -<a name="l01672"></a>01672 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( <span class="keyword">const</span> std::string& _value, <span class="keywordtype">int</span> index )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( _value.c_str(), index ); } -<a name="l01673"></a>01673 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( <span class="keyword">const</span> std::string& _value, <span class="keywordtype">int</span> index )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( _value.c_str(), index ); } -<a name="l01674"></a>01674 <span class="preprocessor"> #endif</span> -<a name="l01675"></a>01675 <span class="preprocessor"></span> -<a name="l01678"></a><a class="code" href="classTiXmlHandle.html#af678e5088e83be67baf76f699756f2c3">01678</a> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlHandle.html#af678e5088e83be67baf76f699756f2c3" title="Return the handle as a TiXmlNode.">ToNode</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node; } -<a name="l01681"></a><a class="code" href="classTiXmlHandle.html#abc6e7ed383a5fe1e52b0c0004b457b9e">01681</a> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlHandle.html#abc6e7ed383a5fe1e52b0c0004b457b9e" title="Return the handle as a TiXmlElement.">ToElement</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } -<a name="l01684"></a><a class="code" href="classTiXmlHandle.html#a4ac53a652296203a5b5e13854d923586">01684</a> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlHandle.html#a4ac53a652296203a5b5e13854d923586" title="Return the handle as a TiXmlText.">ToText</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ( ( node && node->ToText() ) ? node->ToText() : 0 ); } -<a name="l01687"></a><a class="code" href="classTiXmlHandle.html#a1381c17507a130767b1e23afc93b3674">01687</a> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlHandle.html#a1381c17507a130767b1e23afc93b3674" title="Return the handle as a TiXmlUnknown.">ToUnknown</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } -<a name="l01688"></a>01688 -<a name="l01692"></a><a class="code" href="classTiXmlHandle.html#ab44b723a8dc9af72838a303c079d0376">01692</a> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlHandle.html#ab44b723a8dc9af72838a303c079d0376">Node</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#af678e5088e83be67baf76f699756f2c3" title="Return the handle as a TiXmlNode.">ToNode</a>(); } -<a name="l01696"></a><a class="code" href="classTiXmlHandle.html#acb5fe8388a526289ea65e817a51e05e7">01696</a> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlHandle.html#acb5fe8388a526289ea65e817a51e05e7">Element</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#abc6e7ed383a5fe1e52b0c0004b457b9e" title="Return the handle as a TiXmlElement.">ToElement</a>(); } -<a name="l01700"></a><a class="code" href="classTiXmlHandle.html#a9fc739c8a18d160006f82572fc143d13">01700</a> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlHandle.html#a9fc739c8a18d160006f82572fc143d13">Text</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a4ac53a652296203a5b5e13854d923586" title="Return the handle as a TiXmlText.">ToText</a>(); } -<a name="l01704"></a><a class="code" href="classTiXmlHandle.html#a49675b74357ba2aae124657a9a1ef465">01704</a> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlHandle.html#a49675b74357ba2aae124657a9a1ef465">Unknown</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a1381c17507a130767b1e23afc93b3674" title="Return the handle as a TiXmlUnknown.">ToUnknown</a>(); } -<a name="l01705"></a>01705 -<a name="l01706"></a>01706 <span class="keyword">private</span>: -<a name="l01707"></a>01707 <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* node; -<a name="l01708"></a>01708 }; -<a name="l01709"></a>01709 -<a name="l01710"></a>01710 -<a name="l01730"></a><a class="code" href="classTiXmlPrinter.html">01730</a> <span class="keyword">class </span><a class="code" href="classTiXmlPrinter.html" title="Print to memory functionality.">TiXmlPrinter</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a> -<a name="l01731"></a>01731 { -<a name="l01732"></a>01732 <span class="keyword">public</span>: -<a name="l01733"></a>01733 <a class="code" href="classTiXmlPrinter.html" title="Print to memory functionality.">TiXmlPrinter</a>() : depth( 0 ), simpleTextPrint( <span class="keyword">false</span> ), -<a name="l01734"></a>01734 buffer(), indent( <span class="stringliteral">" "</span> ), lineBreak( <span class="stringliteral">"\n"</span> ) {} -<a name="l01735"></a>01735 -<a name="l01736"></a>01736 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a799f4f0388570cbb54c0d3c345fef7c1" title="Visit a document.">VisitEnter</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& doc ); -<a name="l01737"></a>01737 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a66b33edd76c538b462f789b797a4fdf2" title="Visit a document.">VisitExit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& doc ); -<a name="l01738"></a>01738 -<a name="l01739"></a>01739 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a799f4f0388570cbb54c0d3c345fef7c1" title="Visit a document.">VisitEnter</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& element, <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* firstAttribute ); -<a name="l01740"></a>01740 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a66b33edd76c538b462f789b797a4fdf2" title="Visit a document.">VisitExit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& element ); -<a name="l01741"></a>01741 -<a name="l01742"></a>01742 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& declaration ); -<a name="l01743"></a>01743 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& text ); -<a name="l01744"></a>01744 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& comment ); -<a name="l01745"></a>01745 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& unknown ); -<a name="l01746"></a>01746 -<a name="l01750"></a><a class="code" href="classTiXmlPrinter.html#a213377a4070c7e625bae59716b089e5e">01750</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlPrinter.html#a213377a4070c7e625bae59716b089e5e" title="Set the indent characters for printing.">SetIndent</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _indent ) { indent = _indent ? _indent : <span class="stringliteral">""</span> ; } -<a name="l01752"></a><a class="code" href="classTiXmlPrinter.html#abb33ec7d4bad6aaeb57f4304394b133d">01752</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlPrinter.html#abb33ec7d4bad6aaeb57f4304394b133d" title="Query the indention string.">Indent</a>() { <span class="keywordflow">return</span> indent.c_str(); } -<a name="l01757"></a><a class="code" href="classTiXmlPrinter.html#a4be1e37e69e3858c59635aa947174fe6">01757</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlPrinter.html#a4be1e37e69e3858c59635aa947174fe6" title="Set the line breaking string.">SetLineBreak</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : <span class="stringliteral">""</span>; } -<a name="l01759"></a><a class="code" href="classTiXmlPrinter.html#a11f1b4804a460b175ec244eb5724d96d">01759</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlPrinter.html#a11f1b4804a460b175ec244eb5724d96d" title="Query the current line breaking string.">LineBreak</a>() { <span class="keywordflow">return</span> lineBreak.c_str(); } -<a name="l01760"></a>01760 -<a name="l01764"></a><a class="code" href="classTiXmlPrinter.html#ab23a90629e374cb1cadca090468bbd19">01764</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlPrinter.html#ab23a90629e374cb1cadca090468bbd19" title="Switch over to &quot;stream printing&quot; which is the most dense formatting without...">SetStreamPrinting</a>() { indent = <span class="stringliteral">""</span>; -<a name="l01765"></a>01765 lineBreak = <span class="stringliteral">""</span>; -<a name="l01766"></a>01766 } -<a name="l01768"></a><a class="code" href="classTiXmlPrinter.html#a859eede9597d3e0355b77757be48735e">01768</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlPrinter.html#a859eede9597d3e0355b77757be48735e" title="Return the result.">CStr</a>() { <span class="keywordflow">return</span> buffer.c_str(); } -<a name="l01770"></a><a class="code" href="classTiXmlPrinter.html#ad01375ae9199bd2f48252eaddce3039d">01770</a> <span class="keywordtype">size_t</span> <a class="code" href="classTiXmlPrinter.html#ad01375ae9199bd2f48252eaddce3039d" title="Return the length of the result string.">Size</a>() { <span class="keywordflow">return</span> buffer.size(); } -<a name="l01771"></a>01771 -<a name="l01772"></a>01772 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> -<a name="l01774"></a><a class="code" href="classTiXmlPrinter.html#a3bd4daf44309b41f5813a833caa0d1c9">01774</a> <span class="preprocessor"> const std::string& Str() { return buffer; }</span> -<a name="l01775"></a>01775 <span class="preprocessor"></span><span class="preprocessor"> #endif</span> -<a name="l01776"></a>01776 <span class="preprocessor"></span> -<a name="l01777"></a>01777 <span class="keyword">private</span>: -<a name="l01778"></a>01778 <span class="keywordtype">void</span> DoIndent() { -<a name="l01779"></a>01779 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<depth; ++i ) -<a name="l01780"></a>01780 buffer += indent; -<a name="l01781"></a>01781 } -<a name="l01782"></a>01782 <span class="keywordtype">void</span> DoLineBreak() { -<a name="l01783"></a>01783 buffer += lineBreak; -<a name="l01784"></a>01784 } -<a name="l01785"></a>01785 -<a name="l01786"></a>01786 <span class="keywordtype">int</span> depth; -<a name="l01787"></a>01787 <span class="keywordtype">bool</span> simpleTextPrint; -<a name="l01788"></a>01788 TIXML_STRING buffer; -<a name="l01789"></a>01789 TIXML_STRING indent; -<a name="l01790"></a>01790 TIXML_STRING lineBreak; -<a name="l01791"></a>01791 }; +<a name="l01532"></a><a class="code" href="classTiXmlDocument.html#a1dc977bde3e4fe85a8eb9d88a35ef5a4">01532</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>* <a class="code" href="classTiXmlDocument.html#a1dc977bde3e4fe85a8eb9d88a35ef5a4" title="Cast to a more defined type. Will return null not of the requested type.">ToDocument</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01533"></a><a class="code" href="classTiXmlDocument.html#a1025d942a1f328fd742d545e37efdd42">01533</a> <span class="keyword">virtual</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>* <a class="code" href="classTiXmlDocument.html#a1025d942a1f328fd742d545e37efdd42" title="Cast to a more defined type. Will return null not of the requested type.">ToDocument</a>() { <span class="keywordflow">return</span> <span class="keyword">this</span>; } +<a name="l01534"></a>01534 +<a name="l01537"></a>01537 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlDocument.html#aa545aae325d9752ad64120bc4ecf939a" title="Walk the XML tree visiting this node and all of its children.">Accept</a>( <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a>* content ) <span class="keyword">const</span>; +<a name="l01538"></a>01538 +<a name="l01539"></a>01539 <span class="keyword">protected</span> : +<a name="l01540"></a>01540 <span class="comment">// [internal use]</span> +<a name="l01541"></a>01541 <span class="keyword">virtual</span> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlDocument.html#a4968661cab4a1f44a23329c6f8db1907" title="Create an exact duplicate of this node and return it.">Clone</a>() <span class="keyword">const</span>; +<a name="l01542"></a>01542 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01543"></a>01543 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StreamIn( std::istream * in, TIXML_STRING * tag ); +<a name="l01544"></a>01544 <span class="preprocessor"> #endif</span> +<a name="l01545"></a>01545 <span class="preprocessor"></span> +<a name="l01546"></a>01546 <span class="keyword">private</span>: +<a name="l01547"></a>01547 <span class="keywordtype">void</span> CopyTo( <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>* target ) <span class="keyword">const</span>; +<a name="l01548"></a>01548 +<a name="l01549"></a>01549 <span class="keywordtype">bool</span> error; +<a name="l01550"></a>01550 <span class="keywordtype">int</span> errorId; +<a name="l01551"></a>01551 TIXML_STRING errorDesc; +<a name="l01552"></a>01552 <span class="keywordtype">int</span> tabsize; +<a name="l01553"></a>01553 TiXmlCursor errorLocation; +<a name="l01554"></a>01554 <span class="keywordtype">bool</span> useMicrosoftBOM; <span class="comment">// the UTF-8 BOM were found when read. Note this, and try to write.</span> +<a name="l01555"></a>01555 }; +<a name="l01556"></a>01556 +<a name="l01557"></a>01557 +<a name="l01638"></a><a class="code" href="classTiXmlHandle.html">01638</a> <span class="keyword">class </span><a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> +<a name="l01639"></a>01639 { +<a name="l01640"></a>01640 <span class="keyword">public</span>: +<a name="l01642"></a><a class="code" href="classTiXmlHandle.html#aba18fd7bdefb942ecdea4bf4b8e29ec8">01642</a> <a class="code" href="classTiXmlHandle.html#aba18fd7bdefb942ecdea4bf4b8e29ec8" title="Create a handle from any node (at any depth of the tree.) This can be a null pointer...">TiXmlHandle</a>( <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* _node ) { this->node = _node; } +<a name="l01644"></a><a class="code" href="classTiXmlHandle.html#a236d7855e1e56ccc7b980630c48c7fd7">01644</a> <a class="code" href="classTiXmlHandle.html#a236d7855e1e56ccc7b980630c48c7fd7" title="Copy constructor.">TiXmlHandle</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a>& ref ) { this->node = ref.node; } +<a name="l01645"></a>01645 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> operator=( <span class="keyword">const</span> <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a>& ref ) { <span class="keywordflow">if</span> ( &ref != <span class="keyword">this</span> ) this->node = ref.node; <span class="keywordflow">return</span> *<span class="keyword">this</span>; } +<a name="l01646"></a>01646 +<a name="l01648"></a>01648 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>() <span class="keyword">const</span>; +<a name="l01650"></a>01650 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * value ) <span class="keyword">const</span>; +<a name="l01652"></a>01652 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>() <span class="keyword">const</span>; +<a name="l01654"></a>01654 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * value ) <span class="keyword">const</span>; +<a name="l01655"></a>01655 +<a name="l01659"></a>01659 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* value, <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; +<a name="l01663"></a>01663 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; +<a name="l01668"></a>01668 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* value, <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; +<a name="l01673"></a>01673 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( <span class="keywordtype">int</span> index ) <span class="keyword">const</span>; +<a name="l01674"></a>01674 +<a name="l01675"></a>01675 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01676"></a>01676 <span class="preprocessor"></span> <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>( <span class="keyword">const</span> std::string& _value )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#acdb1faaf88a700b40ca2c8d9aee21139" title="Return a handle to the first child node.">FirstChild</a>( _value.c_str() ); } +<a name="l01677"></a>01677 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>( <span class="keyword">const</span> std::string& _value )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a24d1112e995e937e4dddb202d4113d4a" title="Return a handle to the first child element.">FirstChildElement</a>( _value.c_str() ); } +<a name="l01678"></a>01678 +<a name="l01679"></a>01679 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( <span class="keyword">const</span> std::string& _value, <span class="keywordtype">int</span> index )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a072492b4be1acdb0db2d03cd8f71ccc4" title="Return a handle to the &quot;index&quot; child with the given name.">Child</a>( _value.c_str(), index ); } +<a name="l01680"></a>01680 <a class="code" href="classTiXmlHandle.html" title="A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly...">TiXmlHandle</a> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( <span class="keyword">const</span> std::string& _value, <span class="keywordtype">int</span> index )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a979a3f850984a176ee884e394c7eed2d" title="Return a handle to the &quot;index&quot; child element with the given name.">ChildElement</a>( _value.c_str(), index ); } +<a name="l01681"></a>01681 <span class="preprocessor"> #endif</span> +<a name="l01682"></a>01682 <span class="preprocessor"></span> +<a name="l01685"></a><a class="code" href="classTiXmlHandle.html#af678e5088e83be67baf76f699756f2c3">01685</a> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlHandle.html#af678e5088e83be67baf76f699756f2c3" title="Return the handle as a TiXmlNode.">ToNode</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node; } +<a name="l01688"></a><a class="code" href="classTiXmlHandle.html#abc6e7ed383a5fe1e52b0c0004b457b9e">01688</a> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlHandle.html#abc6e7ed383a5fe1e52b0c0004b457b9e" title="Return the handle as a TiXmlElement.">ToElement</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } +<a name="l01691"></a><a class="code" href="classTiXmlHandle.html#a4ac53a652296203a5b5e13854d923586">01691</a> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlHandle.html#a4ac53a652296203a5b5e13854d923586" title="Return the handle as a TiXmlText.">ToText</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ( ( node && node->ToText() ) ? node->ToText() : 0 ); } +<a name="l01694"></a><a class="code" href="classTiXmlHandle.html#a1381c17507a130767b1e23afc93b3674">01694</a> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlHandle.html#a1381c17507a130767b1e23afc93b3674" title="Return the handle as a TiXmlUnknown.">ToUnknown</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } +<a name="l01695"></a>01695 +<a name="l01699"></a><a class="code" href="classTiXmlHandle.html#ab44b723a8dc9af72838a303c079d0376">01699</a> <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* <a class="code" href="classTiXmlHandle.html#ab44b723a8dc9af72838a303c079d0376">Node</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#af678e5088e83be67baf76f699756f2c3" title="Return the handle as a TiXmlNode.">ToNode</a>(); } +<a name="l01703"></a><a class="code" href="classTiXmlHandle.html#acb5fe8388a526289ea65e817a51e05e7">01703</a> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>* <a class="code" href="classTiXmlHandle.html#acb5fe8388a526289ea65e817a51e05e7">Element</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#abc6e7ed383a5fe1e52b0c0004b457b9e" title="Return the handle as a TiXmlElement.">ToElement</a>(); } +<a name="l01707"></a><a class="code" href="classTiXmlHandle.html#a9fc739c8a18d160006f82572fc143d13">01707</a> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>* <a class="code" href="classTiXmlHandle.html#a9fc739c8a18d160006f82572fc143d13">Text</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a4ac53a652296203a5b5e13854d923586" title="Return the handle as a TiXmlText.">ToText</a>(); } +<a name="l01711"></a><a class="code" href="classTiXmlHandle.html#a49675b74357ba2aae124657a9a1ef465">01711</a> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>* <a class="code" href="classTiXmlHandle.html#a49675b74357ba2aae124657a9a1ef465">Unknown</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classTiXmlHandle.html#a1381c17507a130767b1e23afc93b3674" title="Return the handle as a TiXmlUnknown.">ToUnknown</a>(); } +<a name="l01712"></a>01712 +<a name="l01713"></a>01713 <span class="keyword">private</span>: +<a name="l01714"></a>01714 <a class="code" href="classTiXmlNode.html" title="The parent class for everything in the Document Object Model.">TiXmlNode</a>* node; +<a name="l01715"></a>01715 }; +<a name="l01716"></a>01716 +<a name="l01717"></a>01717 +<a name="l01737"></a><a class="code" href="classTiXmlPrinter.html">01737</a> <span class="keyword">class </span><a class="code" href="classTiXmlPrinter.html" title="Print to memory functionality.">TiXmlPrinter</a> : <span class="keyword">public</span> <a class="code" href="classTiXmlVisitor.html" title="Implements the interface to the &quot;Visitor pattern&quot; (see the Accept() method...">TiXmlVisitor</a> +<a name="l01738"></a>01738 { +<a name="l01739"></a>01739 <span class="keyword">public</span>: +<a name="l01740"></a>01740 <a class="code" href="classTiXmlPrinter.html" title="Print to memory functionality.">TiXmlPrinter</a>() : depth( 0 ), simpleTextPrint( <span class="keyword">false</span> ), +<a name="l01741"></a>01741 buffer(), indent( <span class="stringliteral">" "</span> ), lineBreak( <span class="stringliteral">"\n"</span> ) {} +<a name="l01742"></a>01742 +<a name="l01743"></a>01743 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a799f4f0388570cbb54c0d3c345fef7c1" title="Visit a document.">VisitEnter</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& doc ); +<a name="l01744"></a>01744 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a66b33edd76c538b462f789b797a4fdf2" title="Visit a document.">VisitExit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDocument.html" title="Always the top level node.">TiXmlDocument</a>& doc ); +<a name="l01745"></a>01745 +<a name="l01746"></a>01746 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a799f4f0388570cbb54c0d3c345fef7c1" title="Visit a document.">VisitEnter</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& element, <span class="keyword">const</span> <a class="code" href="classTiXmlAttribute.html" title="An attribute is a name-value pair.">TiXmlAttribute</a>* firstAttribute ); +<a name="l01747"></a>01747 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#a66b33edd76c538b462f789b797a4fdf2" title="Visit a document.">VisitExit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlElement.html" title="The element is a container class.">TiXmlElement</a>& element ); +<a name="l01748"></a>01748 +<a name="l01749"></a>01749 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlDeclaration.html" title="In correct XML the declaration is the first entry in the file.">TiXmlDeclaration</a>& declaration ); +<a name="l01750"></a>01750 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlText.html" title="XML text.">TiXmlText</a>& text ); +<a name="l01751"></a>01751 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlComment.html" title="An XML comment.">TiXmlComment</a>& comment ); +<a name="l01752"></a>01752 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classTiXmlPrinter.html#ace1b14d33eede2575c0743e2350f6a38" title="Visit a declaration.">Visit</a>( <span class="keyword">const</span> <a class="code" href="classTiXmlUnknown.html" title="Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.">TiXmlUnknown</a>& unknown ); +<a name="l01753"></a>01753 +<a name="l01757"></a><a class="code" href="classTiXmlPrinter.html#a213377a4070c7e625bae59716b089e5e">01757</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlPrinter.html#a213377a4070c7e625bae59716b089e5e" title="Set the indent characters for printing.">SetIndent</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _indent ) { indent = _indent ? _indent : <span class="stringliteral">""</span> ; } +<a name="l01759"></a><a class="code" href="classTiXmlPrinter.html#abb33ec7d4bad6aaeb57f4304394b133d">01759</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlPrinter.html#abb33ec7d4bad6aaeb57f4304394b133d" title="Query the indention string.">Indent</a>() { <span class="keywordflow">return</span> indent.c_str(); } +<a name="l01764"></a><a class="code" href="classTiXmlPrinter.html#a4be1e37e69e3858c59635aa947174fe6">01764</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlPrinter.html#a4be1e37e69e3858c59635aa947174fe6" title="Set the line breaking string.">SetLineBreak</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : <span class="stringliteral">""</span>; } +<a name="l01766"></a><a class="code" href="classTiXmlPrinter.html#a11f1b4804a460b175ec244eb5724d96d">01766</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlPrinter.html#a11f1b4804a460b175ec244eb5724d96d" title="Query the current line breaking string.">LineBreak</a>() { <span class="keywordflow">return</span> lineBreak.c_str(); } +<a name="l01767"></a>01767 +<a name="l01771"></a><a class="code" href="classTiXmlPrinter.html#ab23a90629e374cb1cadca090468bbd19">01771</a> <span class="keywordtype">void</span> <a class="code" href="classTiXmlPrinter.html#ab23a90629e374cb1cadca090468bbd19" title="Switch over to &quot;stream printing&quot; which is the most dense formatting without...">SetStreamPrinting</a>() { indent = <span class="stringliteral">""</span>; +<a name="l01772"></a>01772 lineBreak = <span class="stringliteral">""</span>; +<a name="l01773"></a>01773 } +<a name="l01775"></a><a class="code" href="classTiXmlPrinter.html#a859eede9597d3e0355b77757be48735e">01775</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classTiXmlPrinter.html#a859eede9597d3e0355b77757be48735e" title="Return the result.">CStr</a>() { <span class="keywordflow">return</span> buffer.c_str(); } +<a name="l01777"></a><a class="code" href="classTiXmlPrinter.html#ad01375ae9199bd2f48252eaddce3039d">01777</a> <span class="keywordtype">size_t</span> <a class="code" href="classTiXmlPrinter.html#ad01375ae9199bd2f48252eaddce3039d" title="Return the length of the result string.">Size</a>() { <span class="keywordflow">return</span> buffer.size(); } +<a name="l01778"></a>01778 +<a name="l01779"></a>01779 <span class="preprocessor"> #ifdef TIXML_USE_STL</span> +<a name="l01781"></a><a class="code" href="classTiXmlPrinter.html#a3bd4daf44309b41f5813a833caa0d1c9">01781</a> <span class="preprocessor"> const std::string& Str() { return buffer; }</span> +<a name="l01782"></a>01782 <span class="preprocessor"></span><span class="preprocessor"> #endif</span> +<a name="l01783"></a>01783 <span class="preprocessor"></span> +<a name="l01784"></a>01784 <span class="keyword">private</span>: +<a name="l01785"></a>01785 <span class="keywordtype">void</span> DoIndent() { +<a name="l01786"></a>01786 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<depth; ++i ) +<a name="l01787"></a>01787 buffer += indent; +<a name="l01788"></a>01788 } +<a name="l01789"></a>01789 <span class="keywordtype">void</span> DoLineBreak() { +<a name="l01790"></a>01790 buffer += lineBreak; +<a name="l01791"></a>01791 } <a name="l01792"></a>01792 -<a name="l01793"></a>01793 -<a name="l01794"></a>01794 <span class="preprocessor">#ifdef _MSC_VER</span> -<a name="l01795"></a>01795 <span class="preprocessor"></span><span class="preprocessor">#pragma warning( pop )</span> -<a name="l01796"></a>01796 <span class="preprocessor"></span><span class="preprocessor">#endif</span> -<a name="l01797"></a>01797 <span class="preprocessor"></span> -<a name="l01798"></a>01798 <span class="preprocessor">#endif</span> -<a name="l01799"></a>01799 <span class="preprocessor"></span> +<a name="l01793"></a>01793 <span class="keywordtype">int</span> depth; +<a name="l01794"></a>01794 <span class="keywordtype">bool</span> simpleTextPrint; +<a name="l01795"></a>01795 TIXML_STRING buffer; +<a name="l01796"></a>01796 TIXML_STRING indent; +<a name="l01797"></a>01797 TIXML_STRING lineBreak; +<a name="l01798"></a>01798 }; +<a name="l01799"></a>01799 +<a name="l01800"></a>01800 +<a name="l01801"></a>01801 <span class="preprocessor">#ifdef _MSC_VER</span> +<a name="l01802"></a>01802 <span class="preprocessor"></span><span class="preprocessor">#pragma warning( pop )</span> +<a name="l01803"></a>01803 <span class="preprocessor"></span><span class="preprocessor">#endif</span> +<a name="l01804"></a>01804 <span class="preprocessor"></span> +<a name="l01805"></a>01805 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> diff --git a/shared/tinyxml/echo.dsp b/shared/tinyxml/echo.dsp deleted file mode 100644 index d81db12e..00000000 --- a/shared/tinyxml/echo.dsp +++ /dev/null @@ -1,113 +0,0 @@ -# Microsoft Developer Studio Project File - Name="echo" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=echo - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "echo.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "echo.mak" CFG="echo - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "echo - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "echo - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "echo - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "echoRelease" -# PROP Intermediate_Dir "echoRelease" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "echo - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "echo___Win32_Debug" -# PROP BASE Intermediate_Dir "echo___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "echoDebug" -# PROP Intermediate_Dir "echoDebug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /FR /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "echo - Win32 Release" -# Name "echo - Win32 Debug" -# Begin Source File - -SOURCE=.\xmltester\bugtest.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinystr.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinystr.h -# End Source File -# Begin Source File - -SOURCE=.\tinyxml.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxml.h -# End Source File -# Begin Source File - -SOURCE=.\tinyxmlerror.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxmlparser.cpp -# End Source File -# End Target -# End Project diff --git a/shared/tinyxml/tinyXmlTest.dsp b/shared/tinyxml/tinyXmlTest.dsp deleted file mode 100644 index bf4baf02..00000000 --- a/shared/tinyxml/tinyXmlTest.dsp +++ /dev/null @@ -1,92 +0,0 @@ -# Microsoft Developer Studio Project File - Name="tinyXmlTest" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=tinyXmlTest - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "tinyXmlTest.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "tinyXmlTest.mak" CFG="tinyXmlTest - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "tinyXmlTest - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "tinyXmlTest - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "tinyXmlTest - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "tinyXmlTest___Win32_Release" -# PROP BASE Intermediate_Dir "tinyXmlTest___Win32_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "tinyXmlTest___Win32_Release" -# PROP Intermediate_Dir "tinyXmlTest___Win32_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 ./Release/tinyxml.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "tinyXmlTest - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "tinyXmlTest___Win32_Debug" -# PROP BASE Intermediate_Dir "tinyXmlTest___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "tinyXmlTest___Win32_Debug" -# PROP Intermediate_Dir "tinyXmlTest___Win32_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TUNE" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ./Debug/tinyxmld.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "tinyXmlTest - Win32 Release" -# Name "tinyXmlTest - Win32 Debug" -# Begin Source File - -SOURCE=.\xmltest.cpp -# End Source File -# End Target -# End Project diff --git a/shared/tinyxml/tinyXmlTest.vcproj b/shared/tinyxml/tinyXmlTest.vcproj deleted file mode 100644 index e32ecdff..00000000 --- a/shared/tinyxml/tinyXmlTest.vcproj +++ /dev/null @@ -1,226 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9.00" - Name="tinyXmlTest" - ProjectGUID="{34719950-09E8-457E-BE23-8F1CE3A1F1F6}" - TargetFrameworkVersion="131072" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory=".\tinyXmlTest___Win32_Debug" - IntermediateDirectory=".\tinyXmlTest___Win32_Debug" - ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\tinyXmlTest___Win32_Debug/tinyXmlTest.tlb" - HeaderFileName="" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;TUNE;_CRT_SECURE_NO_WARNINGS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - PrecompiledHeaderFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.pch" - AssemblerListingLocation=".\tinyXmlTest___Win32_Debug/" - ObjectFile=".\tinyXmlTest___Win32_Debug/" - ProgramDataBaseFileName=".\tinyXmlTest___Win32_Debug/" - BrowseInformation="1" - WarningLevel="4" - SuppressStartupBanner="true" - Detect64BitPortabilityProblems="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="./Debug/tinyxmld.lib" - OutputFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.exe" - LinkIncremental="2" - SuppressStartupBanner="true" - GenerateDebugInformation="true" - ProgramDatabaseFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.pdb" - SubSystem="1" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory=".\tinyXmlTest___Win32_Release" - IntermediateDirectory=".\tinyXmlTest___Win32_Release" - ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\tinyXmlTest___Win32_Release/tinyXmlTest.tlb" - HeaderFileName="" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" - StringPooling="true" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.pch" - AssemblerListingLocation=".\tinyXmlTest___Win32_Release/" - ObjectFile=".\tinyXmlTest___Win32_Release/" - ProgramDataBaseFileName=".\tinyXmlTest___Win32_Release/" - BrowseInformation="1" - WarningLevel="3" - SuppressStartupBanner="true" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="./Release/tinyxml.lib" - OutputFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.exe" - LinkIncremental="1" - SuppressStartupBanner="true" - ProgramDatabaseFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.pdb" - SubSystem="1" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <File - RelativePath="xmltest.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/shared/tinyxml/tinyXmlTest.vcxproj b/shared/tinyxml/tinyXmlTest.vcxproj new file mode 100644 index 00000000..573b5543 --- /dev/null +++ b/shared/tinyxml/tinyXmlTest.vcxproj @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{34719950-09E8-457E-BE23-8F1CE3A1F1F6}</ProjectGuid> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IncludePath)</IncludePath> + <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LibraryPath)</LibraryPath> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Midl> + <TypeLibraryName>.\tinyXmlTest___Win32_Debug/tinyXmlTest.tlb</TypeLibraryName> + <HeaderFileName> + </HeaderFileName> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;TUNE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <BrowseInformation>true</BrowseInformation> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Midl> + <TypeLibraryName>.\tinyXmlTest___Win32_Release/tinyXmlTest.tlb</TypeLibraryName> + <HeaderFileName> + </HeaderFileName> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <BrowseInformation>true</BrowseInformation> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> + <SuppressStartupBanner>true</SuppressStartupBanner> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="xmltest.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="tinyxml_lib.vcxproj"> + <Project>{c406daec-0886-4771-8dea-9d7329b46cc1}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/shared/tinyxml/tinyXmlTestSTL.dsp b/shared/tinyxml/tinyXmlTestSTL.dsp deleted file mode 100644 index c4b1926e..00000000 --- a/shared/tinyxml/tinyXmlTestSTL.dsp +++ /dev/null @@ -1,92 +0,0 @@ -# Microsoft Developer Studio Project File - Name="tinyXmlTestSTL" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=tinyXmlTestSTL - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "tinyXmlTestSTL.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "tinyXmlTestSTL.mak" CFG="tinyXmlTestSTL - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "tinyXmlTestSTL - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "tinyXmlTestSTL - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "tinyXmlTestSTL - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "tinyXmlTestSTL___Win32_Release" -# PROP BASE Intermediate_Dir "tinyXmlTestSTL___Win32_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "tinyXmlTestSTL___Win32_Release" -# PROP Intermediate_Dir "tinyXmlTestSTL___Win32_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 ./Release_STL/tinyxml_stl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "tinyXmlTestSTL - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "tinyXmlTestSTL___Win32_Debug" -# PROP BASE Intermediate_Dir "tinyXmlTestSTL___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "tinyXmlTestSTL___Win32_Debug" -# PROP Intermediate_Dir "tinyXmlTestSTL___Win32_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /D "TUNE" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ./Debug_STL/tinyxmld_stl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "tinyXmlTestSTL - Win32 Release" -# Name "tinyXmlTestSTL - Win32 Debug" -# Begin Source File - -SOURCE=.\xmltest.cpp -# End Source File -# End Target -# End Project diff --git a/shared/tinyxml/tinyXmlTestSTL.vcproj b/shared/tinyxml/tinyXmlTestSTL.vcproj deleted file mode 100644 index 482a5aa7..00000000 --- a/shared/tinyxml/tinyXmlTestSTL.vcproj +++ /dev/null @@ -1,225 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9.00" - Name="tinyXmlTestSTL" - ProjectGUID="{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}" - TargetFrameworkVersion="131072" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory=".\tinyXmlTestSTL___Win32_Debug" - IntermediateDirectory=".\tinyXmlTestSTL___Win32_Debug" - ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.tlb" - HeaderFileName="" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;TIXML_USE_STL;TUNE;_CRT_SECURE_NO_WARNINGS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - PrecompiledHeaderFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.pch" - AssemblerListingLocation=".\tinyXmlTestSTL___Win32_Debug/" - ObjectFile=".\tinyXmlTestSTL___Win32_Debug/" - ProgramDataBaseFileName=".\tinyXmlTestSTL___Win32_Debug/" - BrowseInformation="1" - WarningLevel="4" - SuppressStartupBanner="true" - Detect64BitPortabilityProblems="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="./Debug_STL/tinyxmld_stl.lib" - OutputFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.exe" - LinkIncremental="1" - SuppressStartupBanner="true" - GenerateDebugInformation="true" - ProgramDatabaseFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.pdb" - SubSystem="1" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory=".\tinyXmlTestSTL___Win32_Release" - IntermediateDirectory=".\tinyXmlTestSTL___Win32_Release" - ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.tlb" - HeaderFileName="" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;TIXML_USE_STL;_CRT_SECURE_NO_WARNINGS" - StringPooling="true" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.pch" - AssemblerListingLocation=".\tinyXmlTestSTL___Win32_Release/" - ObjectFile=".\tinyXmlTestSTL___Win32_Release/" - ProgramDataBaseFileName=".\tinyXmlTestSTL___Win32_Release/" - WarningLevel="3" - SuppressStartupBanner="true" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="./Release_STL/tinyxml_stl.lib" - OutputFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.exe" - LinkIncremental="1" - SuppressStartupBanner="true" - ProgramDatabaseFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.pdb" - SubSystem="1" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <File - RelativePath="xmltest.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/shared/tinyxml/tinyXmlTestSTL.vcxproj b/shared/tinyxml/tinyXmlTestSTL.vcxproj new file mode 100644 index 00000000..71cc6301 --- /dev/null +++ b/shared/tinyxml/tinyXmlTestSTL.vcxproj @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}</ProjectGuid> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IncludePath)</IncludePath> + <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LibraryPath)</LibraryPath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IncludePath)</IncludePath> + <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LibraryPath)</LibraryPath> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Midl> + <TypeLibraryName>.\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.tlb</TypeLibraryName> + <HeaderFileName> + </HeaderFileName> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;TIXML_USE_STL;TUNE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <BrowseInformation>true</BrowseInformation> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Midl> + <TypeLibraryName>.\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.tlb</TypeLibraryName> + <HeaderFileName> + </HeaderFileName> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;TIXML_USE_STL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> + <SuppressStartupBanner>true</SuppressStartupBanner> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="xmltest.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="tinyxmlSTL.vcxproj"> + <Project>{a3a84737-5017-4577-b8a2-79429a25b8b6}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/shared/tinyxml/tinystr.cpp b/shared/tinyxml/tinystr.cpp index 86377ad1..2e28a874 100644 --- a/shared/tinyxml/tinystr.cpp +++ b/shared/tinyxml/tinystr.cpp @@ -1,6 +1,5 @@ /* www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -22,10 +21,6 @@ must not be misrepresented as being the original software. distribution. */ -/* - * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005. - */ - #ifndef TIXML_USE_STL diff --git a/shared/tinyxml/tinystr.h b/shared/tinyxml/tinystr.h index b11407a4..9555549f 100644 --- a/shared/tinyxml/tinystr.h +++ b/shared/tinyxml/tinystr.h @@ -1,6 +1,5 @@ /* www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -22,17 +21,6 @@ must not be misrepresented as being the original software. distribution. */ -/* - * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005. - * - * - completely rewritten. compact, clean, and fast implementation. - * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems) - * - fixed reserve() to work as per specification. - * - fixed buggy compares operator==(), operator<(), and operator>() - * - fixed operator+=() to take a const ref argument, following spec. - * - added "copy" constructor with length, and most compare operators. - * - added swap(), clear(), size(), capacity(), operator+(). - */ #ifndef TIXML_USE_STL @@ -106,13 +94,11 @@ public : quit(); } - // = operator TiXmlString& operator = (const char* copy) { return assign( copy, (size_type)strlen(copy)); } - // = operator TiXmlString& operator = (const TiXmlString& copy) { return assign(copy.start(), copy.length()); diff --git a/shared/tinyxml/tinyxml.cpp b/shared/tinyxml/tinyxml.cpp index 2b8f17a8..a9c6e22b 100644 --- a/shared/tinyxml/tinyxml.cpp +++ b/shared/tinyxml/tinyxml.cpp @@ -1,6 +1,6 @@ /* www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) +Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -57,10 +57,10 @@ void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) { unsigned char c = (unsigned char) str[i]; - if (c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) { // Hexadecimal character reference. // Pass through unchanged. @@ -191,7 +191,8 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) { delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } @@ -214,7 +215,8 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = addThis.Clone(); @@ -233,7 +235,8 @@ TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } @@ -266,7 +269,8 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } @@ -548,10 +552,11 @@ TiXmlElement::TiXmlElement( const TiXmlElement& copy) } -void TiXmlElement::operator=( const TiXmlElement& base ) +TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base ) { ClearThis(); base.CopyTo( this ); + return *this; } @@ -674,6 +679,45 @@ int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const } +int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value2 ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + int ival = 0; + int result = node->QueryIntValue( &ival ); + *value2 = (unsigned)ival; + return result; +} + + +int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + int result = TIXML_WRONG_TYPE; + if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) ) + { + *bval = true; + result = TIXML_SUCCESS; + } + else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) ) + { + *bval = false; + result = TIXML_SUCCESS; + } + return result; +} + + + #ifdef TIXML_USE_STL int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const { @@ -921,10 +965,11 @@ TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode } -void TiXmlDocument::operator=( const TiXmlDocument& copy ) +TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy ) { Clear(); copy.CopyTo( this ); + return *this; } @@ -1280,10 +1325,11 @@ TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::T } -void TiXmlComment::operator=( const TiXmlComment& base ) +TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base ) { Clear(); base.CopyTo( this ); + return *this; } @@ -1401,10 +1447,11 @@ TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) } -void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) +TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) { Clear(); copy.CopyTo( this ); + return *this; } @@ -1416,32 +1463,17 @@ void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) co if ( !version.empty() ) { if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ()); - if ( str ) - { - (*str) += "version=\""; - (*str) += version; - (*str) += "\" "; - } + if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; } } if ( !encoding.empty() ) { if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); - if ( str ) - { - (*str) += "encoding=\""; - (*str) += encoding; - (*str) += "\" "; - } + if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; } } if ( !standalone.empty() ) { if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); - if ( str ) - { - (*str) += "standalone=\""; - (*str) += standalone; - (*str) += "\" "; - } + if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; } } if ( cfile ) fprintf( cfile, "?>" ); if ( str ) (*str) += "?>"; @@ -1796,9 +1828,9 @@ bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute else { buffer += ">"; - if (element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) { simpleTextPrint = true; // no DoLineBreak()! diff --git a/shared/tinyxml/tinyxml.dsw b/shared/tinyxml/tinyxml.dsw deleted file mode 100644 index 6ff9cfae..00000000 --- a/shared/tinyxml/tinyxml.dsw +++ /dev/null @@ -1,71 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "tinyXmlTest"=.\tinyXmlTest.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name tinyxml - End Project Dependency -}}} - -############################################################################### - -Project: "tinyXmlTestSTL"=.\tinyXmlTestSTL.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name tinyxmlSTL - End Project Dependency -}}} - -############################################################################### - -Project: "tinyxml"=.\tinyxml_lib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "tinyxmlSTL"=.\tinyxmlSTL.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/shared/tinyxml/tinyxml.h b/shared/tinyxml/tinyxml.h index 226415c9..32801d0f 100644 --- a/shared/tinyxml/tinyxml.h +++ b/shared/tinyxml/tinyxml.h @@ -1,6 +1,6 @@ /* www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) +Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -91,7 +91,7 @@ class TiXmlParsingData; const int TIXML_MAJOR_VERSION = 2; const int TIXML_MINOR_VERSION = 6; -const int TIXML_PATCH_VERSION = 1; +const int TIXML_PATCH_VERSION = 2; /* Internal structure for tracking location of items in the XML file. @@ -146,7 +146,7 @@ public: virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } /// Visit a comment node virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } - /// Visit an unknow node + /// Visit an unknown node virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } }; @@ -689,8 +689,8 @@ public: #endif /** Query the type (as an enumerated value, above) of this node. - The possible types are: DOCUMENT, ELEMENT, COMMENT, - UNKNOWN, TEXT, and DECLARATION. + The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, + TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION. */ int Type() const { return type; } @@ -965,7 +965,7 @@ public: TiXmlElement( const TiXmlElement& ); - void operator=( const TiXmlElement& base ); + TiXmlElement& operator=( const TiXmlElement& base ); virtual ~TiXmlElement(); @@ -998,6 +998,13 @@ public: does not exist, then TIXML_NO_ATTRIBUTE is returned. */ int QueryIntAttribute( const char* name, int* _value ) const; + /// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute(). + int QueryUnsignedAttribute( const char* name, unsigned* _value ) const; + /** QueryBoolAttribute examines the attribute - see QueryIntAttribute(). + Note that '1', 'true', or 'yes' are considered true, while '0', 'false' + and 'no' are considered false. + */ + int QueryBoolAttribute( const char* name, bool* _value ) const; /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). int QueryDoubleAttribute( const char* name, double* _value ) const; /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). @@ -1182,7 +1189,7 @@ public: SetValue( _value ); } TiXmlComment( const TiXmlComment& ); - void operator=( const TiXmlComment& base ); + TiXmlComment& operator=( const TiXmlComment& base ); virtual ~TiXmlComment() {} @@ -1196,8 +1203,8 @@ public: */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ @@ -1247,7 +1254,7 @@ public: #endif TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } - void operator=( const TiXmlText& base ) { base.CopyTo( this ); } + TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; } // Write this text object to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; @@ -1314,7 +1321,7 @@ public: const char* _standalone ); TiXmlDeclaration( const TiXmlDeclaration& copy ); - void operator=( const TiXmlDeclaration& copy ); + TiXmlDeclaration& operator=( const TiXmlDeclaration& copy ); virtual ~TiXmlDeclaration() {} @@ -1372,7 +1379,7 @@ public: virtual ~TiXmlUnknown() {} TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } - void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } + TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; } /// Creates a copy of this Unknown and returns it. virtual TiXmlNode* Clone() const; @@ -1381,8 +1388,8 @@ public: virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ @@ -1418,7 +1425,7 @@ public: #endif TiXmlDocument( const TiXmlDocument& copy ); - void operator=( const TiXmlDocument& copy ); + TiXmlDocument& operator=( const TiXmlDocument& copy ); virtual ~TiXmlDocument() {} @@ -1658,7 +1665,7 @@ public: TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } /// Copy constructor TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } - TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } + TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; } /// Return a handle to the first child node. TiXmlHandle FirstChild() const; @@ -1823,4 +1830,3 @@ private: #endif #endif - diff --git a/shared/tinyxml/tinyxml.sln b/shared/tinyxml/tinyxml.sln index 394baf2c..b3a4d3d7 100644 --- a/shared/tinyxml/tinyxml.sln +++ b/shared/tinyxml/tinyxml.sln @@ -1,19 +1,13 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyXmlTest", "tinyXmlTest.vcproj", "{34719950-09E8-457E-BE23-8F1CE3A1F1F6}" - ProjectSection(ProjectDependencies) = postProject - {C406DAEC-0886-4771-8DEA-9D7329B46CC1} = {C406DAEC-0886-4771-8DEA-9D7329B46CC1} - EndProjectSection +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyXmlTest", "tinyXmlTest.vcxproj", "{34719950-09E8-457E-BE23-8F1CE3A1F1F6}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyXmlTestSTL", "tinyXmlTestSTL.vcproj", "{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}" - ProjectSection(ProjectDependencies) = postProject - {A3A84737-5017-4577-B8A2-79429A25B8B6} = {A3A84737-5017-4577-B8A2-79429A25B8B6} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyXmlTestSTL", "tinyXmlTestSTL.vcxproj", "{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml_lib.vcproj", "{C406DAEC-0886-4771-8DEA-9D7329B46CC1}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml_lib.vcxproj", "{C406DAEC-0886-4771-8DEA-9D7329B46CC1}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxmlSTL", "tinyxmlSTL.vcproj", "{A3A84737-5017-4577-B8A2-79429A25B8B6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxmlSTL", "tinyxmlSTL.vcxproj", "{A3A84737-5017-4577-B8A2-79429A25B8B6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/shared/tinyxml/tinyxmlSTL.dsp b/shared/tinyxml/tinyxmlSTL.dsp deleted file mode 100644 index 8f50e449..00000000 --- a/shared/tinyxml/tinyxmlSTL.dsp +++ /dev/null @@ -1,126 +0,0 @@ -# Microsoft Developer Studio Project File - Name="tinyxmlSTL" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=tinyxmlSTL - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "tinyxmlSTL.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "tinyxmlSTL.mak" CFG="tinyxmlSTL - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "tinyxmlSTL - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "tinyxmlSTL - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "tinyxmlSTL - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "tinyxmlSTL___Win32_Release" -# PROP BASE Intermediate_Dir "tinyxmlSTL___Win32_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_STL" -# PROP Intermediate_Dir "Release_STL" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "TIXML_USE_STL" /FR /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Release_STL\tinyxml_STL.lib" - -!ELSEIF "$(CFG)" == "tinyxmlSTL - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "tinyxmlSTL___Win32_Debug0" -# PROP BASE Intermediate_Dir "tinyxmlSTL___Win32_Debug0" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_STL" -# PROP Intermediate_Dir "Debug_STL" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "TIXML_USE_STL" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Debug_STL\tinyxmld_STL.lib" - -!ENDIF - -# Begin Target - -# Name "tinyxmlSTL - Win32 Release" -# Name "tinyxmlSTL - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\tinystr.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxml.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxmlerror.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxmlparser.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\tinystr.h -# End Source File -# Begin Source File - -SOURCE=.\tinyxml.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\changes.txt -# End Source File -# Begin Source File - -SOURCE=.\readme.txt -# End Source File -# End Target -# End Project diff --git a/shared/tinyxml/tinyxmlSTL.vcproj b/shared/tinyxml/tinyxmlSTL.vcproj deleted file mode 100644 index 933dfd67..00000000 --- a/shared/tinyxml/tinyxmlSTL.vcproj +++ /dev/null @@ -1,279 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9.00" - Name="tinyxmlSTL" - ProjectGUID="{A3A84737-5017-4577-B8A2-79429A25B8B6}" - TargetFrameworkVersion="131072" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory=".\Debug_STL" - IntermediateDirectory=".\Debug_STL" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;TIXML_USE_STL;" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - PrecompiledHeaderFile=".\Debug_STL/tinyxmlSTL.pch" - AssemblerListingLocation=".\Debug_STL/" - ObjectFile=".\Debug_STL/" - ProgramDataBaseFileName=".\Debug_STL/" - BrowseInformation="1" - WarningLevel="4" - SuppressStartupBanner="true" - Detect64BitPortabilityProblems="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - OutputFile="Debug_STL\tinyxmld_STL.lib" - SuppressStartupBanner="true" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\Debug_STL/tinyxmlSTL.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory=".\Release_STL" - IntermediateDirectory=".\Release_STL" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB;TIXML_USE_STL" - StringPooling="true" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\Release_STL/tinyxmlSTL.pch" - AssemblerListingLocation=".\Release_STL/" - ObjectFile=".\Release_STL/" - ProgramDataBaseFileName=".\Release_STL/" - BrowseInformation="1" - WarningLevel="3" - SuppressStartupBanner="true" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - OutputFile="Release_STL\tinyxml_STL.lib" - SuppressStartupBanner="true" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\Release_STL/tinyxmlSTL.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - > - <File - RelativePath="tinystr.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="tinyxml.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="tinyxmlerror.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="tinyxmlparser.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - </Filter> - <Filter - Name="Header Files" - > - <File - RelativePath="tinystr.h" - > - </File> - <File - RelativePath="tinyxml.h" - > - </File> - </Filter> - <File - RelativePath="changes.txt" - > - </File> - <File - RelativePath="readme.txt" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/shared/tinyxml/tinyxmlSTL.vcxproj b/shared/tinyxml/tinyxmlSTL.vcxproj new file mode 100644 index 00000000..db7a2fc9 --- /dev/null +++ b/shared/tinyxml/tinyxmlSTL.vcxproj @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{A3A84737-5017-4577-B8A2-79429A25B8B6}</ProjectGuid> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IncludePath)</IncludePath> + <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LibraryPath)</LibraryPath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IncludePath)</IncludePath> + <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LibraryPath)</LibraryPath> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;TIXML_USE_STL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <BrowseInformation>true</BrowseInformation> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Lib> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Lib> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;TIXML_USE_STL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <BrowseInformation>true</BrowseInformation> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Lib> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Lib> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="tinystr.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ClCompile Include="tinyxml.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ClCompile Include="tinyxmlerror.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ClCompile Include="tinyxmlparser.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="tinystr.h" /> + <ClInclude Include="tinyxml.h" /> + </ItemGroup> + <ItemGroup> + <None Include="changes.txt" /> + <None Include="readme.txt" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/shared/tinyxml/tinyxml_lib.dsp b/shared/tinyxml/tinyxml_lib.dsp deleted file mode 100644 index 833d3436..00000000 --- a/shared/tinyxml/tinyxml_lib.dsp +++ /dev/null @@ -1,130 +0,0 @@ -# Microsoft Developer Studio Project File - Name="tinyxml" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=tinyxml - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "tinyxml_lib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "tinyxml_lib.mak" CFG="tinyxml - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "tinyxml - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "tinyxml - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "tinyxml - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Release\tinyxml.lib" - -!ELSEIF "$(CFG)" == "tinyxml - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Debug\tinyxmld.lib" - -!ENDIF - -# Begin Target - -# Name "tinyxml - Win32 Release" -# Name "tinyxml - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\tinystr.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxml.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxmlerror.cpp -# End Source File -# Begin Source File - -SOURCE=.\tinyxmlparser.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\tinystr.h -# End Source File -# Begin Source File - -SOURCE=.\tinyxml.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\changes.txt -# End Source File -# Begin Source File - -SOURCE=.\readme.txt -# End Source File -# Begin Source File - -SOURCE=.\tutorial_gettingStarted.txt -# End Source File -# End Target -# End Project diff --git a/shared/tinyxml/tinyxml_lib.vcproj b/shared/tinyxml/tinyxml_lib.vcproj deleted file mode 100644 index 41a9266b..00000000 --- a/shared/tinyxml/tinyxml_lib.vcproj +++ /dev/null @@ -1,284 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9.00" - Name="tinyxml" - ProjectGUID="{C406DAEC-0886-4771-8DEA-9D7329B46CC1}" - TargetFrameworkVersion="131072" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Release|Win32" - OutputDirectory=".\Release" - IntermediateDirectory=".\Release" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB" - StringPooling="true" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\Release/tinyxml_lib.pch" - AssemblerListingLocation=".\Release/" - ObjectFile=".\Release/" - ProgramDataBaseFileName=".\Release/" - WarningLevel="3" - SuppressStartupBanner="true" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1031" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - OutputFile="Release\tinyxml.lib" - SuppressStartupBanner="true" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\Release/tinyxml_lib.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Debug|Win32" - OutputDirectory=".\Debug" - IntermediateDirectory=".\Debug" - ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - PrecompiledHeaderFile=".\Debug/tinyxml_lib.pch" - AssemblerListingLocation=".\Debug/" - ObjectFile=".\Debug/" - ProgramDataBaseFileName=".\Debug/" - BrowseInformation="1" - WarningLevel="4" - SuppressStartupBanner="true" - Detect64BitPortabilityProblems="false" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1031" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - OutputFile="Debug\tinyxmld.lib" - SuppressStartupBanner="true" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\Debug/tinyxml_lib.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" - > - <File - RelativePath="tinystr.cpp" - > - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="tinyxml.cpp" - > - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="tinyxmlerror.cpp" - > - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="tinyxmlparser.cpp" - > - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl" - > - <File - RelativePath="tinystr.h" - > - </File> - <File - RelativePath="tinyxml.h" - > - </File> - </Filter> - <File - RelativePath="changes.txt" - > - </File> - <File - RelativePath="readme.txt" - > - </File> - <File - RelativePath="tutorial_gettingStarted.txt" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/shared/tinyxml/tinyxml_lib.vcxproj b/shared/tinyxml/tinyxml_lib.vcxproj new file mode 100644 index 00000000..0da3981a --- /dev/null +++ b/shared/tinyxml/tinyxml_lib.vcxproj @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectName>tinyxml</ProjectName> + <ProjectGuid>{C406DAEC-0886-4771-8DEA-9D7329B46CC1}</ProjectGuid> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IncludePath)</IncludePath> + <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LibraryPath)</LibraryPath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IncludePath)</IncludePath> + <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LibraryPath)</LibraryPath> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)$(ProjectName)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0407</Culture> + </ResourceCompile> + <Lib> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Lib> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <BrowseInformation>true</BrowseInformation> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0407</Culture> + </ResourceCompile> + <Lib> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Lib> + <Bscmake> + <SuppressStartupBanner>true</SuppressStartupBanner> + </Bscmake> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="tinystr.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ClCompile Include="tinyxml.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ClCompile Include="tinyxmlerror.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <ClCompile Include="tinyxmlparser.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="tinystr.h" /> + <ClInclude Include="tinyxml.h" /> + </ItemGroup> + <ItemGroup> + <None Include="changes.txt" /> + <None Include="readme.txt" /> + <None Include="tutorial_gettingStarted.txt" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/shared/tinyxml/tinyxmlerror.cpp b/shared/tinyxml/tinyxmlerror.cpp index 3034074b..12d90c2a 100644 --- a/shared/tinyxml/tinyxmlerror.cpp +++ b/shared/tinyxml/tinyxmlerror.cpp @@ -31,7 +31,7 @@ distribution. // It also cleans up the code a bit. // -const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = +const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] = { "No error", "Error", diff --git a/shared/tinyxml/tinyxmlparser.cpp b/shared/tinyxml/tinyxmlparser.cpp index ea691fd4..6b21a2b5 100644 --- a/shared/tinyxml/tinyxmlparser.cpp +++ b/shared/tinyxml/tinyxmlparser.cpp @@ -1,6 +1,6 @@ /* www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) +Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -40,7 +40,7 @@ distribution. // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries // or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = +TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] = { { "&", 5, '&' }, { "<", 4, '<' }, @@ -100,10 +100,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng else if ( input < 0x200000 ) *length = 4; else - { - *length = 0; // This code won't covert this correctly anyway. - return; - } + { *length = 0; return; } // This code won't covert this correctly anyway. output += *length; @@ -177,10 +174,7 @@ class TiXmlParsingData public: void Stamp( const char* now, TiXmlEncoding encoding ); - const TiXmlCursor& Cursor() - { - return cursor; - } + const TiXmlCursor& Cursor() const { return cursor; } private: // Only used by the document! @@ -281,10 +275,7 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) p += 3; else - { - p +=3; // A normal character. - ++col; - } + { p +=3; ++col; } // A normal character. } } else @@ -425,8 +416,8 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING* name, TiXmlEncodin // After that, they can be letters, underscores, numbers, // hyphens, or colons. (Colons are valid ony for namespaces, // but tinyxml can't tell namespaces from names.) - if (p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) + if ( p && *p + && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) { const char* start = p; while( p && *p @@ -592,8 +583,8 @@ const char* TiXmlBase::ReadText( const char* p, TiXmlEncoding encoding ) { *text = ""; - if (!trimWhiteSpace // certain tags always keep whitespace - || !condenseWhiteSpace ) // if true, whitespace is always kept + if ( !trimWhiteSpace // certain tags always keep whitespace + || !condenseWhiteSpace ) // if true, whitespace is always kept { // Keep all the white space. while ( p && *p @@ -646,7 +637,7 @@ const char* TiXmlBase::ReadText( const char* p, } if ( p && *p ) p += strlen( endTag ); - return p; + return ( p && *p ) ? p : 0; } #ifdef TIXML_USE_STL @@ -778,8 +769,8 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX } // Did we get encoding info? - if (encoding == TIXML_ENCODING_UNKNOWN - && node->ToDeclaration() ) + if ( encoding == TIXML_ENCODING_UNKNOWN + && node->ToDeclaration() ) { TiXmlDeclaration* dec = node->ToDeclaration(); const char* enc = dec->Encoding(); @@ -888,8 +879,8 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) #endif returnNode = new TiXmlUnknown(); } - else if (IsAlpha( *(p+1), encoding ) - || *(p+1) == '_' ) + else if ( IsAlpha( *(p+1), encoding ) + || *(p+1) == '_' ) { #ifdef DEBUG_PARSER TIXML_LOG( "XML parsing Element\n" ); @@ -939,8 +930,8 @@ void TiXmlElement::StreamIn (std::istream* in, TIXML_STRING* tag) // Okay...if we are a "/>" tag, then we're done. We've read a complete tag. // If not, identify and stream. - if (tag->at( tag->length() - 1 ) == '>' - && tag->at( tag->length() - 2 ) == '/' ) + if ( tag->at( tag->length() - 1 ) == '>' + && tag->at( tag->length() - 2 ) == '/' ) { // All good! return; @@ -1315,9 +1306,10 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p ) { - if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding ); + if ( document ) + document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding ); } - if ( *p == '>' ) + if ( p && *p == '>' ) return p+1; return p; } @@ -1367,7 +1359,8 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !StringEqual( p, startTag, false, encoding ) ) { - document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); + if ( document ) + document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); return 0; } p += strlen( startTag ); @@ -1532,7 +1525,8 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi if ( !StringEqual( p, startTag, false, encoding ) ) { - document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + if ( document ) + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); return 0; } p += strlen( startTag ); @@ -1556,7 +1550,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi const char* end = "<"; p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p ) + if ( p && *p ) return p-1; // don't truncate the '<' return 0; } diff --git a/shared/tinyxml/xmltest.cpp b/shared/tinyxml/xmltest.cpp index b4d3551c..7d920466 100644 --- a/shared/tinyxml/xmltest.cpp +++ b/shared/tinyxml/xmltest.cpp @@ -69,6 +69,19 @@ bool XmlTest( const char* testString, int expected, int found, bool noEcho ) } +void NullLineEndings( char* p ) +{ + while( p && *p ) + { + if ( *p == '\n' || *p == '\r' ) + { + *p = 0; + return; + } + ++p; + } +} + // // This file demonstrates some basic functionality of TinyXml. // Note that the example is very contrived. It presumes you know @@ -590,20 +603,30 @@ int main() FILE* saved = fopen( "utf8testout.xml", "r" ); FILE* verify = fopen( "utf8testverify.xml", "r" ); + + //bool firstLineBOM=true; if ( saved && verify ) { while ( fgets( verifyBuf, 256, verify ) ) { fgets( savedBuf, 256, saved ); - if ( strcmp( verifyBuf, savedBuf ) ) + NullLineEndings( verifyBuf ); + NullLineEndings( savedBuf ); + + if ( /*!firstLineBOM && */ strcmp( verifyBuf, savedBuf ) ) { + printf( "verify:%s<\n", verifyBuf ); + printf( "saved :%s<\n", savedBuf ); okay = 0; break; } + //firstLineBOM = false; } + } + if ( saved ) fclose( saved ); + if ( verify ) fclose( verify ); - } XmlTest( "UTF-8: Verified multi-language round trip.", 1, okay ); // On most Western machines, this is an element that contains @@ -1327,6 +1350,13 @@ int main() } { + // This one must not result in an infinite loop + TiXmlDocument xml; + xml.Parse( "<infinite>loop" ); + XmlTest( "Infinite loop test.", true, true ); + } + + { // 1709904 - can not repro the crash { TiXmlDocument xml; @@ -1355,6 +1385,7 @@ int main() xml.Print(stdout); } */ + #if defined( WIN32 ) && defined( TUNE ) _CrtMemCheckpoint( &endMemState ); //_CrtMemDumpStatistics( &endMemState ); diff --git a/shared/util.cpp b/shared/util.cpp index 7ab5b4e7..ab0b5a44 100644 --- a/shared/util.cpp +++ b/shared/util.cpp @@ -13,17 +13,18 @@ #include "file_handling.h" #include "string_conv.h" #include <stdexcept> -#include "system_func.h" +#include "last_error.h" #include "check_exist.h" #include "assert_static.h" #include "system_constants.h" +#include "global_func.h" #ifdef FFS_WIN #include <wx/msw/wrapwin.h> //includes "windows.h" #endif -wxString ffs3::extractJobName(const wxString& configFilename) +wxString zen::extractJobName(const wxString& configFilename) { using namespace common; @@ -33,29 +34,22 @@ wxString ffs3::extractJobName(const wxString& configFilename) } -wxString ffs3::formatFilesizeToShortString(const wxLongLong& filesize) +wxString zen::formatFilesizeToShortString(zen::UInt64 size) { - return ffs3::formatFilesizeToShortString(filesize.ToDouble()); -} - - -wxString ffs3::formatFilesizeToShortString(const wxULongLong& filesize) -{ - return ffs3::formatFilesizeToShortString(filesize.ToDouble()); -} - + if (to<zen::Int64>(size) < 0) return _("Error"); -wxString ffs3::formatFilesizeToShortString(double filesize) -{ - if (filesize < 0) - return _("Error"); - - wxString output = _("%x Bytes"); - - if (filesize > 999) + if (size <= 999U) { + wxString output = _P("1 Byte", "%x Bytes", to<int>(size)); + output.Replace(wxT("%x"), zen::toStringSep(size)); //no decimal places in case of bytes + return output; + } + else + { + double filesize = to<double>(size); + filesize /= 1024; - output = _("%x kB"); + wxString output = _("%x KB"); if (filesize > 999) { filesize /= 1024; @@ -82,19 +76,14 @@ wxString ffs3::formatFilesizeToShortString(double filesize) return _("Error"); output.Replace(wxT("%x"), wxString::Format(wxT("%.*f"), static_cast<int>(3 - leadDigitCount), filesize)); + return output; } - else - { - output.Replace(wxT("%x"), common::numberToString(static_cast<int>(filesize))); //no decimal places in case of bytes - } - - return output; } -wxString ffs3::formatPercentage(const wxLongLong& dividend, const wxLongLong& divisor) +wxString zen::formatPercentage(zen::Int64 dividend, zen::Int64 divisor) { - const double ratio = divisor != 0 ? dividend.ToDouble() * 100 / divisor.ToDouble() : 0; + const double ratio = divisor != 0 ? to<double>(dividend) * 100.0 / to<double>(divisor) : 0; wxString output = _("%x%"); output.Replace(wxT("%x"), wxString::Format(wxT("%3.2f"), ratio), false); return output; @@ -105,13 +94,13 @@ wxString ffs_Impl::includeNumberSeparator(const wxString& number) { wxString output(number); for (size_t i = output.size(); i > 3; i -= 3) - output.insert(i - 3, ffs3::getThousandsSeparator()); + output.insert(i - 3, zen::getThousandsSeparator()); return output; } -void ffs3::scrollToBottom(wxScrolledWindow* scrWindow) +void zen::scrollToBottom(wxScrolledWindow* scrWindow) { int height = 0; scrWindow->GetClientSize(NULL, &height); @@ -149,28 +138,28 @@ bool isVistaOrLater() } -wxString ffs3::utcTimeToLocalString(const wxLongLong& utcTime) +wxString zen::utcTimeToLocalString(zen::Int64 utcTime) { #ifdef FFS_WIN //convert ansi C time to FILETIME - wxLongLong fileTimeLong(utcTime); - fileTimeLong += wxLongLong(2, 3054539008UL); //timeshift between ansi C time and FILETIME in seconds == 11644473600s - fileTimeLong *= 10000000; + zen::UInt64 fileTimeLong = to<zen::UInt64>(utcTime + //may be < 0 + zen::Int64(3054539008UL, 2)); //timeshift between ansi C time and FILETIME in seconds == 11644473600s + fileTimeLong *= 10000000U; FILETIME lastWriteTimeUtc = {}; - lastWriteTimeUtc.dwLowDateTime = fileTimeLong.GetLo(); //GetLo() returns unsigned - lastWriteTimeUtc.dwHighDateTime = static_cast<DWORD>(fileTimeLong.GetHi()); //GetHi() returns signed + lastWriteTimeUtc.dwLowDateTime = fileTimeLong.getLo(); + lastWriteTimeUtc.dwHighDateTime = fileTimeLong.getHi(); - assert(fileTimeLong.GetHi() >= 0); - assert_static(sizeof(DWORD) == sizeof(long)); - assert_static(sizeof(long) == 4); + //dates less than a few (let's say 13) hours after 1.1.1601 cause conversion errors in ::SystemTimeToTzSpecificLocalTime() if timezone is subtracted! + if (lastWriteTimeUtc.dwHighDateTime < 110) + return _("Error"); SYSTEMTIME systemTimeLocal = {}; static const bool useNewLocalTimeCalculation = isVistaOrLater(); if (useNewLocalTimeCalculation) //use DST setting from source date (like in Windows 7, see http://msdn.microsoft.com/en-us/library/ms724277(VS.85).aspx) { - if (lastWriteTimeUtc.dwHighDateTime > 0x7FFFFFFF) + if (lastWriteTimeUtc.dwHighDateTime >= 0x80000000) return _("Error"); SYSTEMTIME systemTimeUtc = {}; @@ -178,7 +167,8 @@ wxString ffs3::utcTimeToLocalString(const wxLongLong& utcTime) &lastWriteTimeUtc, //__in const FILETIME *lpFileTime, &systemTimeUtc)) //__out LPSYSTEMTIME lpSystemTime throw std::runtime_error(std::string((wxString(_("Conversion error:")) + wxT(" FILETIME -> SYSTEMTIME: ") + - wxT("(") + wxULongLong(lastWriteTimeUtc.dwHighDateTime, lastWriteTimeUtc.dwLowDateTime).ToString() + wxT(") ") + + wxT("(") + wxT("UTC [s]: ") + toString<wxString>(utcTime) + wxT(" ") + + wxT("UTC FILETIME: ") + toString<wxString>(fileTimeLong) + wxT(") ") + wxT("\n\n") + getLastErrorFormatted()).ToAscii())); if (!::SystemTimeToTzSpecificLocalTime( @@ -186,29 +176,39 @@ wxString ffs3::utcTimeToLocalString(const wxLongLong& utcTime) &systemTimeUtc, //__in LPSYSTEMTIME lpUniversalTime, &systemTimeLocal)) //__out LPSYSTEMTIME lpLocalTime throw std::runtime_error(std::string((wxString(_("Conversion error:")) + wxT(" SYSTEMTIME -> local SYSTEMTIME: ") + - wxT("(") + wxULongLong(lastWriteTimeUtc.dwHighDateTime, lastWriteTimeUtc.dwLowDateTime).ToString() + wxT(") ") + + wxT("(") + wxT("UTC [s]: ") + toString<wxString>(utcTime) + wxT("\n") + + wxT("UTC System time: ") + + toString<wxString>(systemTimeUtc.wYear) + wxT(" ") + + toString<wxString>(systemTimeUtc.wMonth) + wxT(" ") + + toString<wxString>(systemTimeUtc.wDay) + wxT(" ") + + toString<wxString>(systemTimeUtc.wHour) + wxT(" ") + + toString<wxString>(systemTimeUtc.wMinute) + wxT(" ") + + toString<wxString>(systemTimeUtc.wSecond) + wxT(")") + wxT("\n\n") + getLastErrorFormatted()).ToAscii())); } - else //use current DST setting (like in Windows 2000 and XP) + else //use DST setting (like in Windows 2000 and XP) { FILETIME fileTimeLocal = {}; if (!::FileTimeToLocalFileTime( //convert to local time &lastWriteTimeUtc, //pointer to UTC file time to convert &fileTimeLocal)) //pointer to converted file time throw std::runtime_error(std::string((wxString(_("Conversion error:")) + wxT(" FILETIME -> local FILETIME: ") + - wxT("(") + wxULongLong(lastWriteTimeUtc.dwHighDateTime, lastWriteTimeUtc.dwLowDateTime).ToString() + wxT(") ") + + wxT("(") + wxT("UTC [s]: ") + toString<wxString>(utcTime) + wxT(" ") + + wxT("UTC FILETIME: ") + toString<wxString>(fileTimeLong) + wxT(") ") + wxT("\n\n") + getLastErrorFormatted()).ToAscii())); - if (fileTimeLocal.dwHighDateTime > 0x7FFFFFFF) + if (fileTimeLocal.dwHighDateTime >= 0x80000000) return _("Error"); //this actually CAN happen if UTC time is just below this border and ::FileTimeToLocalFileTime() adds 2 hours due to DST or whatever! //Testcase (UTC): dateHigh = 2147483647 (=0x7fffffff) -> year 30000 // dateLow = 4294967295 - if (!::FileTimeToSystemTime( - &fileTimeLocal, //pointer to file time to convert - &systemTimeLocal)) //pointer to structure to receive system time + if (!::FileTimeToSystemTime(&fileTimeLocal, //pointer to file time to convert + &systemTimeLocal)) //pointer to structure to receive system time throw std::runtime_error(std::string((wxString(_("Conversion error:")) + wxT(" local FILETIME -> local SYSTEMTIME: ") + - wxT("(") + wxULongLong(fileTimeLocal.dwHighDateTime, fileTimeLocal.dwLowDateTime).ToString() + wxT(") ") + + wxT("(") + wxT("UTC [s]: ") + toString<wxString>(utcTime) + wxT(" ") + + wxT("local FILETIME: ") + + wxT("High: ") + toString<wxString>(fileTimeLocal.dwHighDateTime) + + wxT("Low: ") + toString<wxString>(fileTimeLocal.dwLowDateTime) + wxT(") ") + wxT("\n\n") + getLastErrorFormatted()).ToAscii())); } @@ -220,9 +220,8 @@ wxString ffs3::utcTimeToLocalString(const wxLongLong& utcTime) systemTimeLocal.wSecond); #elif defined FFS_LINUX - tm* timeinfo; - const time_t fileTime = utcTime.ToLong(); - timeinfo = localtime(&fileTime); //convert to local time + const time_t fileTime = to<time_t>(utcTime); + const tm* timeinfo = ::localtime(&fileTime); //convert to local time /* char buffer[50]; diff --git a/shared/util.h b/shared/util.h index 90a73094..2c9af176 100644 --- a/shared/util.h +++ b/shared/util.h @@ -8,31 +8,45 @@ #define UTIL_H_INCLUDED #include <wx/string.h> -#include <wx/longlong.h> #include <wx/textctrl.h> #include <wx/filepicker.h> #include <wx/combobox.h> #include <wx/scrolwin.h> +#include <wx/choice.h> #include "zstring.h" -#include "global_func.h" +#include "string_tools.h" +#include "int64.h" - -namespace ffs3 +namespace zen { wxString extractJobName(const wxString& configFilename); -wxString formatFilesizeToShortString(const wxLongLong& filesize); -wxString formatFilesizeToShortString(const wxULongLong& filesize); -wxString formatFilesizeToShortString(double filesize); - -wxString formatPercentage(const wxLongLong& dividend, const wxLongLong& divisor); +wxString formatFilesizeToShortString(zen::UInt64 filesize); +wxString formatPercentage(zen::Int64 dividend, zen::Int64 divisor); template <class NumberType> -wxString numberToStringSep(NumberType number); //convert number to wxString including thousands separator +wxString toStringSep(NumberType number); //convert number to wxString including thousands separator void scrollToBottom(wxScrolledWindow* scrWindow); -wxString utcTimeToLocalString(const wxLongLong& utcTime); //throw std::runtime_error +wxString utcTimeToLocalString(zen::Int64 utcTime); //throw std::runtime_error + + +//handle mapping of enum values to wxChoice controls +template <class Enum> +struct EnumDescrList +{ + EnumDescrList& add(Enum value, const wxString& text, const wxString& tooltip = wxEmptyString) + { + descrList.push_back(std::make_pair(value, std::make_pair(text, tooltip))); + return *this; + } + typedef std::vector<std::pair<Enum, std::pair<wxString, wxString> > > DescrList; + DescrList descrList; +}; +template <class Enum> void setEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl, Enum value); +template <class Enum> Enum getEnumVal(const EnumDescrList<Enum>& mapping, const wxChoice& ctrl); +template <class Enum> void updateTooltipEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl); } @@ -69,23 +83,59 @@ wxString includeNumberSeparator(const wxString& number); } -namespace ffs3 +namespace zen { -//wxULongLongNative doesn't support operator<<(std::ostream&, wxULongLongNative) -template <> +template <class NumberType> inline -wxString numberToStringSep(wxULongLongNative number) +wxString toStringSep(NumberType number) { - return ffs_Impl::includeNumberSeparator(number.ToString()); + return ffs_Impl::includeNumberSeparator(zen::toString<wxString>(number)); } +template <class Enum> +void setEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl, Enum value) +{ + ctrl.Clear(); + + int selectedPos = 0; + for (typename EnumDescrList<Enum>::DescrList::const_iterator i = mapping.descrList.begin(); i != mapping.descrList.end(); ++i) + { + ctrl.Append(i->second.first); + if (i->first == value) + { + selectedPos = i - mapping.descrList.begin(); + + if (!i->second.second.empty()) + ctrl.SetToolTip(i->second.second); + } + } + + ctrl.SetSelection(selectedPos); +} -template <class NumberType> -inline -wxString numberToStringSep(NumberType number) +template <class Enum> +Enum getEnumVal(const EnumDescrList<Enum>& mapping, const wxChoice& ctrl) { - return ffs_Impl::includeNumberSeparator(common::numberToString(number)); + const int selectedPos = ctrl.GetSelection(); + + if (0 <= selectedPos && selectedPos < static_cast<int>(mapping.descrList.size())) + return mapping.descrList[selectedPos].first; + else + { + assert(false); + return Enum(0); + } } + +template <class Enum> void updateTooltipEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl) +{ + const Enum value = getEnumVal(mapping, ctrl); + + for (typename EnumDescrList<Enum>::DescrList::const_iterator i = mapping.descrList.begin(); i != mapping.descrList.end(); ++i) + if (i->first == value) + ctrl.SetToolTip(i->second.second); +} + } diff --git a/shared/xml_base.cpp b/shared/xml_base.cpp index 3f2a9e48..efed738a 100644 --- a/shared/xml_base.cpp +++ b/shared/xml_base.cpp @@ -9,30 +9,10 @@ #include "i18n.h" #include "string_conv.h" #include "system_constants.h" -#include <boost/scoped_array.hpp> #include "file_handling.h" -using namespace ffs3; - - -std::string getTypeName(xmlAccess::XmlType type) -{ - switch (type) - { - case xmlAccess::XML_GUI_CONFIG: - return "GUI"; - case xmlAccess::XML_BATCH_CONFIG: - return "BATCH"; - case xmlAccess::XML_GLOBAL_SETTINGS: - return "GLOBAL"; - case xmlAccess::XML_REAL_CONFIG: - return "REAL"; - case xmlAccess::XML_OTHER: - break; - } - assert(false); - return "OTHER"; -} +using namespace zen; +using namespace xmlAccess; namespace @@ -44,9 +24,9 @@ void normalize(std::vector<char>& stream) for (std::vector<char>::const_iterator i = stream.begin(); i != stream.end(); ++i) switch (*i) { - case 0xD: - tmp.push_back(0xA); - if (i + 1 != stream.end() && *(i + 1) == 0xA) + case '\xD': + tmp.push_back('\xA'); + if (i + 1 != stream.end() && *(i + 1) == '\xA') ++i; break; default: @@ -57,105 +37,55 @@ void normalize(std::vector<char>& stream) } -void loadRawXmlDocument(const wxString& filename, TiXmlDocument& document) //throw XmlError() +void parseRawXmlDocument(const wxString& filename, TiXmlDocument& document) //throw XmlError() { - using xmlAccess::XmlError; - - const size_t BUFFER_SIZE = 2 * 1024 * 1024; //maximum size of a valid FreeFileSync XML file! - - std::vector<char> inputBuffer; - inputBuffer.resize(BUFFER_SIZE); + const zen::UInt64 fs = zen::getFilesize(wxToZ(filename)); try { + { + //quick test whether input is an XML: avoid loading large binary files up front! + std::string xmlBegin = "<?xml version="; + std::vector<char> buffer(xmlBegin.size()); + + FileInput inputFile(wxToZ(filename)); //throw (FileError); + const size_t bytesRead = inputFile.read(&buffer[0], buffer.size()); //throw (FileError) + if (bytesRead < xmlBegin.size() || !std::equal(buffer.begin(), buffer.end(), xmlBegin.begin())) + throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"")); + } + + std::vector<char> buffer(to<size_t>(fs) + 1); //inc. null-termination (already set!) + FileInput inputFile(wxToZ(filename)); //throw (FileError); - const size_t bytesRead = inputFile.read(&inputBuffer[0], inputBuffer.size()); //throw (FileError) + const size_t bytesRead = inputFile.read(&buffer[0], to<size_t>(fs)); //throw (FileError) + if (bytesRead < to<size_t>(fs)) + { + wxString errorMessage = wxString(_("Error reading file:")) + wxT("\n\"") + filename + wxT("\""); + throw XmlError(errorMessage + wxT("\n\n")); + } - if (bytesRead == 0 || bytesRead >= inputBuffer.size()) //treat XML files larger than 2 MB as erroneous: loading larger files just wastes CPU + memory - throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"")); + //convert (0xD, 0xA) and (0xD) to (0xA): just like in TiXmlDocument::LoadFile(); not sure if actually needed + normalize(buffer); - inputBuffer.resize(bytesRead + 1); - inputBuffer[bytesRead] = 0; //set null-termination!!!! + document.Parse(&buffer[0], 0, TIXML_ENCODING_UTF8); //respect null-termination! } catch (const FileError& error) //more detailed error messages than with wxWidgets { throw XmlError(error.msg()); } - - //convert (0xD, 0xA) and (0xD) to (0xA): just like in TiXmlDocument::LoadFile(); not sure if actually needed - normalize(inputBuffer); - - document.Parse(&inputBuffer[0], 0, TIXML_DEFAULT_ENCODING); //respect null-termination! - - TiXmlElement* root = document.RootElement(); - - if (root && (root->ValueStr() == std::string("FreeFileSync"))) //check for FFS configuration xml - return; //finally... success! - - throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"")); } } -xmlAccess::XmlType xmlAccess::getXmlType(const wxString& filename) //throw() -{ - try - { - TiXmlDocument doc; - ::loadRawXmlDocument(filename, doc); //throw XmlError() - - TiXmlElement* root = doc.RootElement(); - if (root) - { - const char* cfgType = root->Attribute("XmlType"); - if (cfgType) - { - const std::string type(cfgType); - - if (type == getTypeName(XML_GUI_CONFIG)) - return XML_GUI_CONFIG; - else if (type == getTypeName(XML_BATCH_CONFIG)) - return XML_BATCH_CONFIG; - else if (type == getTypeName(XML_GLOBAL_SETTINGS)) - return XML_GLOBAL_SETTINGS; - else if (type == getTypeName(XML_REAL_CONFIG)) - return XML_REAL_CONFIG; - } - } - } - catch (const XmlError&) {} - - return XML_OTHER; -} - - -void xmlAccess::loadXmlDocument(const wxString& filename, const xmlAccess::XmlType type, TiXmlDocument& document) //throw XmlError() +void xmlAccess::loadXmlDocument(const wxString& filename, TiXmlDocument& document) //throw XmlError() { TiXmlBase::SetCondenseWhiteSpace(false); //do not condense whitespace characters - ::loadRawXmlDocument(filename, document); //throw XmlError() + ::parseRawXmlDocument(filename, document); //throw XmlError() TiXmlElement* root = document.RootElement(); - if (root) - { - const char* cfgType = root->Attribute("XmlType"); - if (cfgType && std::string(cfgType) == getTypeName(type)) - return; //finally... success! - } - - throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"")); -} - - -void xmlAccess::getDefaultXmlDocument(const XmlType type, TiXmlDocument& document) -{ - TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", ""); //delete won't be necessary later; ownership passed to TiXmlDocument! - document.LinkEndChild(decl); - - TiXmlElement* root = new TiXmlElement("FreeFileSync"); - root->SetAttribute("XmlType", getTypeName(type)); //xml configuration type - - document.LinkEndChild(root); + if (!root) + throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"")); } @@ -165,18 +95,18 @@ bool saveNecessary(const Zstring& filename, const std::string& dataToWrite) //th { try { - if (ffs3::getFilesize(filename) != static_cast<unsigned long>(dataToWrite.size())) //throw (FileError); + if (zen::getFilesize(filename) != static_cast<unsigned long>(dataToWrite.size())) //throw (FileError); return true; - boost::scoped_array<char> inputBuffer(new char[dataToWrite.size() + 1]); //+ 1 in order to test for end of file! + std::vector<char> inputBuffer(dataToWrite.size() + 1); //+ 1 in order to test for end of file! FileInput inputFile(filename); //throw (FileError); - const size_t bytesRead = inputFile.read(inputBuffer.get(), dataToWrite.size() + 1); //throw (FileError) + const size_t bytesRead = inputFile.read(&inputBuffer[0], inputBuffer.size()); //throw (FileError) if (bytesRead != dataToWrite.size()) //implicit test for eof! return true; - return ::memcmp(inputBuffer.get(), dataToWrite.c_str(), dataToWrite.size()) != 0; + return ::memcmp(&inputBuffer[0], dataToWrite.c_str(), dataToWrite.size()) != 0; } catch (const FileError&) { @@ -260,21 +190,21 @@ bool xmlAccess::readXmlElement(const std::string& name, const TiXmlElement* pare { if (parent) { - output.clear(); - //load elements - const TiXmlElement* element = parent->FirstChildElement(name); - while (element) + const TiXmlElement* xmlList = parent->FirstChildElement(name); + if (xmlList) { - const char* text = element->GetText(); - if (text) //may be NULL!! - output.push_back(wxString::FromUTF8(text)); - else - output.push_back(wxEmptyString); - - element = element->NextSiblingElement(); + output.clear(); + for (const TiXmlElement* item = xmlList->FirstChildElement("Item"); item != NULL; item = item->NextSiblingElement()) + { + const char* text = item->GetText(); + if (text) //may be NULL!! + output.push_back(wxString::FromUTF8(text)); + else + output.push_back(wxEmptyString); + } + return true; } - return true; } return false; @@ -351,8 +281,14 @@ void xmlAccess::addXmlElement(const std::string& name, const bool value, TiXmlEl void xmlAccess::addXmlElement(const std::string& name, const std::vector<wxString>& value, TiXmlElement* parent) { - for (std::vector<wxString>::const_iterator i = value.begin(); i != value.end(); ++i) - addXmlElement(name, std::string(i->ToUTF8()), parent); + if (parent) + { + TiXmlElement* xmlList= new TiXmlElement(name); + parent->LinkEndChild(xmlList); + + for (std::vector<wxString>::const_iterator i = value.begin(); i != value.end(); ++i) + addXmlElement("Item", std::string(i->ToUTF8()), xmlList); + } } @@ -378,21 +314,15 @@ void xmlAccess::addXmlAttribute(const std::string& name, const bool value, TiXml } -using xmlAccess::XmlParser; +using xmlAccess::XmlErrorLogger; -void XmlParser::logError(const std::string& nodeName) +void XmlErrorLogger::logError(const std::string& nodeName) { failedNodes.push_back(wxString::FromUTF8(nodeName.c_str())); } -bool XmlParser::errorsOccurred() const -{ - return !failedNodes.empty(); -} - - -const wxString XmlParser::getErrorMessageFormatted() const +const wxString XmlErrorLogger::getErrorMessageFormatted() const { wxString errorMessage = wxString(_("Could not read values for the following XML nodes:")) + wxT("\n"); for (std::vector<wxString>::const_iterator i = failedNodes.begin(); i != failedNodes.end(); ++i) diff --git a/shared/xml_base.h b/shared/xml_base.h index 44650ec9..337bfbd8 100644 --- a/shared/xml_base.h +++ b/shared/xml_base.h @@ -7,33 +7,33 @@ #ifndef XMLBASE_H_INCLUDED #define XMLBASE_H_INCLUDED -#include "tinyxml/tinyxml.h" -#include "global_func.h" #include <string> #include <vector> +#include "tinyxml/tinyxml.h" +#include "string_tools.h" #include <wx/string.h> #include "xml_error.h" namespace xmlAccess { +/* Init XML document: -enum XmlType -{ - XML_GUI_CONFIG, - XML_BATCH_CONFIG, - XML_GLOBAL_SETTINGS, - XML_REAL_CONFIG, - XML_OTHER -}; - -XmlType getXmlType(const wxString& filename); //throw() + TiXmlDocument doc; + TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", ""); + doc.LinkEndChild(decl); //ownership passed -void loadXmlDocument(const wxString& fileName, const XmlType type, TiXmlDocument& document); //throw (XmlError) -void getDefaultXmlDocument(const XmlType type, TiXmlDocument& document); + TiXmlElement* root = new TiXmlElement("HeaderName"); + doc.LinkEndChild(root); +*/ +void loadXmlDocument(const wxString& fileName, TiXmlDocument& document); //throw (XmlError) void saveXmlDocument(const wxString& fileName, const TiXmlDocument& document); //throw (XmlError) +#ifndef TIXML_USE_STL +#error we need this macro +#endif + //------------------------------------------------------------------------------------------ //small helper functions @@ -44,13 +44,6 @@ bool readXmlElement(const std::string& name, const TiXmlElement* parent, wxStrin bool readXmlElement(const std::string& name, const TiXmlElement* parent, bool& output); bool readXmlElement(const std::string& name, const TiXmlElement* parent, std::vector<wxString>& output); - -template <class T> -bool readXmlAttribute(const std::string& name, const TiXmlElement* node, T& output); -bool readXmlAttribute(const std::string& name, const TiXmlElement* node, std::string& output); -bool readXmlAttribute(const std::string& name, const TiXmlElement* node, wxString& output); -bool readXmlAttribute(const std::string& name, const TiXmlElement* node, bool& output); - template <class T> void addXmlElement(const std::string& name, T value, TiXmlElement* parent); void addXmlElement(const std::string& name, const std::string& value, TiXmlElement* parent); @@ -59,6 +52,12 @@ void addXmlElement(const std::string& name, const bool value, TiXmlEleme void addXmlElement(const std::string& name, const std::vector<wxString>& value, TiXmlElement* parent); template <class T> +bool readXmlAttribute(const std::string& name, const TiXmlElement* node, T& output); +bool readXmlAttribute(const std::string& name, const TiXmlElement* node, std::string& output); +bool readXmlAttribute(const std::string& name, const TiXmlElement* node, wxString& output); +bool readXmlAttribute(const std::string& name, const TiXmlElement* node, bool& output); + +template <class T> void addXmlAttribute(const std::string& name, T value, TiXmlElement* node); void addXmlAttribute(const std::string& name, const std::string& value, TiXmlElement* node); void addXmlAttribute(const std::string& name, const wxString& value, TiXmlElement* node); @@ -66,16 +65,15 @@ void addXmlAttribute(const std::string& name, const bool value, TiXmlEle -class XmlParser +class XmlErrorLogger { public: - XmlParser(const TiXmlElement* rootElement) : root(rootElement) {} + virtual ~XmlErrorLogger() {} void logError(const std::string& nodeName); - bool errorsOccurred() const; + bool errorsOccurred() const { return !failedNodes.empty(); } const wxString getErrorMessageFormatted() const; -protected: //another level of indirection: if errors occur during xml parsing they are logged template <class T> void readXmlElementLogging(const std::string& name, const TiXmlElement* parent, T& output) @@ -91,13 +89,7 @@ protected: logError(name); } - const TiXmlElement* const getRoot() const - { - return root; - } - private: - const TiXmlElement* const root; std::vector<wxString> failedNodes; }; } @@ -113,10 +105,7 @@ public: return TiXmlHandleConst(m_element != NULL ? m_element->FirstChildElement(name) : NULL); } - const TiXmlElement* ToElement() const - { - return m_element; - } + const TiXmlElement* ToElement() const { return m_element; } private: const TiXmlElement* const m_element; @@ -172,7 +161,7 @@ bool xmlAccess::readXmlElement(const std::string& name, const TiXmlElement* pare if (!readXmlElement(name, parent, temp)) return false; - output = common::stringToNumber<T>(temp); + output = zen::toNumber<T>(temp); return true; } @@ -181,7 +170,7 @@ template <class T> inline void xmlAccess::addXmlElement(const std::string& name, T value, TiXmlElement* parent) { - addXmlElement(name, common::numberToString<std::string::value_type>(value), parent); + addXmlElement(name, zen::toString<std::string>(value), parent); } @@ -192,7 +181,7 @@ bool xmlAccess::readXmlAttribute(const std::string& name, const TiXmlElement* no std::string dummy; if (readXmlAttribute(name, node, dummy)) { - output = common::stringToNumber<T>(dummy); + output = zen::toNumber<T>(dummy); return true; } else @@ -204,7 +193,7 @@ template <class T> inline void xmlAccess::addXmlAttribute(const std::string& name, T value, TiXmlElement* node) { - addXmlAttribute(name, common::numberToString<std::string::value_type>(value), node); + addXmlAttribute(name, zen::toString<std::string>(value), node); } #endif // XMLBASE_H_INCLUDED diff --git a/shared/zbase.h b/shared/zbase.h index f08a87e3..5bc43295 100644 --- a/shared/zbase.h +++ b/shared/zbase.h @@ -7,14 +7,11 @@ #ifndef Z_BASE_H_INCLUDED #define Z_BASE_H_INCLUDED -#include <cstddef> //size_t -#include <cctype> //isspace -#include <cwctype> //iswspace #include <cassert> #include <vector> #include <sstream> #include <algorithm> - +#include "string_tools.h" /* Allocator Policy: @@ -25,15 +22,8 @@ Allocator Policy: class AllocatorFreeStore //same performance characterisics like malloc()/free() { public: - static void* allocate(size_t size) //throw (std::bad_alloc) - { - return ::operator new(size); - } - - static void deallocate(void* ptr) - { - ::operator delete(ptr); - } + static void* allocate(size_t size) { return ::operator new(size); } //throw (std::bad_alloc) + static void deallocate(void* ptr) { ::operator delete(ptr); } }; @@ -219,10 +209,12 @@ class Zbase : public SP<T, AP> { public: Zbase(); - Zbase(T source); Zbase(const T* source); Zbase(const T* source, size_t length); Zbase(const Zbase& source); + explicit Zbase(T source); //dangerous if implicit: T buffer[]; Zbase name = buffer; ups... + //allow explicit construction from different string type, prevent ambiguity via SFINAE + template <class S> explicit Zbase(const S& other, typename S::value_type = 0); ~Zbase(); operator const T* () const; //implicit conversion to C-string @@ -239,20 +231,25 @@ public: T* end(); //wxString-like functions - bool StartsWith(const Zbase& prefix) const; - bool StartsWith(const T* prefix) const; - bool StartsWith(T prefix) const; - bool EndsWith(const Zbase& postfix) const; - bool EndsWith(const T* postfix) const; - bool EndsWith(T postfix) const; - Zbase& Truncate(size_t newLen); - Zbase& Replace(const T* old, const T* replacement, bool replaceAll = true); - Zbase AfterLast( T ch) const; //returns the whole string if "ch" not found - Zbase BeforeLast( T ch) const; //returns empty string if "ch" not found - Zbase AfterFirst( T ch) const; //returns empty string if "ch" not found - Zbase BeforeFirst(T ch) const; //returns the whole string if "ch" not found - Zbase& Trim(bool fromLeft = true, bool fromRight = true); - std::vector<Zbase> Split(T delimiter) const; + bool StartsWith(const Zbase& prefix ) const { return zen::startsWith(*this, prefix ); } + bool StartsWith(const T* prefix ) const { return zen::startsWith(*this, prefix ); } + bool StartsWith( T prefix ) const { return zen::startsWith(*this, prefix ); } + bool EndsWith (const Zbase& postfix) const { return zen::endsWith (*this, postfix); } + bool EndsWith (const T* postfix) const { return zen::endsWith (*this, postfix); } + bool EndsWith ( T postfix) const { return zen::endsWith (*this, postfix); } + void Truncate(size_t newLen) { return zen::truncate(*this, newLen); } + Zbase& Replace(const T* old, const T* replacement, bool replaceAll = true) { zen::replace(*this, old, replacement, replaceAll); return *this; } + Zbase AfterLast( T ch) const { return zen::afterLast (*this, ch); } //returns the whole string if "ch" not found + Zbase BeforeLast( T ch) const { return zen::beforeLast (*this, ch); } //returns empty string if "ch" not found + Zbase AfterFirst( T ch) const { return zen::afterFirst (*this, ch); } //returns empty string if "ch" not found + Zbase BeforeFirst(T ch) const { return zen::beforeFirst(*this, ch); } //returns the whole string if "ch" not found + void Trim(bool fromLeft = true, bool fromRight = true) { zen::trim(*this, fromLeft, fromRight); } + std::vector<Zbase> Split(T delimiter) const { return zen::split(*this, delimiter); } + std::vector<Zbase> Split(const Zbase& delimiter) const { return zen::split(*this, delimiter); } + + //number conversion + template <class N> static Zbase fromNumber(N number) { return zen::toString<Zbase>(number); } + template <class N> N toNumber() const { return zen::toNumber<N>(*this); } //std::string functions size_t length() const; @@ -275,10 +272,6 @@ public: void swap(Zbase& other); void push_back(T val); //STL access - //number conversion - template <class N> static Zbase fromNumber(N number); - template <class N> N toNumber() const; - Zbase& operator=(const Zbase& source); Zbase& operator=(const T* source); Zbase& operator=(T source); @@ -350,22 +343,6 @@ template <class T, template <class, class> class SP, class AP> const Zbase<T, SP //################################# inline implementation ######################################## -namespace z_impl -{ -//-------------C-string helper functions --------------------------------------------------------- -template <class T> -inline -size_t cStringLength(const T* input) //strlen() -{ - const T* iter = input; - while (*iter != 0) - ++iter; - return iter - input; -} -} - - -//-------------------------------------------------------------------------------------------------- template <class T, template <class, class> class SP, class AP> inline Zbase<T, SP, AP>::Zbase() @@ -390,7 +367,7 @@ template <class T, template <class, class> class SP, class AP> inline Zbase<T, SP, AP>::Zbase(const T* source) { - const size_t sourceLen = z_impl::cStringLength(source); + const size_t sourceLen = zen::cStringLength(source); rawStr = this->create(sourceLen); std::copy(source, source + sourceLen + 1, rawStr); //include null-termination } @@ -415,159 +392,30 @@ Zbase<T, SP, AP>::Zbase(const Zbase<T, SP, AP>& source) template <class T, template <class, class> class SP, class AP> +template <class S> inline -Zbase<T, SP, AP>::~Zbase() -{ - this->destroy(rawStr); -} - - -template <class T, template <class, class> class SP, class AP> -inline -Zbase<T, SP, AP>::operator const T* () const -{ - return rawStr; -} - - -// get all characters after the last occurence of ch -// (returns the whole string if ch not found) -template <class T, template <class, class> class SP, class AP> -inline -Zbase<T, SP, AP> Zbase<T, SP, AP>::AfterLast(T ch) const -{ - const size_t pos = rfind(ch, npos); - if (pos != npos ) - return Zbase(rawStr + pos + 1, length() - pos - 1); - else - return *this; -} - - -// get all characters before the last occurence of ch -// (returns empty string if ch not found) -template <class T, template <class, class> class SP, class AP> -inline -Zbase<T, SP, AP> Zbase<T, SP, AP>::BeforeLast(T ch) const -{ - const size_t pos = rfind(ch, npos); - if (pos != npos) - return Zbase(rawStr, pos); //data is non-empty string in this context: else ch would not have been found! - else - return Zbase(); -} - - -//returns empty string if ch not found -template <class T, template <class, class> class SP, class AP> -inline -Zbase<T, SP, AP> Zbase<T, SP, AP>::AfterFirst(T ch) const -{ - const size_t pos = find(ch, 0); - if (pos != npos) - return Zbase(rawStr + pos + 1, length() - pos - 1); - else - return Zbase(); - -} - -//returns the whole string if ch not found -template <class T, template <class, class> class SP, class AP> -inline -Zbase<T, SP, AP> Zbase<T, SP, AP>::BeforeFirst(T ch) const -{ - const size_t pos = find(ch, 0); - if (pos != npos) - return Zbase(rawStr, pos); //data is non-empty string in this context: else ch would not have been found! - else - return *this; -} - - -template <class T, template <class, class> class SP, class AP> -inline -bool Zbase<T, SP, AP>::StartsWith(const T* prefix) const -{ - const size_t pfLength = z_impl::cStringLength(prefix); - if (length() < pfLength) - return false; - - return std::equal(rawStr, rawStr + pfLength, - prefix); -} - - -template <class T, template <class, class> class SP, class AP> -inline -bool Zbase<T, SP, AP>::StartsWith(T prefix) const -{ - return length() != 0 && operator[](0) == prefix; -} - - -template <class T, template <class, class> class SP, class AP> -inline -bool Zbase<T, SP, AP>::StartsWith(const Zbase<T, SP, AP>& prefix) const -{ - if (length() < prefix.length()) - return false; - - return std::equal(rawStr, rawStr + prefix.length(), - prefix.rawStr); -} - - -template <class T, template <class, class> class SP, class AP> -inline -bool Zbase<T, SP, AP>::EndsWith(const T* postfix) const -{ - const size_t pfLength = z_impl::cStringLength(postfix); - if (length() < pfLength) - return false; - - const T* cmpBegin = rawStr + length() - pfLength; - return std::equal(cmpBegin, cmpBegin + pfLength, - postfix); -} - - -template <class T, template <class, class> class SP, class AP> -inline -bool Zbase<T, SP, AP>::EndsWith(T postfix) const +Zbase<T, SP, AP>::Zbase(const S& other, typename S::value_type) { - const size_t len = length(); - return len != 0 && operator[](len - 1) == postfix; + const size_t sourceLen = other.size(); + rawStr = this->create(sourceLen); + std::copy(other.c_str(), other.c_str() + sourceLen, rawStr); + rawStr[sourceLen] = 0; } template <class T, template <class, class> class SP, class AP> inline -bool Zbase<T, SP, AP>::EndsWith(const Zbase<T, SP, AP>& postfix) const +Zbase<T, SP, AP>::~Zbase() { - if (length() < postfix.length()) - return false; - - const T* cmpBegin = rawStr + length() - postfix.length(); - return std::equal(cmpBegin, cmpBegin + postfix.length(), - postfix.rawStr); + this->destroy(rawStr); } template <class T, template <class, class> class SP, class AP> inline -Zbase<T, SP, AP>& Zbase<T, SP, AP>::Truncate(size_t newLen) +Zbase<T, SP, AP>::operator const T* () const { - if (newLen < length()) - { - if (canWrite(rawStr, newLen)) - { - rawStr[newLen] = 0; - setLength(rawStr, newLen); - } - else - *this = Zbase(rawStr, newLen); - } - return *this; + return rawStr; } @@ -590,7 +438,7 @@ size_t Zbase<T, SP, AP>::find(const T* str, size_t pos) const assert(pos <= length()); const T* thisEnd = end(); //respect embedded 0 const T* iter = std::search(begin() + pos, thisEnd, - str, str + z_impl::cStringLength(str)); + str, str + zen::cStringLength(str)); return iter == thisEnd ? npos : iter - begin(); } @@ -632,7 +480,7 @@ size_t Zbase<T, SP, AP>::rfind(const T* str, size_t pos) const { assert(pos == npos || pos <= length()); - const size_t strLen = z_impl::cStringLength(str); + const size_t strLen = zen::cStringLength(str); const T* currEnd = pos == npos ? end() : begin() + std::min(pos + strLen, length()); const T* iter = std::find_end(begin(), currEnd, @@ -686,26 +534,6 @@ Zbase<T, SP, AP>& Zbase<T, SP, AP>::replace(size_t pos1, size_t n1, const T* str template <class T, template <class, class> class SP, class AP> inline -Zbase<T, SP, AP>& Zbase<T, SP, AP>::Replace(const T* old, const T* replacement, bool replaceAll) -{ - const size_t oldLen = z_impl::cStringLength(old); - const size_t replacementLen = z_impl::cStringLength(replacement); - - size_t pos = 0; - while ((pos = find(old, pos)) != npos) - { - replace(pos, oldLen, replacement, replacementLen); - pos += replacementLen; //move past the string that was replaced - - if (!replaceAll) - break; - } - return *this; -} - - -template <class T, template <class, class> class SP, class AP> -inline void Zbase<T, SP, AP>::resize(size_t newSize, T fillChar) { if (canWrite(rawStr, newSize)) @@ -746,7 +574,7 @@ template <class T, template <class, class> class SP, class AP> inline bool operator==(const Zbase<T, SP, AP>& lhs, const T* rhs) { - return lhs.length() == z_impl::cStringLength(rhs) && std::equal(lhs.begin(), lhs.end(), rhs); //respect embedded 0 + return lhs.length() == zen::cStringLength(rhs) && std::equal(lhs.begin(), lhs.end(), rhs); //respect embedded 0 } @@ -796,7 +624,7 @@ inline bool operator<(const Zbase<T, SP, AP>& lhs, const T* rhs) { return std::lexicographical_compare(lhs.begin(), lhs.end(), //respect embedded 0 - rhs, rhs + z_impl::cStringLength(rhs)); + rhs, rhs + zen::cStringLength(rhs)); } @@ -804,7 +632,7 @@ template <class T, template <class, class> class SP, class AP> inline bool operator<(const T* lhs, const Zbase<T, SP, AP>& rhs) { - return std::lexicographical_compare(lhs, lhs + z_impl::cStringLength(lhs), //respect embedded 0 + return std::lexicographical_compare(lhs, lhs + zen::cStringLength(lhs), //respect embedded 0 rhs.begin(), rhs.end()); } @@ -944,7 +772,7 @@ template <class T, template <class, class> class SP, class AP> inline const Zbase<T, SP, AP> operator+(T lhs, const Zbase<T, SP, AP>& rhs) { - return Zbase<T, SP, AP>(lhs) += rhs; + return (Zbase<T, SP, AP>() += lhs) += rhs; } @@ -1019,7 +847,7 @@ template <class T, template <class, class> class SP, class AP> inline Zbase<T, SP, AP>& Zbase<T, SP, AP>::operator=(const T* source) { - return assign(source, z_impl::cStringLength(source)); + return assign(source, zen::cStringLength(source)); } @@ -1059,7 +887,7 @@ inline Zbase<T, SP, AP>& Zbase<T, SP, AP>::operator+=(const T* other) { const size_t thisLen = length(); - const size_t otherLen = z_impl::cStringLength(other); + const size_t otherLen = zen::cStringLength(other); reserve(thisLen + otherLen); //make unshared and check capacity std::copy(other, other + otherLen + 1, rawStr + thisLen); //include null-termination @@ -1080,113 +908,4 @@ Zbase<T, SP, AP>& Zbase<T, SP, AP>::operator+=(T ch) return *this; } - -template <class T, template <class, class> class SP, class AP> -template <class N> -inline -Zbase<T, SP, AP> Zbase<T, SP, AP>::fromNumber(N number) -{ - std::basic_ostringstream<T> ss; - ss << number; - return Zbase<T, SP, AP>(ss.str().c_str()); -} - - -template <class T, template <class, class> class SP, class AP> -template <class N> -inline -N Zbase<T, SP, AP>::toNumber() const -{ - std::basic_istringstream<T> ss((std::basic_string<T>(rawStr))); - N number = 0; - ss >> number; - return number; -} - - -namespace z_impl -{ -template <class T> -bool cStringWhiteSpace(T ch); - -template <> -inline -bool cStringWhiteSpace(char ch) -{ - return std::isspace(static_cast<unsigned char>(ch)) != 0; //some compilers (e.g. VC++ 6.0) return true for a call to isspace('\xEA'); but no issue with newer versions of MSVC -} - - -template <> -inline -bool cStringWhiteSpace(wchar_t ch) -{ - return std::iswspace(ch) != 0; //some compilers (e.g. VC++ 6.0) return true for a call to isspace('\xEA'); but no issue with newer versions of MSVC -} -} - - -template <class T, template <class, class> class SP, class AP> -Zbase<T, SP, AP>& Zbase<T, SP, AP>::Trim(bool fromLeft, bool fromRight) -{ - assert(fromLeft || fromRight); - - const T* newBegin = rawStr; - const T* newEnd = rawStr + length(); - - if (fromRight) - while (newBegin != newEnd && z_impl::cStringWhiteSpace(newEnd[-1])) - --newEnd; - - if (fromLeft) - while (newBegin != newEnd && z_impl::cStringWhiteSpace(*newBegin)) - ++newBegin; - - const size_t newLength = newEnd - newBegin; - if (newLength != length()) - { - if (canWrite(rawStr, newLength)) - { - std::copy(newBegin, newBegin + newLength, rawStr); //shift left => std::copy, shift right std::copy_backward - rawStr[newLength] = 0; - setLength(rawStr, newLength); - } - else - *this = Zbase(newBegin, newLength); - } - return *this; -} - - -template <class T, template <class, class> class SP, class AP> -std::vector<Zbase<T, SP, AP> > Zbase<T, SP, AP>::Split(T delimiter) const -{ - std::vector<Zbase> output; - - const size_t thisLen = length(); - size_t startPos = 0; - for (;;) //make MSVC happy - { - size_t endPos = find(delimiter, startPos); - if (endPos == npos) - endPos = thisLen; - - if (startPos != endPos) //do not add empty strings - { - Zbase newEntry = substr(startPos, endPos - startPos); - newEntry.Trim(); //remove whitespace characters - - if (!newEntry.empty()) - output.push_back(newEntry); - } - if (endPos == thisLen) - break; - - startPos = endPos + 1; //skip delimiter - } - - return output; -} - - #endif //Z_BASE_H_INCLUDED diff --git a/shared/zstring.cpp b/shared/zstring.cpp index 6440c9af..2955ec3e 100644 --- a/shared/zstring.cpp +++ b/shared/zstring.cpp @@ -12,7 +12,6 @@ #undef min #undef max #include "dll_loader.h" -#include <boost/scoped_array.hpp> #endif //FFS_WIN #ifndef NDEBUG @@ -161,16 +160,16 @@ int z_impl::compareFilenamesWin(const wchar_t* a, const wchar_t* b, size_t sizeA } else //use freestore { - boost::scoped_array<wchar_t> bufferA(new wchar_t[minSize]); - boost::scoped_array<wchar_t> bufferB(new wchar_t[minSize]); + std::vector<wchar_t> bufferA(minSize); + std::vector<wchar_t> bufferB(minSize); - if (::LCMapString(ZSTRING_INVARIANT_LOCALE, LCMAP_UPPERCASE, a, static_cast<int>(minSize), bufferA.get(), static_cast<int>(minSize)) == 0) + if (::LCMapString(ZSTRING_INVARIANT_LOCALE, LCMAP_UPPERCASE, a, static_cast<int>(minSize), &bufferA[0], static_cast<int>(minSize)) == 0) throw std::runtime_error("Error comparing strings! (LCMapString: FS)"); - if (::LCMapString(ZSTRING_INVARIANT_LOCALE, LCMAP_UPPERCASE, b, static_cast<int>(minSize), bufferB.get(), static_cast<int>(minSize)) == 0) + if (::LCMapString(ZSTRING_INVARIANT_LOCALE, LCMAP_UPPERCASE, b, static_cast<int>(minSize), &bufferB[0], static_cast<int>(minSize)) == 0) throw std::runtime_error("Error comparing strings! (LCMapString: FS)"); - rv = ::wmemcmp(bufferA.get(), bufferB.get(), minSize); + rv = ::wmemcmp(&bufferA[0], &bufferB[0], minSize); } return rv == 0 ? diff --git a/shared/zstring.h b/shared/zstring.h index 286ed7cc..ae77d333 100644 --- a/shared/zstring.h +++ b/shared/zstring.h @@ -112,6 +112,9 @@ typedef wchar_t Zchar; #elif defined FFS_LINUX //Linux uses UTF-8 typedef char Zchar; #define Zstr(x) x + +#else +#error define platform you are in: FFS_WIN or FFS_LINUX #endif //"The reason for all the fuss above" (Loki/SmartPtr) |