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.

120 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VCPROJCONVERT_H
  8. #define VCPROJCONVERT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "stdafx.h"
  13. #include "utlvector.h"
  14. #include "utlsymbol.h"
  15. #ifdef _WIN32
  16. #include "msxml2.h"
  17. #elif _LINUX
  18. #include "xercesc/dom/DOMDocument.hpp"
  19. #define IXMLDOMDocument DOMDocument
  20. #define IXMLDOMElement DOMElement
  21. XERCES_CPP_NAMESPACE_USE
  22. #else
  23. #error "Unsupported Platform"
  24. #endif
  25. //-----------------------------------------------------------------------------
  26. // Purpose: constructor
  27. //-----------------------------------------------------------------------------
  28. class CVCProjConvert
  29. {
  30. public:
  31. CVCProjConvert();
  32. ~CVCProjConvert();
  33. bool LoadProject( const char *project );
  34. int GetNumConfigurations();
  35. CUtlSymbol & GetName() { return m_Name; }
  36. CUtlSymbol & GetBaseDir() { return m_BaseDir; }
  37. class CConfiguration
  38. {
  39. public:
  40. CConfiguration() {}
  41. ~CConfiguration() {}
  42. typedef enum
  43. {
  44. FILE_SOURCE,
  45. FILE_HEADER,
  46. FILE_LIBRARY,
  47. FILE_TYPE_UNKNOWN_E
  48. } FileType_e;
  49. class CFileEntry
  50. {
  51. public:
  52. CFileEntry( CUtlSymbol name, FileType_e type ) { m_Name = name; m_Type = type; }
  53. ~CFileEntry() {}
  54. const char *GetName() { return m_Name.String(); }
  55. FileType_e GetType() { return m_Type; }
  56. bool operator==( const CFileEntry other ) const { return m_Name == other.m_Name; }
  57. private:
  58. FileType_e m_Type;
  59. CUtlSymbol m_Name;
  60. };
  61. void InsertFile( CFileEntry file ) { m_Files.AddToTail( file ); }
  62. void RemoveFile( CUtlSymbol file ) { m_Files.FindAndRemove( CFileEntry( file, FILE_TYPE_UNKNOWN_E ) ); } // file type doesn't matter on remove
  63. void SetName( CUtlSymbol name ) { m_Name = name; }
  64. int GetNumFileNames() { return m_Files.Count(); }
  65. const char * GetFileName(int i) { return m_Files[i].GetName(); }
  66. FileType_e GetFileType(int i) { return m_Files[i].GetType(); }
  67. CUtlSymbol & GetName() { return m_Name; }
  68. void ResetDefines() { m_Defines.RemoveAll(); }
  69. void AddDefine( CUtlSymbol define ) { m_Defines.AddToTail( define ); }
  70. int GetNumDefines() { return m_Defines.Count(); }
  71. const char *GetDefine( int i ) { return m_Defines[i].String(); }
  72. void ResetIncludes() { m_Includes.RemoveAll(); }
  73. void AddInclude( CUtlSymbol include ) { m_Includes.AddToTail( include ); }
  74. int GetNumIncludes() { return m_Includes.Count(); }
  75. const char *GetInclude( int i ) { return m_Includes[i].String(); }
  76. private:
  77. CUtlSymbol m_Name;
  78. CUtlVector<CUtlSymbol> m_Defines;
  79. CUtlVector<CUtlSymbol> m_Includes;
  80. CUtlVector<CFileEntry> m_Files;
  81. };
  82. CConfiguration & GetConfiguration( int i );
  83. int FindConfiguration( CUtlSymbol name );
  84. private:
  85. bool ExtractFiles( IXMLDOMDocument *pDoc );
  86. bool ExtractConfigurations( IXMLDOMDocument *pDoc );
  87. bool ExtractProjectName( IXMLDOMDocument *pDoc );
  88. bool ExtractIncludes( IXMLDOMElement *pDoc, CConfiguration & config );
  89. bool IterateFileConfigurations( IXMLDOMElement *pFile, CUtlSymbol fileName );
  90. // helper funcs
  91. CUtlSymbol GetXMLNodeName( IXMLDOMElement *p );
  92. CUtlSymbol GetXMLAttribValue( IXMLDOMElement *p, const char *attribName );
  93. CConfiguration::FileType_e GetFileType( const char *fileName );
  94. void FindFileCaseInsensitive( char *file, int fileNameSize );
  95. // data
  96. CUtlVector<CConfiguration> m_Configurations;
  97. CUtlSymbol m_Name;
  98. CUtlSymbol m_BaseDir;
  99. bool m_bProjectLoaded;
  100. };
  101. #endif // VCPROJCONVERT_H