InfoSink.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
  3. // All rights reserved.
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions
  7. // are met:
  8. //
  9. // Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. //
  12. // Redistributions in binary form must reproduce the above
  13. // copyright notice, this list of conditions and the following
  14. // disclaimer in the documentation and/or other materials provided
  15. // with the distribution.
  16. //
  17. // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
  18. // contributors may be used to endorse or promote products derived
  19. // from this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. // POSSIBILITY OF SUCH DAMAGE.
  33. //
  34. #include "../Include/InfoSink.h"
  35. #include <cstring>
  36. namespace glslang {
  37. void TInfoSinkBase::append(const char* s)
  38. {
  39. if (outputStream & EString) {
  40. if (s == nullptr)
  41. sink.append("(null)");
  42. else {
  43. checkMem(strlen(s));
  44. sink.append(s);
  45. }
  46. }
  47. //#ifdef _WIN32
  48. // if (outputStream & EDebugger)
  49. // OutputDebugString(s);
  50. //#endif
  51. if (outputStream & EStdOut)
  52. fprintf(stdout, "%s", s);
  53. }
  54. void TInfoSinkBase::append(int count, char c)
  55. {
  56. if (outputStream & EString) {
  57. checkMem(count);
  58. sink.append(count, c);
  59. }
  60. //#ifdef _WIN32
  61. // if (outputStream & EDebugger) {
  62. // char str[2];
  63. // str[0] = c;
  64. // str[1] = '\0';
  65. // OutputDebugString(str);
  66. // }
  67. //#endif
  68. if (outputStream & EStdOut)
  69. fprintf(stdout, "%c", c);
  70. }
  71. void TInfoSinkBase::append(const TPersistString& t)
  72. {
  73. if (outputStream & EString) {
  74. checkMem(t.size());
  75. sink.append(t);
  76. }
  77. //#ifdef _WIN32
  78. // if (outputStream & EDebugger)
  79. // OutputDebugString(t.c_str());
  80. //#endif
  81. if (outputStream & EStdOut)
  82. fprintf(stdout, "%s", t.c_str());
  83. }
  84. void TInfoSinkBase::append(const TString& t)
  85. {
  86. if (outputStream & EString) {
  87. checkMem(t.size());
  88. sink.append(t.c_str());
  89. }
  90. //#ifdef _WIN32
  91. // if (outputStream & EDebugger)
  92. // OutputDebugString(t.c_str());
  93. //#endif
  94. if (outputStream & EStdOut)
  95. fprintf(stdout, "%s", t.c_str());
  96. }
  97. } // end namespace glslang