More Linux work. This has Render, Animate and Genome building and running on Linux.

This commit is contained in:
mfeemster
2014-12-05 18:30:46 -08:00
parent 4777ab52bc
commit a15f6d6b32
44 changed files with 2614 additions and 1021 deletions

View File

@ -12,13 +12,18 @@
#include <SDKDDKVer.h>
#include <windows.h>
#include <winsock.h>//For htons().
#include <BaseTsd.h>
#include <crtdbg.h>
#include <tchar.h>
#define snprintf _snprintf
#else
#include <arpa/inet.h>
#define _TCHAR char
#define _tmain main
#define _T
#define fprintf_s fprintf
#endif
#include <BaseTsd.h>
#include <crtdbg.h>
#include <iostream>
#include <iomanip>
#include <ostream>
@ -27,11 +32,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
#include "jconfig.h"
#include "jpeglib.h"
#define PNG_SKIP_SETJMP_CHECK 1
#include "png.h"
//#include "pnginfo.h"

View File

@ -6,7 +6,7 @@
/// EmberOptionEntry and EmberOptions classes.
/// </summary>
static char* DescriptionString = "Ember - Fractal flames C++ port and enhancement with OpenCL GPU support";
static const char* DescriptionString = "Ember - Fractal flames C++ port and enhancement with OpenCL GPU support";
/// <summary>
/// Enum for specifying which command line programs an option is meant to be used with.
@ -142,7 +142,7 @@ private:
m_OptionUse = OPT_USE_ALL;
m_Option.nArgType = SO_NONE;
m_Option.nId = 0;
m_Option.pszArg = _T("--fillmein");
m_Option.pszArg = _T("--fillmein");
m_DocString = "Dummy doc";
}
@ -175,7 +175,7 @@ public:
{
*this = entry;
}
/// <summary>
/// Functor accessors.
/// </summary>
@ -277,7 +277,7 @@ public:
INITBOOLOPTION(DoProgress, Eob(OPT_USE_ALL, OPT_PROGRESS, _T("--progress"), false, SO_NONE, "\t--progress Display progress. This will slow down processing by about 10%%.\n"));
INITBOOLOPTION(OpenCLInfo, Eob(OPT_USE_ALL, OPT_DUMP_OPENCL_INFO, _T("--openclinfo"), false, SO_NONE, "\t--openclinfo Display platforms and devices for OpenCL.\n"));
//Execution bools.
//Execution bools.
INITBOOLOPTION(EmberCL, Eob(OPT_USE_ALL, OPT_OPENCL, _T("--opencl"), false, SO_NONE, "\t--opencl Use OpenCL renderer (EmberCL) for rendering [default: false].\n"));
INITBOOLOPTION(EarlyClip, Eob(OPT_USE_ALL, OPT_EARLYCLIP, _T("--earlyclip"), false, SO_NONE, "\t--earlyclip Perform clipping of RGB values before spatial filtering for better antialiasing and resizing [default: false].\n"));
INITBOOLOPTION(YAxisUp, Eob(OPT_USE_ALL, OPT_POS_Y_UP, _T("--yaxisup"), false, SO_NONE, "\t--yaxisup Orient the image with the positive y axis pointing up [default: false].\n"));
@ -493,6 +493,10 @@ public:
PARSESTRINGOPTION(OPT_USE_VARS, UseVars);
PARSESTRINGOPTION(OPT_DONT_USE_VARS, DontUseVars);
PARSESTRINGOPTION(OPT_EXTRAS, Extras);
default:
{
break;//Do nothing.
}
}
}
else

View File

