foobar2000 SDK  2015-08-03
playable_location.cpp
Go to the documentation of this file.
1 #include "foobar2000.h"
2 
3 int playable_location::g_compare(const playable_location & p_item1,const playable_location & p_item2) {
4  int ret = metadb::path_compare(p_item1.get_path(),p_item2.get_path());
5  if (ret != 0) return ret;
6  return pfc::compare_t(p_item1.get_subsong(),p_item2.get_subsong());
7 }
8 
9 bool playable_location::g_equals( const playable_location & p_item1, const playable_location & p_item2) {
10  return g_compare(p_item1, p_item2) == 0;
11 }
12 
14 {
15  p_fmt << "\"" << file_path_display(p_location.get_path()) << "\"";
16  t_uint32 index = p_location.get_subsong_index();
17  if (index != 0) p_fmt << " / index: " << p_location.get_subsong_index();
18  return p_fmt;
19 }
20 
21 
22 bool playable_location::operator==(const playable_location & p_other) const {
23  return metadb::path_compare(get_path(),p_other.get_path()) == 0 && get_subsong() == p_other.get_subsong();
24 }
25 bool playable_location::operator!=(const playable_location & p_other) const {
26  return !(*this == p_other);
27 }
28 
30  set_path("");set_subsong(0);
31 }
32 
34  return * get_path() == 0;
35 }
36 
38  return !is_empty();
39 }
40 
41 const char * playable_location_impl::get_path() const {
42  return m_path;
43 }
44 
45 void playable_location_impl::set_path(const char* p_path) {
46  m_path=p_path;
47 }
48 
50  return m_subsong;
51 }
52 
54  m_subsong=p_subsong;
55 }
56 
58  copy(src);return *this;
59 }
60 
62 playable_location_impl::playable_location_impl(const char * p_path,t_uint32 p_subsong) : m_path(p_path), m_subsong(p_subsong) {}
64 
65 
66 
67 void make_playable_location::set_path(const char*) {throw pfc::exception_not_implemented();}
68 void make_playable_location::set_subsong(t_uint32) {throw pfc::exception_not_implemented();}
69 
70 const char * make_playable_location::get_path() const {return path;}
72 
73 make_playable_location::make_playable_location(const char * p_path,t_uint32 p_num) : path(p_path), num(p_num) {}
virtual t_uint32 get_subsong() const =0
virtual void set_subsong(t_uint32)=0
bool is_empty() const
virtual t_uint32 get_subsong() const
virtual const char * get_path() const =0
virtual void set_path(const char *p_path)
virtual const char * get_path() const
static bool g_equals(const playable_location &p_item1, const playable_location &p_item2)
virtual void set_subsong(t_uint32)
virtual void set_subsong(t_uint32 p_subsong)
virtual void set_path(const char *)=0
bool operator!=(const playable_location &p_other) const
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
static int path_compare(const char *p1, const char *p2)
Definition: metadb.h:245
virtual t_uint32 get_subsong() const
t_uint32 get_subsong_index() const
virtual const char * get_path() const
void copy(const playable_location &p_other)
bool is_valid() const
pfc::string_simple m_path
pfc::string_base & operator<<(pfc::string_base &p_fmt, const playable_location &p_location)
make_playable_location(const char *p_path, t_uint32 p_num)
static int g_compare(const playable_location &p_item1, const playable_location &p_item2)
uint32_t t_uint32
Definition: int_types.h:5
const playable_location_impl & operator=(const playable_location &src)
bool operator==(const playable_location &p_other) const
virtual void set_path(const char *)