mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-24 22:46:14 +02:00
getQuery convenience function
This commit is contained in:
parent
54e8eb2dcc
commit
f6e3c57ee5
3 changed files with 13 additions and 4 deletions
|
@ -37,9 +37,7 @@ using namespace std;
|
|||
PipeStream::PipeStream(PcmListener* pcmListener, const StreamUri& uri) : PcmStream(pcmListener, uri), fd_(-1)
|
||||
{
|
||||
umask(0);
|
||||
string mode = uri_.query["mode"];
|
||||
if (mode.empty())
|
||||
mode = "create";
|
||||
string mode = uri_.getQuery("mode", "create");
|
||||
|
||||
logO << "PipeStream mode: " << mode << "\n";
|
||||
if ((mode != "read") && (mode != "create"))
|
||||
|
|
|
@ -123,3 +123,12 @@ std::string StreamUri::id() const
|
|||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
|
||||
std::string StreamUri::getQuery(const std::string& key, const std::string& def) const
|
||||
{
|
||||
auto iter = query.find(key);
|
||||
if (iter != query.end())
|
||||
return iter->second;
|
||||
return def;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
using json = nlohmann::json;
|
||||
|
||||
|
||||
// scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
|
||||
struct StreamUri
|
||||
{
|
||||
StreamUri(const std::string& uri);
|
||||
|
@ -47,6 +48,7 @@ struct StreamUri
|
|||
|
||||
std::string id() const;
|
||||
json toJson() const;
|
||||
std::string getQuery(const std::string& key, const std::string& def = "") const;
|
||||
|
||||
private:
|
||||
std::string id_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue