2015-06-24 10:24:55 +08:00
|
|
|
/*
|
2020-12-20 04:06:08 +08:00
|
|
|
ISC License
|
|
|
|
|
|
|
|
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link>
|
2016-01-15 05:50:22 +08:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2015-06-24 10:24:55 +08:00
|
|
|
*/
|
|
|
|
|
2020-12-20 04:06:08 +08:00
|
|
|
#include "category.hpp"
|
2016-09-14 20:36:06 +08:00
|
|
|
#include "errno.hpp"
|
2020-12-20 04:06:08 +08:00
|
|
|
#include "str.hpp"
|
2015-06-24 10:24:55 +08:00
|
|
|
|
2018-10-14 11:48:30 +08:00
|
|
|
#include <string>
|
2015-06-24 10:24:55 +08:00
|
|
|
|
2019-01-07 01:52:55 +08:00
|
|
|
int
|
2020-12-20 04:06:08 +08:00
|
|
|
Category::Base::from_string(const std::string &s_)
|
2015-06-24 10:24:55 +08:00
|
|
|
{
|
2020-12-20 04:06:08 +08:00
|
|
|
int rv;
|
|
|
|
|
|
|
|
for(auto func : funcs)
|
|
|
|
{
|
|
|
|
rv = func->from_string(s_);
|
|
|
|
if(rv < 0)
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
Category::Base::to_string(void) const
|
|
|
|
{
|
|
|
|
std::set<std::string> rv;
|
|
|
|
|
2022-07-10 04:06:18 +08:00
|
|
|
for(const auto func : funcs)
|
2020-12-20 04:06:08 +08:00
|
|
|
rv.insert(func->to_string());
|
|
|
|
|
|
|
|
return str::join(rv,',');
|
2015-06-24 10:24:55 +08:00
|
|
|
}
|