@ -21,7 +21,7 @@ static bool WritePpm(const char* filename, unsigned char* image, size_t width, s
if (fopen_s(&file, filename, "wb") == 0)
{
fprintf_s(file, "P6\n");
fprintf_s(file, "%d %d\n255\n", width, height);
fprintf_s(file, "%lu %lu\n255\n", width, height);
b = (size == fwrite(image, 1, size, file));
fclose(file);
@ -57,11 +57,11 @@ static bool WriteJpeg(const char* filename, unsigned char* image, size_t width,
char nickString[64], urlString[128], idString[128];
char bvString[64], niString[64], rtString[64];
char genomeString[65536], verString[64];
//Create the mandatory comment strings.
snprintf_s(genomeString, 65536, "flam3_genome: %s", comments.m_Genome.c_str());
snprintf_s(bvString, 64, "flam3_error_rate: %s", comments.m_Badvals.c_str());
snprintf_s(niString, 64, "flam3_samples: %s", comments.m_NumIters);
snprintf_s(niString, 64, "flam3_samples: %s", comments.m_NumIters.c_str());
snprintf_s(rtString, 64, "flam3_time: %s", comments.m_Runtime.c_str());
snprintf_s(verString, 64, "flam3_version: %s", EmberVersion());
@ -75,7 +75,7 @@ static bool WriteJpeg(const char* filename, unsigned char* image, size_t width,
jpeg_set_defaults(&info);
jpeg_set_quality(&info, quality, TRUE);
jpeg_start_compress(&info, TRUE);
//Write comments to jpeg.
if (enableComments)
{
@ -92,7 +92,7 @@ static bool WriteJpeg(const char* filename, unsigned char* image, size_t width,
snprintf_s(urlString, 128, "flam3_url: %s", url.c_str());
jpeg_write_marker(&info, JPEG_COM, (unsigned char*)urlString, (int)strlen(urlString));
}
if (id != "")
{
snprintf_s(idString, 128, "flam3_id: %s", id.c_str());
@ -150,41 +150,41 @@ static bool WritePng(const char* filename, unsigned char* image, size_t width, s
vector<unsigned char*> rows(height);
text[0].compression = PNG_TEXT_COMPRESSION_NONE;
text[0].key = "flam3_version";
text[0].key = (png_charp)"flam3_version";
text[0].text = (png_charp)EmberVersion();
text[1].compression = PNG_TEXT_COMPRESSION_NONE;
text[1].key = "flam3_nickname";
text[1].key = (png_charp)"flam3_nickname";
text[1].text = (png_charp)nick.c_str();
text[2].compression = PNG_TEXT_COMPRESSION_NONE;
text[2].key = "flam3_url";
text[2].key = (png_charp)"flam3_url";
text[2].text = (png_charp)url.c_str();
text[3].compression = PNG_TEXT_COMPRESSION_NONE;
text[3].key = "flam3_id";
text[3].key = (png_charp)"flam3_id";
text[3].text = (png_charp)id.c_str();
text[4].compression = PNG_TEXT_COMPRESSION_NONE;
text[4].key = "flam3_error_rate";
text[4].key = (png_charp)"flam3_error_rate";
text[4].text = (png_charp)comments.m_Badvals.c_str();
text[5].compression = PNG_TEXT_COMPRESSION_NONE;
text[5].key = "flam3_samples";
text[5].key = (png_charp)"flam3_samples";
text[5].text = (png_charp)comments.m_NumIters.c_str();
text[6].compression = PNG_TEXT_COMPRESSION_NONE;
text[6].key = "flam3_time";
text[6].key = (png_charp)"flam3_time";
text[6].text = (png_charp)comments.m_Runtime.c_str();
text[7].compression = PNG_TEXT_COMPRESSION_zTXt;
text[7].key = "flam3_genome";
text[7].key = (png_charp)"flam3_genome";
text[7].text = (png_charp)comments.m_Genome.c_str();
for (i = 0; i < height; i++)
rows[i] = (unsigned char*)image + i * width * 4 * bytesPerChannel;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
info_ptr = png_create_info_struct(png_ptr);
if (setjmp(png_jmpbuf(png_ptr)))
@ -202,7 +202,7 @@ static bool WritePng(const char* filename, unsigned char* image, size_t width, s
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE,
PNG_FILTER_TYPE_BASE);
if (enableComments == 1)
png_set_text(png_ptr, info_ptr, text, PNG_COMMENT_MAX);
@ -232,20 +232,20 @@ static bool WritePng(const char* filename, unsigned char* image, size_t width, s
/// <param name="height">The height.</param>
/// <param name="newSize">The size of the new buffer created</param>
/// <returns>The converted buffer if successful, else NULL.</returns>
static BYTE* ConvertRGBToBMPBuffer(BYTE* buffer, size_t width, size_t height, size_t& newSize)
static unsigned char* ConvertRGBToBMPBuffer(unsigned char* buffer, size_t width, size_t height, size_t& newSize)
{
if (NULL == buffer || width == 0 || height == 0)
return NULL;
if (buffer == nullptr || width == 0 || height == 0)
return nullptr;
size_t padding = 0;
size_t scanlinebytes = width * 3;
while ((scanlinebytes + padding ) % 4 != 0)
while ((scanlinebytes + padding ) % 4 != 0)
padding++;
size_t psw = scanlinebytes + padding;
newSize = height * psw;
BYTE* newBuf = new BYTE[newSize];
unsigned char* newBuf = new unsigned char[newSize];
if (newBuf)
{
@ -274,7 +274,7 @@ static BYTE* ConvertRGBToBMPBuffer(BYTE* buffer, size_t width, size_t height, si
return newBuf;
}
return NULL;
return nullptr;
}
/// <summary>
@ -286,8 +286,9 @@ static BYTE* ConvertRGBToBMPBuffer(BYTE* buffer, size_t width, size_t height, si
/// <param name="height">Height of the image in pixels</param>
/// <param name="paddedSize">Padded size, greater than or equal to total image size.</param>
/// <returns>True if success, else false</returns>
static bool SaveBmp(const char* filename, BYTE* image, size_t width, size_t height, size_t paddedSize)
static bool SaveBmp(const char* filename, unsigned char* image, size_t width, size_t height, size_t paddedSize)
{
#ifdef WIN32
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER info;
DWORD bwritten;
@ -304,14 +305,14 @@ static bool SaveBmp(const char* filename, BYTE* image, size_t width, size_t heig
info.biSize = sizeof(BITMAPINFOHEADER);
info.biWidth = (LONG)width;
info.biHeight = (LONG)height;
info.biPlanes = 1;
info.biPlanes = 1;
info.biBitCount = 24;
info.biCompression = BI_RGB;
info.biCompression = BI_RGB;
info.biSizeImage = 0;
info.biXPelsPerMeter = 0x0ec4;
info.biYPelsPerMeter = 0x0ec4;
info.biClrUsed = 0;
info.biClrImportant = 0;
info.biXPelsPerMeter = 0x0ec4;
info.biYPelsPerMeter = 0x0ec4;
info.biClrUsed = 0;
info.biClrImportant = 0;
if ((file = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == NULL)
{
@ -320,24 +321,25 @@ static bool SaveBmp(const char* filename, BYTE* image, size_t width, size_t heig
}
if (WriteFile(file, &bmfh, sizeof (BITMAPFILEHEADER), &bwritten, NULL) == false)
{
{
CloseHandle(file);
return false;
}
if (WriteFile(file, &info, sizeof(BITMAPINFOHEADER), &bwritten, NULL) == false)
{
{
CloseHandle(file);
return false;
}
if (WriteFile(file, image, (DWORD)paddedSize, &bwritten, NULL) == false)
{
{
CloseHandle(file);
return false;
}
CloseHandle(file);
#endif
return true;
}
@ -353,7 +355,7 @@ static bool WriteBmp(const char* filename, unsigned char* image, size_t width, s
{
bool b = false;
size_t newSize;
unique_ptr<BYTE> bgrBuf(ConvertRGBToBMPBuffer(image, width, height, newSize));
unique_ptr<unsigned char> bgrBuf(ConvertRGBToBMPBuffer(image, width, height, newSize));
if (bgrBuf.get())
b = SaveBmp(filename, bgrBuf.get(), width, height, newSize);

View File

@ -3,22 +3,22 @@
@version 3.6
@brief A cross-platform file globbing library providing the ability to
expand wildcards in command-line arguments to a list of all matching
files. It is designed explicitly to be portable to any platform and has
been tested on Windows and Linux. See CSimpleGlobTempl for the class
expand wildcards in command-line arguments to a list of all matching
files. It is designed explicitly to be portable to any platform and has
been tested on Windows and Linux. See CSimpleGlobTempl for the class
definition.
@section features FEATURES
- MIT Licence allows free use in all software (including GPL and
- MIT Licence allows free use in all software (including GPL and
commercial)
- multi-platform (Windows 95/98/ME/NT/2K/XP, Linux, Unix)
- supports most of the standard linux glob() options
- recognition of a forward paths as equivalent to a backward slash
- recognition of a forward paths as equivalent to a backward slash
on Windows. e.g. "c:/path/foo*" is equivalent to "c:\path\foo*".
- implemented with only a single C++ header file
- char, wchar_t and Windows TCHAR in the same program
- complete working examples included
- compiles cleanly at warning level 4 (Windows/VC.NET 2003),
- compiles cleanly at warning level 4 (Windows/VC.NET 2003),
warning level 3 (Windows/VC6) and -Wall (Linux/gcc)
@section usage USAGE
@ -70,12 +70,12 @@
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</pre>
*/
@ -83,7 +83,7 @@
#ifndef INCLUDED_SimpleGlob
#define INCLUDED_SimpleGlob
/*! @brief The operation of SimpleGlob is fine-tuned via the use of a
/*! @brief The operation of SimpleGlob is fine-tuned via the use of a
combination of the following flags.
The flags may be passed at initialization of the class and used for every
@ -99,15 +99,15 @@
@param SG_GLOB_NOSORT
By default, files are returned in sorted into string order. With this
flag, no sorting is done. This is not compatible with
flag, no sorting is done. This is not compatible with
SG_GLOB_FULLSORT.
@param SG_GLOB_FULLSORT
By default, files are sorted in groups belonging to each filespec that
was added. For example if the filespec "b*" was added before the
filespec "a*" then the argv array will contain all b* files sorted in
order, followed by all a* files sorted in order. If this flag is
specified, the entire array will be sorted ignoring the filespec
was added. For example if the filespec "b*" was added before the
filespec "a*" then the argv array will contain all b* files sorted in
order, followed by all a* files sorted in order. If this flag is
specified, the entire array will be sorted ignoring the filespec
groups.
@param SG_GLOB_NOCHECK
@ -117,7 +117,7 @@
Tilde expansion is carried out (on Unix platforms)
@param SG_GLOB_ONLYDIR
Return only directories which match (not compatible with
Return only directories which match (not compatible with
SG_GLOB_ONLYFILE)
@param SG_GLOB_ONLYFILE
@ -409,7 +409,7 @@ struct SimpleGlobBase
int nFlags = GLOB_MARK | GLOB_NOSORT;
if (a_uiFlags & SG_GLOB_ERR) nFlags |= GLOB_ERR;
if (a_uiFlags & SG_GLOB_TILDE) nFlags |= GLOB_TILDE;
int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
int rc = glob(a_pszFileSpec, nFlags, nullptr, &m_glob);
if (rc == GLOB_NOSPACE) return SG_ERR_MEMORY;
if (rc == GLOB_ABORTED) return SG_ERR_FAILURE;
if (rc == GLOB_NOMATCH) return SG_ERR_NOMATCH;
@ -422,7 +422,7 @@ struct SimpleGlobBase
int FindFirstFileS(const UChar * a_pszFileSpec, unsigned int a_uiFlags) {
char buf[PATH_MAX] = { 0 };
UErrorCode status = U_ZERO_ERROR;
u_strToUTF8(buf, sizeof(buf), NULL, a_pszFileSpec, -1, &status);
u_strToUTF8(buf, sizeof(buf), nullptr, a_pszFileSpec, -1, &status);
if (U_FAILURE(status)) return SG_ERR_FAILURE;
return this->FindFirstFileS(buf, a_uiFlags);
}
@ -457,11 +457,11 @@ struct SimpleGlobBase
#if SG_HAVE_ICU
const UChar * GetFileNameS(UChar) const {
const char * pszFile = this->GetFileNameS((char)0);
if (!pszFile) return NULL;
if (!pszFile) return nullptr;
UErrorCode status = U_ZERO_ERROR;
memset(m_szBuf, 0, sizeof(m_szBuf));
u_strFromUTF8(m_szBuf, PATH_MAX, NULL, pszFile, -1, &status);
if (U_FAILURE(status)) return NULL;
u_strFromUTF8(m_szBuf, PATH_MAX, nullptr, pszFile, -1, &status);
if (U_FAILURE(status)) return nullptr;
return m_szBuf;
}
#endif
@ -495,7 +495,7 @@ struct SimpleGlobBase
SG_FileType GetFileTypeS(const UChar * a_pszPath) const {
char buf[PATH_MAX] = { 0 };
UErrorCode status = U_ZERO_ERROR;
u_strToUTF8(buf, sizeof(buf), NULL, a_pszPath, -1, &status);
u_strToUTF8(buf, sizeof(buf), nullptr, a_pszPath, -1, &status);
if (U_FAILURE(status)) return SG_FILETYPE_INVALID;
return this->GetFileTypeS(buf);
}
@ -558,7 +558,7 @@ public:
@param a_pszFileSpec Filespec to add to the glob.
@return SG_SUCCESS Matching files were added to the glob.
@return SG_ERR_NOMATCH Nothing matched the pattern. To ignore this
@return SG_ERR_NOMATCH Nothing matched the pattern. To ignore this
error compare return value to >= SG_SUCCESS.
@return SG_ERR_MEMORY Out of memory failure.
@return SG_ERR_FAILURE General failure.
@ -574,7 +574,7 @@ public:
@param a_rgpszFileSpec Array of filespec to add to the glob.
@return SG_SUCCESS Matching files were added to the glob.
@return SG_ERR_NOMATCH Nothing matched the pattern. To ignore this
@return SG_ERR_NOMATCH Nothing matched the pattern. To ignore this
error compare return value to >= SG_SUCCESS.
@return SG_ERR_MEMORY Out of memory failure.
@return SG_ERR_FAILURE General failure.
@ -602,8 +602,8 @@ private:
CSimpleGlobTempl & operator=(const CSimpleGlobTempl &); // disabled
/*! @brief The argv array has it's members stored as either an offset into
the string buffer, or as pointers to their string in the buffer. The
offsets are used because if the string buffer is dynamically resized,
the string buffer, or as pointers to their string in the buffer. The
offsets are used because if the string buffer is dynamically resized,
all pointers into that buffer would become invalid.
*/
enum ARG_ARRAY_TYPE { OFFSETS, POINTERS };
@ -620,13 +620,13 @@ private:
/*! @brief Grow the string buffer to the required size. */
bool GrowStringBuffer(size_t a_uiMinSize);
/*! @brief Compare two (possible NULL) strings */
/*! @brief Compare two (possible nullptr) strings */
static int fileSortCompare(const void *a1, const void *a2);
private:
unsigned int m_uiFlags;
ARG_ARRAY_TYPE m_nArgArrayType; //!< argv is indexes or pointers
SOCHAR ** m_rgpArgs; //!< argv
SOCHAR ** m_rgpArgs; //!< argv
int m_nReservedSlots; //!< # client slots in argv array
int m_nArgsSize; //!< allocated size of array
int m_nArgsLen; //!< used length
@ -646,9 +646,9 @@ CSimpleGlobTempl<SOCHAR>::CSimpleGlobTempl(
int a_nReservedSlots
)
{
m_rgpArgs = NULL;
m_rgpArgs = nullptr;
m_nArgsSize = 0;
m_pBuffer = NULL;
m_pBuffer = nullptr;
m_uiBufferSize = 0;
Init(a_uiFlags, a_nReservedSlots);
@ -679,7 +679,7 @@ CSimpleGlobTempl<SOCHAR>::Init(
return SG_ERR_MEMORY;
}
for (int n = 0; n < m_nReservedSlots; ++n) {
m_rgpArgs[n] = NULL;
m_rgpArgs[n] = nullptr;
}
}
@ -693,8 +693,8 @@ CSimpleGlobTempl<SOCHAR>::Add(
)
{
#ifdef _WIN32
// Windows FindFirst/FindNext recognizes forward slash as the same as
// backward slash and follows the directories. We need to do the same
// Windows FindFirst/FindNext recognizes forward slash as the same as
// backward slash and follows the directories. We need to do the same
// when calculating the prefix and when we have no wildcards.
SOCHAR szFileSpec[MAX_PATH];
SimpleGlobUtil::strcpy_s(szFileSpec, MAX_PATH, a_pszFileSpec);
@ -722,10 +722,10 @@ CSimpleGlobTempl<SOCHAR>::Add(
}
#ifdef _WIN32
// Windows doesn't return the directory with the filename, so we need to
// extract the path from the search string ourselves and prefix it to the
// Windows doesn't return the directory with the filename, so we need to
// extract the path from the search string ourselves and prefix it to the
// filename we get back.
const SOCHAR * pszFilename =
const SOCHAR * pszFilename =
SimpleGlobUtil::strrchr(a_pszFileSpec, SG_PATH_CHAR);
if (pszFilename) {
SimpleGlobUtil::strcpy_s(m_szPathPrefix, MAX_PATH, a_pszFileSpec);
@ -820,7 +820,7 @@ CSimpleGlobTempl<SOCHAR>::AppendName(
// ensure that we have enough room in the string buffer (+1 for null)
size_t uiPrefixLen = SimpleGlobUtil::strlen(m_szPathPrefix);
size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1;
size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1;
if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
++uiLen; // need space for the backslash
}
@ -857,14 +857,14 @@ CSimpleGlobTempl<SOCHAR>::SetArgvArrayType(
SG_ASSERT(m_nArgArrayType == OFFSETS);
for (int n = 0; n < m_nArgsLen; ++n) {
m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR*)-1) ?
NULL : m_pBuffer + (size_t) m_rgpArgs[n];
nullptr : m_pBuffer + (size_t) m_rgpArgs[n];
}
}
else {
SG_ASSERT(a_nNewType == OFFSETS);
SG_ASSERT(m_nArgArrayType == POINTERS);
for (int n = 0; n < m_nArgsLen; ++n) {
m_rgpArgs[n] = (m_rgpArgs[n] == NULL) ?
m_rgpArgs[n] = (m_rgpArgs[n] == nullptr) ?
(SOCHAR*) -1 : (SOCHAR*) (m_rgpArgs[n] - m_pBuffer);
}
}
@ -879,7 +879,7 @@ CSimpleGlobTempl<SOCHAR>::GrowArgvArray(
{
if (a_nNewLen >= m_nArgsSize) {
static const int SG_ARGV_INITIAL_SIZE = 32;
int nNewSize = (m_nArgsSize > 0) ?
int nNewSize = (m_nArgsSize > 0) ?
m_nArgsSize * 2 : SG_ARGV_INITIAL_SIZE;
while (a_nNewLen >= nNewSize) {
nNewSize *= 2;
@ -900,7 +900,7 @@ CSimpleGlobTempl<SOCHAR>::GrowStringBuffer(
{
if (a_uiMinSize >= m_uiBufferSize) {
static const int SG_BUFFER_INITIAL_SIZE = 1024;
size_t uiNewSize = (m_uiBufferSize > 0) ?
size_t uiNewSize = (m_uiBufferSize > 0) ?
m_uiBufferSize * 2 : SG_BUFFER_INITIAL_SIZE;
while (a_uiMinSize >= uiNewSize) {
uiNewSize *= 2;
@ -925,7 +925,7 @@ CSimpleGlobTempl<SOCHAR>::fileSortCompare(
if (s1 && s2) {
return SimpleGlobUtil::strcasecmp(s1, s2);
}
// NULL sorts first
// nullptr sorts first
return s1 == s2 ? 0 : (s1 ? 1 : -1);
}
@ -937,11 +937,11 @@ CSimpleGlobTempl<SOCHAR>::fileSortCompare(
typedef CSimpleGlobTempl<char> CSimpleGlobA;
/*! @brief wchar_t version of CSimpleGlob */
typedef CSimpleGlobTempl<wchar_t> CSimpleGlobW;
typedef CSimpleGlobTempl<wchar_t> CSimpleGlobW;
#if SG_HAVE_ICU
/*! @brief UChar version of CSimpleGlob */
typedef CSimpleGlobTempl<UChar> CSimpleGlobU;
typedef CSimpleGlobTempl<UChar> CSimpleGlobU;
#endif
#ifdef _UNICODE
@ -949,11 +949,11 @@ typedef CSimpleGlobTempl<UChar> CSimpleGlobU;
# if SG_HAVE_ICU
# define CSimpleGlob CSimpleGlobU
# else
# define CSimpleGlob CSimpleGlobW
# define CSimpleGlob CSimpleGlobW
# endif
#else
/*! @brief TCHAR version dependent on if _UNICODE is defined */
# define CSimpleGlob CSimpleGlobA
# define CSimpleGlob CSimpleGlobA
#endif
#endif // INCLUDED_SimpleGlob

View File

@ -3,70 +3,70 @@
@version 3.6
@brief A cross-platform command line library which can parse almost any
of the standard command line formats in use today. It is designed
explicitly to be portable to any platform and has been tested on Windows
of the standard command line formats in use today. It is designed
explicitly to be portable to any platform and has been tested on Windows
and Linux. See CSimpleOptTempl for the class definition.
@section features FEATURES
- MIT Licence allows free use in all software (including GPL
- MIT Licence allows free use in all software (including GPL
and commercial)
- multi-platform (Windows 95/98/ME/NT/2K/XP, Linux, Unix)
- supports all lengths of option names:
<table width="60%">
<tr><td width="30%"> -
<tr><td width="30%"> -
<td>switch character only (e.g. use stdin for input)
<tr><td> -o
<tr><td> -o
<td>short (single character)
<tr><td> -long
<tr><td> -long
<td>long (multiple character, single switch character)
<tr><td> --longer
<tr><td> --longer
<td>long (multiple character, multiple switch characters)
</table>
- supports all types of arguments for options:
<table width="60%">
<tr><td width="30%"> --option
<tr><td width="30%"> --option
<td>short/long option flag (no argument)
<tr><td> --option ARG
<tr><td> --option ARG
<td>short/long option with separate required argument
<tr><td> --option=ARG
<tr><td> --option=ARG
<td>short/long option with combined required argument
<tr><td> --option[=ARG]
<tr><td> --option[=ARG]
<td>short/long option with combined optional argument
<tr><td> -oARG
<tr><td> -oARG
<td>short option with combined required argument
<tr><td> -o[ARG]
<tr><td> -o[ARG]
<td>short option with combined optional argument
</table>
- supports options with multiple or variable numbers of arguments:
<table width="60%">
<tr><td width="30%"> --multi ARG1 ARG2
<tr><td width="30%"> --multi ARG1 ARG2
<td>Multiple arguments
<tr><td> --multi N ARG-1 ARG-2 ... ARG-N
<tr><td> --multi N ARG-1 ARG-2 ... ARG-N
<td>Variable number of arguments
</table>
- supports case-insensitive option matching on short, long and/or
- supports case-insensitive option matching on short, long and/or
word arguments.
- supports options which do not use a switch character. i.e. a special
word which is construed as an option.
e.g. "foo.exe open /directory/file.txt"
- supports clumping of multiple short options (no arguments) in a string
- supports options which do not use a switch character. i.e. a special
word which is construed as an option.
e.g. "foo.exe open /directory/file.txt"
- supports clumping of multiple short options (no arguments) in a string
e.g. "foo.exe -abcdef file1" <==> "foo.exe -a -b -c -d -e -f file1"
- automatic recognition of a single slash as equivalent to a single
- automatic recognition of a single slash as equivalent to a single
hyphen on Windows, e.g. "/f FILE" is equivalent to "-f FILE".
- file arguments can appear anywhere in the argument list:
"foo.exe file1.txt -a ARG file2.txt --flag file3.txt file4.txt"
files will be returned to the application in the same order they were
files will be returned to the application in the same order they were
supplied on the command line
- short-circuit option matching: "--man" will match "--mandate"
invalid options can be handled while continuing to parse the command
invalid options can be handled while continuing to parse the command
line valid options list can be changed dynamically during command line
processing, i.e. accept different options depending on an option
processing, i.e. accept different options depending on an option
supplied earlier in the command line.
- implemented with only a single C++ header file
- optionally use no C runtime or OS functions
- char, wchar_t and Windows TCHAR in the same program
- complete working examples included
- compiles cleanly at warning level 4 (Windows/VC.NET 2003), warning
- compiles cleanly at warning level 4 (Windows/VC.NET 2003), warning
level 3 (Windows/VC6) and -Wall (Linux/gcc)
@section usage USAGE
@ -89,19 +89,19 @@
</pre>
Note that all options must start with a hyphen even if the slash will
be accepted. This is because the slash character is automatically
converted into a hyphen to test against the list of options.
For example, the following line matches both "-?" and "/?"
converted into a hyphen to test against the list of options.
For example, the following line matches both "-?" and "/?"
(on Windows).
<pre>
{ OPT_HELP, _T("-?"), SO_NONE }, // "-?"
</pre>
<li> Instantiate a CSimpleOpt object supplying argc, argv and the option
<li> Instantiate a CSimpleOpt object supplying argc, argv and the option
table
<pre>
@link CSimpleOptTempl CSimpleOpt @endlink args(argc, argv, g_rgOptions);
</pre>
<li> Process the arguments by calling Next() until it returns false.
On each call, first check for an error by calling LastError(), then
<li> Process the arguments by calling Next() until it returns false.
On each call, first check for an error by calling LastError(), then
either handle the error or process the argument.
<pre>
while (args.Next()) {
@ -142,12 +142,12 @@ ShowFiles(args.FileCount(), args.Files());
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</pre>
*/
@ -165,24 +165,24 @@ ShowFiles(args.FileCount(), args.Files());
A cross-platform library providing a simple method to parse almost any of
the standard command-line formats in use today.
See the @link SimpleOpt.h SimpleOpt @endlink documentation for full
See the @link SimpleOpt.h SimpleOpt @endlink documentation for full
details.
@section SimpleGlob SimpleGlob
A cross-platform file globbing library providing the ability to
expand wildcards in command-line arguments to a list of all matching
expand wildcards in command-line arguments to a list of all matching
files.
See the @link SimpleGlob.h SimpleGlob @endlink documentation for full
See the @link SimpleGlob.h SimpleGlob @endlink documentation for full
details.
*/
#ifndef INCLUDED_SimpleOpt
#define INCLUDED_SimpleOpt
// Default the max arguments to a fixed value. If you want to be able to
// handle any number of arguments, then predefine this to 0 and it will
// Default the max arguments to a fixed value. If you want to be able to
// handle any number of arguments, then predefine this to 0 and it will
// use an internal dynamically allocated buffer instead.
#ifdef SO_MAX_ARGS
# define SO_STATICBUF SO_MAX_ARGS
@ -196,101 +196,101 @@ ShowFiles(args.FileCount(), args.Files());
typedef enum _ESOError
{
//! No error
SO_SUCCESS = 0,
SO_SUCCESS = 0,
/*! It looks like an option (it starts with a switch character), but
/*! It looks like an option (it starts with a switch character), but
it isn't registered in the option table. */
SO_OPT_INVALID = -1,
SO_OPT_INVALID = -1,
/*! Multiple options matched the supplied option text.
/*! Multiple options matched the supplied option text.
Only returned when NOT using SO_O_EXACT. */
SO_OPT_MULTIPLE = -2,
SO_OPT_MULTIPLE = -2,
/*! Option doesn't take an argument, but a combined argument was
/*! Option doesn't take an argument, but a combined argument was
supplied. */
SO_ARG_INVALID = -3,
SO_ARG_INVALID = -3,
/*! SO_REQ_CMB style-argument was supplied to a SO_REQ_SEP option
Only returned when using SO_O_PEDANTIC. */
SO_ARG_INVALID_TYPE = -4,
SO_ARG_INVALID_TYPE = -4,
//! Required argument was not supplied
SO_ARG_MISSING = -5,
SO_ARG_MISSING = -5,
/*! Option argument looks like another option.
/*! Option argument looks like another option.
Only returned when NOT using SO_O_NOERR. */
SO_ARG_INVALID_DATA = -6
SO_ARG_INVALID_DATA = -6
} ESOError;
//! Option flags
enum _ESOFlags
{
/*! Disallow partial matching of option names */
SO_O_EXACT = 0x0001,
SO_O_EXACT = 0x0001,
/*! Disallow use of slash as an option marker on Windows.
/*! Disallow use of slash as an option marker on Windows.
Un*x only ever recognizes a hyphen. */
SO_O_NOSLASH = 0x0002,
SO_O_NOSLASH = 0x0002,
/*! Permit arguments on single letter options with no equals sign.
/*! Permit arguments on single letter options with no equals sign.
e.g. -oARG or -o[ARG] */
SO_O_SHORTARG = 0x0004,
SO_O_SHORTARG = 0x0004,
/*! Permit single character options to be clumped into a single
/*! Permit single character options to be clumped into a single
option string. e.g. "-a -b -c" <==> "-abc" */
SO_O_CLUMP = 0x0008,
SO_O_CLUMP = 0x0008,
/*! Process the entire argv array for options, including the
/*! Process the entire argv array for options, including the
argv[0] entry. */
SO_O_USEALL = 0x0010,
SO_O_USEALL = 0x0010,
/*! Do not generate an error for invalid options. errors for missing
arguments will still be generated. invalid options will be
treated as files. invalid options in clumps will be silently
/*! Do not generate an error for invalid options. errors for missing
arguments will still be generated. invalid options will be
treated as files. invalid options in clumps will be silently
ignored. */
SO_O_NOERR = 0x0020,
SO_O_NOERR = 0x0020,
/*! Validate argument type pedantically. Return an error when a
separated argument "-opt arg" is supplied by the user as a
combined argument "-opt=arg". By default this is not considered
/*! Validate argument type pedantically. Return an error when a
separated argument "-opt arg" is supplied by the user as a
combined argument "-opt=arg". By default this is not considered
an error. */
SO_O_PEDANTIC = 0x0040,
SO_O_PEDANTIC = 0x0040,
/*! Case-insensitive comparisons for short arguments */
SO_O_ICASE_SHORT = 0x0100,
SO_O_ICASE_SHORT = 0x0100,
/*! Case-insensitive comparisons for long arguments */
SO_O_ICASE_LONG = 0x0200,
SO_O_ICASE_LONG = 0x0200,
/*! Case-insensitive comparisons for word arguments
/*! Case-insensitive comparisons for word arguments
i.e. arguments without any hyphens at the start. */
SO_O_ICASE_WORD = 0x0400,
SO_O_ICASE_WORD = 0x0400,
/*! Case-insensitive comparisons for all arg types */
SO_O_ICASE = 0x0700
SO_O_ICASE = 0x0700
};
/*! Types of arguments that options may have. Note that some of the _ESOFlags
are not compatible with all argument types. SO_O_SHORTARG requires that
relevant options use either SO_REQ_CMB or SO_OPT. SO_O_CLUMP requires
relevant options use either SO_REQ_CMB or SO_OPT. SO_O_CLUMP requires
that relevant options use only SO_NONE.
*/
typedef enum _ESOArgType {
/*! No argument. Just the option flags.
e.g. -o --opt */
SO_NONE,
SO_NONE,
/*! Required separate argument.
/*! Required separate argument.
e.g. -o ARG --opt ARG */
SO_REQ_SEP,
SO_REQ_SEP,
/*! Required combined argument.
/*! Required combined argument.
e.g. -oARG -o=ARG --opt=ARG */
SO_REQ_CMB,
SO_REQ_CMB,
/*! Optional combined argument.
/*! Optional combined argument.
e.g. -o[ARG] -o[=ARG] --opt[=ARG] */
SO_OPT,
SO_OPT,
/*! Multiple separate arguments. The actual number of arguments is
determined programatically at the time the argument is processed.
@ -299,7 +299,7 @@ typedef enum _ESOArgType {
} ESOArgType;
//! this option definition must be the last entry in the table
#define SO_END_OF_OPTIONS { -1, NULL, SO_NONE }
#define SO_END_OF_OPTIONS { -1, nullptr, SO_NONE }
#ifdef _DEBUG
# ifdef _MSC_VER
@ -328,7 +328,7 @@ public:
//SOption()//Added for compatibility with fractal flames.
//{
// nId = 0;
// pszArg = NULL;
// pszArg = nullptr;
// nArgType = SO_NONE;
//}
@ -340,34 +340,34 @@ public:
//}
/*! ID to return for this flag. Optional but must be >= 0 */
int nId;
int nId;
/*! arg string to search for, e.g. "open", "-", "-f", "--file"
/*! arg string to search for, e.g. "open", "-", "-f", "--file"
Note that on Windows the slash option marker will be converted
to a hyphen so that "-f" will also match "/f". */
const SOCHAR * pszArg;
/*! type of argument accepted by this option */
ESOArgType nArgType;
ESOArgType nArgType;
};
/*! @brief Initialize the class. Init() must be called later. */
CSimpleOptTempl()
: m_rgShuffleBuf(NULL)
{
Init(0, NULL, NULL, 0);
CSimpleOptTempl()
: m_rgShuffleBuf(nullptr)
{
Init(0, nullptr, nullptr, 0);
}
/*! @brief Initialize the class in preparation for use. */
CSimpleOptTempl(
int argc,
SOCHAR * argv[],
const SOption * a_rgOptions,
int argc,
SOCHAR * argv[],
const SOption * a_rgOptions,
int a_nFlags = 0
)
: m_rgShuffleBuf(NULL)
{
Init(argc, argv, a_rgOptions, a_nFlags);
)
: m_rgShuffleBuf(nullptr)
{
Init(argc, argv, a_rgOptions, a_nFlags);
}
#ifndef SO_MAX_ARGS
@ -389,17 +389,17 @@ public:
@param a_argc Argument array size
@param a_argv Argument array
@param a_rgOptions Valid option array
@param a_nFlags Optional flags to modify the processing of
@param a_nFlags Optional flags to modify the processing of
the arguments
@return true Successful
@return true Successful
@return false if SO_MAX_ARGC > 0: Too many arguments
if SO_MAX_ARGC == 0: Memory allocation failure
*/
bool Init(
int a_argc,
SOCHAR * a_argv[],
const SOption * a_rgOptions,
int a_argc,
SOCHAR * a_argv[],
const SOption * a_rgOptions,
int a_nFlags = 0
);
@ -407,8 +407,8 @@ public:
@param a_rgOptions Valid option array
*/
inline void SetOptions(const SOption * a_rgOptions) {
m_rgOptions = a_rgOptions;
inline void SetOptions(const SOption * a_rgOptions) {
m_rgOptions = a_rgOptions;
}
/*! @brief Change the current flags during option parsing.
@ -421,16 +421,16 @@ public:
inline void SetFlags(int a_nFlags) { m_nFlags = a_nFlags; }
/*! @brief Query if a particular flag is set */
inline bool HasFlag(int a_nFlag) const {
return (m_nFlags & a_nFlag) == a_nFlag;
inline bool HasFlag(int a_nFlag) const {
return (m_nFlags & a_nFlag) == a_nFlag;
}
/*! @brief Advance to the next option if available.
When all options have been processed it will return false. When true
has been returned, you must check for an invalid or unrecognized
option using the LastError() method. This will be return an error
value other than SO_SUCCESS on an error. All standard data
option using the LastError() method. This will be return an error
value other than SO_SUCCESS on an error. All standard data
(e.g. OptionText(), OptionArg(), OptionId(), etc) will be available
depending on the error.
@ -450,7 +450,7 @@ public:
/*! @brief Return the last error that occurred.
This function must always be called before processing the current
This function must always be called before processing the current
option. This function is available only when Next() has returned true.
*/
inline ESOError LastError() const { return m_nLastError; }
@ -462,7 +462,7 @@ public:
*/
inline int OptionId() const { return m_nOptionId; }
/*! @brief Return the pszArg from the options array for the current
/*! @brief Return the pszArg from the options array for the current
option.
This function is available only when Next() has returned true.
@ -471,7 +471,7 @@ public:
/*! @brief Return the argument for the current option where one exists.
If there is no argument for the option, this will return NULL.
If there is no argument for the option, this will return nullptr.
This function is available only when Next() has returned true.
*/
inline SOCHAR * OptionArg() const { return m_pszOptionArg; }
@ -483,7 +483,7 @@ public:
each time returning the desired number of arguments. Previously
returned argument pointers are remain valid.
If an error occurs during processing, NULL will be returned and
If an error occurs during processing, nullptr will be returned and
the error will be available via LastError().
@param n Number of arguments to return.
@ -523,7 +523,7 @@ private:
// Find the '=' character within a string.
inline SOCHAR * FindEquals(SOCHAR *s) const {
while (*s && *s != (SOCHAR)'=') ++s;
return *s ? s : NULL;
return *s ? s : nullptr;
}
bool IsEqual(SOCHAR a_cLeft, SOCHAR a_cRight, int a_nArgType) const;
@ -537,11 +537,11 @@ private:
}
private:
const SOption * m_rgOptions; //!< pointer to options table
int m_nFlags; //!< flags
const SOption * m_rgOptions; //!< pointer to options table
int m_nFlags; //!< flags
int m_nOptionIdx; //!< current argv option index
int m_nOptionId; //!< id of current option (-1 = invalid)
int m_nNextOption; //!< index of next option
int m_nNextOption; //!< index of next option
int m_nLastArg; //!< last argument, after this are files
int m_argc; //!< argc to process
SOCHAR ** m_argv; //!< argv
@ -573,13 +573,13 @@ CSimpleOptTempl<SOCHAR>::Init(
m_nLastError = SO_SUCCESS;
m_nOptionIdx = 0;
m_nOptionId = -1;
m_pszOptionText = NULL;
m_pszOptionArg = NULL;
m_pszOptionText = nullptr;
m_pszOptionArg = nullptr;
m_nNextOption = (a_nFlags & SO_O_USEALL) ? 0 : 1;
m_szShort[0] = (SOCHAR)'-';
m_szShort[2] = (SOCHAR)'\0';
m_nFlags = a_nFlags;
m_pszClump = NULL;
m_pszClump = nullptr;
#ifdef SO_MAX_ARGS
if (m_argc > SO_MAX_ARGS) {
@ -627,13 +627,13 @@ CSimpleOptTempl<SOCHAR>::Next()
}
}
SO_ASSERT(!m_pszClump || !*m_pszClump);
m_pszClump = NULL;
m_pszClump = nullptr;
// init for the next option
m_nOptionIdx = m_nNextOption;
m_nOptionId = -1;
m_pszOptionText = NULL;
m_pszOptionArg = NULL;
m_pszOptionText = nullptr;
m_pszOptionArg = nullptr;
m_nLastError = SO_SUCCESS;
// find the next option
@ -642,7 +642,7 @@ CSimpleOptTempl<SOCHAR>::Next()
int nOptIdx = m_nOptionIdx;
while (nTableIdx < 0 && nOptIdx < m_nLastArg) {
SOCHAR * pszArg = m_argv[nOptIdx];
m_pszOptionArg = NULL;
m_pszOptionArg = nullptr;
// find this option in the options table
cFirst = PrepareArg(pszArg);
@ -698,7 +698,7 @@ CSimpleOptTempl<SOCHAR>::Next()
m_pszOptionText = pszArg;
break;
}
pszArg[0] = cFirst;
++nOptIdx;
if (m_pszOptionArg) {
@ -736,7 +736,7 @@ CSimpleOptTempl<SOCHAR>::Next()
case SO_REQ_SEP:
if (m_pszOptionArg) {
// they wanted separate args, but we got a combined one,
// they wanted separate args, but we got a combined one,
// unless we are pedantic, just accept it.
if (HasFlag(SO_O_PEDANTIC)) {
m_nLastError = SO_ARG_INVALID_TYPE;
@ -759,6 +759,8 @@ CSimpleOptTempl<SOCHAR>::Next()
// nothing to do. Caller must now check for valid arguments
// using GetMultiArg()
break;
default:
break;
}
}
@ -769,9 +771,9 @@ CSimpleOptTempl<SOCHAR>::Next()
// we need to return the separate arg if required, just re-use the
// multi-arg code because it all does the same thing
if ( nArgType == SO_REQ_SEP
&& !m_pszOptionArg
&& m_nLastError == SO_SUCCESS)
if ( nArgType == SO_REQ_SEP
&& !m_pszOptionArg
&& m_nLastError == SO_SUCCESS)
{
SOCHAR ** ppArgs = MultiArg(1);
if (ppArgs) {
@ -821,8 +823,8 @@ CSimpleOptTempl<SOCHAR>::NextClumped()
// prepare for the next clumped option
m_szShort[1] = *m_pszClump++;
m_nOptionId = -1;
m_pszOptionText = NULL;
m_pszOptionArg = NULL;
m_pszOptionText = nullptr;
m_pszOptionArg = nullptr;
m_nLastError = SO_SUCCESS;
// lookup this option, ensure that we are using exact matching
@ -950,7 +952,7 @@ CSimpleOptTempl<SOCHAR>::CalcMatch(
// match and skip leading hyphens
while (*a_pszSource == (SOCHAR)'-' && *a_pszSource == *a_pszTest) {
++a_pszSource;
++a_pszSource;
++a_pszTest;
}
if (*a_pszSource == (SOCHAR)'-' || *a_pszTest == (SOCHAR)'-') {
@ -960,8 +962,8 @@ CSimpleOptTempl<SOCHAR>::CalcMatch(
// find matching number of characters in the strings
int nLen = 0;
while (*a_pszSource && IsEqual(*a_pszSource, *a_pszTest, nArgType)) {
++a_pszSource;
++a_pszTest;
++a_pszSource;
++a_pszTest;
++nLen;
}
@ -1014,7 +1016,7 @@ CSimpleOptTempl<SOCHAR>::MultiArg(
// ensure we have enough arguments
if (m_nNextOption + a_nCount > m_nLastArg) {
m_nLastError = SO_ARG_MISSING;
return NULL;
return nullptr;
}
// our argument array
@ -1028,7 +1030,7 @@ CSimpleOptTempl<SOCHAR>::MultiArg(
if (rgpszArg[n][0] == (SOCHAR)'-') {
rgpszArg[n][0] = ch;
m_nLastError = SO_ARG_INVALID_DATA;
return NULL;
return nullptr;
}
rgpszArg[n][0] = ch;
}
@ -1045,18 +1047,18 @@ CSimpleOptTempl<SOCHAR>::MultiArg(
// ---------------------------------------------------------------------------
/*! @brief ASCII/MBCS version of CSimpleOpt */
typedef CSimpleOptTempl<char> CSimpleOptA;
typedef CSimpleOptTempl<char> CSimpleOptA;
/*! @brief wchar_t version of CSimpleOpt */
typedef CSimpleOptTempl<wchar_t> CSimpleOptW;
typedef CSimpleOptTempl<wchar_t> CSimpleOptW;
#if defined(_UNICODE)
/*! @brief TCHAR version dependent on if _UNICODE is defined */
# define CSimpleOpt CSimpleOptW
# define CSimpleOpt CSimpleOptW
# define CharT wchar_t
#else
/*! @brief TCHAR version dependent on if _UNICODE is defined */
# define CSimpleOpt CSimpleOptA
# define CSimpleOpt CSimpleOptA
# define CharT char
#endif