Commit 53db2bb5 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Add mpeg ts reader helper function to find entries by name.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent c918bbc6
......@@ -330,19 +330,29 @@ TSReader::entries()
return m_entries;
}
const TSReader::Entry *
TSReader::find (const string& name) const
{
for (const auto& entry : m_entries)
if (entry.filename == name)
return &entry;
return nullptr;
}
map<string, string>
TSReader::parse_vars (const string& name)
{
map<string, string> vars;
for (auto entry : m_entries)
{
if (entry.filename == name)
{
auto entry = find (name);
if (!entry)
return vars;
enum { KEY, VALUE } mode = KEY;
string s;
string key;
for (auto c : entry.data)
for (auto c : entry->data)
{
if (c == '=' && mode == KEY)
{
......@@ -361,8 +371,6 @@ TSReader::parse_vars (const string& name)
s += c;
}
}
}
}
return vars;
}
......
......@@ -37,6 +37,7 @@ private:
public:
Error load (const std::string& inname);
const std::vector<Entry>& entries();
const Entry *find (const std::string& filename) const;
std::map<std::string, std::string> parse_vars (const std::string& name);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment