Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: dll-agnostic routines (no dll dependencies here)
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. // Author: Matthew D. Campbell ([email protected]), 2003
  8. #ifndef SHARED_UTIL_H
  9. #define SHARED_UTIL_H
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //--------------------------------------------------------------------------------------------------------
  13. /**
  14. * Returns the token parsed by SharedParse()
  15. */
  16. char *SharedGetToken( void );
  17. //--------------------------------------------------------------------------------------------------------
  18. /**
  19. * Sets the character used to delimit quoted strings. Default is '\"'. Be sure to set it back when done.
  20. */
  21. void SharedSetQuoteChar( char c );
  22. //--------------------------------------------------------------------------------------------------------
  23. /**
  24. * Parse a token out of a string
  25. */
  26. const char *SharedParse( const char *data );
  27. //--------------------------------------------------------------------------------------------------------
  28. /**
  29. * Returns true if additional data is waiting to be processed on this line
  30. */
  31. bool SharedTokenWaiting( const char *buffer );
  32. //--------------------------------------------------------------------------------------------------------
  33. /**
  34. * Simple utility function to allocate memory and duplicate a string
  35. */
  36. /*
  37. inline char *CloneString( const char *str )
  38. {
  39. char *cloneStr = new char [ strlen(str)+1 ];
  40. strcpy( cloneStr, str );
  41. return cloneStr;
  42. }*/
  43. //--------------------------------------------------------------------------------------------------------
  44. /**
  45. * Simple utility function to allocate memory and duplicate a wide string
  46. */
  47. #ifdef _WIN32
  48. extern inline wchar_t *CloneWString( const wchar_t *str );
  49. // {
  50. // wchar_t *cloneStr = new wchar_t [ wcslen(str)+1 ];
  51. // wcscpy( cloneStr, str );
  52. // return cloneStr;
  53. // }
  54. #endif
  55. //--------------------------------------------------------------------------------------------------------------
  56. /**
  57. * snprintf-alike that allows multiple prints into a buffer
  58. */
  59. char * BufPrintf(char *buf, int& len, PRINTF_FORMAT_STRING const char *fmt, ...);
  60. //--------------------------------------------------------------------------------------------------------------
  61. /**
  62. * wide char version of BufPrintf
  63. */
  64. #ifdef _WIN32
  65. wchar_t * BufWPrintf(wchar_t *buf, int& len, PRINTF_FORMAT_STRING const wchar_t *fmt, ...);
  66. #endif
  67. //--------------------------------------------------------------------------------------------------------------
  68. /**
  69. * convenience function that prints an int into a static wchar_t*
  70. */
  71. #ifdef _WIN32
  72. const wchar_t * NumAsWString( int val );
  73. #endif
  74. // dgoodenough - PS3 needs this guy as well.
  75. // PS3_BUILDFIX
  76. #ifdef _PS3
  77. const wchar_t * NumAsWString( int val );
  78. #endif
  79. //--------------------------------------------------------------------------------------------------------------
  80. /**
  81. * convenience function that prints an int into a static char*
  82. */
  83. const char * NumAsString( int val );
  84. //--------------------------------------------------------------------------------------------------------------
  85. /**
  86. * convenience function that composes a string into a static char*
  87. */
  88. char * SharedVarArgs(PRINTF_FORMAT_STRING const char *format, ...);
  89. #include "tier0/memdbgoff.h"
  90. #endif // SHARED_UTIL_H