ratl.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #if !defined(RATL_COMMON_INC)
  2. #include "ratl_common.h"
  3. #endif
  4. #if 0
  5. #include "array_vs.h"
  6. #include "bits_vs.h"
  7. #include "heap_vs.h"
  8. #include "pool_vs.h"
  9. #include "list_vs.h"
  10. #include "queue_vs.h"
  11. #include "stack_vs.h"
  12. #include "string_vs.h"
  13. #include "vector_vs.h"
  14. #include "handle_pool_vs.h"
  15. #include "hash_pool_vs.h"
  16. #include "map_vs.h"
  17. #include "scheduler_vs.h"
  18. #endif
  19. #if !defined(CTYPE_H_INC)
  20. #include <ctype.h>
  21. #define CTYPE_H_INC
  22. #endif
  23. #if !defined(STDARG_H_INC)
  24. #include <stdarg.h>
  25. #define STDARG_H_INC
  26. #endif
  27. #if !defined(STDIO_H_INC)
  28. #include <stdio.h>
  29. #define STDIO_H_INC
  30. #endif
  31. #if !defined(RUFL_HFILE_INC)
  32. #include "..\Rufl\hfile.h"
  33. #endif
  34. void* ratl::ratl_base::OutputPrint = 0;
  35. namespace ratl
  36. {
  37. #ifdef _DEBUG
  38. int HandleSaltValue=1027; //this is used in debug for global uniqueness of handles
  39. int FoolTheOptimizer=5; //this is used to make sure certain things aren't optimized out
  40. #endif
  41. #ifndef _XBOX
  42. void ratl_base::save(hfile& file)
  43. {
  44. }
  45. void ratl_base::load(hfile& file)
  46. {
  47. }
  48. #endif
  49. ////////////////////////////////////////////////////////////////////////////////////////
  50. // A Profile Print Function
  51. ////////////////////////////////////////////////////////////////////////////////////////
  52. #if !defined(FINAL_BUILD)
  53. void ratl_base::ProfilePrint(const char * format, ...)
  54. {
  55. static char string[2][1024]; // in case this is called by nested functions
  56. static int index = 0;
  57. static char nFormat[300];
  58. char* buf;
  59. // Tack On The Standard Format Around The Given Format
  60. //-----------------------------------------------------
  61. sprintf(nFormat, "[PROFILE] %s\n", format);
  62. // Resolve Remaining Elipsis Parameters Into Newly Formated String
  63. //-----------------------------------------------------------------
  64. buf = string[index & 1];
  65. index++;
  66. va_list argptr;
  67. va_start (argptr, format);
  68. vsprintf (buf, nFormat, argptr);
  69. va_end (argptr);
  70. // Print It To Debug Output Console
  71. //----------------------------------
  72. if (OutputPrint!=0)
  73. {
  74. void (*OutputPrintFcn)(const char* text) = (void (__cdecl*)(const char*))OutputPrint;
  75. OutputPrintFcn(buf);
  76. }
  77. }
  78. #else
  79. void ratl_base::ProfilePrint(const char * format, ...)
  80. {
  81. }
  82. #endif
  83. namespace str
  84. {
  85. void to_upper(char *dest)
  86. {
  87. for (int i=0; i<len(dest);i++)
  88. {
  89. dest[i] = (char)(toupper(dest[i]));
  90. }
  91. }
  92. void to_lower(char *dest)
  93. {
  94. for (int i=0; i<len(dest);i++)
  95. {
  96. dest[i] = (char)(tolower(dest[i]));
  97. }
  98. }
  99. void printf(char *dest,const char *formatS, ...)
  100. {
  101. va_list argptr;
  102. va_start (argptr, formatS);
  103. vsprintf (dest, formatS,argptr);
  104. va_end (argptr);
  105. }
  106. }
  107. }