2017-10-03 03:28:02 +03:00
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
// CommandLineHelpers.h
|
|
|
|
//
|
|
|
|
// Advanced Technology Group (ATG)
|
|
|
|
// Copyright (C) Microsoft Corporation. All rights reserved.
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace ATG
|
|
|
|
{
|
|
|
|
struct SValue
|
|
|
|
{
|
|
|
|
const wchar_t *name;
|
|
|
|
unsigned value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<size_t _SIZE>
|
|
|
|
inline bool LookupByName(const wchar_t *name, const SValue(&table)[_SIZE], unsigned &result)
|
|
|
|
{
|
2019-07-13 08:41:26 +03:00
|
|
|
for (size_t i = 0; i < _SIZE; ++i)
|
2017-10-03 03:28:02 +03:00
|
|
|
{
|
|
|
|
if (!_wcsicmp(name, table[i].name))
|
|
|
|
{
|
|
|
|
result = table[i].value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<size_t _SIZE>
|
|
|
|
inline const wchar_t *LookupByValue(unsigned value, const SValue(&table)[_SIZE])
|
|
|
|
{
|
2019-07-13 08:41:26 +03:00
|
|
|
for (size_t i = 0; i < _SIZE; ++i)
|
2017-10-03 03:28:02 +03:00
|
|
|
{
|
|
|
|
if (value == table[i].value)
|
|
|
|
return table[i].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return L"";
|
|
|
|
}
|
|
|
|
|
|
|
|
template<size_t _SIZE>
|
|
|
|
inline bool ParseTableValue(unsigned option, const wchar_t *name, const SValue(&table)[_SIZE], unsigned &result)
|
|
|
|
{
|
|
|
|
const wchar_t pleaseUseMsg[] = L"Please use one of the following: ";
|
|
|
|
|
|
|
|
if (!LookupByName(name, table, result))
|
|
|
|
{
|
2019-04-27 09:40:17 +03:00
|
|
|
wprintf(L"Invalid value specified with -%ls (%ls)\n", LookupByValue(option, ::g_Options), name);
|
2017-10-03 03:28:02 +03:00
|
|
|
wprintf(pleaseUseMsg);
|
|
|
|
PrintTable(_countof(pleaseUseMsg) - 1, table);
|
|
|
|
wprintf(L"\n\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<size_t _SIZE>
|
|
|
|
inline void PrintTable(size_t indent, const SValue(&table)[_SIZE])
|
|
|
|
{
|
|
|
|
size_t idt = indent;
|
2019-07-13 08:41:26 +03:00
|
|
|
for (size_t i = 0; i < _SIZE; ++i)
|
2017-10-03 03:28:02 +03:00
|
|
|
{
|
|
|
|
size_t cchName = wcslen(table[i].name);
|
|
|
|
|
|
|
|
if (idt + cchName + 2 >= 80)
|
|
|
|
{
|
|
|
|
wprintf(L"\n");
|
|
|
|
for (idt = 0; idt < indent; ++idt) wprintf(L" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
wprintf(L"%ls ", table[i].name);
|
|
|
|
idt += cchName + 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
wprintf(L"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
const wchar_t *ConsumeDigits(const wchar_t *value);
|
|
|
|
|
|
|
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
|
|
|
typedef struct tagWCRANGE
|
|
|
|
{
|
|
|
|
WCHAR wcLow;
|
|
|
|
USHORT cGlyphs;
|
|
|
|
} WCRANGE, *PWCRANGE, FAR *LPWCRANGE;
|
|
|
|
#endif
|
|
|
|
WCRANGE MakeRange(wchar_t c0, wchar_t c1);
|
|
|
|
|
|
|
|
bool ParseCharacterRegion(const wchar_t *rangeSpec, std::vector<WCRANGE> ®ions);
|
|
|
|
|
|
|
|
} // namespace ATG
|