|
a/upmpd/upmpdutils.hxx |
|
b/upmpd/upmpdutils.hxx |
|
... |
|
... |
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#ifndef _UPMPDUTILS_H_X_INCLUDED_
|
17 |
#ifndef _UPMPDUTILS_H_X_INCLUDED_
|
18 |
#define _UPMPDUTILS_H_X_INCLUDED_
|
18 |
#define _UPMPDUTILS_H_X_INCLUDED_
|
19 |
|
19 |
|
20 |
#include <string>
|
20 |
#include <sys/types.h> // for pid_t
|
21 |
#include <unordered_map>
|
21 |
|
|
|
22 |
#include <string> // for string
|
|
|
23 |
#include <unordered_map> // for unordered_map
|
|
|
24 |
#include <vector> // for vector
|
|
|
25 |
|
|
|
26 |
class UpSong;
|
22 |
|
27 |
|
23 |
/** Read protocol info file. This contains the connection manager protocol info data
|
28 |
/** Read protocol info file. This contains the connection manager protocol info data
|
24 |
*
|
29 |
*
|
25 |
* We strip white-space from beginning/ends of lines, and allow
|
30 |
* We strip white-space from beginning/ends of lines, and allow
|
26 |
* #-started comments (on a line alone only, comments after data not allowed).
|
31 |
* #-started comments (on a line alone only, comments after data not allowed).
|
27 |
*/
|
32 |
*/
|
28 |
bool read_protocolinfo(const string& fn, string& out);
|
33 |
bool read_protocolinfo(const std::string& fn, std::string& out);
|
29 |
|
34 |
|
30 |
/**
|
35 |
/**
|
31 |
* Read file into string.
|
36 |
* Read file into string.
|
32 |
* @return true for ok, false else
|
37 |
* @return true for ok, false else
|
33 |
*/
|
38 |
*/
|
34 |
extern bool file_to_string(const std::string &filename, std::string &data,
|
39 |
extern bool file_to_string(const std::string &filename, std::string &data,
|
35 |
std::string *reason = 0);
|
40 |
std::string *reason = 0);
|
36 |
|
41 |
|
37 |
extern void path_catslash(std::string &s);
|
42 |
extern void path_catslash(std::string &s);
|
38 |
extern std::string path_cat(const std::string &s1, const std::string &s2);
|
43 |
extern std::string path_cat(const std::string &s1, const std::string &s2);
|
39 |
extern void trimstring(string &s, const char *ws = " \t");
|
44 |
extern void trimstring(std::string &s, const char *ws = " \t");
|
40 |
extern string path_tildexpand(const string &s);
|
45 |
extern std::string path_tildexpand(const std::string &s);
|
41 |
extern void stringToTokens(const string &s, vector<string> &tokens,
|
46 |
extern void stringToTokens(const std::string &s, std::vector<std::string> &tokens,
|
42 |
const string &delims = " \t", bool skipinit=true);
|
47 |
const std::string &delims = " \t", bool skipinit=true);
|
43 |
extern bool path_makepath(const string& path, int mode);
|
48 |
extern bool path_makepath(const std::string& path, int mode);
|
44 |
|
49 |
|
45 |
// Convert between db value to percent values (Get/Set Volume and VolumeDb)
|
50 |
// Convert between db value to percent values (Get/Set Volume and VolumeDb)
|
46 |
extern int percentodbvalue(int value);
|
51 |
extern int percentodbvalue(int value);
|
47 |
extern int dbvaluetopercent(int dbvalue);
|
52 |
extern int dbvaluetopercent(int dbvalue);
|
48 |
|
53 |
|
|
... |
|
... |
53 |
extern const std::string& mapget(
|
58 |
extern const std::string& mapget(
|
54 |
const std::unordered_map<std::string, std::string>& im,
|
59 |
const std::unordered_map<std::string, std::string>& im,
|
55 |
const std::string& k);
|
60 |
const std::string& k);
|
56 |
|
61 |
|
57 |
// Format a didl fragment from MPD status data
|
62 |
// Format a didl fragment from MPD status data
|
58 |
class UpSong;
|
|
|
59 |
extern std::string didlmake(const UpSong& song);
|
63 |
extern std::string didlmake(const UpSong& song);
|
60 |
|
64 |
|
61 |
// Replace the first occurrence of regexp. cxx11 regex does not work
|
65 |
// Replace the first occurrence of regexp. cxx11 regex does not work
|
62 |
// that well yet...
|
66 |
// that well yet...
|
63 |
extern std::string regsub1(const std::string& sexp, const std::string& input,
|
67 |
extern std::string regsub1(const std::string& sexp, const std::string& input,
|