Files
Open-Shell-Menu/ClassicStartSrc/ClassicStartLib/StringUtils.h
Xenhat 0adcd693e4 Some branding and licensing work (#22)
* Fix stdafx include

* Fix basic handling of "Games" folder on Windows10 RS4 (#10)
This does the following:
- Sets the default state to hidden
- Skips the Games folder when searching

This does not:
- Hide the dead menu entry.

I do not currently know how to actively change the user preference setting to forcefully hide it.

* Add basic Visual Studio gitignore

* Add specific entries to gitignore

* Do not set default menu to Win7 on RS4 (#10)

* Rename "PC Settings" to "Settings" (#12)

* Create distinction between modern and legacy settings in search results

* Add more build artifacts to gitignore

* Add default paths for toolset and build all languages

* Fix several memsize, memtype and nullpointer issues

* create trunk branch containing all changes

* set fallback and next version to 4.3.2, set resource fallback value to allow loading in IDE

* add generated en-US.dll to gitignore

* Don't echo script contents, add disabled "git clean -dfx" to build fresh

* Initial re-branding work (#21)

* Create copy of __MakeFinal to build all languages (Use this file when releasing new versions)

* Move the registry key IvoSoft->Passionate-Coder (#21)

* Change company/mfg name IvoSoft->Passionate-Coder (#21)

* Update some leftover copyright dates (#21)

* Fix accidental copy-paste breaking MakeFinal scripts

* Fix invalid company name for Wix and change registry keys to match the new string (#21)

* Update more copyright and legal text (#21)

* Update RTF files format (Wordpad generated those) (#21)

* update license text in RTF files (#21)
We lost the blue link text in the installer page. Will have to manually re-color all the links later.
2018-06-25 01:42:52 -04:00

114 lines
4.9 KiB
C++

// Classic Shell (c) 2009-2017, Ivo Beltchev
// Classic Start (c) 2017-2018, The Passionate-Coder Team
// Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author
// StringUtils is also available under the CPOL license as part of the FormatString article
// on CodeProject: http://www.codeproject.com/KB/string/FormatString.aspx
#ifndef _STRINGUTILS_H
#define _STRINGUTILS_H
// StringUtils provides secure implementations of common string functions.
// All strings are guaranteed to be zero-terminated and to not contain partial
// double-byte characters or partial surrogate pairs.
// It also provides char and wchar_t overrides of the same functions.
//
///////////////////////////////////////////////////////////////////////////////
// Configuration of the string functions
// If defined, enables the use of WideCharToMultiByte and MultiByteToWideChar
// If not defined, wcstombs and mbstowcs are used instead. they always use the default code page
// and don't support surrogate pairs
#define STR_USE_WIN32_CONV
// If defined, enables the use of Windows localization functions - GetNumberFormat, GetTimeFormat, etc
// If not defined, then the numbers, currency, time and date use fixed formats
#define STR_USE_WIN32_NLS
// If defined, enables support for SYSTEMTIME, FILETIME and DATE
// If not defined, only time_t is supported as a time format
#define STR_USE_WIN32_TIME
// If defined, enables the use of IsDBCSLeadByte to support DBCS code pages
// If not defined, isleadbyte is used instead
#define STR_USE_WIN32_DBCS
// enables support for STL strings and streams
//#define STR_USE_STL
#include <string.h>
#include <stdarg.h>
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif
#ifdef STR_USE_STL
#include <string>
#endif
// _countof: compute the number of elements in a statically-allocated array
// VS2005 supports this, but earlier versions do not
#ifndef _countof
#define _countof(x) (sizeof(x)/sizeof((x)[0]))
#endif
// Returns 1 if the ANSI code page is single-byte, or 2 if it is double-byte (DBCS)
int GetMaxCharSize( void );
// Returns the length of a string
inline int Strlen( const char *str ) { return (int)strlen(str); }
inline int Strlen( const wchar_t *str ) { return (int)wcslen(str); }
// Copies src to dst. size is the size of dst in characters, including the terminating 0.
// Returns the number of characters copied, excluding the terminating 0.
// The return value is <=size-1. If size is 0, returns 0 and does nothing.
// The result in dst is always 0 terminated.
int Strcpy( char *dst, int size, const char *src );
int Strcpy( wchar_t *dst, int size, const wchar_t *src );
// Copies src to dst. size is the size of dst in characters, including the terminating 0.
// Copies up to len characters and always appends terminating 0.
int Strncpy( char *dst, int size, const char *src, int len );
int Strncpy( wchar_t *dst, int size, const wchar_t *src, int len );
// Appends src to dst. size is the size of dst in bytes, including the terminating 0.
// Returns the number of characters copied, excluding the terminating 0.
// The return value is <=size-1-strlen(dst). If size>=strlen(dst), returns 0 and does nothing.
// The result in dst is always 0 terminated.
int Strcat( char *dst, int size, const char *src );
int Strcat( wchar_t *dst, int size, const wchar_t *src );
// Writes formatted string to dst. size is the size of dst in characters, including the terminating 0.
// Returns the number of characters written, excluding the terminating 0.
// The return value is <=size-1. If size is 0, returns 0 and does nothing.
// The result in dst is always 0 terminated.
int _cdecl Sprintf( char *dst, int size, const char *format, ... );
int _cdecl Sprintf( wchar_t *dst, int size, const wchar_t *format, ... );
int _cdecl Vsprintf( char *dst, int size, const char *format, va_list args );
int _cdecl Vsprintf( wchar_t *dst, int size, const wchar_t *format, va_list args );
// Outputs a formatted debug string
void Trace( const char *format, ... );
void Trace( const wchar_t *format, ... );
// Converts between multi-byte and wide characters. size is the size of dst in characters, including the
// terminating 0.
// Returns the number of characters copied, excluding the terminating 0.
// The return value is <=size-1. If size is 0, returns 0 and does nothing.
// The result in dst is always 0 terminated.
// If dst is NULL the size is ignored and the function just returns the number of characters (not counting the 0)
#ifdef STR_USE_WIN32_CONV
int MbsToWcs( wchar_t *dst, int size, const char *src, int codePage=CP_ACP );
int WcsToMbs( char *dst, int size, const wchar_t *src, int codePage=CP_ACP );
#else
int MbsToWcs( wchar_t *dst, int size, const char *src );
int WcsToMbs( char *dst, int size, const wchar_t *src );
#endif
const char *GetToken( const char *text, char *token, int size, const char *separators );
const wchar_t *GetToken( const wchar_t *text, wchar_t *token, int size, const wchar_t *separators );
#endif