]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia/mmsolve.cpp
fd4fef2f0320ff3744a687427069d694642029f1
1 ////////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
7 // Copyright: (C) 1997, 1998, Guilhem Lavaux
8 // License: wxWindows license
9 ////////////////////////////////////////////////////////////////////////////////
11 #pragma implementation
15 wxMMediaFile
*wxMediaFileSolve::ByExtension(const wxString
& filename
)
17 wxMFileList
*list
= m_first
;
19 int pos
= filename
.Find('.', TRUE
)+1;
22 f_ext
= tmp(pos
, filename
.Length()-pos
);
24 printf("f_ext = %s\n", f_ext
.GetData());
26 printf("list->ext = %s\n", list
->ext
.GetData());
27 if (list
->ext
.CompareTo(f_ext
) == 0) {
28 wxMMediaFile
*mmf
= list
->creator();
36 wxMMediaFile
*wxMediaFileSolve::ByName(const wxString
& name
)
38 wxMFileList
*list
= m_first
;
41 if (list
->name
== name
)
42 return (wxMMediaFile
*)(list
->creator());
48 bool wxMatchMimeType(const wxString
& mime_obj
, const wxString
& type
)
50 #ifdef USE_GNU_WXSTRING
51 wxString mime2_obj
= mime_obj
;
52 wxString type2
= type
;
53 #define mime_obj mime2_obj
57 if (mime_obj
.Find('*') != -1) {
58 wxString part_str1
[2], part_str2
[2];
60 part_str1
[0] = mime_obj
.Left('/');
61 part_str1
[1] = mime_obj
.After('/');
63 part_str2
[0] = type
.Left('/');
64 part_str2
[1] = type
.After('/');
66 if (part_str1
[0] == "*" && part_str1
[1] == "*")
69 if (part_str1
[0] == "*" && part_str1
[1] == part_str2
[1])
72 if (part_str1
[1] == "*" && part_str1
[0] == part_str2
[1])
82 wxMMediaFile
*wxMediaFileSolve::ByType(const wxString
& type
)
84 wxMFileList
*list
= m_first
;
87 if (wxMatchMimeType(*(list
->mime_type
), type
))
88 return (wxMMediaFile
*)(list
->creator());
94 void wxMediaFileSolve::ListMDevice(wxString
*& names
, wxUint8
& devices
)
96 wxMFileList
*list
= m_first
;
104 names
= new wxString
[devices
];
107 names
[d
++] = list
->name
;
112 wxMMDfileRegister::wxMMDfileRegister(wxMediaFileCreator cbk
,
113 char *mtype
, char *ext
, char *name
)
115 wxMediaFileSolve::wxMFileList
*entry
= new wxMediaFileSolve::wxMFileList
;
117 entry
->next
= wxMediaFileSolve::m_first
;
118 entry
->creator
= cbk
;
119 entry
->mime_type
= wxString(mtype
);
120 entry
->name
= wxString(name
);
121 entry
->ext
= wxString(ext
);
122 wxMediaFileSolve::m_devnum
++;
123 wxMediaFileSolve::m_first
= entry
;