m_spIO;
-
- WAVEFORMATEX m_wfeSource;
- int m_nHeaderBytes;
- int m_nDataBytes;
- int m_nTerminatingBytes;
- int m_nFileBytes;
- BOOL m_bIsValid;
-};
-
-/*************************************************************************************
-Input souce creation
-*************************************************************************************/
-CInputSource * CreateInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
-
-#endif // #ifndef APE_WAVINPUTSOURCE_H
diff --git a/MAC_SDK/Source/MACLib/md5.h b/MAC_SDK/Source/MACLib/md5.h
deleted file mode 100644
index 0167ab3..0000000
--- a/MAC_SDK/Source/MACLib/md5.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.
- *
- * License to copy and use this software is granted provided that it is identified
- * as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing this software or this function.
- *
- * License is also granted to make and use derivative works provided that such
- * works are identified as "derived from the RSA Data Security, Inc. MD5 Message-
- * Digest Algorithm" in all material mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either the
- * merchantability of this software or the suitability of this software for any
- * particular purpose. It is provided "as is" without express or implied warranty
- * of any kind. These notices must be retained in any copies of any part of this
- * documentation and/or software.
- */
-
-#ifndef MD5SUM_MD5_H
-#define MD5SUM_MD5_H
-
-typedef unsigned int uint32_t;
-typedef unsigned char uint8_t;
-
-/*
- * Define the MD5 context structure
- * Please DO NOT change the order or contents of the structure as various assembler files depend on it !!
- */
-
-typedef struct {
- uint32_t state [ 4]; /* state (ABCD) */
- uint32_t count [ 2]; /* number of bits, modulo 2^64 (least sig word first) */
- uint8_t buffer [64]; /* input buffer for incomplete buffer data */
-} MD5_CTX;
-
-void MD5Init ( MD5_CTX* ctx );
-void MD5Update ( MD5_CTX* ctx, const uint8_t* buf, size_t len );
-void MD5Final ( uint8_t digest [16], MD5_CTX* ctx );
-
-class CMD5Helper
-{
-public:
-
- CMD5Helper(BOOL bInitialize = TRUE)
- {
- if (bInitialize)
- Initialize();
- }
-
- BOOL Initialize()
- {
- memset(&m_MD5Context, 0, sizeof(m_MD5Context));
- MD5Init(&m_MD5Context);
- m_nTotalBytes = 0;
- return TRUE;
- }
-
- inline void AddData(const void * pData, int nBytes)
- {
- MD5Update(&m_MD5Context, (const unsigned char *) pData, nBytes);
- m_nTotalBytes += nBytes;
- }
-
- BOOL GetResult(unsigned char cResult[16])
- {
- memset(cResult, 0, 16);
- MD5Final(cResult, &m_MD5Context);
- return TRUE;
- }
-
-protected:
-
- MD5_CTX m_MD5Context;
- BOOL m_bStopped;
- int m_nTotalBytes;
-};
-
-
-#endif /* MD5SUM_MD5_H */
diff --git a/MAC_SDK/Source/Makefile b/MAC_SDK/Source/Makefile
deleted file mode 100644
index 63adbe7..0000000
--- a/MAC_SDK/Source/Makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# Simple Makefile
-#
-# Frank Klemm
-#
-
-TARGET = mac
-INCLUDES = -IShared -IMACLib -IConsole
-CPPOPT = -s -O3 -Wall -pedantic -D__GNUC_IA32__
-COMPILER = gcc
-
-SOURCEFILES = \
-Console/Console.cpp \
-MACLib/APECompress.cpp \
-MACLib/APECompressCore.cpp \
-MACLib/APECompressCreate.cpp \
-MACLib/APEDecompress.cpp \
-MACLib/APEInfo.cpp \
-MACLib/APELink.cpp \
-MACLib/APESimple.cpp \
-MACLib/APETag.cpp \
-MACLib/BitArray.cpp \
-MACLib/MACLib.cpp \
-MACLib/MACProgressHelper.cpp \
-MACLib/NNFilter.cpp \
-MACLib/NewPredictor.cpp \
-MACLib/Prepare.cpp \
-MACLib/UnBitArray.cpp \
-MACLib/UnBitArrayBase.cpp \
-MACLib/WAVInputSource.cpp \
-Shared/GlobalFunctions.cpp \
-Shared/StdLibFileIO.cpp \
-Shared/WinFileIO.cpp \
-MACLib/NNFilterAsm.o
-
-
-
-$(TARGET): $(SOURCEFILES)
- $(COMPILER) -static $(CPPOPT) $(INCLUDES) -o $(TARGET)-static $(SOURCEFILES)
- $(COMPILER) $(CPPOPT) $(INCLUDES) -o $(TARGET) $(SOURCEFILES)
-
-MACLib/NNFilterAsm.o : MACLib/NNFilterAsm.nas
- nasm -f elf -o MACLib/NNFilterAsm.o MACLib/NNFilterAsm.nas -l MACLib/NNFilterAsm.lst
-
-APE_Source.tar.bz2:
- @sh ./MakeSourceBall
-
-test:
- @echo e4dd45d9b5ec4cc91f3bd2210a543df6
- @./$(TARGET) Adagio.ape - -d | md5sum
-
-speed:
- @sync
- @cat Adagio.ape > /dev/null
- @sync
- time ./mac Adagio.ape /dev/null -d
-
-
-# Samual Barber: Adagio for Strings (10:10.84)
-#
-# C version 203.01 sec
-# First ASM version 76.89 sec
-# 76.85 sec
-# 77.12 sec
-# 76.23 sec
-# 75.67 sec
-# 76.26 sec
-# 76.79 sec
-# 76.70 sec
diff --git a/MAC_SDK/Source/Readme.htm b/MAC_SDK/Source/Readme.htm
deleted file mode 100644
index 5f8c51e..0000000
--- a/MAC_SDK/Source/Readme.htm
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-Monkey
-
-
-
-
-Monkey's Audio Source Code
-Readme
-(last updated July 7, 2002)
-Introduction
-First off, just to be clear, you have to fully
-agree with the included license agreement before using / viewing any of the
-included materials. The big points are that you can't steal code or try to
-make money with it (without permission) and that you have to submit changes and
-improvements back to the Monkey's Audio project. With that out of the way,
-I'm hoping that by releasing the source code, we'll be able to work together to
-make Monkey's Audio better. Please direct any suggestions or improvements
-to the Monkey's Audio developer's forum or to me personally when appropriate.
-(email @ monkeysaudio.com) And thank you for taking the time to help.
-Important Note
-The Monkey's Audio format is not
-"finalized". In fact, the compression / decompression engines
-are continually being improved. This is what makes MAC fun to work on, and
-it's what makes progress possible. I realize that this can be a pain for
-3rd party developers, but it's the only way to avoid stagnation. So, you
-can not hard code Monkey's Audio support and expect it to work with the newest
-versions of MAC forever. Either use a DLL or else accept that you'll have
-to re-link to MACLib once in a while.
-Things that it'd be great if you worked on
-1. It would be nice to have makefiles for gcc
-or any other compilers that people commonly use.
-2. Pour through the code and look for bone-head
-maneuvers.
-3. Submit any necessary changes for
-cross-platform compilation.
-4. XMMS, Lame DLL, PocketPC, etc. plugins /
-implementations.
-5. A console front-end that doesn't suck. (more
-options, etc.) Also, don't worry about maintaining compatibility with the
-current parameter passing scheme -- just use whatever makes sense.
-Tips for building MACLib outside of Windows
-1. in "Shared/All.h" do this:
-
- - #define BUILD_CROSS_PLATFORM
- - look through "Shared/All.h" and
- "Shared/NoWindows.h" to make sure all the defines are acceptable
-
-2. You need to use NASM to build the assembly
-if you want it. (helps speed a lot) Check out "MacLib/Assembly/..."
-for more information.
-Known non-Windows problems (help fixing them
-would be great)
-2. The macros PUMP_MESSAGE_LOOP, MESSAGEBOX, and a few others don't work.
-
--
-All materials and programs copyrighted ©2000-2002 by Matthew T. Ashland -
--
-All rights reserved. -
-
-
-
-
diff --git a/MAC_SDK/Source/Shared/APEInfoDialog.cpp b/MAC_SDK/Source/Shared/APEInfoDialog.cpp
deleted file mode 100644
index a4a99da..0000000
--- a/MAC_SDK/Source/Shared/APEInfoDialog.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-#include "All.h"
-#include "APEInfo.h"
-#include "APEInfoDialog.h"
-#include "ID3Genres.h"
-#include "APECompress.h"
-#include "CharacterHelper.h"
-
-/***************************************************************************************
-The dialog component ID's
-***************************************************************************************/
-#define FILE_NAME_EDIT 1000
-
-#define ENCODER_VERSION_STATIC 2000
-#define COMPRESSION_LEVEL_STATIC 2001
-#define FORMAT_FLAGS_STATIC 2002
-#define HAS_TAG_STATIC 2003
-
-#define SAMPLE_RATE_STATIC 3000
-#define CHANNELS_STATIC 3001
-#define BITS_PER_SAMPLE_STATIC 3002
-#define PEAK_LEVEL_STATIC 3003
-
-#define TRACK_LENGTH_STATIC 4000
-#define WAV_SIZE_STATIC 4001
-#define APE_SIZE_STATIC 4002
-#define COMPRESSION_RATIO_STATIC 4003
-
-#define TITLE_EDIT 5000
-#define ARTIST_EDIT 5001
-#define ALBUM_EDIT 5002
-#define COMMENT_EDIT 5003
-#define YEAR_EDIT 5004
-#define GENRE_COMBOBOX 5005
-#define TRACK_EDIT 5006
-
-#define SAVE_TAG_BUTTON 6000
-#define REMOVE_TAG_BUTTON 6001
-#define CANCEL_BUTTON 6002
-
-/***************************************************************************************
-Global pointer to this instance
-***************************************************************************************/
-CAPEInfoDialog * g_pAPEDecompressDialog = NULL;
-
-/***************************************************************************************
-Construction / destruction
-***************************************************************************************/
-CAPEInfoDialog::CAPEInfoDialog()
-{
- g_pAPEDecompressDialog = NULL;
-}
-
-CAPEInfoDialog::~CAPEInfoDialog()
-{
-
-}
-
-/***************************************************************************************
-Display the file info dialog
-***************************************************************************************/
-int CAPEInfoDialog::ShowAPEInfoDialog(const str_utf16 * pFilename, HINSTANCE hInstance, const str_utf16 * lpszTemplateName, HWND hWndParent)
-{
- // only allow one instance at a time
- if (g_pAPEDecompressDialog != NULL) { return -1; }
-
- // open the file
- int nErrorCode = ERROR_SUCCESS;
- m_pAPEDecompress = CreateIAPEDecompress(pFilename, &nErrorCode);
- if (m_pAPEDecompress == NULL || nErrorCode != ERROR_SUCCESS)
- return nErrorCode;
-
- g_pAPEDecompressDialog = this;
-
- DialogBoxParam(hInstance, lpszTemplateName, hWndParent, (DLGPROC) DialogProc, 0);
-
- // clean up
- SAFE_DELETE(m_pAPEDecompress);
- g_pAPEDecompressDialog = NULL;
-
- return 0;
-}
-
-/***************************************************************************************
-Fill the genre combobox
-***************************************************************************************/
-int CAPEInfoDialog::FillGenreComboBox(HWND hDlg, int nComboBoxID, char *pSelectedGenre)
-{
- // declare the variables
- int nRetVal;
- HWND hGenreComboBox = GetDlgItem(hDlg, nComboBoxID);
-
- // reset the contents of the combobox
- SendMessage(hGenreComboBox, CB_RESETCONTENT, 0, 0);
-
- // propagate the combobox (0 to 126 so "Undefined" isn't repeated)
- for (int z = 0; z < GENRE_COUNT; z++)
- {
- //add the genre string
- nRetVal = SendMessage(hGenreComboBox, CB_ADDSTRING, 0, (LPARAM) g_ID3Genre[z]);
- if (nRetVal == CB_ERR) { return -1; }
- }
-
- // add the 'Undefined' genre
- nRetVal = SendMessage(hGenreComboBox, CB_ADDSTRING, 0, (LPARAM) "Undefined");
- if (nRetVal == CB_ERR) { return -1; }
-
- // set the genre id (if it's specified)
- if (pSelectedGenre)
- {
- if (strlen(pSelectedGenre) > 0)
- SendMessage(hGenreComboBox, CB_SELECTSTRING, -1, (LPARAM) pSelectedGenre);
- }
-
- return 0;
-}
-
-/***************************************************************************************
-The dialog procedure
-***************************************************************************************/
-LRESULT CALLBACK CAPEInfoDialog::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
-{
- // get the class
- IAPEDecompress * pAPEDecompress = g_pAPEDecompressDialog->m_pAPEDecompress;
-
- int wmID, wmEvent;
-
- switch (message)
- {
- case WM_INITDIALOG:
- {
- // variable declares
- TCHAR cTemp[1024] = { 0 };
-
- // set info
- wchar_t cFilename[MAX_PATH + 1] = {0};
- GET_IO(pAPEDecompress)->GetName(&cFilename[0]);
-
- SetDlgItemText(hDlg, FILE_NAME_EDIT, cFilename);
-
- switch (pAPEDecompress->GetInfo(APE_INFO_COMPRESSION_LEVEL))
- {
- case COMPRESSION_LEVEL_FAST: _stprintf(cTemp, _T("Mode: Fast")); break;
- case COMPRESSION_LEVEL_NORMAL: _stprintf(cTemp, _T("Mode: Normal")); break;
- case COMPRESSION_LEVEL_HIGH: _stprintf(cTemp, _T("Mode: High")); break;
- case COMPRESSION_LEVEL_EXTRA_HIGH: _stprintf(cTemp, _T("Mode: Extra High")); break;
- case COMPRESSION_LEVEL_INSANE: _stprintf(cTemp, _T("Mode: Insane")); break;
- default: _stprintf(cTemp, _T("Mode: Unknown")); break;
- }
- SetDlgItemText(hDlg, COMPRESSION_LEVEL_STATIC, cTemp);
-
- _stprintf(cTemp, _T("Version: %.2f"), float(pAPEDecompress->GetInfo(APE_INFO_FILE_VERSION)) / float(1000));
- SetDlgItemText(hDlg, ENCODER_VERSION_STATIC, cTemp);
-
- _stprintf(cTemp, _T("Format Flags: %d"), pAPEDecompress->GetInfo(APE_INFO_FORMAT_FLAGS));
- SetDlgItemText(hDlg, FORMAT_FLAGS_STATIC, cTemp);
-
- _stprintf(cTemp, _T("Sample Rate: %d"), pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE));
- SetDlgItemText(hDlg, SAMPLE_RATE_STATIC, cTemp);
-
- _stprintf(cTemp, _T("Channels: %d"), pAPEDecompress->GetInfo(APE_INFO_CHANNELS));
- SetDlgItemText(hDlg, CHANNELS_STATIC, cTemp);
-
- _stprintf(cTemp, _T("Bits Per Sample: %d"), pAPEDecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE));
- SetDlgItemText(hDlg, BITS_PER_SAMPLE_STATIC, cTemp);
-
- int nSeconds = pAPEDecompress->GetInfo(APE_INFO_LENGTH_MS) / 1000; int nMinutes = nSeconds / 60; nSeconds = nSeconds % 60; int nHours = nMinutes / 60; nMinutes = nMinutes % 60;
- if (nHours > 0) _stprintf(cTemp, _T("Length: %d:%02d:%02d"), nHours, nMinutes, nSeconds);
- else if (nMinutes > 0) _stprintf(cTemp, _T("Length: %d:%02d"), nMinutes, nSeconds);
- else _stprintf(cTemp, _T("Length: 0:%02d"), nSeconds);
- SetDlgItemText(hDlg, TRACK_LENGTH_STATIC, cTemp);
-
- int nPeakLevel = pAPEDecompress->GetInfo(APE_INFO_PEAK_LEVEL);
- if (nPeakLevel >= 0) _stprintf(cTemp, _T("Peak Level: %d"), nPeakLevel);
- else _stprintf(cTemp, _T("Peak Level: ?"));
- SetDlgItemText(hDlg, PEAK_LEVEL_STATIC, cTemp);
-
- // the file size
- _stprintf(cTemp, _T("APE: %.2f MB"), float(pAPEDecompress->GetInfo(APE_INFO_APE_TOTAL_BYTES)) / float(1048576));
- SetDlgItemText(hDlg, APE_SIZE_STATIC, cTemp);
-
- _stprintf(cTemp, _T("WAV: %.2f MB"), float(pAPEDecompress->GetInfo(APE_INFO_WAV_TOTAL_BYTES)) / float(1048576));
- SetDlgItemText(hDlg, WAV_SIZE_STATIC, cTemp);
-
- // the compression ratio
- _stprintf(cTemp, _T("Compression: %.2f%%"), float(pAPEDecompress->GetInfo(APE_INFO_AVERAGE_BITRATE) * 100) / float(pAPEDecompress->GetInfo(APE_INFO_DECOMPRESSED_BITRATE)));
- SetDlgItemText(hDlg, COMPRESSION_RATIO_STATIC, cTemp);
-
- // the has tag
- BOOL bHasID3Tag = GET_TAG(pAPEDecompress)->GetHasID3Tag();
- BOOL bHasAPETag = GET_TAG(pAPEDecompress)->GetHasAPETag();
-
- if (!bHasID3Tag && !bHasAPETag)
- _stprintf(cTemp, _T("Tag: None"));
- else if (bHasID3Tag && !bHasAPETag)
- _stprintf(cTemp, _T("Tag: ID3v1.1"));
- else if (!bHasID3Tag && bHasAPETag)
- _stprintf(cTemp, _T("Tag: APE Tag"));
- else
- _stprintf(cTemp, _T("Tag: Corrupt"));
- SetDlgItemText(hDlg, HAS_TAG_STATIC, cTemp);
-
- wchar_t cBuffer[256];
- int nBufferBytes = 256;
-
- nBufferBytes = 256;
- GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_TITLE, cBuffer, &nBufferBytes);
- SetDlgItemText(hDlg, TITLE_EDIT, cBuffer);
-
- nBufferBytes = 256;
- GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_ARTIST, cBuffer, &nBufferBytes);
- SetDlgItemText(hDlg, ARTIST_EDIT, cBuffer);
-
- nBufferBytes = 256;
- GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_ALBUM, cBuffer, &nBufferBytes);
- SetDlgItemText(hDlg, ALBUM_EDIT, cBuffer);
-
- nBufferBytes = 256;
- GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_COMMENT, cBuffer, &nBufferBytes);
- SetDlgItemText(hDlg, COMMENT_EDIT, cBuffer);
-
- nBufferBytes = 256;
- GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_YEAR, cBuffer, &nBufferBytes);
- SetDlgItemText(hDlg, YEAR_EDIT, cBuffer);
-
- nBufferBytes = 256;
- GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_TRACK, cBuffer, &nBufferBytes);
- SetDlgItemText(hDlg, TRACK_EDIT, cBuffer);
-
- g_pAPEDecompressDialog->FillGenreComboBox(hDlg, GENRE_COMBOBOX, NULL);
-
- nBufferBytes = 256;
- GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_GENRE, cBuffer, &nBufferBytes);
- SetDlgItemText(hDlg, GENRE_COMBOBOX, cBuffer);
-
- return TRUE;
- break;
- }
- case WM_COMMAND:
- wmID = LOWORD(wParam);
- wmEvent = HIWORD(wParam);
-
- switch (wmID)
- {
- case IDCANCEL:
- // traps the [esc] key
- EndDialog(hDlg, 0);
- return TRUE;
- break;
- case CANCEL_BUTTON:
- EndDialog(hDlg, 0);
- return TRUE;
- break;
- case REMOVE_TAG_BUTTON:
- {
- // make sure you really wanted to
- int nRetVal = ::MessageBox(hDlg, _T("Are you sure you want to permanently remove the tag?"), _T("Are You Sure?"), MB_YESNO | MB_ICONQUESTION);
- if (nRetVal == IDYES)
- {
- // remove the ID3 tag...
- if (GET_TAG(pAPEDecompress)->Remove() != 0)
- {
- MessageBox(hDlg, _T("Error removing tag. (could the file be read-only?)"), _T("Error Removing Tag"), MB_OK | MB_ICONEXCLAMATION);
- return TRUE;
- }
- else
- {
- EndDialog(hDlg, 0);
- return TRUE;
- }
- }
- break;
- }
- case SAVE_TAG_BUTTON:
-
- // make the id3 tag
- TCHAR cBuffer[256]; int z;
-
- #define SAVE_FIELD(ID, Field) \
- for (z = 0; z < 256; z++) { cBuffer[z] = 0; } \
- GetDlgItemText(hDlg, ID, cBuffer, 256); \
- GET_TAG(pAPEDecompress)->SetFieldString(Field, cBuffer);
-
- SAVE_FIELD(TITLE_EDIT, APE_TAG_FIELD_TITLE)
- SAVE_FIELD(ARTIST_EDIT, APE_TAG_FIELD_ARTIST)
- SAVE_FIELD(ALBUM_EDIT, APE_TAG_FIELD_ALBUM)
- SAVE_FIELD(COMMENT_EDIT, APE_TAG_FIELD_COMMENT)
- SAVE_FIELD(TRACK_EDIT, APE_TAG_FIELD_TRACK)
- SAVE_FIELD(YEAR_EDIT, APE_TAG_FIELD_YEAR)
- SAVE_FIELD(GENRE_COMBOBOX, APE_TAG_FIELD_GENRE)
-
- if (GET_TAG(pAPEDecompress)->Save() != 0)
- {
- MessageBox(hDlg, _T("Error saving tag. (could the file be read-only?)"), _T("Error Saving Tag"), MB_OK | MB_ICONEXCLAMATION);
- return TRUE;
- }
-
- EndDialog(hDlg, 0);
- break;
- }
- break;
- case WM_CLOSE:
- EndDialog(hDlg, 0);
- return TRUE;
- break;
- }
-
- return FALSE;
-}
\ No newline at end of file
diff --git a/MAC_SDK/Source/Shared/APEInfoDialog.h b/MAC_SDK/Source/Shared/APEInfoDialog.h
deleted file mode 100644
index 60a2495..0000000
--- a/MAC_SDK/Source/Shared/APEInfoDialog.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef APE_APEINFODIALOG_H
-#define APE_APEINFODIALOG_H
-
-BOOL CALLBACK FileInfoDialogProcedureA(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
-
-class CAPEInfoDialog
-{
-public:
-
- CAPEInfoDialog();
- ~CAPEInfoDialog();
-
- int ShowAPEInfoDialog(const str_utf16 * pFilename, HINSTANCE hInstance, const str_utf16 * lpszTemplateName, HWND hWndParent);
-
-private:
-
- static LRESULT CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
- int FillGenreComboBox(HWND hDlg, int nComboBoxID, char * pSelectedGenre);
- IAPEDecompress * m_pAPEDecompress;
-};
-
-#endif // #ifndef APE_APEINFODIALOG_H
\ No newline at end of file
diff --git a/MAC_SDK/Source/Shared/All.h b/MAC_SDK/Source/Shared/All.h
deleted file mode 100644
index 32f9a22..0000000
--- a/MAC_SDK/Source/Shared/All.h
+++ /dev/null
@@ -1,237 +0,0 @@
-#ifndef APE_ALL_H
-#define APE_ALL_H
-
-/*****************************************************************************************
-Cross platform building switch
-*****************************************************************************************/
-//#define BUILD_CROSS_PLATFORM
-
-/*****************************************************************************************
-Unicode
-*****************************************************************************************/
-#ifdef _UNICODE
-
-#else
-
-#endif // #ifdef _UNICODE
-
-
-/*****************************************************************************************
-Global includes
-*****************************************************************************************/
-#ifndef BUILD_CROSS_PLATFORM
- #include
-#endif
-
-#ifdef _WIN32
- #include
- #include
-#else
- #include
- #include
- #include
- #include
- #include
- #include "NoWindows.h"
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#include "SmartPtr.h"
-
-/*****************************************************************************************
-Global compiler settings (useful for porting)
-*****************************************************************************************/
-#ifndef BUILD_CROSS_PLATFORM
-#ifndef _WIN64
- #define ENABLE_ASSEMBLY
-#endif
-#endif
-
-#define NO_BACKWARDS_COMPATIBILITY
-
-#define ENABLE_COMPRESSION_MODE_FAST
-#define ENABLE_COMPRESSION_MODE_NORMAL
-#define ENABLE_COMPRESSION_MODE_HIGH
-#define ENABLE_COMPRESSION_MODE_EXTRA_HIGH
-
-#ifdef _WIN32
- typedef unsigned __int32 uint32;
- typedef __int32 int32;
- typedef unsigned __int16 uint16;
- typedef __int16 int16;
- typedef unsigned __int8 uint8;
- typedef __int8 int8;
- typedef char str_ansi;
- typedef unsigned char str_utf8;
- typedef wchar_t str_utf16;
-
- #define IO_USE_WIN_FILE_IO
- #define IO_HEADER_FILE "WinFileIO.h"
- #define NO_IO_CLASS_NAME CWinFileIO
- #define DLLEXPORT __declspec(dllexport)
- #define SLEEP(MILLISECONDS) ::Sleep(MILLISECONDS)
- #define MESSAGEBOX(PARENT, TEXT, CAPTION, TYPE) ::MessageBox(PARENT, TEXT, CAPTION, TYPE)
- #define PUMP_MESSAGE_LOOP { MSG Msg; while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE) != 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } }
- #define ODS OutputDebugString
- #define TICK_COUNT_TYPE unsigned long
- #define TICK_COUNT_READ(VARIABLE) VARIABLE = GetTickCount()
- #define TICK_COUNT_FREQ 1000
-#else
- #define IO_USE_STD_LIB_FILE_IO
- #define IO_HEADER_FILE "StdLibFileIO.h"
- #define IO_CLASS_NAME CStdLibFileIO
- #define DLLEXPORT
- #define SLEEP(MILLISECONDS) { struct timespec t; t.tv_sec = (MILLISECONDS) / 1000; t.tv_nsec = (MILLISECONDS) % 1000 * 1000000; nanosleep(&t, NULL); }
- #define MESSAGEBOX(PARENT, TEXT, CAPTION, TYPE)
- #define PUMP_MESSAGE_LOOP
- #define ODS printf
- #define TICK_COUNT_TYPE unsigned long long
- #define TICK_COUNT_READ(VARIABLE) { struct timeval t; gettimeofday(&t, NULL); VARIABLE = t.tv_sec * 1000000LLU + t.tv_usec; }
- #define TICK_COUNT_FREQ 1000000
-#endif
-
-/*****************************************************************************************
-Global defines
-*****************************************************************************************/
-#define MAC_VERSION_NUMBER 3990
-#define MAC_VERSION_STRING _T("3.99")
-#define MAC_NAME _T("Monkey's Audio 3.99")
-#define PLUGIN_NAME "Monkey's Audio Player v3.99"
-#define MJ_PLUGIN_NAME _T("APE Plugin (v3.99)")
-#define CONSOLE_NAME "--- Monkey's Audio Console Front End (v 3.99) (c) Matthew T. Ashland ---\n"
-#define PLUGIN_ABOUT _T("Monkey's Audio Player v3.99\nCopyrighted (c) 2000-2004 by Matthew T. Ashland")
-#define MAC_DLL_INTERFACE_VERSION_NUMBER 1000
-
-/*****************************************************************************************
-Byte order
-*****************************************************************************************/
-#define __LITTLE_ENDIAN 1234
-#define __BIG_ENDIAN 4321
-#define __BYTE_ORDER __LITTLE_ENDIAN
-
-/*****************************************************************************************
-Macros
-*****************************************************************************************/
-#define MB(TEST) MESSAGEBOX(NULL, TEST, _T("Information"), MB_OK);
-#define MBN(NUMBER) { TCHAR cNumber[16]; _stprintf(cNumber, _T("%d"), NUMBER); MESSAGEBOX(NULL, cNumber, _T("Information"), MB_OK); }
-
-#define SAFE_DELETE(POINTER) if (POINTER) { delete POINTER; POINTER = NULL; }
-#define SAFE_ARRAY_DELETE(POINTER) if (POINTER) { delete [] POINTER; POINTER = NULL; }
-#define SAFE_VOID_CLASS_DELETE(POINTER, Class) { Class *pClass = (Class *) POINTER; if (pClass) { delete pClass; POINTER = NULL; } }
-#define SAFE_FILE_CLOSE(HANDLE) if (HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = INVALID_HANDLE_VALUE; }
-
-#define ODN(NUMBER) { TCHAR cNumber[16]; _stprintf(cNumber, _T("%d\n"), int(NUMBER)); ODS(cNumber); }
-
-#define CATCH_ERRORS(CODE) try { CODE } catch(...) { }
-
-#define RETURN_ON_ERROR(FUNCTION) { int nRetVal = FUNCTION; if (nRetVal != 0) { return nRetVal; } }
-#define RETURN_VALUE_ON_ERROR(FUNCTION, VALUE) { int nRetVal = FUNCTION; if (nRetVal != 0) { return VALUE; } }
-#define RETURN_ON_EXCEPTION(CODE, VALUE) { try { CODE } catch(...) { return VALUE; } }
-
-#define THROW_ON_ERROR(CODE) { int nRetVal = CODE; if (nRetVal != 0) throw(nRetVal); }
-
-#define EXPAND_1_TIMES(CODE) CODE
-#define EXPAND_2_TIMES(CODE) CODE CODE
-#define EXPAND_3_TIMES(CODE) CODE CODE CODE
-#define EXPAND_4_TIMES(CODE) CODE CODE CODE CODE
-#define EXPAND_5_TIMES(CODE) CODE CODE CODE CODE CODE
-#define EXPAND_6_TIMES(CODE) CODE CODE CODE CODE CODE CODE
-#define EXPAND_7_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_8_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_9_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_12_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_14_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_15_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_16_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_30_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_31_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_32_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_64_TIMES(CODE) CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
-#define EXPAND_N_TIMES(NUMBER, CODE) EXPAND_##NUMBER##_TIMES(CODE)
-
-#define UNROLL_4_TIMES(MACRO) MACRO(0) MACRO(1) MACRO(2) MACRO(3)
-#define UNROLL_8_TIMES(MACRO) MACRO(0) MACRO(1) MACRO(2) MACRO(3) MACRO(4) MACRO(5) MACRO(6) MACRO(7)
-#define UNROLL_15_TIMES(MACRO) MACRO(0) MACRO(1) MACRO(2) MACRO(3) MACRO(4) MACRO(5) MACRO(6) MACRO(7) MACRO(8) MACRO(9) MACRO(10) MACRO(11) MACRO(12) MACRO(13) MACRO(14)
-#define UNROLL_16_TIMES(MACRO) MACRO(0) MACRO(1) MACRO(2) MACRO(3) MACRO(4) MACRO(5) MACRO(6) MACRO(7) MACRO(8) MACRO(9) MACRO(10) MACRO(11) MACRO(12) MACRO(13) MACRO(14) MACRO(15)
-#define UNROLL_64_TIMES(MACRO) MACRO(0) MACRO(1) MACRO(2) MACRO(3) MACRO(4) MACRO(5) MACRO(6) MACRO(7) MACRO(8) MACRO(9) MACRO(10) MACRO(11) MACRO(12) MACRO(13) MACRO(14) MACRO(15) MACRO(16) MACRO(17) MACRO(18) MACRO(19) MACRO(20) MACRO(21) MACRO(22) MACRO(23) MACRO(24) MACRO(25) MACRO(26) MACRO(27) MACRO(28) MACRO(29) MACRO(30) MACRO(31) MACRO(32) MACRO(33) MACRO(34) MACRO(35) MACRO(36) MACRO(37) MACRO(38) MACRO(39) MACRO(40) MACRO(41) MACRO(42) MACRO(43) MACRO(44) MACRO(45) MACRO(46) MACRO(47) MACRO(48) MACRO(49) MACRO(50) MACRO(51) MACRO(52) MACRO(53) MACRO(54) MACRO(55) MACRO(56) MACRO(57) MACRO(58) MACRO(59) MACRO(60) MACRO(61) MACRO(62) MACRO(63)
-#define UNROLL_128_TIMES(MACRO) MACRO(0) MACRO(1) MACRO(2) MACRO(3) MACRO(4) MACRO(5) MACRO(6) MACRO(7) MACRO(8) MACRO(9) MACRO(10) MACRO(11) MACRO(12) MACRO(13) MACRO(14) MACRO(15) MACRO(16) MACRO(17) MACRO(18) MACRO(19) MACRO(20) MACRO(21) MACRO(22) MACRO(23) MACRO(24) MACRO(25) MACRO(26) MACRO(27) MACRO(28) MACRO(29) MACRO(30) MACRO(31) MACRO(32) MACRO(33) MACRO(34) MACRO(35) MACRO(36) MACRO(37) MACRO(38) MACRO(39) MACRO(40) MACRO(41) MACRO(42) MACRO(43) MACRO(44) MACRO(45) MACRO(46) MACRO(47) MACRO(48) MACRO(49) MACRO(50) MACRO(51) MACRO(52) MACRO(53) MACRO(54) MACRO(55) MACRO(56) MACRO(57) MACRO(58) MACRO(59) MACRO(60) MACRO(61) MACRO(62) MACRO(63) MACRO(64) MACRO(65) MACRO(66) MACRO(67) MACRO(68) MACRO(69) MACRO(70) MACRO(71) MACRO(72) MACRO(73) MACRO(74) MACRO(75) MACRO(76) MACRO(77) MACRO(78) MACRO(79) MACRO(80) MACRO(81) MACRO(82) MACRO(83) MACRO(84) MACRO(85) MACRO(86) MACRO(87) MACRO(88) MACRO(89) MACRO(90) MACRO(91) MACRO(92) MACRO(93) MACRO(94) MACRO(95) MACRO(96) MACRO(97) MACRO(98) MACRO(99) MACRO(100) MACRO(101) MACRO(102) MACRO(103) MACRO(104) MACRO(105) MACRO(106) MACRO(107) MACRO(108) MACRO(109) MACRO(110) MACRO(111) MACRO(112) MACRO(113) MACRO(114) MACRO(115) MACRO(116) MACRO(117) MACRO(118) MACRO(119) MACRO(120) MACRO(121) MACRO(122) MACRO(123) MACRO(124) MACRO(125) MACRO(126) MACRO(127)
-#define UNROLL_256_TIMES(MACRO) MACRO(0) MACRO(1) MACRO(2) MACRO(3) MACRO(4) MACRO(5) MACRO(6) MACRO(7) MACRO(8) MACRO(9) MACRO(10) MACRO(11) MACRO(12) MACRO(13) MACRO(14) MACRO(15) MACRO(16) MACRO(17) MACRO(18) MACRO(19) MACRO(20) MACRO(21) MACRO(22) MACRO(23) MACRO(24) MACRO(25) MACRO(26) MACRO(27) MACRO(28) MACRO(29) MACRO(30) MACRO(31) MACRO(32) MACRO(33) MACRO(34) MACRO(35) MACRO(36) MACRO(37) MACRO(38) MACRO(39) MACRO(40) MACRO(41) MACRO(42) MACRO(43) MACRO(44) MACRO(45) MACRO(46) MACRO(47) MACRO(48) MACRO(49) MACRO(50) MACRO(51) MACRO(52) MACRO(53) MACRO(54) MACRO(55) MACRO(56) MACRO(57) MACRO(58) MACRO(59) MACRO(60) MACRO(61) MACRO(62) MACRO(63) MACRO(64) MACRO(65) MACRO(66) MACRO(67) MACRO(68) MACRO(69) MACRO(70) MACRO(71) MACRO(72) MACRO(73) MACRO(74) MACRO(75) MACRO(76) MACRO(77) MACRO(78) MACRO(79) MACRO(80) MACRO(81) MACRO(82) MACRO(83) MACRO(84) MACRO(85) MACRO(86) MACRO(87) MACRO(88) MACRO(89) MACRO(90) MACRO(91) MACRO(92) MACRO(93) MACRO(94) MACRO(95) MACRO(96) MACRO(97) MACRO(98) MACRO(99) MACRO(100) MACRO(101) MACRO(102) MACRO(103) MACRO(104) MACRO(105) MACRO(106) MACRO(107) MACRO(108) MACRO(109) MACRO(110) MACRO(111) MACRO(112) MACRO(113) MACRO(114) MACRO(115) MACRO(116) MACRO(117) MACRO(118) MACRO(119) MACRO(120) MACRO(121) MACRO(122) MACRO(123) MACRO(124) MACRO(125) MACRO(126) MACRO(127) \
- MACRO(128) MACRO(129) MACRO(130) MACRO(131) MACRO(132) MACRO(133) MACRO(134) MACRO(135) MACRO(136) MACRO(137) MACRO(138) MACRO(139) MACRO(140) MACRO(141) MACRO(142) MACRO(143) MACRO(144) MACRO(145) MACRO(146) MACRO(147) MACRO(148) MACRO(149) MACRO(150) MACRO(151) MACRO(152) MACRO(153) MACRO(154) MACRO(155) MACRO(156) MACRO(157) MACRO(158) MACRO(159) MACRO(160) MACRO(161) MACRO(162) MACRO(163) MACRO(164) MACRO(165) MACRO(166) MACRO(167) MACRO(168) MACRO(169) MACRO(170) MACRO(171) MACRO(172) MACRO(173) MACRO(174) MACRO(175) MACRO(176) MACRO(177) MACRO(178) MACRO(179) MACRO(180) MACRO(181) MACRO(182) MACRO(183) MACRO(184) MACRO(185) MACRO(186) MACRO(187) MACRO(188) MACRO(189) MACRO(190) MACRO(191) MACRO(192) MACRO(193) MACRO(194) MACRO(195) MACRO(196) MACRO(197) MACRO(198) MACRO(199) MACRO(200) MACRO(201) MACRO(202) MACRO(203) MACRO(204) MACRO(205) MACRO(206) MACRO(207) MACRO(208) MACRO(209) MACRO(210) MACRO(211) MACRO(212) MACRO(213) MACRO(214) MACRO(215) MACRO(216) MACRO(217) MACRO(218) MACRO(219) MACRO(220) MACRO(221) MACRO(222) MACRO(223) MACRO(224) MACRO(225) MACRO(226) MACRO(227) MACRO(228) MACRO(229) MACRO(230) MACRO(231) MACRO(232) MACRO(233) MACRO(234) MACRO(235) MACRO(236) MACRO(237) MACRO(238) MACRO(239) MACRO(240) MACRO(241) MACRO(242) MACRO(243) MACRO(244) MACRO(245) MACRO(246) MACRO(247) MACRO(248) MACRO(249) MACRO(250) MACRO(251) MACRO(252) MACRO(253) MACRO(254) MACRO(255)
-
-/*****************************************************************************************
-Error Codes
-*****************************************************************************************/
-
-// success
-#ifndef ERROR_SUCCESS
-#define ERROR_SUCCESS 0
-#endif
-
-// file and i/o errors (1000's)
-#define ERROR_IO_READ 1000
-#define ERROR_IO_WRITE 1001
-#define ERROR_INVALID_INPUT_FILE 1002
-#define ERROR_INVALID_OUTPUT_FILE 1003
-#define ERROR_INPUT_FILE_TOO_LARGE 1004
-#define ERROR_INPUT_FILE_UNSUPPORTED_BIT_DEPTH 1005
-#define ERROR_INPUT_FILE_UNSUPPORTED_SAMPLE_RATE 1006
-#define ERROR_INPUT_FILE_UNSUPPORTED_CHANNEL_COUNT 1007
-#define ERROR_INPUT_FILE_TOO_SMALL 1008
-#define ERROR_INVALID_CHECKSUM 1009
-#define ERROR_DECOMPRESSING_FRAME 1010
-#define ERROR_INITIALIZING_UNMAC 1011
-#define ERROR_INVALID_FUNCTION_PARAMETER 1012
-#define ERROR_UNSUPPORTED_FILE_TYPE 1013
-#define ERROR_UPSUPPORTED_FILE_VERSION 1014
-
-// memory errors (2000's)
-#define ERROR_INSUFFICIENT_MEMORY 2000
-
-// dll errors (3000's)
-#define ERROR_LOADINGAPE_DLL 3000
-#define ERROR_LOADINGAPE_INFO_DLL 3001
-#define ERROR_LOADING_UNMAC_DLL 3002
-
-// general and misc errors
-#define ERROR_USER_STOPPED_PROCESSING 4000
-#define ERROR_SKIPPED 4001
-
-// programmer errors
-#define ERROR_BAD_PARAMETER 5000
-
-// IAPECompress errors
-#define ERROR_APE_COMPRESS_TOO_MUCH_DATA 6000
-
-// unknown error
-#define ERROR_UNDEFINED -1
-
-#define ERROR_EXPLANATION \
- { ERROR_IO_READ , "I/O read error" }, \
- { ERROR_IO_WRITE , "I/O write error" }, \
- { ERROR_INVALID_INPUT_FILE , "invalid input file" }, \
- { ERROR_INVALID_OUTPUT_FILE , "invalid output file" }, \
- { ERROR_INPUT_FILE_TOO_LARGE , "input file file too large" }, \
- { ERROR_INPUT_FILE_UNSUPPORTED_BIT_DEPTH , "input file unsupported bit depth" }, \
- { ERROR_INPUT_FILE_UNSUPPORTED_SAMPLE_RATE , "input file unsupported sample rate" }, \
- { ERROR_INPUT_FILE_UNSUPPORTED_CHANNEL_COUNT , "input file unsupported channel count" }, \
- { ERROR_INPUT_FILE_TOO_SMALL , "input file too small" }, \
- { ERROR_INVALID_CHECKSUM , "invalid checksum" }, \
- { ERROR_DECOMPRESSING_FRAME , "decompressing frame" }, \
- { ERROR_INITIALIZING_UNMAC , "initializing unmac" }, \
- { ERROR_INVALID_FUNCTION_PARAMETER , "invalid function parameter" }, \
- { ERROR_UNSUPPORTED_FILE_TYPE , "unsupported file type" }, \
- { ERROR_INSUFFICIENT_MEMORY , "insufficient memory" }, \
- { ERROR_LOADINGAPE_DLL , "loading MAC.dll" }, \
- { ERROR_LOADINGAPE_INFO_DLL , "loading MACinfo.dll" }, \
- { ERROR_LOADING_UNMAC_DLL , "loading UnMAC.dll" }, \
- { ERROR_USER_STOPPED_PROCESSING , "user stopped processing" }, \
- { ERROR_SKIPPED , "skipped" }, \
- { ERROR_BAD_PARAMETER , "bad parameter" }, \
- { ERROR_APE_COMPRESS_TOO_MUCH_DATA , "APE compress too much data" }, \
- { ERROR_UNDEFINED , "undefined" }, \
-
-#endif // #ifndef APE_ALL_H
\ No newline at end of file
diff --git a/MAC_SDK/Source/Shared/CharacterHelper.cpp b/MAC_SDK/Source/Shared/CharacterHelper.cpp
deleted file mode 100644
index fb4bbc6..0000000
--- a/MAC_SDK/Source/Shared/CharacterHelper.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-#include "All.h"
-#include "CharacterHelper.h"
-
-str_ansi * GetANSIFromUTF8(const str_utf8 * pUTF8)
-{
- str_utf16 * pUTF16 = GetUTF16FromUTF8(pUTF8);
- str_ansi * pANSI = GetANSIFromUTF16(pUTF16);
- delete [] pUTF16;
- return pANSI;
-}
-
-str_ansi * GetANSIFromUTF16(const str_utf16 * pUTF16)
-{
- const int nCharacters = pUTF16 ? wcslen(pUTF16) : 0;
- #ifdef _WIN32
- int nANSICharacters = (2 * nCharacters);
- str_ansi * pANSI = new str_ansi [nANSICharacters + 1];
- memset(pANSI, 0, (nANSICharacters + 1) * sizeof(str_ansi));
- if (pUTF16)
- WideCharToMultiByte(CP_ACP, 0, pUTF16, -1, pANSI, nANSICharacters, NULL, NULL);
- #else
- str_utf8 * pANSI = new str_utf8 [nCharacters + 1];
- for (int z = 0; z < nCharacters; z++)
- pANSI[z] = (pUTF16[z] >= 256) ? '?' : (str_utf8) pUTF16[z];
- pANSI[nCharacters] = 0;
- #endif
-
- return (str_ansi *) pANSI;
-}
-
-str_utf16 * GetUTF16FromANSI(const str_ansi * pANSI)
-{
- const int nCharacters = pANSI ? strlen(pANSI) : 0;
- str_utf16 * pUTF16 = new str_utf16 [nCharacters + 1];
-
- #ifdef _WIN32
- memset(pUTF16, 0, sizeof(str_utf16) * (nCharacters + 1));
- if (pANSI)
- MultiByteToWideChar(CP_ACP, 0, pANSI, -1, pUTF16, nCharacters);
- #else
- for (int z = 0; z < nCharacters; z++)
- pUTF16[z] = (str_utf16) ((str_utf8) pANSI[z]);
- pUTF16[nCharacters] = 0;
- #endif
-
- return pUTF16;
-}
-
-str_utf16 * GetUTF16FromUTF8(const str_utf8 * pUTF8)
-{
- // get the length
- int nCharacters = 0; int nIndex = 0;
- while (pUTF8[nIndex] != 0)
- {
- if ((pUTF8[nIndex] & 0x80) == 0)
- nIndex += 1;
- else if ((pUTF8[nIndex] & 0xE0) == 0xE0)
- nIndex += 3;
- else
- nIndex += 2;
-
- nCharacters += 1;
- }
-
- // make a UTF-16 string
- str_utf16 * pUTF16 = new str_utf16 [nCharacters + 1];
- nIndex = 0; nCharacters = 0;
- while (pUTF8[nIndex] != 0)
- {
- if ((pUTF8[nIndex] & 0x80) == 0)
- {
- pUTF16[nCharacters] = pUTF8[nIndex];
- nIndex += 1;
- }
- else if ((pUTF8[nIndex] & 0xE0) == 0xE0)
- {
- pUTF16[nCharacters] = ((pUTF8[nIndex] & 0x1F) << 12) | ((pUTF8[nIndex + 1] & 0x3F) << 6) | (pUTF8[nIndex + 2] & 0x3F);
- nIndex += 3;
- }
- else
- {
- pUTF16[nCharacters] = ((pUTF8[nIndex] & 0x3F) << 6) | (pUTF8[nIndex + 1] & 0x3F);
- nIndex += 2;
- }
-
- nCharacters += 1;
- }
- pUTF16[nCharacters] = 0;
-
- return pUTF16;
-}
-
-str_utf8 * GetUTF8FromANSI(const str_ansi * pANSI)
-{
- str_utf16 * pUTF16 = GetUTF16FromANSI(pANSI);
- str_utf8 * pUTF8 = GetUTF8FromUTF16(pUTF16);
- delete [] pUTF16;
- return pUTF8;
-}
-
-str_utf8 * GetUTF8FromUTF16(const str_utf16 * pUTF16)
-{
- // get the size(s)
- int nCharacters = wcslen(pUTF16);
- int nUTF8Bytes = 0;
- for (int z = 0; z < nCharacters; z++)
- {
- if (pUTF16[z] < 0x0080)
- nUTF8Bytes += 1;
- else if (pUTF16[z] < 0x0800)
- nUTF8Bytes += 2;
- else
- nUTF8Bytes += 3;
- }
-
- // allocate a UTF-8 string
- str_utf8 * pUTF8 = new str_utf8 [nUTF8Bytes + 1];
-
- // create the UTF-8 string
- int nUTF8Index = 0;
- for (int z = 0; z < nCharacters; z++)
- {
- if (pUTF16[z] < 0x0080)
- {
- pUTF8[nUTF8Index++] = (str_utf8) pUTF16[z];
- }
- else if (pUTF16[z] < 0x0800)
- {
- pUTF8[nUTF8Index++] = 0xC0 | (pUTF16[z] >> 6);
- pUTF8[nUTF8Index++] = 0x80 | (pUTF16[z] & 0x3F);
- }
- else
- {
- pUTF8[nUTF8Index++] = 0xE0 | (pUTF16[z] >> 12);
- pUTF8[nUTF8Index++] = 0x80 | ((pUTF16[z] >> 6) & 0x3F);
- pUTF8[nUTF8Index++] = 0x80 | (pUTF16[z] & 0x3F);
- }
- }
- pUTF8[nUTF8Index++] = 0;
-
- // return the UTF-8 string
- return pUTF8;
-}
\ No newline at end of file
diff --git a/MAC_SDK/Source/Shared/CharacterHelper.h b/MAC_SDK/Source/Shared/CharacterHelper.h
deleted file mode 100644
index 6f63a1e..0000000
--- a/MAC_SDK/Source/Shared/CharacterHelper.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************************
-Character set conversion helpers
-*******************************************************************************************/
-
-#ifndef CHARACTER_HELPER_H
-#define CHARACTER_HELPER_H
-
-str_ansi * GetANSIFromUTF8(const str_utf8 * pUTF8);
-str_ansi * GetANSIFromUTF16(const str_utf16 * pUTF16);
-str_utf16 * GetUTF16FromANSI(const str_ansi * pANSI);
-str_utf16 * GetUTF16FromUTF8(const str_utf8 * pUTF8);
-str_utf8 * GetUTF8FromANSI(const str_ansi * pANSI);
-str_utf8 * GetUTF8FromUTF16(const str_utf16 * pUTF16);
-
-#endif // #ifndef CHARACTER_HELPER_H
\ No newline at end of file
diff --git a/MAC_SDK/Source/Shared/CircleBuffer.cpp b/MAC_SDK/Source/Shared/CircleBuffer.cpp
deleted file mode 100644
index 7ed9ec2..0000000
--- a/MAC_SDK/Source/Shared/CircleBuffer.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "All.h"
-#include "CircleBuffer.h"
-
-CCircleBuffer::CCircleBuffer()
-{
- m_pBuffer = NULL;
- m_nTotal = 0;
- m_nHead = 0;
- m_nTail = 0;
- m_nEndCap = 0;
- m_nMaxDirectWriteBytes = 0;
-}
-
-CCircleBuffer::~CCircleBuffer()
-{
- SAFE_ARRAY_DELETE(m_pBuffer)
-}
-
-void CCircleBuffer::CreateBuffer(int nBytes, int nMaxDirectWriteBytes)
-{
- SAFE_ARRAY_DELETE(m_pBuffer)
-
- m_nMaxDirectWriteBytes = nMaxDirectWriteBytes;
- m_nTotal = nBytes + 1 + nMaxDirectWriteBytes;
- m_pBuffer = new unsigned char [m_nTotal];
- m_nHead = 0;
- m_nTail = 0;
- m_nEndCap = m_nTotal;
-}
-
-int CCircleBuffer::MaxAdd()
-{
- int nMaxAdd = (m_nTail >= m_nHead) ? (m_nTotal - 1 - m_nMaxDirectWriteBytes) - (m_nTail - m_nHead) : m_nHead - m_nTail - 1;
- return nMaxAdd;
-}
-
-int CCircleBuffer::MaxGet()
-{
- return (m_nTail >= m_nHead) ? m_nTail - m_nHead : (m_nEndCap - m_nHead) + m_nTail;
-}
-
-int CCircleBuffer::Get(unsigned char * pBuffer, int nBytes)
-{
- int nTotalGetBytes = 0;
-
- if (pBuffer != NULL && nBytes > 0)
- {
- int nHeadBytes = min(m_nEndCap - m_nHead, nBytes);
- int nFrontBytes = nBytes - nHeadBytes;
-
- memcpy(&pBuffer[0], &m_pBuffer[m_nHead], nHeadBytes);
- nTotalGetBytes = nHeadBytes;
-
- if (nFrontBytes > 0)
- {
- memcpy(&pBuffer[nHeadBytes], &m_pBuffer[0], nFrontBytes);
- nTotalGetBytes += nFrontBytes;
- }
-
- RemoveHead(nBytes);
- }
-
- return nTotalGetBytes;
-}
-
-void CCircleBuffer::Empty()
-{
- m_nHead = 0;
- m_nTail = 0;
- m_nEndCap = m_nTotal;
-}
-
-int CCircleBuffer::RemoveHead(int nBytes)
-{
- nBytes = min(MaxGet(), nBytes);
- m_nHead += nBytes;
- if (m_nHead >= m_nEndCap)
- m_nHead -= m_nEndCap;
- return nBytes;
-}
-
-int CCircleBuffer::RemoveTail(int nBytes)
-{
- nBytes = min(MaxGet(), nBytes);
- m_nTail -= nBytes;
- if (m_nTail < 0)
- m_nTail += m_nEndCap;
- return nBytes;
-}
diff --git a/MAC_SDK/Source/Shared/CircleBuffer.h b/MAC_SDK/Source/Shared/CircleBuffer.h
deleted file mode 100644
index 3d008dd..0000000
--- a/MAC_SDK/Source/Shared/CircleBuffer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef APE_CIRCLEBUFFER_H
-#define APE_CIRCLEBUFFER_H
-
-class CCircleBuffer
-{
-public:
-
- // construction / destruction
- CCircleBuffer();
- virtual ~CCircleBuffer();
-
- // create the buffer
- void CreateBuffer(int nBytes, int nMaxDirectWriteBytes);
-
- // query
- int MaxAdd();
- int MaxGet();
-
- // direct writing
- inline unsigned char * CCircleBuffer::GetDirectWritePointer()
- {
- // return a pointer to the tail -- note that it will always be safe to write
- // at least m_nMaxDirectWriteBytes since we use an end cap region
- return &m_pBuffer[m_nTail];
- }
-
- inline void CCircleBuffer::UpdateAfterDirectWrite(int nBytes)
- {
- // update the tail
- m_nTail += nBytes;
-
- // if the tail enters the "end cap" area, set the end cap and loop around
- if (m_nTail >= (m_nTotal - m_nMaxDirectWriteBytes))
- {
- m_nEndCap = m_nTail;
- m_nTail = 0;
- }
- }
-
- // get data
- int Get(unsigned char * pBuffer, int nBytes);
-
- // remove / empty
- void Empty();
- int RemoveHead(int nBytes);
- int RemoveTail(int nBytes);
-
-private:
-
- int m_nTotal;
- int m_nMaxDirectWriteBytes;
- int m_nEndCap;
- int m_nHead;
- int m_nTail;
- unsigned char * m_pBuffer;
-};
-
-
-#endif // #ifndef APE_CIRCLEBUFFER_H
diff --git a/MAC_SDK/Source/Shared/GlobalFunctions.cpp b/MAC_SDK/Source/Shared/GlobalFunctions.cpp
deleted file mode 100644
index 5f0b578..0000000
--- a/MAC_SDK/Source/Shared/GlobalFunctions.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "All.h"
-#include "GlobalFunctions.h"
-#include "IO.h"
-
-/*
-#ifndef __GNUC_IA32__
-
-extern "C" BOOL GetMMXAvailable(void)
-{
-#ifdef ENABLE_ASSEMBLY
-
- unsigned long nRegisterEDX;
-
- try
- {
- __asm mov eax, 1
- __asm CPUID
- __asm mov nRegisterEDX, edx
- }
- catch(...)
- {
- return FALSE;
- }
-
- if (nRegisterEDX & 0x800000)
- RETURN_ON_EXCEPTION(__asm emms, FALSE)
- else
- return FALSE;
-
- return TRUE;
-
-#else
- return FALSE;
-#endif
-}
-
-#endif // #ifndef __GNUC_IA32__
-*/
-
-int ReadSafe(CIO * pIO, void * pBuffer, int nBytes)
-{
- unsigned int nBytesRead = 0;
- int nRetVal = pIO->Read(pBuffer, nBytes, &nBytesRead);
- if (nRetVal == ERROR_SUCCESS)
- {
- if (nBytes != int(nBytesRead))
- nRetVal = ERROR_IO_READ;
- }
-
- return nRetVal;
-}
-
-int WriteSafe(CIO * pIO, void * pBuffer, int nBytes)
-{
- unsigned int nBytesWritten = 0;
- int nRetVal = pIO->Write(pBuffer, nBytes, &nBytesWritten);
- if (nRetVal == ERROR_SUCCESS)
- {
- if (nBytes != int(nBytesWritten))
- nRetVal = ERROR_IO_WRITE;
- }
-
- return nRetVal;
-}
-
-BOOL FileExists(wchar_t * pFilename)
-{
- if (0 == wcscmp(pFilename, L"-") || 0 == wcscmp(pFilename, L"/dev/stdin"))
- return TRUE;
-
-#ifdef _WIN32
-
- BOOL bFound = FALSE;
-
- WIN32_FIND_DATA WFD;
- HANDLE hFind = FindFirstFile(pFilename, &WFD);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- bFound = TRUE;
- CloseHandle(hFind);
- }
-
- return bFound;
-
-#else
-
- CSmartPtr spANSI(GetANSIFromUTF16(pFilename), TRUE);
-
- struct stat b;
-
- if (stat(spANSI, &b) != 0)
- return FALSE;
-
- if (!S_ISREG(b.st_mode))
- return FALSE;
-
- return TRUE;
-
-#endif
-}
\ No newline at end of file
diff --git a/MAC_SDK/Source/Shared/GlobalFunctions.h b/MAC_SDK/Source/Shared/GlobalFunctions.h
deleted file mode 100644
index 0928cbb..0000000
--- a/MAC_SDK/Source/Shared/GlobalFunctions.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef APE_GLOBALFUNCTIONS_H
-#define APE_GLOBALFUNCTIONS_H
-
-/*************************************************************************************
-Definitions
-*************************************************************************************/
-class CIO;
-
-/*************************************************************************************
-Read / Write from an IO source and return failure if the number of bytes specified
-isn't read or written
-*************************************************************************************/
-int ReadSafe(CIO * pIO, void * pBuffer, int nBytes);
-int WriteSafe(CIO * pIO, void * pBuffer, int nBytes);
-
-/*************************************************************************************
-Checks for the existence of a file
-*************************************************************************************/
-BOOL FileExists(wchar_t * pFilename);
-
-#endif // #ifndef APE_GLOBALFUNCTIONS_H
diff --git a/MAC_SDK/Source/Shared/ID3Genres.h b/MAC_SDK/Source/Shared/ID3Genres.h
deleted file mode 100644
index aa168ee..0000000
--- a/MAC_SDK/Source/Shared/ID3Genres.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef APE_ID3GENRES_H
-#define APE_ID3GENRES_H
-
-#define GENRE_UNDEFINED 255
-#define GENRE_COUNT 148
-
-const LPCWSTR g_ID3Genre[GENRE_COUNT] =
-{
- L"Blues", L"Classic Rock", L"Country", L"Dance", L"Disco", L"Funk", L"Grunge", L"Hip-Hop",
- L"Jazz", L"Metal", L"New Age", L"Oldies", L"Other", L"Pop", L"R&B", L"Rap", L"Reggae", L"Rock", L"Techno",
- L"Industrial", L"Alternative", L"Ska", L"Death Metal", L"Pranks", L"Soundtrack", L"Euro-Techno", L"Ambient",
- L"Trip-Hop", L"Vocal", L"Jazz+Funk", L"Fusion", L"Trance", L"Classical", L"Instrumental", L"Acid", L"House", L"Game",
- L"Sound Clip", L"Gospel", L"Noise", L"AlternRock", L"Bass", L"Soul", L"Punk", L"Space", L"Meditative", L"Instrumental Pop",
- L"Instrumental Rock", L"Ethnic", L"Gothic", L"Darkwave", L"Techno-Industrial", L"Electronic", L"Pop-Folk", L"Eurodance",
- L"Dream", L"Southern Rock", L"Comedy", L"Cult", L"Gangsta", L"Top 40", L"Christian Rap", L"Pop/Funk", L"Jungle",
- L"Native American", L"Cabaret", L"New Wave", L"Psychadelic", L"Rave", L"Showtunes", L"Trailer", L"Lo-Fi", L"Tribal",
- L"Acid Punk", L"Acid Jazz", L"Polka", L"Retro", L"Musical", L"Rock & Roll", L"Hard Rock", L"Folk", L"Folk-Rock", L"National Folk",
- L"Swing", L"Fast Fusion", L"Bebop", L"Latin", L"Revival", L"Celtic", L"Bluegrass", L"Avantgarde", L"Gothic Rock", L"Progressive Rock",
- L"Psychedelic Rock", L"Symphonic Rock", L"Slow Rock", L"Big Band", L"Chorus", L"Easy Listening", L"Acoustic", L"Humour",
- L"Speech", L"Chanson", L"Opera", L"Chamber Music", L"Sonata", L"Symphony", L"Booty Bass", L"Primus", L"Porn Groove",
- L"Satire", L"Slow Jam", L"Club", L"Tango", L"Samba", L"Folklore", L"Ballad", L"Power Ballad", L"Rhythmic Soul", L"Freestyle",
- L"Duet", L"Punk Rock", L"Drum Solo", L"Acapella", L"Euro-House", L"Dance Hall", L"Goa", L"Drum & Bass", L"Club House", L"Hardcore",
- L"Terror", L"Indie", L"BritPop", L"Black Punk", L"Polsk Punk", L"Beat", L"Christian Gangsta", L"Heavy Metal", L"Black Metal",
- L"Crossover", L"Contemporary C", L"Christian Rock", L"Merengue", L"Salsa", L"Thrash Metal", L"Anime", L"JPop", L"SynthPop"
-};
-
-#endif // #ifndef APE_ID3GENRES_H
diff --git a/MAC_SDK/Source/Shared/IO.h b/MAC_SDK/Source/Shared/IO.h
deleted file mode 100644
index ddf46bb..0000000
--- a/MAC_SDK/Source/Shared/IO.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef APE_IO_H
-#define APE_IO_H
-
-#ifndef FILE_BEGIN
- #define FILE_BEGIN 0
-#endif
-
-#ifndef FILE_CURRENT
- #define FILE_CURRENT 1
-#endif
-
-#ifndef FILE_END
- #define FILE_END 2
-#endif
-
-class CIO
-{
-
-public:
-
- //construction / destruction
- CIO() { }
- virtual ~CIO() { };
-
- // open / close
- virtual int Open(const wchar_t * pName, int fReadonly = 0) = 0;
- virtual int Close() = 0;
-
- // read / write
- virtual int Read(void * pBuffer, unsigned int nBytesToRead, unsigned int * pBytesRead) = 0;
- virtual int Write(const void * pBuffer, unsigned int nBytesToWrite, unsigned int * pBytesWritten) = 0;
-
- // seek
- virtual int Seek(int nDistance, unsigned int nMoveMode) = 0;
-
- // creation / destruction
- virtual int Create(const wchar_t * pName) = 0;
- virtual int Delete() = 0;
-
- // other functions
- virtual int SetEOF() = 0;
-
- // attributes
- virtual int GetPosition() = 0;
- virtual int GetSize() = 0;
- virtual int GetName(wchar_t * pBuffer) = 0;
-};
-
-#endif // #ifndef APE_IO_H
diff --git a/MAC_SDK/Source/Shared/NoWindows.h b/MAC_SDK/Source/Shared/NoWindows.h
deleted file mode 100644
index e6519d7..0000000
--- a/MAC_SDK/Source/Shared/NoWindows.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef _WIN32
-
-#ifndef APE_NOWINDOWS_H
-#define APE_NOWINDOWS_H
-
-#define FALSE 0
-#define TRUE 1
-
-#define NEAR
-#define FAR
-
-typedef unsigned int uint32;
-typedef int int32;
-typedef unsigned short uint16;
-typedef short int16;
-typedef unsigned char uint8;
-typedef char int8;
-typedef char str_ansi;
-typedef unsigned char str_utf8;
-typedef wchar_t str_utf16;
-
-typedef unsigned long DWORD;
-typedef int BOOL;
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef float FLOAT;
-typedef void * HANDLE;
-typedef unsigned int UINT;
-typedef unsigned int WPARAM;
-typedef long LPARAM;
-typedef const char * LPCSTR;
-typedef char * LPSTR;
-typedef long LRESULT;
-
-#define ZeroMemory(POINTER, BYTES) memset(POINTER, 0, BYTES);
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-
-#define __stdcall
-#define CALLBACK
-
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-
-#define _FPOSOFF(fp) ((long)(fp).__pos)
-#define MAX_PATH 260
-
-#ifndef _WAVEFORMATEX_
-#define _WAVEFORMATEX_
-
-typedef struct tWAVEFORMATEX
-{
- WORD wFormatTag; /* format type */
- WORD nChannels; /* number of channels (i.e. mono, stereo...) */
- DWORD nSamplesPerSec; /* sample rate */
- DWORD nAvgBytesPerSec; /* for buffer estimation */
- WORD nBlockAlign; /* block size of data */
- WORD wBitsPerSample; /* number of bits per sample of mono data */
- WORD cbSize; /* the count in bytes of the size of */
- /* extra information (after cbSize) */
-} WAVEFORMATEX, *PWAVEFORMATEX, NEAR *NPWAVEFORMATEX, FAR *LPWAVEFORMATEX;
-typedef const WAVEFORMATEX FAR *LPCWAVEFORMATEX;
-
-#endif // #ifndef _WAVEFORMATEX_
-
-#endif // #ifndef APE_NOWINDOWS_H
-
-#endif // #ifndef _WIN32
diff --git a/MAC_SDK/Source/Shared/RollBuffer.h b/MAC_SDK/Source/Shared/RollBuffer.h
deleted file mode 100644
index 0c5b8e0..0000000
--- a/MAC_SDK/Source/Shared/RollBuffer.h
+++ /dev/null
@@ -1,120 +0,0 @@
-#ifndef APE_ROLLBUFFER_H
-#define APE_ROLLBUFFER_H
-
-template class CRollBuffer
-{
-public:
-
- CRollBuffer()
- {
- m_pData = NULL;
- m_pCurrent = NULL;
- }
-
- ~CRollBuffer()
- {
- SAFE_ARRAY_DELETE(m_pData);
- }
-
- int Create(int nWindowElements, int nHistoryElements)
- {
- SAFE_ARRAY_DELETE(m_pData)
- m_nWindowElements = nWindowElements;
- m_nHistoryElements = nHistoryElements;
-
- m_pData = new TYPE[m_nWindowElements + m_nHistoryElements];
- if (m_pData == NULL)
- return ERROR_INSUFFICIENT_MEMORY;
-
- Flush();
- return 0;
- }
-
- void Flush()
- {
- ZeroMemory(m_pData, (m_nHistoryElements + 1) * sizeof(TYPE));
- m_pCurrent = &m_pData[m_nHistoryElements];
- }
-
- void Roll()
- {
- memcpy(&m_pData[0], &m_pCurrent[-m_nHistoryElements], m_nHistoryElements * sizeof(TYPE));
- m_pCurrent = &m_pData[m_nHistoryElements];
- }
-
- __inline void IncrementSafe()
- {
- m_pCurrent++;
- if (m_pCurrent == &m_pData[m_nWindowElements + m_nHistoryElements])
- Roll();
- }
-
- __inline void IncrementFast()
- {
- m_pCurrent++;
- }
-
- __inline TYPE & operator[](const int nIndex) const
- {
- return m_pCurrent[nIndex];
- }
-
-protected:
-
- TYPE * m_pData;
- TYPE * m_pCurrent;
- int m_nHistoryElements;
- int m_nWindowElements;
-};
-
-template class CRollBufferFast
-{
-public:
-
- CRollBufferFast()
- {
- m_pData = new TYPE[WINDOW_ELEMENTS + HISTORY_ELEMENTS];
- Flush();
- }
-
- ~CRollBufferFast()
- {
- SAFE_ARRAY_DELETE(m_pData);
- }
-
- void Flush()
- {
- ZeroMemory(m_pData, (HISTORY_ELEMENTS + 1) * sizeof(TYPE));
- m_pCurrent = &m_pData[HISTORY_ELEMENTS];
- }
-
- void Roll()
- {
- memcpy(&m_pData[0], &m_pCurrent[-HISTORY_ELEMENTS], HISTORY_ELEMENTS * sizeof(TYPE));
- m_pCurrent = &m_pData[HISTORY_ELEMENTS];
- }
-
- __inline void IncrementSafe()
- {
- m_pCurrent++;
- if (m_pCurrent == &m_pData[WINDOW_ELEMENTS + HISTORY_ELEMENTS])
- Roll();
- }
-
- __inline void IncrementFast()
- {
- m_pCurrent++;
- }
-
- __inline TYPE & operator[](const int nIndex) const
- {
- return m_pCurrent[nIndex];
- }
-
-protected:
-
- TYPE * m_pData;
- TYPE * m_pCurrent;
-};
-
-#endif // #ifndef APE_ROLLBUFFER_H
diff --git a/MAC_SDK/Source/Shared/SmartPtr.h b/MAC_SDK/Source/Shared/SmartPtr.h
deleted file mode 100644
index c9bb9be..0000000
--- a/MAC_SDK/Source/Shared/SmartPtr.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef APE_SMARTPTR_H
-#define APE_SMARTPTR_H
-
-// disable the operator -> on UDT warning
-#ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4284)
-#endif
-
-/*************************************************************************************************
-CSmartPtr - a simple smart pointer class that can automatically initialize and free memory
- note: (doesn't do garbage collection / reference counting because of the many pitfalls)
-*************************************************************************************************/
-template class CSmartPtr
-{
-public:
- TYPE * m_pObject;
- BOOL m_bArray;
- BOOL m_bDelete;
-
- CSmartPtr()
- {
- m_bDelete = TRUE;
- m_pObject = NULL;
- }
- CSmartPtr(TYPE * a_pObject, BOOL a_bArray = FALSE, BOOL a_bDelete = TRUE)
- {
- m_bDelete = TRUE;
- m_pObject = NULL;
- Assign(a_pObject, a_bArray, a_bDelete);
- }
-
- ~CSmartPtr()
- {
- Delete();
- }
-
- void Assign(TYPE * a_pObject, BOOL a_bArray = FALSE, BOOL a_bDelete = TRUE)
- {
- Delete();
-
- m_bDelete = a_bDelete;
- m_bArray = a_bArray;
- m_pObject = a_pObject;
- }
-
- void Delete()
- {
- if (m_bDelete && m_pObject)
- {
- if (m_bArray)
- delete [] m_pObject;
- else
- delete m_pObject;
-
- m_pObject = NULL;
- }
- }
-
- void SetDelete(const BOOL a_bDelete)
- {
- m_bDelete = a_bDelete;
- }
-
- __inline TYPE * GetPtr() const
- {
- return m_pObject;
- }
-
- __inline operator TYPE * () const
- {
- return m_pObject;
- }
-
- __inline TYPE * operator ->() const
- {
- return m_pObject;
- }
-
- // declare assignment, but don't implement (compiler error if we try to use)
- // that way we can't carelessly mix smart pointers and regular pointers
- __inline void * operator =(void *) const;
-};
-
-#ifdef _MSC_VER
- #pragma warning(pop)
-#endif _MSC_VER
-
-#endif // #ifndef APE_SMARTPTR_H
diff --git a/MAC_SDK/Source/Shared/StdLibFileIO.cpp b/MAC_SDK/Source/Shared/StdLibFileIO.cpp
deleted file mode 100644
index 5f59069..0000000
--- a/MAC_SDK/Source/Shared/StdLibFileIO.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-#include "All.h"
-
-#ifdef IO_USE_STD_LIB_FILE_IO
-
-#include "StdLibFileIO.h"
-
-///////////////////////////////////////////////////////
-
-// low level I/O, where are prototypes and constants?
-#if defined _WIN32 || defined __TURBOC__ || defined __ZTC__ || defined _MSC_VER
-# include
-# include
-# include
-# include
-# include
-#elif defined __unix__ || defined __linux__
-# include
-# include
-# include
-# include
-# include
-# include
-#else
-# include
-# include
-# include
-# include
-#endif
-
-
-#ifndef O_BINARY
-# ifdef _O_BINARY
-# define O_BINARY _O_BINARY
-# else
-# define O_BINARY 0
-# endif
-#endif
-
-//// Binary/Low-Level-IO ///////////////////////////////////////////
-//
-// All file I/O is basicly handled via an ANSI file pointer (type: FILE*) in
-// FILEIO-Mode 1 and via a POSIX file descriptor (type: int) in
-// FILEIO-Mode 2 and 3.
-//
-// Some operation are only available via the POSIX interface (fcntl, setmode,
-// ...) so we need a function to get the file descriptor from a file pointer.
-// In FILEIO-Mode 2 and 3 this is a dummy function because we always working
-// with this file descriptors.
-//
-
-#if defined __BORLANDC__ || defined _WIN32
-# define FILENO(__fp) _fileno ((__fp))
-#elif defined __CYGWIN__ || defined __TURBOC__ || defined __unix__ || defined __EMX__ || defined _MSC_VER
-# define FILENO(__fp) fileno ((__fp))
-#else
-# define FILENO(__fp) fileno ((__fp))
-#endif
-
-
-//
-// If we have access to a file via file name, we can open the file with an
-// additional "b" or a O_BINARY within the (f)open function to get a
-// transparent untranslated data stream which is necessary for audio bitstream
-// data and also for PCM data. If we are working with
-// stdin/stdout/FILENO_STDIN/FILENO_STDOUT we can't open the file with this
-// attributes, because the files are already open. So we need a non
-// standardized sequence to switch to this mode (not necessary for Unix).
-// Mostly the sequency is the same for incoming and outgoing streams, but only
-// mostly so we need one for IN and one for OUT.
-// Macros are called with the file pointer and you get back the untransalted file
-// pointer which can be equal or different from the original.
-//
-
-#if defined __EMX__
-# define SETBINARY_IN(__fp) (_fsetmode ( (__fp), "b" ), (__fp))
-# define SETBINARY_OUT(__fp) (_fsetmode ( (__fp), "b" ), (__fp))
-#elif defined __TURBOC__ || defined __BORLANDC__
-# define SETBINARY_IN(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
-#elif defined __CYGWIN__
-# define SETBINARY_IN(__fp) (setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp) (setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
-#elif defined _WIN32
-# define SETBINARY_IN(__fp) (_setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp) (_setmode ( FILENO ((__fp)), _O_BINARY ), (__fp))
-#elif defined _MSC_VER
-# define SETBINARY_IN(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp) (setmode ( FILENO ((__fp)), O_BINARY ), (__fp))
-#elif defined __unix__
-# define SETBINARY_IN(__fp) (__fp)
-# define SETBINARY_OUT(__fp) (__fp)
-#elif 0
-# define SETBINARY_IN(__fp) (freopen ( NULL, "rb", (__fp) ), (__fp))
-# define SETBINARY_OUT(__fp) (freopen ( NULL, "wb", (__fp) ), (__fp))
-#else
-# define SETBINARY_IN(__fp) (__fp)
-# define SETBINARY_OUT(__fp) (__fp)
-#endif
-
-
-///////////////////////////////////////////////////////
-
-CStdLibFileIO::CStdLibFileIO()
-{
- memset(m_cFileName, 0, MAX_PATH);
- m_bReadOnly = FALSE;
- m_pFile = NULL;
-}
-
-CStdLibFileIO::~CStdLibFileIO()
-{
- Close();
-}
-
-int CStdLibFileIO::GetHandle()
-{
- return FILENO(m_pFile);
-}
-
-int CStdLibFileIO::Open(LPCTSTR pName)
-{
- Close();
-
- m_bReadOnly = FALSE;
-
- if (0 == strcmp(pName, "-") || 0 == strcmp(pName, "/dev/stdin"))
- {
- m_pFile = SETBINARY_IN(stdin);
- m_bReadOnly = TRUE; // ReadOnly
- }
- else if (0 == strcmp (pName, "/dev/stdout"))
- {
- m_pFile = SETBINARY_OUT(stdout);
- m_bReadOnly = FALSE; // WriteOnly
- }
- else
- {
- m_pFile = fopen(pName, "rb");
- m_bReadOnly = FALSE; // Read/Write
- }
-
- if (!m_pFile)
- return -1;
-
- strcpy(m_cFileName, pName);
-
- return 0;
-}
-
-int CStdLibFileIO::Close()
-{
- int nRetVal = -1;
-
- if (m_pFile != NULL)
- {
- nRetVal = fclose(m_pFile);
- m_pFile = NULL;
- }
-
- return nRetVal;
-}
-
-int CStdLibFileIO::Read(void * pBuffer, unsigned int nBytesToRead, unsigned int * pBytesRead)
-{
- *pBytesRead = fread(pBuffer, 1, nBytesToRead, m_pFile);
- return ferror(m_pFile) ? ERROR_IO_READ : 0;
-}
-
-int CStdLibFileIO::Write(const void * pBuffer, unsigned int nBytesToWrite, unsigned int * pBytesWritten)
-{
- *pBytesWritten = fwrite(pBuffer, 1, nBytesToWrite, m_pFile);
-
- return (ferror(m_pFile) || (*pBytesWritten != nBytesToWrite)) ? ERROR_IO_WRITE : 0;
-}
-
-int CStdLibFileIO::Seek(int nDistance, unsigned int nMoveMode)
-{
- return fseek(m_pFile, nDistance, nMoveMode);
-}
-
-int CStdLibFileIO::SetEOF()
-{
- return ftruncate(GetHandle(), GetPosition());
-}
-
-int CStdLibFileIO::GetPosition()
-{
- fpos_t fPosition;
-
- memset(&fPosition, 0, sizeof(fPosition));
- fgetpos(m_pFile, &fPosition);
- return _FPOSOFF(fPosition);
-}
-
-int CStdLibFileIO::GetSize()
-{
- int nCurrentPosition = GetPosition();
- Seek(0, FILE_END);
- int nLength = GetPosition();
- Seek(nCurrentPosition, FILE_BEGIN);
- return nLength;
-}
-
-int CStdLibFileIO::GetName(char * pBuffer)
-{
- strcpy(pBuffer, m_cFileName);
- return 0;
-}
-
-int CStdLibFileIO::Create(const wchar_t * pName)
-{
- Close();
-
- if (0 == strcmp (pName, "-") || 0 == strcmp (pName, "/dev/stdout"))
- {
- m_pFile = SETBINARY_OUT(stdout);
- m_bReadOnly = FALSE; // WriteOnly
- }
- else
- {
- m_pFile = fopen (pName, "wb"); // Read/Write
- m_bReadOnly = FALSE;
- }
-
- if (!m_pFile)
- return -1;
-
- strcpy (m_cFileName, pName);
-
- return 0;
-}
-
-int CStdLibFileIO::Delete()
-{
- Close();
- return unlink (m_cFileName); // 0 success, -1 error
-}
-
-#endif // #ifdef IO_USE_STD_LIB_FILE_IO
diff --git a/MAC_SDK/Source/Shared/StdLibFileIO.h b/MAC_SDK/Source/Shared/StdLibFileIO.h
deleted file mode 100644
index cf4b2b6..0000000
--- a/MAC_SDK/Source/Shared/StdLibFileIO.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifdef IO_USE_STD_LIB_FILE_IO
-
-#ifndef APE_STDLIBFILEIO_H
-#define APE_STDLIBFILEIO_H
-
-#include "IO.h"
-
-class CStdLibFileIO : public CIO
-{
-public:
-
- // construction / destruction
- CStdLibFileIO();
- ~CStdLibFileIO();
-
- // open / close
- int Open(LPCTSTR pName);
- int Close();
-
- // read / write
- int Read(void * pBuffer, unsigned int nBytesToRead, unsigned int * pBytesRead);
- int Write(const void * pBuffer, unsigned int nBytesToWrite, unsigned int * pBytesWritten);
-
- // seek
- int Seek(int nDistance, unsigned int nMoveMode);
-
- // other functions
- int SetEOF();
-
- // creation / destruction
- int Create(const char * pName);
- int Delete();
-
- // attributes
- int GetPosition();
- int GetSize();
- int GetName(char * pBuffer);
- int GetHandle();
-
-private:
-
- char m_cFileName[MAX_PATH];
- BOOL m_bReadOnly;
- FILE * m_pFile;
-};
-
-#endif // #ifndef APE_STDLIBFILEIO_H
-
-#endif // #ifdef IO_USE_STD_LIB_FILE_IO
-
diff --git a/MAC_SDK/Source/Shared/StdString.h b/MAC_SDK/Source/Shared/StdString.h
deleted file mode 100644
index a1709f5..0000000
--- a/MAC_SDK/Source/Shared/StdString.h
+++ /dev/null
@@ -1,3015 +0,0 @@
-// =============================================================================
-// FILE: StdString.h
-// AUTHOR: Joe O'Leary (with outside help noted in comments)
-// REMARKS:
-// This header file declares the CStdStr template. This template derives
-// the Standard C++ Library basic_string<> template and add to it the
-// the following conveniences:
-// - The full MFC CString set of functions (including implicit cast)
-// - writing to/reading from COM IStream interfaces
-// - Functional objects for use in STL algorithms
-//
-// From this template, we intstantiate two classes: CStdStringA and
-// CStdStringW. The name "CStdString" is just a #define of one of these,
-// based upone the _UNICODE macro setting
-//
-// This header also declares our own version of the MFC/ATL UNICODE-MBCS
-// conversion macros. Our version looks exactly like the Microsoft's to
-// facilitate portability.
-//
-// NOTE:
-// If you you use this in an MFC or ATL build, you should include either
-// afx.h or atlbase.h first, as appropriate.
-//
-// PEOPLE WHO HAVE CONTRIBUTED TO THIS CLASS:
-//
-// Several people have helped me iron out problems and othewise improve
-// this class. OK, this is a long list but in my own defense, this code
-// has undergone two major rewrites. Many of the improvements became
-// necessary after I rewrote the code as a template. Others helped me
-// improve the CString facade.
-//
-// Anyway, these people are (in chronological order):
-//
-// - Pete the Plumber (???)
-// - Julian Selman
-// - Chris (of Melbsys)
-// - Dave Plummer
-// - John C Sipos
-// - Chris Sells
-// - Nigel Nunn
-// - Fan Xia
-// - Matthew Williams
-// - Carl Engman
-// - Mark Zeren
-// - Craig Watson
-// - Rich Zuris
-// - Karim Ratib
-// - Chris Conti
-// - Baptiste Lepilleur
-// - Greg Pickles
-// - Jim Cline
-// - Jeff Kohn
-// - Todd Heckel
-// - Ullrich Pollähne
-// - Joe Vitaterna
-// - Joe Woodbury
-// - Aaron (no last name)
-// - Joldakowski (???)
-// - Scott Hathaway
-// - Eric Nitzche
-// - Pablo Presedo
-//
-// REVISION HISTORY
-// 2001-APR-27 - StreamLoad was calculating the number of BYTES in one
-// case, not characters. Thanks to Pablo Presedo for this.
-//
-// 2001-FEB-23 - Replace() had a bug which caused infinite loops if the
-// source string was empty. Fixed thanks to Eric Nitzsche.
-//
-// 2001-FEB-23 - Scott Hathaway was a huge help in providing me with the
-// ability to build CStdString on Sun Unix systems. He
-// sent me detailed build reports about what works and what
-// does not. If CStdString compiles on your Unix box, you
-// can thank Scott for it.
-//
-// 2000-DEC-29 - Joldakowski noticed one overload of Insert failed to do
-// range check as CString's does. Now fixed -- thanks!
-//
-// 2000-NOV-07 - Aaron pointed out that I was calling static member
-// functions of char_traits via a temporary. This was not
-// technically wrong, but it was unnecessary and caused
-// problems for poor old buggy VC5. Thanks Aaron!
-//
-// 2000-JUL-11 - Joe Woodbury noted that the CString::Find docs don't match
-// what the CString::Find code really ends up doing. I was
-// trying to match the docs. Now I match the CString code
-// - Joe also caught me truncating strings for GetBuffer() calls
-// when the supplied length was less than the current length.
-//
-// 2000-MAY-25 - Better support for STLPORT's Standard library distribution
-// - Got rid of the NSP macro - it interfered with Koenig lookup
-// - Thanks to Joe Woodbury for catching a TrimLeft() bug that
-// I introduced in January. Empty strings were not getting
-// trimmed
-//
-// 2000-APR-17 - Thanks to Joe Vitaterna for pointing out that ReverseFind
-// is supposed to be a const function.
-//
-// 2000-MAR-07 - Thanks to Ullrich Pollähne for catching a range bug in one
-// of the overloads of assign.
-//
-// 2000-FEB-01 - You can now use CStdString on the Mac with CodeWarrior!
-// Thanks to Todd Heckel for helping out with this.
-//
-// 2000-JAN-23 - Thanks to Jim Cline for pointing out how I could make the
-// Trim() function more efficient.
-// - Thanks to Jeff Kohn for prompting me to find and fix a typo
-// in one of the addition operators that takes _bstr_t.
-// - Got rid of the .CPP file - you only need StdString.h now!
-//
-// 1999-DEC-22 - Thanks to Greg Pickles for helping me identify a problem
-// with my implementation of CStdString::FormatV in which
-// resulting string might not be properly NULL terminated.
-//
-// 1999-DEC-06 - Chris Conti pointed yet another basic_string<> assignment
-// bug that MS has not fixed. CStdString did nothing to fix
-// it either but it does now! The bug was: create a string
-// longer than 31 characters, get a pointer to it (via c_str())
-// and then assign that pointer to the original string object.
-// The resulting string would be empty. Not with CStdString!
-//
-// 1999-OCT-06 - BufferSet was erasing the string even when it was merely
-// supposed to shrink it. Fixed. Thanks to Chris Conti.
-// - Some of the Q172398 fixes were not checking for assignment-
-// to-self. Fixed. Thanks to Baptiste Lepilleur.
-//
-// 1999-AUG-20 - Improved Load() function to be more efficient by using
-// SizeOfResource(). Thanks to Rich Zuris for this.
-// - Corrected resource ID constructor, again thanks to Rich.
-// - Fixed a bug that occurred with UNICODE characters above
-// the first 255 ANSI ones. Thanks to Craig Watson.
-// - Added missing overloads of TrimLeft() and TrimRight().
-// Thanks to Karim Ratib for pointing them out
-//
-// 1999-JUL-21 - Made all calls to GetBuf() with no args check length first.
-//
-// 1999-JUL-10 - Improved MFC/ATL independence of conversion macros
-// - Added SS_NO_REFCOUNT macro to allow you to disable any
-// reference-counting your basic_string<> impl. may do.
-// - Improved ReleaseBuffer() to be as forgiving as CString.
-// Thanks for Fan Xia for helping me find this and to
-// Matthew Williams for pointing it out directly.
-//
-// 1999-JUL-06 - Thanks to Nigel Nunn for catching a very sneaky bug in
-// ToLower/ToUpper. They should call GetBuf() instead of
-// data() in order to ensure the changed string buffer is not
-// reference-counted (in those implementations that refcount).
-//
-// 1999-JUL-01 - Added a true CString facade. Now you can use CStdString as
-// a drop-in replacement for CString. If you find this useful,
-// you can thank Chris Sells for finally convincing me to give
-// in and implement it.
-// - Changed operators << and >> (for MFC CArchive) to serialize
-// EXACTLY as CString's do. So now you can send a CString out
-// to a CArchive and later read it in as a CStdString. I have
-// no idea why you would want to do this but you can.
-//
-// 1999-JUN-21 - Changed the CStdString class into the CStdStr template.
-// - Fixed FormatV() to correctly decrement the loop counter.
-// This was harmless bug but a bug nevertheless. Thanks to
-// Chris (of Melbsys) for pointing it out
-// - Changed Format() to try a normal stack-based array before
-// using to _alloca().
-// - Updated the text conversion macros to properly use code
-// pages and to fit in better in MFC/ATL builds. In other
-// words, I copied Microsoft's conversion stuff again.
-// - Added equivalents of CString::GetBuffer, GetBufferSetLength
-// - new sscpy() replacement of CStdString::CopyString()
-// - a Trim() function that combines TrimRight() and TrimLeft().
-//
-// 1999-MAR-13 - Corrected the "NotSpace" functional object to use _istpace()
-// instead of _isspace() Thanks to Dave Plummer for this.
-//
-// 1999-FEB-26 - Removed errant line (left over from testing) that #defined
-// _MFC_VER. Thanks to John C Sipos for noticing this.
-//
-// 1999-FEB-03 - Fixed a bug in a rarely-used overload of operator+() that
-// caused infinite recursion and stack overflow
-// - Added member functions to simplify the process of
-// persisting CStdStrings to/from DCOM IStream interfaces
-// - Added functional objects (e.g. StdStringLessNoCase) that
-// allow CStdStrings to be used as keys STL map objects with
-// case-insensitive comparison
-// - Added array indexing operators (i.e. operator[]). I
-// originally assumed that these were unnecessary and would be
-// inherited from basic_string. However, without them, Visual
-// C++ complains about ambiguous overloads when you try to use
-// them. Thanks to Julian Selman to pointing this out.
-//
-// 1998-FEB-?? - Added overloads of assign() function to completely account
-// for Q172398 bug. Thanks to "Pete the Plumber" for this
-//
-// 1998-FEB-?? - Initial submission
-//
-// COPYRIGHT:
-// 1999 Joseph M. O'Leary. This code is free. Use it anywhere you want.
-// Rewrite it, restructure it, whatever. Please don't blame me if it makes
-// your $30 billion dollar satellite explode in orbit. If you redistribute
-// it in any form, I'd appreciate it if you would leave this notice here.
-//
-// If you find any bugs, please let me know:
-//
-// jmoleary@earthlink.net
-// http://home.earthlink.net/~jmoleary
-// =============================================================================
-
-// Avoid multiple inclusion the VC++ way,
-// Turn off browser references
-// Turn off unavoidable compiler warnings
-
-#if defined(_MSC_VER) && (_MSC_VER > 1100)
- #pragma once
- #pragma component(browser, off, references, "CStdString")
- #pragma warning (disable : 4290) // C++ Exception Specification ignored
- #pragma warning (disable : 4127) // Conditional expression is constant
- #pragma warning (disable : 4097) // typedef name used as synonym for class name
-#endif
-
-#ifndef STDSTRING_H
-#define STDSTRING_H
-
-// MACRO: SS_NO_REFCOUNT:
-// turns off reference counting at the assignment level
-// I define this by default. comment it out if you don't want it.
-
-#define SS_NO_REFCOUNT
-
-// In non-Visual C++ and/or non-Win32 builds, we can't use some cool stuff.
-
-#if !defined(_MSC_VER) || !defined(_WIN32)
- #define SS_ANSI
-#endif
-
-// Avoid legacy code screw up: if _UNICODE is defined, UNICODE must be as well
-
-#if defined (_UNICODE) && !defined (UNICODE)
- #define UNICODE
-#endif
-#if defined (UNICODE) && !defined (_UNICODE)
- #define _UNICODE
-#endif
-
-// -----------------------------------------------------------------------------
-// MIN and MAX. The Standard C++ template versions go by so many names (at
-// at least in the MS implementation) that you never know what's available
-// -----------------------------------------------------------------------------
-template
-inline const Type& SSMIN(const Type& arg1, const Type& arg2)
-{
- return arg2 < arg1 ? arg2 : arg1;
-}
-template
-inline const Type& SSMAX(const Type& arg1, const Type& arg2)
-{
- return arg2 > arg1 ? arg2 : arg1;
-}
-
-// If they have not #included W32Base.h (part of my W32 utility library) then
-// we need to define some stuff. Otherwise, this is all defined there.
-
-#if !defined(W32BASE_H)
-
- // If they want us to use only standard C++ stuff (no Win32 stuff)
-
- #ifdef SS_ANSI
-
- // On non-Win32 platforms, there is no TCHAR.H so define what we need
-
- #ifndef _WIN32
-
- typedef const char* PCSTR;
- typedef char* PSTR;
- typedef const wchar_t* PCWSTR;
- typedef wchar_t* PWSTR;
- #ifdef UNICODE
- typedef wchar_t TCHAR;
- #else
- typedef char TCHAR;
- #endif
- typedef wchar_t OLECHAR;
-
- #else
-
- #include
- #include
- #ifndef STRICT
- #define STRICT
- #endif
-
- #endif // #ifndef _WIN32
-
-
- // Make sure ASSERT and verify are defined in an ANSI fashion
-
- #ifndef ASSERT
- #include
- #define ASSERT(f) assert((f))
- #endif
- #ifndef VERIFY
- #ifdef _DEBUG
- #define VERIFY(x) ASSERT((x))
- #else
- #define VERIFY(x) x
- #endif
- #endif
-
- #else // #ifdef SS_ANSI
-
- #include
- #include
- #ifndef STRICT
- #define STRICT
- #endif
-
- // Make sure ASSERT and verify are defined
-
- #ifndef ASSERT
- #include
- #define ASSERT(f) _ASSERTE((f))
- #endif
- #ifndef VERIFY
- #ifdef _DEBUG
- #define VERIFY(x) ASSERT((x))
- #else
- #define VERIFY(x) x
- #endif
- #endif
-
- #endif // #ifdef SS_ANSI
-
- #ifndef UNUSED
- #define UNUSED(x) x
- #endif
-
-#endif // #ifndef W32BASE_H
-
-// Standard headers needed
-
-#include // basic_string
-#include // for_each, etc.
-#include // for StdStringLessNoCase, et al
-#include // for various facets
-
-// If this is a recent enough version of VC include comdef.h, so we can write
-// member functions to deal with COM types & compiler support classes e.g. _bstr_t
-
-#if defined (_MSC_VER) && (_MSC_VER >= 1100)
- #include
- #define SS_INC_COMDEF // signal that we #included MS comdef.h file
- #define STDSTRING_INC_COMDEF
- #define SS_NOTHROW __declspec(nothrow)
-#else
- #define SS_NOTHROW
-#endif
-
-#ifndef TRACE
- #define TRACE_DEFINED_HERE
- #define TRACE
-#endif
-
-// Microsoft defines PCSTR, PCWSTR, etc, but no PCTSTR. I hate to use the
-// versions with the "L" in front of them because that's a leftover from Win 16
-// days, even though it evaluates to the same thing. Therefore, Define a PCSTR
-// as an LPCTSTR.
-
-#if !defined(PCTSTR) && !defined(PCTSTR_DEFINED)
- typedef const TCHAR* PCTSTR;
- #define PCTSTR_DEFINED
-#endif
-
-#if !defined(PCOLESTR) && !defined(PCOLESTR_DEFINED)
- typedef const OLECHAR* PCOLESTR;
- #define PCOLESTR_DEFINED
-#endif
-
-#if !defined(POLESTR) && !defined(POLESTR_DEFINED)
- typedef OLECHAR* POLESTR;
- #define POLESTR_DEFINED
-#endif
-
-#if !defined(PCUSTR) && !defined(PCUSTR_DEFINED)
- typedef const unsigned char* PCUSTR;
- typedef unsigned char* PUSTR;
- #define PCUSTR_DEFINED
-#endif
-
-// SS_USE_FACET macro and why we need it:
-//
-// Since I'm a good little Standard C++ programmer, I use locales. Thus, I
-// need to make use of the use_facet<> template function here. Unfortunately,
-// this need is complicated by the fact the MS' implementation of the Standard
-// C++ Library has a non-standard version of use_facet that takes more
-// arguments than the standard dictates. Since I'm trying to write CStdString
-// to work with any version of the Standard library, this presents a problem.
-//
-// The upshot of this is that I can't do 'use_facet' directly. The MS' docs
-// tell me that I have to use a macro, _USE() instead. Since _USE obviously
-// won't be available in other implementations, this means that I have to write
-// my OWN macro -- SS_USE_FACET -- that evaluates either to _USE or to the
-// standard, use_facet.
-//
-// If you are having trouble with the SS_USE_FACET macro, in your implementation
-// of the Standard C++ Library, you can define your own version of SS_USE_FACET.
-#ifndef schMSG
- #define schSTR(x) #x
- #define schSTR2(x) schSTR(x)
- #define schMSG(desc) message(__FILE__ "(" schSTR2(__LINE__) "):" #desc)
-#endif
-
-#ifndef SS_USE_FACET
- // STLPort #defines a macro (__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) for
- // all MSVC builds, erroneously in my opinion. It causes problems for
- // my SS_ANSI builds. In my code, I always comment out that line. You'll
- // find it in \stlport\config\stl_msvc.h
- #if defined(__SGI_STL_PORT) && (__SGI_STL_PORT >= 0x400 )
- #if defined(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && defined(_MSC_VER)
- #ifdef SS_ANSI
- #pragma schMSG(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS defined!!)
- #endif
- #endif
- #define SS_USE_FACET(loc, fac) std::use_facet(loc)
- #elif defined(_MSC_VER )
- #define SS_USE_FACET(loc, fac) _USE(loc, fac)
-
- // ...and
- #elif defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE)
- #define SS_USE_FACET(loc, fac) std::use_facet(loc, (fac*)0)
- #else
- #define SS_USE_FACET(loc, fac) std::use_facet(loc)
- #endif
-#endif
-
-// =============================================================================
-// UNICODE/MBCS conversion macros. Made to work just like the MFC/ATL ones.
-// =============================================================================
-
-// First define the conversion helper functions. We define these regardless of
-// any preprocessor macro settings since their names won't collide.
-
-#ifdef SS_ANSI // Are we doing things the standard, non-Win32 way?...
-
- typedef std::codecvt SSCodeCvt;
-
- // Not sure if we need all these headers. I believe ANSI says we do.
-
- #include
- #include
- #include
- #ifndef va_start
- #include
- #endif
-
- // StdCodeCvt - made to look like Win32 functions WideCharToMultiByte annd
- // MultiByteToWideChar but uses locales in SS_ANSI builds
- inline PWSTR StdCodeCvt(PWSTR pW, PCSTR pA, int nChars,
- const std::locale& loc=std::locale())
- {
- ASSERT(0 != pA);
- ASSERT(0 != pW);
- pW[0] = '\0';
- PCSTR pBadA = 0;
- PWSTR pBadW = 0;
- SSCodeCvt::result res = SSCodeCvt::ok;
- const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
- SSCodeCvt::state_type st= { 0 };
- res = conv.in(st,
- pA, pA + nChars, pBadA,
- pW, pW + nChars, pBadW);
- ASSERT(SSCodeCvt::ok == res);
- return pW;
- }
- inline PWSTR StdCodeCvt(PWSTR pW, PCUSTR pA, int nChars,
- const std::locale& loc=std::locale())
- {
- return StdCodeCvt(pW, (PCSTR)pA, nChars, loc);
- }
-
- inline PSTR StdCodeCvt(PSTR pA, PCWSTR pW, int nChars,
- const std::locale& loc=std::locale())
- {
- ASSERT(0 != pA);
- ASSERT(0 != pW);
- pA[0] = '\0';
- PSTR pBadA = 0;
- PCWSTR pBadW = 0;
- SSCodeCvt::result res = SSCodeCvt::ok;
- const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt);
- SSCodeCvt::state_type st= { 0 };
- res = conv.out(st,
- pW, pW + nChars, pBadW,
- pA, pA + nChars, pBadA);
- ASSERT(SSCodeCvt::ok == res);
- return pA;
- }
- inline PUSTR StdCodeCvt(PUSTR pA, PCWSTR pW, int nChars,
- const std::locale& loc=std::locale())
- {
- return (PUSTR)StdCodeCvt((PSTR)pA, pW, nChars, loc);
- }
-
-#else // ...or are we doing things assuming win32 and Visual C++?
-
- #include // needed for _alloca
-
- inline PWSTR StdCodeCvt(PWSTR pW, PCSTR pA, int nChars, UINT acp=CP_ACP)
- {
- ASSERT(0 != pA);
- ASSERT(0 != pW);
- pW[0] = '\0';
- MultiByteToWideChar(acp, 0, pA, -1, pW, nChars);
- return pW;
- }
- inline PWSTR StdCodeCvt(PWSTR pW, PCUSTR pA, int nChars, UINT acp=CP_ACP)
- {
- return StdCodeCvt(pW, (PCSTR)pA, nChars, acp);
- }
-
- inline PSTR StdCodeCvt(PSTR pA, PCWSTR pW, int nChars, UINT acp=CP_ACP)
- {
- ASSERT(0 != pA);
- ASSERT(0 != pW);
- pA[0] = '\0';
- WideCharToMultiByte(acp, 0, pW, -1, pA, nChars, 0, 0);
- return pA;
- }
- inline PUSTR StdCodeCvt(PUSTR pA, PCWSTR pW, int nChars, UINT acp=CP_ACP)
- {
- return (PUSTR)StdCodeCvt((PSTR)pA, pW, nChars, acp);
- }
-
- // Define our conversion macros to look exactly like Microsoft's to
- // facilitate using this stuff both with and without MFC/ATL
-
- #ifdef _CONVERSION_USES_THREAD_LOCALE
- #ifndef _DEBUG
- #define SSCVT int _cvt; _cvt; UINT _acp=GetACP(); \
- _acp; PCWSTR _pw; _pw; PCSTR _pa; _pa
- #else
- #define SSCVT int _cvt = 0; _cvt; UINT _acp=GetACP();\
- _acp; PCWSTR _pw=0; _pw; PCSTR _pa=0; _pa
- #endif
- #else
- #ifndef _DEBUG
- #define SSCVT int _cvt; _cvt; UINT _acp=CP_ACP; _acp;\
- PCWSTR _pw; _pw; PCSTR _pa; _pa
- #else
- #define SSCVT int _cvt = 0; _cvt; UINT _acp=CP_ACP; \
- _acp; PCWSTR _pw=0; _pw; PCSTR _pa=0; _pa
- #endif
- #endif
-
- #ifdef _CONVERSION_USES_THREAD_LOCALE
- #define SSA2W(pa) (\
- ((_pa = pa) == 0) ? 0 : (\
- _cvt = (strlen(_pa)+1),\
- StdCodeCvt((PWSTR) _alloca(_cvt*2), _pa, _cvt, _acp)))
- #define SSW2A(pw) (\
- ((_pw = pw) == 0) ? 0 : (\
- _cvt = (wcslen(_pw)+1)*2,\
- StdW2AHelper((LPSTR) _alloca(_cvt), _pw, _cvt, _acp)))
- #else
- #define SSA2W(pa) (\
- ((_pa = pa) == 0) ? 0 : (\
- _cvt = (strlen(_pa)+1),\
- StdCodeCvt((PWSTR) _alloca(_cvt*2), _pa, _cvt)))
- #define SSW2A(pw) (\
- ((_pw = pw) == 0) ? 0 : (\
- _cvt = (wcslen(_pw)+1)*2,\
- StdCodeCvt((LPSTR) _alloca(_cvt), _pw, _cvt)))
- #endif
-
- #define SSA2CW(pa) ((PCWSTR)SSA2W((pa)))
- #define SSW2CA(pw) ((PCSTR)SSW2A((pw)))
-
- #ifdef UNICODE
- #define SST2A SSW2A
- #define SSA2T SSA2W
- #define SST2CA SSW2CA
- #define SSA2CT SSA2CW
- inline PWSTR SST2W(PTSTR p) { return p; }
- inline PTSTR SSW2T(PWSTR p) { return p; }
- inline PCWSTR SST2CW(PCTSTR p) { return p; }
- inline PCTSTR SSW2CT(PCWSTR p) { return p; }
- #else
- #define SST2W SSA2W
- #define SSW2T SSW2A
- #define SST2CW SSA2CW
- #define SSW2CT SSW2CA
- inline PSTR SST2A(PTSTR p) { return p; }
- inline PTSTR SSA2T(PSTR p) { return p; }
- inline PCSTR SST2CA(PCTSTR p) { return p; }
- inline PCTSTR SSA2CT(PCSTR p) { return p; }
- #endif // #ifdef UNICODE
-
- #if defined(UNICODE)
- // in these cases the default (TCHAR) is the same as OLECHAR
- inline PCOLESTR SST2COLE(PCTSTR p) { return p; }
- inline PCTSTR SSOLE2CT(PCOLESTR p) { return p; }
- inline POLESTR SST2OLE(PTSTR p) { return p; }
- inline PTSTR SSOLE2T(POLESTR p) { return p; }
- #elif defined(OLE2ANSI)
- // in these cases the default (TCHAR) is the same as OLECHAR
- inline PCOLESTR SST2COLE(PCTSTR p) { return p; }
- inline PCTSTR SSOLE2CT(PCOLESTR p) { return p; }
- inline POLESTR SST2OLE(PTSTR p) { return p; }
- inline PTSTR SSOLE2T(POLESTR p) { return p; }
- #else
- //CharNextW doesn't work on Win95 so we use this
- #define SST2COLE(pa) SSA2CW((pa))
- #define SST2OLE(pa) SSA2W((pa))
- #define SSOLE2CT(po) SSW2CA((po))
- #define SSOLE2T(po) SSW2A((po))
- #endif
-
- #ifdef OLE2ANSI
- #define SSW2OLE SSW2A
- #define SSOLE2W SSA2W
- #define SSW2COLE SSW2CA
- #define SSOLE2CW SSA2CW
- inline POLESTR SSA2OLE(PSTR p) { return p; }
- inline PSTR SSOLE2A(POLESTR p) { return p; }
- inline PCOLESTR SSA2COLE(PCSTR p) { return p; }
- inline PCSTR SSOLE2CA(PCOLESTR p){ return p; }
- #else
- #define SSA2OLE SSA2W
- #define SSOLE2A SSW2A
- #define SSA2COLE SSA2CW
- #define SSOLE2CA SSW2CA
- inline POLESTR SSW2OLE(PWSTR p) { return p; }
- inline PWSTR SSOLE2W(POLESTR p) { return p; }
- inline PCOLESTR SSW2COLE(PCWSTR p) { return p; }
- inline PCWSTR SSOLE2CW(PCOLESTR p){ return p; }
- #endif
-
- // Above we've defined macros that look like MS' but all have
- // an 'SS' prefix. Now we need the real macros. We'll either
- // get them from the macros above or from MFC/ATL. If
- // SS_NO_CONVERSION is #defined, we'll forgo them
-
- #ifndef SS_NO_CONVERSION
-
- #if defined (USES_CONVERSION)
-
- #define _NO_STDCONVERSION // just to be consistent
-
- #else
-
- #ifdef _MFC_VER
-
- #include
- #define _NO_STDCONVERSION // just to be consistent
-
- #else
-
- #define USES_CONVERSION SSCVT
- #define A2CW SSA2CW
- #define W2CA SSW2CA
- #define T2A SST2A
- #define A2T SSA2T
- #define T2W SST2W
- #define W2T SSW2T
- #define T2CA SST2CA
- #define A2CT SSA2CT
- #define T2CW SST2CW
- #define W2CT SSW2CT
- #define ocslen sslen
- #define ocscpy sscpy
- #define T2COLE SST2COLE
- #define OLE2CT SSOLE2CT
- #define T2OLE SST2COLE
- #define OLE2T SSOLE2CT
- #define A2OLE SSA2OLE
- #define OLE2A SSOLE2A
- #define W2OLE SSW2OLE
- #define OLE2W SSOLE2W
- #define A2COLE SSA2COLE
- #define OLE2CA SSOLE2CA
- #define W2COLE SSW2COLE
- #define OLE2CW SSOLE2CW
-
- #endif // #ifdef _MFC_VER
- #endif // #ifndef USES_CONVERSION
- #endif // #ifndef SS_NO_CONVERSION
-
- // Define ostring - generic name for std::basic_string
-
- #if !defined(ostring) && !defined(OSTRING_DEFINED)
- typedef std::basic_string ostring;
- #define OSTRING_DEFINED
- #endif
-
-#endif // #ifndef SS_ANSI
-
-// StdCodeCvt when there's no conversion to be done
-inline PSTR StdCodeCvt(PSTR pDst, PCSTR pSrc, int nChars)
-{
- pDst[0] = '\0';
- std::char_traits::copy(pDst, pSrc, nChars);
- if ( nChars > 0 )
- pDst[nChars] = '\0';
-
- return pDst;
-}
-inline PSTR StdCodeCvt(PSTR pDst, PCUSTR pSrc, int nChars)
-{
- return StdCodeCvt(pDst, (PCSTR)pSrc, nChars);
-}
-inline PUSTR StdCodeCvt(PUSTR pDst, PCSTR pSrc, int nChars)
-{
- return (PUSTR)StdCodeCvt((PSTR)pDst, pSrc, nChars);
-}
-
-inline PWSTR StdCodeCvt(PWSTR pDst, PCWSTR pSrc, int nChars)
-{
- pDst[0] = '\0';
- std::char_traits::copy(pDst, pSrc, nChars);
- if ( nChars > 0 )
- pDst[nChars] = '\0';
-
- return pDst;
-}
-
-
-// Define tstring -- generic name for std::basic_string
-
-#if !defined(tstring) && !defined(TSTRING_DEFINED)
- typedef std::basic_string tstring;
- #define TSTRING_DEFINED
-#endif
-
-// a very shorthand way of applying the fix for KB problem Q172398
-// (basic_string assignment bug)
-
-#if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
- #define Q172398(x) (x).erase()
-#else
- #define Q172398(x)
-#endif
-
-// =============================================================================
-// INLINE FUNCTIONS ON WHICH CSTDSTRING RELIES
-//
-// Usually for generic text mapping, we rely on preprocessor macro definitions
-// to map to string functions. However the CStdStr<> template cannot use
-// macro-based generic text mappings because its character types do not get
-// resolved until template processing which comes AFTER macro processing. In
-// other words, UNICODE is of little help to us in the CStdStr template
-//
-// Therefore, to keep the CStdStr declaration simple, we have these inline
-// functions. The template calls them often. Since they are inline (and NOT
-// exported when this is built as a DLL), they will probably be resolved away
-// to nothing.
-//
-// Without these functions, the CStdStr<> template would probably have to broken
-// out into two, almost identical classes. Either that or it would be a huge,
-// convoluted mess, with tons of "if" statements all over the place checking the
-// size of template parameter CT.
-//
-// In several cases, you will see two versions of each function. One version is
-// the more portable, standard way of doing things, while the other is the
-// non-standard, but often significantly faster Visual C++ way.
-// =============================================================================
-
-// If they defined SS_NO_REFCOUNT, then we must convert all assignments
-
-#ifdef SS_NO_REFCOUNT
- #define SSREF(x) (x).c_str()
-#else
- #define SSREF(x) (x)
-#endif
-
-// -----------------------------------------------------------------------------
-// sslen: strlen/wcslen wrappers
-// -----------------------------------------------------------------------------
-template inline int sslen(const CT* pT)
-{
- return 0 == pT ? 0 : std::char_traits::length(pT);
-}
-inline SS_NOTHROW int sslen(const std::string& s)
-{
- return s.length();
-}
-inline SS_NOTHROW int sslen(const std::wstring& s)
-{
- return s.length();
-}
-
-
-// -----------------------------------------------------------------------------
-// ssasn: assignment functions -- assign "sSrc" to "sDst"
-// -----------------------------------------------------------------------------
-typedef std::string::size_type SS_SIZETYPE; // just for shorthand, really
-typedef std::string::pointer SS_PTRTYPE;
-typedef std::wstring::size_type SW_SIZETYPE;
-typedef std::wstring::pointer SW_PTRTYPE;
-
-inline void ssasn(std::string& sDst, const std::string& sSrc)
-{
- if ( sDst.c_str() != sSrc.c_str() )
- {
- sDst.erase();
- sDst.assign(SSREF(sSrc));
- }
-}
-inline void ssasn(std::string& sDst, PCSTR pA)
-{
- // Watch out for NULLs, as always.
-
- if ( 0 == pA )
- {
- sDst.erase();
- }
-
- // If pA actually points to part of sDst, we must NOT erase(), but
- // rather take a substring
-
- else if ( pA >= sDst.c_str() && pA <= sDst.c_str() + sDst.size() )
- {
- sDst =sDst.substr(static_cast(pA-sDst.c_str()));
- }
-
- // Otherwise (most cases) apply the assignment bug fix, if applicable
- // and do the assignment
-
- else
- {
- Q172398(sDst);
- sDst.assign(pA);
- }
-}
-inline void ssasn(std::string& sDst, const std::wstring& sSrc)
-{
-#ifdef SS_ANSI
- int nLen = sSrc.size();
- sDst.resize(0);
- sDst.resize(nLen);
- StdCodeCvt(const_cast(sDst.data()), sSrc.c_str(), nLen);
-#else
- SSCVT;
- sDst.assign(SSW2CA(sSrc.c_str()));
-#endif
-}
-inline void ssasn(std::string& sDst, PCWSTR pW)
-{
-#ifdef SS_ANSI
- int nLen = sslen(pW);
- sDst.resize(0);
- sDst.resize(nLen);
- StdCodeCvt(const_cast(sDst.data()), pW, nLen);
-#else
- SSCVT;
- sDst.assign(pW ? SSW2CA(pW) : "");
-#endif
-}
-inline void ssasn(std::string& sDst, const int nNull)
-{
- UNUSED(nNull);
- ASSERT(nNull==0);
- sDst.assign("");
-}
-inline void ssasn(std::wstring& sDst, const std::wstring& sSrc)
-{
- if ( sDst.c_str() != sSrc.c_str() )
- {
- sDst.erase();
- sDst.assign(SSREF(sSrc));
- }
-}
-inline void ssasn(std::wstring& sDst, PCWSTR pW)
-{
- // Watch out for NULLs, as always.
-
- if ( 0 == pW )
- {
- sDst.erase();
- }
-
- // If pW actually points to part of sDst, we must NOT erase(), but
- // rather take a substring
-
- else if ( pW >= sDst.c_str() && pW <= sDst.c_str() + sDst.size() )
- {
- sDst = sDst.substr(static_cast(pW-sDst.c_str()));
- }
-
- // Otherwise (most cases) apply the assignment bug fix, if applicable
- // and do the assignment
-
- else
- {
- Q172398(sDst);
- sDst.assign(pW);
- }
-}
-#undef StrSizeType
-inline void ssasn(std::wstring& sDst, const std::string& sSrc)
-{
-#ifdef SS_ANSI
- int nLen = sSrc.size();
- sDst.resize(0);
- sDst.resize(nLen);
- StdCodeCvt(const_cast(sDst.data()), sSrc.c_str(), nLen);
-#else
- SSCVT;
- sDst.assign(SSA2CW(sSrc.c_str()));
-#endif
-}
-inline void ssasn(std::wstring& sDst, PCSTR pA)
-{
-#ifdef SS_ANSI
- int nLen = sslen(pA);
- sDst.resize(0);
- sDst.resize(nLen);
- StdCodeCvt(const_cast(sDst.data()), pA, nLen);
-#else
- SSCVT;
- sDst.assign(pA ? SSA2CW(pA) : L"");
-#endif
-}
-inline void ssasn(std::wstring& sDst, const int nNull)
-{
- UNUSED(nNull);
- ASSERT(nNull==0);
- sDst.assign(L"");
-}
-
-
-// -----------------------------------------------------------------------------
-// ssadd: string object concatenation -- add second argument to first
-// -----------------------------------------------------------------------------
-inline void ssadd(std::string& sDst, const std::wstring& sSrc)
-{
-#ifdef SS_ANSI
- int nLen = sSrc.size();
- sDst.resize(sDst.size() + nLen);
- StdCodeCvt(const_cast(sDst.data()+nLen), sSrc.c_str(), nLen);
-#else
- SSCVT;
- sDst.append(SSW2CA(sSrc.c_str()));
-#endif
-}
-inline void ssadd(std::string& sDst, const std::string& sSrc)
-{
- sDst.append(sSrc.c_str());
-}
-inline void ssadd(std::string& sDst, PCWSTR pW)
-{
-#ifdef SS_ANSI
- int nLen = sslen(pW);
- sDst.resize(sDst.size() + nLen);
- StdCodeCvt(const_cast(sDst.data()+nLen), pW, nLen);
-#else
- SSCVT;
- if ( 0 != pW )
- sDst.append(SSW2CA(pW));
-#endif
-}
-inline void ssadd(std::string& sDst, PCSTR pA)
-{
- if ( pA )
- sDst.append(pA);
-}
-inline void ssadd(std::wstring& sDst, const std::wstring& sSrc)
-{
- sDst.append(sSrc.c_str());
-}
-inline void ssadd(std::wstring& sDst, const std::string& sSrc)
-{
-#ifdef SS_ANSI
- int nLen = sSrc.size();
- sDst.resize(sDst.size() + nLen);
- StdCodeCvt(const_cast(sDst.data()+nLen), sSrc.c_str(), nLen);
-#else
- SSCVT;
- sDst.append(SSA2CW(sSrc.c_str()));
-#endif
-}
-inline void ssadd(std::wstring& sDst, PCSTR pA)
-{
-#ifdef SS_ANSI
- int nLen = sslen(pA);
- sDst.resize(sDst.size() + nLen);
- StdCodeCvt(const_cast(sDst.data()+nLen), pA, nLen);
-#else
- SSCVT;
- if ( 0 != pA )
- sDst.append(SSA2CW(pA));
-#endif
-}
-inline void ssadd(std::wstring& sDst, PCWSTR pW)
-{
- if ( pW )
- sDst.append(pW);
-}
-
-
-// -----------------------------------------------------------------------------
-// ssicmp: comparison (case insensitive )
-// -----------------------------------------------------------------------------
-#ifdef SS_ANSI
- template
- inline int ssicmp(const CT* pA1, const CT* pA2)
- {
- std::locale loc;
- const std::ctype& ct = SS_USE_FACET(loc, std::ctype);
- CT f;
- CT l;
-
- do
- {
- f = ct.tolower(*(pA1++));
- l = ct.tolower(*(pA2++));
- } while ( (f) && (f == l) );
-
- return (int)(f - l);
- }
-#else
- #ifdef _MBCS
- inline long sscmp(PCSTR pA1, PCSTR pA2)
- {
- return _mbscmp((PCUSTR)pA1, (PCUSTR)pA2);
- }
- inline long ssicmp(PCSTR pA1, PCSTR pA2)
- {
- return _mbsicmp((PCUSTR)pA1, (PCUSTR)pA2);
- }
- #else
- inline long sscmp(PCSTR pA1, PCSTR pA2)
- {
- return strcmp(pA1, pA2);
- }
- inline long ssicmp(PCSTR pA1, PCSTR pA2)
- {
- return _stricmp(pA1, pA2);
- }
- #endif
- inline long sscmp(PCWSTR pW1, PCWSTR pW2)
- {
- return wcscmp(pW1, pW2);
- }
- inline long ssicmp(PCWSTR pW1, PCWSTR pW2)
- {
- return _wcsicmp(pW1, pW2);
- }
-#endif
-
-// -----------------------------------------------------------------------------
-// ssupr/sslwr: Uppercase/Lowercase conversion functions
-// -----------------------------------------------------------------------------
-#ifdef SS_ANSI
- template
- inline void sslwr(CT* pT, size_t nLen)
- {
- SS_USE_FACET(std::locale(), std::ctype).tolower(pT, pT+nLen);
- }
- template
- inline void ssupr(CT* pT, size_t nLen)
- {
- SS_USE_FACET(std::locale(), std::ctype).toupper(pT, pT+nLen);
- }
-#else // #else we must be on Win32
- #ifdef _MBCS
- inline void ssupr(PSTR pA, size_t /*nLen*/)
- {
- _mbsupr((PUSTR)pA);
- }
- inline void sslwr(PSTR pA, size_t /*nLen*/)
- {
- _mbslwr((PUSTR)pA);
- }
- #else
- inline void ssupr(PSTR pA, size_t /*nLen*/)
- {
- _strupr(pA);
- }
- inline void sslwr(PSTR pA, size_t /*nLen*/)
- {
- _strlwr(pA);
- }
- #endif
- inline void ssupr(PWSTR pW, size_t /*nLen*/)
- {
- _wcsupr(pW);
- }
- inline void sslwr(PWSTR pW, size_t /*nLen*/)
- {
- _wcslwr(pW);
- }
-#endif // #ifdef SS_ANSI
-
-// -----------------------------------------------------------------------------
-// vsprintf/vswprintf or _vsnprintf/_vsnwprintf equivalents. In standard
-// builds we can't use _vsnprintf/_vsnwsprintf because they're MS extensions.
-// -----------------------------------------------------------------------------
-#ifdef SS_ANSI
- inline int ssvsprintf(PSTR pA, size_t /*nCount*/, PCSTR pFmtA, va_list vl)
- {
- return vsprintf(pA, pFmtA, vl);
- }
- inline int ssvsprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl)
- {
- // JMO: It is beginning to seem like Microsoft Visual C++ is the only
- // CRT distribution whose version of vswprintf takes THREE arguments.
- // All others seem to take FOUR arguments. Therefore instead of
- // checking for every possible distro here, I'll assume that unless
- // I am running with Microsoft's CRT, then vswprintf takes four
- // arguments. If you get a compilation error here, then you can just
- // change this code to call the three-argument version.
-// #if !defined(__MWERKS__) && !defined(__SUNPRO_CC_COMPAT) && !defined(__SUNPRO_CC)
- #ifndef _MSC_VER
- return vswprintf(pW, nCount, pFmtW, vl);
- #else
- nCount;
- return vswprintf(pW, pFmtW, vl);
- #endif
- }
-#else
- inline int ssnprintf(PSTR pA, size_t nCount, PCSTR pFmtA, va_list vl)
- {
- return _vsnprintf(pA, nCount, pFmtA, vl);
- }
- inline int ssnprintf(PWSTR pW, size_t nCount, PCWSTR pFmtW, va_list vl)
- {
- return _vsnwprintf(pW, nCount, pFmtW, vl);
- }
-#endif
-
-
-// -----------------------------------------------------------------------------
-// ssload: Type safe, overloaded ::LoadString wrappers
-// There is no equivalent of these in non-Win32-specific builds. However, I'm
-// thinking that with the message facet, there might eventually be one
-// -----------------------------------------------------------------------------
-#ifdef SS_ANSI
-#else
- inline int ssload(HMODULE hInst, UINT uId, PSTR pBuf, int nMax)
- {
- return ::LoadStringA(hInst, uId, pBuf, nMax);
- }
- inline int ssload(HMODULE hInst, UINT uId, PWSTR pBuf, int nMax)
- {
- return ::LoadStringW(hInst, uId, pBuf, nMax);
- }
-#endif
-
-
-// -----------------------------------------------------------------------------
-// sscoll/ssicoll: Collation wrappers
-// -----------------------------------------------------------------------------
-#ifdef SS_ANSI
- template
- inline int sscoll(const CT* sz1, int nLen1, const CT* sz2, int nLen2)
- {
- const std::collate& coll =
- SS_USE_FACET(std::locale(), std::collate);
- return coll.compare(sz1, sz1+nLen1, sz2, sz2+nLen2);
- }
- template
- inline int ssicoll(const CT* sz1, int nLen1, const CT* sz2, int nLen2)
- {
- const std::locale loc;
- const std::collate& coll = SS_USE_FACET(loc, std::collate);
-
- // Some implementations seem to have trouble using the collate<>
- // facet typedefs so we'll just default to basic_string and hope
- // that's what the collate facet uses (which it generally should)
-
-// std::collate::string_type s1(sz1);
-// std::collate::string_type s2(sz2);
- std::basic_string s1(sz1);
- std::basic_string s2(sz2);
-
- sslwr(const_cast(s1.c_str()), nLen1);
- sslwr(const_cast(s2.c_str()), nLen2);
- return coll.compare(s1.c_str(), s1.c_str()+nLen1,
- s2.c_str(), s2.c_str()+nLen2);
- }
-#else
- #ifdef _MBCS
- inline int sscoll(PCSTR sz1, int /*nLen1*/, PCSTR sz2, int /*nLen2*/)
- {
- return _mbscoll((PCUSTR)sz1, (PCUSTR)sz2);
- }
- inline int ssicoll(PCSTR sz1, int /*nLen1*/, PCSTR sz2, int /*nLen2*/)
- {
- return _mbsicoll((PCUSTR)sz1, (PCUSTR)sz2);
- }
- #else
- inline int sscoll(PCSTR sz1, int /*nLen1*/, PCSTR sz2, int /*nLen2*/)
- {
- return strcoll(sz1, sz2);
- }
- inline int ssicoll(PCSTR sz1, int /*nLen1*/, PCSTR sz2, int /*nLen2*/)
- {
- return _stricoll(sz1, sz2);
- }
- #endif
- inline int sscoll(PCWSTR sz1, int /*nLen1*/, PCWSTR sz2, int /*nLen2*/)
- {
- return wcscoll(sz1, sz2);
- }
- inline int ssicoll(PCWSTR sz1, int /*nLen1*/, PCWSTR sz2, int /*nLen2*/)
- {
- return _wcsicoll(sz1, sz2);
- }
-#endif
-
-
-// -----------------------------------------------------------------------------
-// ssfmtmsg: FormatMessage equivalents. Needed because I added a CString facade
-// Again -- no equivalent of these on non-Win32 builds but their might one day
-// be one if the message facet gets implemented
-// -----------------------------------------------------------------------------
-#ifdef SS_ANSI
-#else
- inline DWORD ssfmtmsg(DWORD dwFlags, LPCVOID pSrc, DWORD dwMsgId,
- DWORD dwLangId, PSTR pBuf, DWORD nSize,
- va_list* vlArgs)
- {
- return FormatMessageA(dwFlags, pSrc, dwMsgId, dwLangId,
- pBuf, nSize,vlArgs);
- }
- inline DWORD ssfmtmsg(DWORD dwFlags, LPCVOID pSrc, DWORD dwMsgId,
- DWORD dwLangId, PWSTR pBuf, DWORD nSize,
- va_list* vlArgs)
- {
- return FormatMessageW(dwFlags, pSrc, dwMsgId, dwLangId,
- pBuf, nSize,vlArgs);
- }
-#endif
-
-
-
-// FUNCTION: sscpy. Copies up to 'nMax' characters from pSrc to pDst.
-// -----------------------------------------------------------------------------
-// FUNCTION: sscpy
-// inline int sscpy(PSTR pDst, PCSTR pSrc, int nMax=-1);
-// inline int sscpy(PUSTR pDst, PCSTR pSrc, int nMax=-1)
-// inline int sscpy(PSTR pDst, PCWSTR pSrc, int nMax=-1);
-// inline int sscpy(PWSTR pDst, PCWSTR pSrc, int nMax=-1);
-// inline int sscpy(PWSTR pDst, PCSTR pSrc, int nMax=-1);
-//
-// DESCRIPTION:
-// This function is very much (but not exactly) like strcpy. These
-// overloads simplify copying one C-style string into another by allowing
-// the caller to specify two different types of strings if necessary.
-//
-// The strings must NOT overlap
-//
-// "Character" is expressed in terms of the destination string, not
-// the source. If no 'nMax' argument is supplied, then the number of
-// characters copied will be sslen(pSrc). A NULL terminator will
-// also be added so pDst must actually be big enough to hold nMax+1
-// characters. The return value is the number of characters copied,
-// not including the NULL terminator.
-//
-// PARAMETERS:
-// pSrc - the string to be copied FROM. May be a char based string, an
-// MBCS string (in Win32 builds) or a wide string (wchar_t).
-// pSrc - the string to be copied TO. Also may be either MBCS or wide
-// nMax - the maximum number of characters to be copied into szDest. Note
-// that this is expressed in whatever a "character" means to pDst.
-// If pDst is a wchar_t type string than this will be the maximum
-// number of wchar_ts that my be copied. The pDst string must be
-// large enough to hold least nMaxChars+1 characters.
-// If the caller supplies no argument for nMax this is a signal to
-// the routine to copy all the characters in pSrc, regardless of
-// how long it is.
-//
-// RETURN VALUE: none
-// -----------------------------------------------------------------------------
-template
-inline int sscpycvt(CT1* pDst, const CT2* pSrc, int nChars)
-{
- StdCodeCvt(pDst, pSrc, nChars);
- pDst[SSMAX(nChars, 0)] = '\0';
- return nChars;
-}
-
-template
-inline int sscpy(CT1* pDst, const CT2* pSrc, int nMax, int nLen)
-{
- return sscpycvt(pDst, pSrc, SSMIN(nMax, nLen));
-}
-template
-inline int sscpy(CT1* pDst, const CT2* pSrc, int nMax)
-{
- return sscpycvt(pDst, pSrc, SSMIN(nMax, sslen(pSrc)));
-}
-template
-inline int sscpy(CT1* pDst, const CT2* pSrc)
-{
- return sscpycvt(pDst, pSrc, sslen(pSrc));
-}
-template
-inline int sscpy(CT1* pDst, const std::basic_string& sSrc, int nMax)
-{
- return sscpycvt(pDst, sSrc.c_str(), SSMIN(nMax, (int)sSrc.length()));
-}
-template
-inline int sscpy(CT1* pDst, const std::basic_string& sSrc)
-{
- return sscpycvt(pDst, sSrc.c_str(), (int)sSrc.length());
-}
-
-#ifdef SS_INC_COMDEF
- template
- inline int sscpy(CT1* pDst, const _bstr_t& bs, int nMax)
- {
- return sscpycvt(pDst, static_cast(bs), SSMIN(nMax, (int)bs.length()));
- }
- template
- inline int sscpy(CT1* pDst, const _bstr_t& bs)
- {
- return sscpy(pDst, bs, bs.length());
- }
-#endif
-
-
-// -----------------------------------------------------------------------------
-// Functional objects for changing case. They also let you pass locales
-// -----------------------------------------------------------------------------
-
-#ifdef SS_ANSI
- template
- struct SSToUpper : public std::binary_function
- {
- inline CT operator()(const CT& t, const std::locale& loc) const
- {
- return std::toupper(t, loc);
- }
- };
- template
- struct SSToLower : public std::binary_function
- {
- inline CT operator()(const CT& t, const std::locale& loc) const
- {
- return std::tolower(t, loc);
- }
- };
-#endif
-
-// This struct is used for TrimRight() and TrimLeft() function implementations.
-//template
-//struct NotSpace : public std::unary_function
-//{
-// const std::locale& loc;
-// inline NotSpace(const std::locale& locArg) : loc(locArg) {}
-// inline bool operator() (CT t) { return !std::isspace(t, loc); }
-//};
-template
-struct NotSpace : public std::unary_function
-{
- const std::locale& loc;
- NotSpace(const std::locale& locArg) : loc(locArg) {}
-
- // DINKUMWARE BUG:
- // Note -- using std::isspace in a COM DLL gives us access violations
- // because it causes the dynamic addition of a function to be called
- // when the library shuts down. Unfortunately the list is maintained
- // in DLL memory but the function is in static memory. So the COM DLL
- // goes away along with the function that was supposed to be called,
- // and then later when the DLL CRT shuts down it unloads the list and
- // tries to call the long-gone function.
- // This is DinkumWare's implementation problem. Until then, we will
- // use good old isspace and iswspace from the CRT unless they
- // specify SS_ANSI
-#ifdef SS_ANSI
- bool operator() (CT t) const { return !std::isspace(t, loc); }
-#else
- bool ssisp(char c) const { return FALSE != ::isspace((int) c); }
- bool ssisp(wchar_t c) const { return FALSE != ::iswspace((wint_t) c); }
- bool operator()(CT t) const { return !ssisp(t); }
-#endif
-};
-
-
-
-
-// Now we can define the template (finally!)
-// =============================================================================
-// TEMPLATE: CStdStr
-// template class CStdStr : public std::basic_string
-//
-// REMARKS:
-// This template derives from basic_string and adds some MFC CString-
-// like functionality
-//
-// Basically, this is my attempt to make Standard C++ library strings as
-// easy to use as the MFC CString class.
-//
-// Note that although this is a template, it makes the assumption that the
-// template argument (CT, the character type) is either char or wchar_t.
-// =============================================================================
-
-//#define CStdStr _SS // avoid compiler warning 4786
-
-
-template
-class CStdStr : public std::basic_string
-{
- // Typedefs for shorter names. Using these names also appears to help
- // us avoid some ambiguities that otherwise arise on some platforms
-
- typedef typename std::basic_string MYBASE; // my base class
- typedef CStdStr MYTYPE; // myself
- typedef typename MYBASE::const_pointer PCMYSTR; // PCSTR or PCWSTR
- typedef typename MYBASE::pointer PMYSTR; // PSTR or PWSTR
- typedef typename MYBASE::iterator MYITER; // my iterator type
- typedef typename MYBASE::const_iterator MYCITER; // you get the idea...
- typedef typename MYBASE::reverse_iterator MYRITER;
- typedef typename MYBASE::size_type MYSIZE;
- typedef typename MYBASE::value_type MYVAL;
- typedef typename MYBASE::allocator_type MYALLOC;
-
-public:
-
- // shorthand conversion from PCTSTR to string resource ID
- #define _TRES(pctstr) (LOWORD((DWORD)(pctstr)))
-
- // CStdStr inline constructors
- CStdStr()
- {
- }
-
- CStdStr(const MYTYPE& str) : MYBASE(SSREF(str))
- {
- }
-
- CStdStr(const std::string& str)
- {
- ssasn(*this, SSREF(str));
- }
-
- CStdStr(const std::wstring& str)
- {
- ssasn(*this, SSREF(str));
- }
-
- CStdStr(PCMYSTR pT, MYSIZE n) : MYBASE(pT, n)
- {
- }
-
- CStdStr(PCSTR pA)
- {
- #ifdef SS_ANSI
- *this = pA;
- #else
- if ( 0 != HIWORD(pA) )
- *this = pA;
- else if ( 0 != pA && !Load(_TRES(pA)) )
- TRACE(_T("Can't load string %u\n"), _TRES(pA));
- #endif
- }
-
- CStdStr(PCWSTR pW)
- {
- #ifdef SS_ANSI
- *this = pW;
- #else
- if ( 0 != HIWORD(pW) )
- *this = pW;
- else if ( 0 != pW && !Load(_TRES(pW)) )
- TRACE(_T("Can't load string %u\n"), _TRES(pW));
- #endif
- }
-
- CStdStr(MYCITER first, MYCITER last)
- : MYBASE(first, last)
- {
- }
-
- CStdStr(MYSIZE nSize, MYVAL ch, const MYALLOC& al=MYALLOC())
- : MYBASE(nSize, ch, al)
- {
- }
-
- #ifdef SS_INC_COMDEF
- CStdStr(const _bstr_t& bstr)
- {
- if ( bstr.length() > 0 )
- append(static_cast(bstr), bstr.length());
- }
- #endif
-
- // CStdStr inline assignment operators -- the ssasn function now takes care
- // of fixing the MSVC assignment bug (see knowledge base article Q172398).
- MYTYPE& operator=(const MYTYPE& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& operator=(const std::string& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& operator=(const std::wstring& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& operator=(PCSTR pA)
- {
- ssasn(*this, pA);
- return *this;
- }
-
- MYTYPE& operator=(PCWSTR pW)
- {
- ssasn(*this, pW);
- return *this;
- }
-
- MYTYPE& operator=(CT t)
- {
- Q172398(*this);
- MYBASE::assign(1, t);
- return *this;
- }
-
- #ifdef SS_INC_COMDEF
- MYTYPE& operator=(const _bstr_t& bstr)
- {
- if ( bstr.length() > 0 )
- return assign(static_cast(bstr), bstr.length());
- else
- {
- erase();
- return *this;
- }
- }
- #endif
-
-
- // Overloads also needed to fix the MSVC assignment bug (KB: Q172398)
- // *** Thanks to Pete The Plumber for catching this one ***
- // They also are compiled if you have explicitly turned off refcounting
- #if ( defined(_MSC_VER) && ( _MSC_VER < 1200 ) ) || defined(SS_NO_REFCOUNT)
-
- MYTYPE& assign(const MYTYPE& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& assign(const MYTYPE& str, MYSIZE nStart, MYSIZE nChars)
- {
- // This overload of basic_string::assign is supposed to assign up to
- // or the NULL terminator, whichever comes first. Since we
- // are about to call a less forgiving overload (in which
- // must be a valid length), we must adjust the length here to a safe
- // value. Thanks to Ullrich Pollähne for catching this bug
-
- nChars = SSMIN(nChars, str.length() - nStart);
-
- // Watch out for assignment to self
-
- if ( this == &str )
- {
- MYTYPE strTemp(str.c_str()+nStart, nChars);
- assign(strTemp);
- }
- else
- {
- Q172398(*this);
- MYBASE::assign(str.c_str()+nStart, nChars);
- }
- return *this;
- }
-
- MYTYPE& assign(const MYBASE& str)
- {
- ssasn(*this, str);
- return *this;
- }
-
- MYTYPE& assign(const MYBASE& str, MYSIZE nStart, MYSIZE nChars)
- {
- // This overload of basic_string::assign is supposed to assign up to
- // or the NULL terminator, whichever comes first. Since we
- // are about to call a less forgiving overload (in which
- // must be a valid length), we must adjust the length here to a safe
- // value. Thanks to Ullrich Pollähne for catching this bug
-
- nChars = SSMIN(nChars, str.length() - nStart);
-
- // Watch out for assignment to self
-
- if ( this == &str ) // watch out for assignment to self
- {
- MYTYPE strTemp(str.c_str() + nStart, nChars);
- assign(strTemp);
- }
- else
- {
- Q172398(*this);
- MYBASE::assign(str.c_str()+nStart, nChars);
- }
- return *this;
- }
-
- MYTYPE& assign(const CT* pC, MYSIZE nChars)
- {
- // Q172398 only fix -- erase before assigning, but not if we're
- // assigning from our own buffer
-
- #if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
- if ( !empty() && ( pC < data() || pC > data() + capacity() ) )
- erase();
- #endif
- Q172398(*this);
- MYBASE::assign(pC, nChars);
- return *this;
- }
-
- MYTYPE& assign(MYSIZE nChars, MYVAL val)
- {
- Q172398(*this);
- MYBASE::assign(nChars, val);
- return *this;
- }
-
- MYTYPE& assign(const CT* pT)
- {
- return assign(pT, CStdStr::traits_type::length(pT));
- }
-
- MYTYPE& assign(MYCITER iterFirst, MYCITER iterLast)
- {
- #if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
- // Q172398 fix. don't call erase() if we're assigning from ourself
- if ( iterFirst < begin() || iterFirst > begin() + size() )
- erase()
- #endif
- replace(begin(), end(), iterFirst, iterLast);
- return *this;
- }
- #endif
-
-
- // -------------------------------------------------------------------------
- // CStdStr inline concatenation.
- // -------------------------------------------------------------------------
- MYTYPE& operator+=(const MYTYPE& str)
- {
- ssadd(*this, str);
- return *this;
- }
-
- MYTYPE& operator+=(const std::string& str)
- {
- ssadd(*this, str);
- return *this;
- }
-
- MYTYPE& operator+=(const std::wstring& str)
- {
- ssadd(*this, str);
- return *this;
- }
-
- MYTYPE& operator+=(PCSTR pA)
- {
- ssadd(*this, pA);
- return *this;
- }
-
- MYTYPE& operator+=(PCWSTR pW)
- {
- ssadd(*this, pW);
- return *this;
- }
-
- MYTYPE& operator+=(CT t)
- {
- append(1, t);
- return *this;
- }
- #ifdef SS_INC_COMDEF // if we have _bstr_t, define a += for it too.
- MYTYPE& operator+=(const _bstr_t& bstr)
- {
- return operator+=(static_cast(bstr));
- }
- #endif
-
-
- // addition operators -- global friend functions.
-
- friend MYTYPE operator+(const MYTYPE& str1, const MYTYPE& str2);
- friend MYTYPE operator+(const MYTYPE& str, CT t);
- friend MYTYPE operator+(const MYTYPE& str, PCSTR sz);
- friend MYTYPE operator+(const MYTYPE& str, PCWSTR sz);
- friend MYTYPE operator+(PCSTR pA, const MYTYPE& str);
- friend MYTYPE operator+(PCWSTR pW, const MYTYPE& str);
-#ifdef SS_INC_COMDEF
- friend MYTYPE operator+(const _bstr_t& bstr, const MYTYPE& str);
- friend MYTYPE operator+(const MYTYPE& str, const _bstr_t& bstr);
-#endif
-
- // -------------------------------------------------------------------------
- // Case changing functions
- // -------------------------------------------------------------------------
- // -------------------------------------------------------------------------
- MYTYPE& ToUpper()
- {
- // Strictly speaking, this would be about the most portable way
-
- // std::transform(begin(),
- // end(),
- // begin(),
- // std::bind2nd(SSToUpper(), std::locale()));
-
- // But practically speaking, this works faster
-
- if ( !empty() )
- ssupr(GetBuf(), size());
-
- return *this;
- }
-
-
-
- MYTYPE& ToLower()
- {
- // Strictly speaking, this would be about the most portable way
-
- // std::transform(begin(),
- // end(),
- // begin(),
- // std::bind2nd(SSToLower(), std::locale()));
-
- // But practically speaking, this works faster
-
- if ( !empty() )
- sslwr(GetBuf(), size());
-
- return *this;
- }
-
-
-
- MYTYPE& Normalize()
- {
- return Trim().ToLower();
- }
-
-
- // -------------------------------------------------------------------------
- // CStdStr -- Direct access to character buffer. In the MS' implementation,
- // the at() function that we use here also calls _Freeze() providing us some
- // protection from multithreading problems associated with ref-counting.
- // -------------------------------------------------------------------------
- CT* GetBuf(int nMinLen=-1)
- {
- if ( static_cast(size()) < nMinLen )
- resize(static_cast(nMinLen));
-
- return empty() ? const_cast(data()) : &(at(0));
- }
-
- CT* SetBuf(int nLen)
- {
- nLen = ( nLen > 0 ? nLen : 0 );
- if ( capacity() < 1 && nLen == 0 )
- resize(1);
-
- resize(static_cast(nLen));
- return const_cast(data());
- }
- void RelBuf(int nNewLen=-1)
- {
- resize(static_cast(nNewLen > -1 ? nNewLen : sslen(c_str())));
- }
-
- void BufferRel() { RelBuf(); } // backwards compatability
- CT* Buffer() { return GetBuf(); } // backwards compatability
- CT* BufferSet(int nLen) { return SetBuf(nLen);}// backwards compatability
-
- bool Equals(const CT* pT, bool bUseCase=false) const
- { // get copy, THEN compare (thread safe)
- return bUseCase ? compare(pT) == 0 : ssicmp(MYTYPE(*this), pT) == 0;
- }
-
- // -------------------------------------------------------------------------
- // FUNCTION: CStdStr::Load
- // REMARKS:
- // Loads string from resource specified by nID
- //
- // PARAMETERS:
- // nID - resource Identifier. Purely a Win32 thing in this case
- //
- // RETURN VALUE:
- // true if successful, false otherwise
- // -------------------------------------------------------------------------
-#ifndef SS_ANSI
- bool Load(UINT nId, HMODULE hModule=NULL)
- {
- bool bLoaded = false; // set to true of we succeed.
-
- #ifdef _MFC_VER // When in Rome...
-
- CString strRes;
- bLoaded = FALSE != strRes.LoadString(nId);
- if ( bLoaded )
- *this = strRes;
-
- #else
-
- // Get the resource name and module handle
-
- if ( NULL == hModule )
- hModule = GetResourceHandle();
-
- PCTSTR szName = MAKEINTRESOURCE((nId>>4)+1); // lifted
- DWORD dwSize = 0;
-
- // No sense continuing if we can't find the resource
-
- HRSRC hrsrc = ::FindResource(hModule, szName, RT_STRING);
-
- if ( NULL == hrsrc )
- TRACE(_T("Cannot find resource %d: 0x%X"), nId, ::GetLastError());
- else if ( 0 == (dwSize = ::SizeofResource(hModule, hrsrc) / sizeof(CT)))
- TRACE(_T("Cant get size of resource %d 0x%X\n"),nId,GetLastError());
- else
- {
- bLoaded = 0 != ssload(hModule, nId, GetBuf(dwSize), dwSize);
- ReleaseBuffer();
- }
-
- #endif
-
- if ( !bLoaded )
- TRACE(_T("String not loaded 0x%X\n"), ::GetLastError());
-
- return bLoaded;
- }
-#endif
-
- // -------------------------------------------------------------------------
- // FUNCTION: CStdStr::Format
- // void _cdecl Formst(CStdStringA& PCSTR szFormat, ...)
- // void _cdecl Format(PCSTR szFormat);
- //
- // DESCRIPTION:
- // This function does sprintf/wsprintf style formatting on CStdStringA
- // objects. It looks a lot like MFC's CString::Format. Some people
- // might even call this identical. Fortunately, these people are now
- // dead.
- //
- // PARAMETERS:
- // nId - ID of string resource holding the format string
- // szFormat - a PCSTR holding the format specifiers
- // argList - a va_list holding the arguments for the format specifiers.
- //
- // RETURN VALUE: None.
- // -------------------------------------------------------------------------
- // formatting (using wsprintf style formatting)
- #ifndef SS_ANSI
- void Format(UINT nId, ...)
- {
- va_list argList;
- va_start(argList, nId);
- va_start(argList, nId);
-
- MYTYPE strFmt;
- if ( strFmt.Load(nId) )
- FormatV(strFmt, argList);
-
- va_end(argList);
- }
- #endif
- void Format(const CT* szFmt, ...)
- {
- va_list argList;
- va_start(argList, szFmt);
- FormatV(szFmt, argList);
- va_end(argList);
- }
- void AppendFormat(const CT* szFmt, ...)
- {
- va_list argList;
- va_start(argList, szFmt);
- AppendFormatV(szFmt, argList);
- va_end(argList);
- }
-
- #define MAX_FMT_TRIES 5 // #of times we try
- #define FMT_BLOCK_SIZE 2048 // # of bytes to increment per try
- #define BUFSIZE_1ST 256
- #define BUFSIZE_2ND 512
- #define STD_BUF_SIZE 1024
-
- // an efficient way to add formatted characters to the string. You may only
- // add up to STD_BUF_SIZE characters at a time, though
- void AppendFormatV(const CT* szFmt, va_list argList)
- {
- CT szBuf[STD_BUF_SIZE];
- #ifdef SS_ANSI
- int nLen = ssvsprintf(szBuf, STD_BUF_SIZE-1, szFmt, argList);
- #else
- int nLen = ssnprintf(szBuf, STD_BUF_SIZE-1, szFmt, argList);
- #endif
- if ( 0 < nLen )
- append(szBuf, nLen);
- }
-
- // -------------------------------------------------------------------------
- // FUNCTION: FormatV
- // void FormatV(PCSTR szFormat, va_list, argList);
- //
- // DESCRIPTION:
- // This function formats the string with sprintf style format-specs.
- // It makes a general guess at required buffer size and then tries
- // successively larger buffers until it finds one big enough or a
- // threshold (MAX_FMT_TRIES) is exceeded.
- //
- // PARAMETERS:
- // szFormat - a PCSTR holding the format of the output
- // argList - a Microsoft specific va_list for variable argument lists
- //
- // RETURN VALUE:
- // -------------------------------------------------------------------------
-
- void FormatV(const CT* szFormat, va_list argList)
- {
- #ifdef SS_ANSI
-
- int nLen = sslen(szFormat) + STD_BUF_SIZE;
- ssvsprintf(GetBuffer(nLen), nLen-1, szFormat, argList);
- ReleaseBuffer();
-
- #else
-
- CT* pBuf = NULL;
- int nChars = 1;
- int nUsed = 0;
- size_type nActual = 0;
- int nTry = 0;
-
- do
- {
- // Grow more than linearly (e.g. 512, 1536, 3072, etc)
-
- nChars += ((nTry+1) * FMT_BLOCK_SIZE);
- pBuf = reinterpret_cast(_alloca(sizeof(CT)*nChars));
- nUsed = ssnprintf(pBuf, nChars-1, szFormat, argList);
-
- // Ensure proper NULL termination.
-
- nActual = nUsed == -1 ? nChars-1 : SSMIN(nUsed, nChars-1);
- pBuf[nActual+1]= '\0';
-
-
- } while ( nUsed < 0 && nTry++ < MAX_FMT_TRIES );
-
- // assign whatever we managed to format
-
- assign(pBuf, nActual);
-
- #endif
- }
-
-
- // -------------------------------------------------------------------------
- // CString Facade Functions:
- //
- // The following methods are intended to allow you to use this class as a
- // drop-in replacement for CString.
- // -------------------------------------------------------------------------
- #ifndef SS_ANSI
- BSTR AllocSysString() const
- {
- ostring os;
- ssasn(os, *this);
- return ::SysAllocString(os.c_str());
- }
- #endif
-
- int Collate(PCMYSTR szThat) const
- {
- return sscoll(c_str(), length(), szThat, sslen(szThat));
- }
-
- int CollateNoCase(PCMYSTR szThat) const
- {
- return ssicoll(c_str(), length(), szThat, sslen(szThat));
- }
-
- int Compare(PCMYSTR szThat) const
- {
- return MYBASE::compare(szThat);
- }
-
- int CompareNoCase(PCMYSTR szThat) const
- {
- return ssicmp(c_str(), szThat);
- }
-
- int Delete(int nIdx, int nCount=1)
- {
- if ( nIdx < GetLength() )
- erase(static_cast(nIdx), static_cast