1 #include "streamcompress.hpp"
6 namespace streamcompress
10 std::map
<std::string
, std::function
<base
*(const std::string
&)>>& compressors()
12 static std::map
<std::string
, std::function
<base
*(const std::string
&)>> x
;
21 std::set
<std::string
> base::get_compressors()
23 std::set
<std::string
> r
;
24 for(auto& i
: compressors())
29 base
* base::create_compressor(const std::string
& name
,
30 const std::string
& args
)
32 if(!compressors().count(name
))
33 throw std::runtime_error("No such compressor");
34 return compressors()[name
](args
);
37 void base::do_register(const std::string
& name
,
38 std::function
<base
*(const std::string
&)> ctor
)
40 compressors()[name
] = ctor
;
43 void base::do_unregister(const std::string
& name
)
45 compressors().erase(name
);
48 std::map
<std::string
, std::string
> parse_attributes(const std::string
& val
)
50 std::map
<std::string
, std::string
> r
;
53 auto x
= regex("([^=]+)=([^,]+)(,(.*)|$)", v
);