comparison foosdk/sdk/foobar2000/SDK/playable_location.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 //playable_location stores location of a playable resource, currently implemented as file path and integer for indicating multiple playable "subsongs" per file
4 //also see: file_info.h
5 //for getting more info about resource referenced by a playable_location, see metadb.h
6
7 //char* strings are all UTF-8
8
9 class NOVTABLE playable_location//interface (for passing around between DLLs)
10 {
11 public:
12 virtual const char * get_path() const = 0;
13 virtual void set_path(const char*) = 0;
14 virtual t_uint32 get_subsong() const = 0;
15 virtual void set_subsong(t_uint32) = 0;
16
17 void copy(const playable_location & p_other) {
18 set_path(p_other.get_path());
19 set_subsong(p_other.get_subsong());
20 }
21
22 static int g_compare(const playable_location & p_item1,const playable_location & p_item2);
23 static bool g_equals( const playable_location & p_item1, const playable_location & p_item2);
24
25 const playable_location & operator=(const playable_location & src) {copy(src);return *this;}
26
27 bool operator==(const playable_location & p_other) const;
28 bool operator!=(const playable_location & p_other) const;
29
30 void reset();
31
32 inline t_uint32 get_subsong_index() const {return get_subsong();}
33 inline void set_subsong_index(t_uint32 v) {set_subsong(v);}
34
35 bool is_empty() const;
36 bool is_valid() const;
37
38
39 enum {case_sensitive = true};
40 typedef pfc::comparator_strcmp path_comparator;
41
42 class comparator {
43 public:
44 static int compare(const playable_location & v1, const playable_location & v2) {return g_compare(v1,v2);}
45 };
46 static int path_compare( const char * p1, const char * p2 );
47
48 protected:
49 playable_location() {}
50 ~playable_location() {}
51 };
52
53 typedef playable_location * pplayable_location;
54 typedef playable_location const * pcplayable_location;
55 typedef playable_location & rplayable_location;
56 typedef playable_location const & rcplayable_location;
57
58 class playable_location_impl : public playable_location//implementation
59 {
60 public:
61 virtual const char * get_path() const;
62 virtual void set_path(const char* p_path);
63 virtual t_uint32 get_subsong() const;
64 virtual void set_subsong(t_uint32 p_subsong);
65
66 const playable_location_impl & operator=(const playable_location & src);
67
68 playable_location_impl();
69 playable_location_impl(const char * p_path,t_uint32 p_subsong);
70 playable_location_impl(const playable_location & src);
71 private:
72 pfc::string_simple m_path;
73 t_uint32 m_subsong;
74 };
75
76 // usage: somefunction( make_playable_location("file://c:\blah.ogg",0) );
77 // only for use as a parameter to a function taking const playable_location &
78 class make_playable_location : public playable_location
79 {
80 const char * path;
81 t_uint32 num;
82
83 virtual void set_path(const char*);
84 virtual void set_subsong(t_uint32);
85 public:
86 virtual const char * get_path() const;
87 virtual t_uint32 get_subsong() const;
88
89 make_playable_location(const char * p_path,t_uint32 p_num);
90 };
91
92 pfc::string_base & operator<<(pfc::string_base & p_fmt,const playable_location & p_location);