summaryrefslogtreecommitdiff
path: root/public/panorama/uifileresource.h
blob: 102875cc00c0ff9321f2e15939563de3f9e9e039 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//=========== Copyright Valve Corporation, All rights reserved. ===============//
//
// Purpose: 
//=============================================================================//

#ifndef UIFILERESOURCE_H
#define UIFILERESOURCE_H


#ifdef _WIN32
#pragma once
#endif

#include "tier1/utlstring.h"

namespace panorama
{

//
// A file reference container, you pass in an opaque string and it interprets what kind of reference is it
//   Supports local file and HTTP url right now
//
class CFileResource
{
public:
	CFileResource();
	CFileResource( const char *pchUTF8Path );
	CFileResource( const CFileResource &src)  { operator=(src); }
	~CFileResource();

	bool BIsValid() const;
	bool BIsHTTPURL() const;
	bool BIsLocalPath() const;
	bool BIsSMBShare() const;
	const CUtlVector<CUtlString> &GetCookieHeadersForHTTPURL() const;

	const CUtlString &GetReferencePath() const;
	CUtlString &GetReferencePathForModify();

	void Set( const char *pchUTF8Path );
	CFileResource &operator=( const CFileResource & src);
	bool operator<( const CFileResource &left ) const;
	bool operator==( const CFileResource &left);
#ifdef DBGFLAG_VALIDATE
	void Validate( CValidator &validator, const tchar *pchName )
	{
		VALIDATE_SCOPE();
		ValidateObj( m_sReference );
		ValidateObj( m_vecCookieHeaders );
		FOR_EACH_VEC( m_vecCookieHeaders, iVec )
			ValidateObj( m_vecCookieHeaders[iVec] );
	}
#endif
private:

	enum EReferenceType
	{
		eNone,
		eHTTPURL,
		eFile,
		eSMB,
		eSource2Relative
	};
	EReferenceType m_eRefType;
	CUtlString m_sReference;

	// Only used for eHTTPURL type
	CUtlVector<CUtlString> m_vecCookieHeaders;
};


//-----------------------------------------------------------------------------
// Purpose: ResourceImage types
//-----------------------------------------------------------------------------
enum EResourceImageType
{
	k_EResourceImageTypeUnknown = 0,
	k_EResourceImageTypeImage,
	k_EResourceImageTypeMovie
};

// Function to determine resource type for a file resource
EResourceImageType DetermineResourceType( const CFileResource &resource );

} // namespace panorama

#endif // UIFILERESOURCE_H