1 #include "streamcompress.hpp"
5 namespace streamcompress
9 std::map
<std::string
, std::function
<base
*(const std::string
&)>>& compressors()
11 static std::map
<std::string
, std::function
<base
*(const std::string
&)>> x
;
20 std::set
<std::string
> base::get_compressors()
22 std::set
<std::string
> r
;
23 for(auto& i
: compressors())
28 base
* base::create_compressor(const std::string
& name
,
29 const std::string
& args
)
31 if(!compressors().count(name
))
32 throw std::runtime_error("No such compressor");
33 return compressors()[name
](args
);
36 void base::do_register(const std::string
& name
,
37 std::function
<base
*(const std::string
&)> ctor
)
39 compressors()[name
] = ctor
;
42 void base::do_unregister(const std::string
& name
)
44 compressors().erase(name
);
47 std::map
<std::string
, std::string
> parse_attributes(const std::string
& val
)
49 std::map
<std::string
, std::string
> r
;
52 auto x
= regex("([^=]+)=([^,]+)(,(.*)|$)", v
);