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.

86 lines
2.1 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef UIFILERESOURCE_H
  6. #define UIFILERESOURCE_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "tier1/utlstring.h"
  11. namespace panorama
  12. {
  13. //
  14. // A file reference container, you pass in an opaque string and it interprets what kind of reference is it
  15. // Supports local file and HTTP url right now
  16. //
  17. class CFileResource
  18. {
  19. public:
  20. CFileResource();
  21. CFileResource( const char *pchUTF8Path );
  22. CFileResource( const CFileResource &src) { operator=(src); }
  23. ~CFileResource();
  24. bool BIsValid() const;
  25. bool BIsHTTPURL() const;
  26. bool BIsLocalPath() const;
  27. bool BIsSMBShare() const;
  28. const CUtlVector<CUtlString> &GetCookieHeadersForHTTPURL() const;
  29. const CUtlString &GetReferencePath() const;
  30. CUtlString &GetReferencePathForModify();
  31. void Set( const char *pchUTF8Path );
  32. CFileResource &operator=( const CFileResource & src);
  33. bool operator<( const CFileResource &left ) const;
  34. bool operator==( const CFileResource &left);
  35. #ifdef DBGFLAG_VALIDATE
  36. void Validate( CValidator &validator, const tchar *pchName )
  37. {
  38. VALIDATE_SCOPE();
  39. ValidateObj( m_sReference );
  40. ValidateObj( m_vecCookieHeaders );
  41. FOR_EACH_VEC( m_vecCookieHeaders, iVec )
  42. ValidateObj( m_vecCookieHeaders[iVec] );
  43. }
  44. #endif
  45. private:
  46. enum EReferenceType
  47. {
  48. eNone,
  49. eHTTPURL,
  50. eFile,
  51. eSMB,
  52. eSource2Relative
  53. };
  54. EReferenceType m_eRefType;
  55. CUtlString m_sReference;
  56. // Only used for eHTTPURL type
  57. CUtlVector<CUtlString> m_vecCookieHeaders;
  58. };
  59. //-----------------------------------------------------------------------------
  60. // Purpose: ResourceImage types
  61. //-----------------------------------------------------------------------------
  62. enum EResourceImageType
  63. {
  64. k_EResourceImageTypeUnknown = 0,
  65. k_EResourceImageTypeImage,
  66. k_EResourceImageTypeMovie
  67. };
  68. // Function to determine resource type for a file resource
  69. EResourceImageType DetermineResourceType( const CFileResource &resource );
  70. } // namespace panorama
  71. #endif // UIFILERESOURCE_H