Switch to unified view

a b/upmpd/upmpdutils.hxx
1
/* Copyright (C) 2014 J.F.Dockes
2
 *     This program is free software; you can redistribute it and/or modify
3
 *     it under the terms of the GNU General Public License as published by
4
 *     the Free Software Foundation; either version 2 of the License, or
5
 *     (at your option) any later version.
6
 *
7
 *     This program is distributed in the hope that it will be useful,
8
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *     GNU General Public License for more details.
11
 *
12
 *     You should have received a copy of the GNU General Public License
13
 *     along with this program; if not, write to the
14
 *     Free Software Foundation, Inc.,
15
 *     59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
17
#ifndef _UPMPDUTILS_H_X_INCLUDED_
18
#define _UPMPDUTILS_H_X_INCLUDED_
19
20
#include <string>
21
#include <map>
22
23
/**
24
 * Read file into string.
25
 * @return true for ok, false else
26
 */
27
extern bool file_to_string(const std::string &filename, std::string &data, 
28
                           std::string *reason = 0);
29
30
// Escape XML special chars.
31
extern std::string xmlquote(const std::string& in);
32
33
// Convert between db value to percent values (Get/Set Volume and VolumeDb)
34
extern int percentodbvalue(int value);
35
extern int dbvaluetopercent(int dbvalue);
36
37
// Format milliseconds into H+:MM:SS
38
extern std::string upnpduration(int ms);
39
40
// Return mapvalue or null strings, for maps where absent entry and
41
// null data are equivalent
42
extern const std::string& mapget(const std::map<std::string, std::string>& im, 
43
                                 const std::string& k);
44
45
// Format a didl fragment from MPD status data
46
class MpdStatus;
47
extern std::string didlmake(const MpdStatus& mpds);
48
49
// Replace the first occurrence of regexp. cxx11 regex does not work
50
// that well yet...
51
extern std::string regsub1(const std::string& sexp, const std::string& input, 
52
                           const std::string& repl);
53
54
#endif /* _UPMPDUTILS_H_X_INCLUDED_ */