Team Fortress 2 Source Code as on 22/4/2020
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.

115 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #if 0
  9. //=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
  10. //
  11. // The copyright to the contents herein is the property of Valve, L.L.C.
  12. // The contents may be used and/or copied only with the written permission of
  13. // Valve, L.L.C., or in accordance with the terms and conditions stipulated in
  14. // the agreement/contract under which the contents have been supplied.
  15. //
  16. // Purpose: Implementation of CLogEvent's C++ IO Stream stuff. this isn't used currently
  17. //
  18. // $Workfile: $
  19. // $Date: $
  20. //
  21. //------------------------------------------------------------------------------------------------------
  22. // $Log: $
  23. //
  24. // $NoKeywords: $
  25. //=============================================================================
  26. #include "LogEvent.h"
  27. #include <string.h>
  28. //none of this is used. I opted for the FILE* implementation instead, this one was giving some weird results, and not working right.
  29. CLogEvent::CLogEvent(istream& is)
  30. :m_EventCode('\0'),m_EventTime(0),m_Valid(false),m_Next(NULL),m_StrippedText(NULL),m_EventType(INVALID)
  31. {
  32. readEvent(is);
  33. }
  34. void CLogEvent::print(ostream& os)
  35. {
  36. os << "(" <<m_EventTime<<") Event Type: "<<TypeNames[m_EventType]<<endl;
  37. os << "Args: ";
  38. for(int i=0;i<m_args.size();i++)
  39. cout<< "\t"<<m_args[i]->getStringValue()<<endl;
  40. }
  41. void CLogEvent::readEvent(istream& is)
  42. {
  43. readEventCode(is);
  44. readEventTime(is);
  45. readEventMessage(is);
  46. determineType();
  47. if(is)
  48. m_Valid=true;
  49. else
  50. m_Valid=false;
  51. }
  52. //note this function assumes you're at the start of a line
  53. void CLogEvent::readEventCode(istream& is)
  54. {
  55. is>>m_EventCode;
  56. }
  57. void CLogEvent::readEventMessage(istream& is)
  58. {
  59. char temp[512]={0,0,0,0};
  60. is.getline(temp,512,'\n');
  61. m_EventMessage=new char[strlen(temp)];
  62. strcpy(m_EventMessage,temp);
  63. }
  64. void CLogEvent::readEventTime(istream& is)
  65. {
  66. int month,day,year;
  67. int hour,minute,second;
  68. // fscanf(f," %i/%i/%i - %i:%i:%i: ",&month,&day,&year,&hour,&minute,&second);
  69. is >> month;
  70. is.ignore(); //'/'
  71. is >> day;
  72. is.ignore(); //'/'
  73. is >> year;
  74. is.ignore(3); //' - '
  75. is >> hour;
  76. is.ignore(); //':'
  77. is >> minute;
  78. is.ignore(); //':'
  79. is >> second;
  80. is.ignore(); //':'
  81. tm t;
  82. t.tm_isdst=0;
  83. t.tm_hour=hour;
  84. t.tm_mday=day;
  85. t.tm_min=minute;
  86. t.tm_sec=second;
  87. t.tm_year=year-1900; //note no y2k prob here, so says the CRT manual
  88. //this allows values greater than 99, but it
  89. //just wants the input with 1900 subtracted.
  90. t.tm_mon=month;
  91. m_EventTime=mktime(&t);
  92. }
  93. #endif