Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "net_http.h"
- #include "../net.h"
- #include <tuple>
- #include <algorithm>
- //typedef std::function<std::vector<uint8_t>(std::vector<std::vector<uint8_t> >) > net_http_function_t;
- static std::vector<std::pair<std::string, net_http_function_t> > registrar;
- void net_http::file::add(
- std::string file,
- net_http_function_t function){
- std::pair<std::string, net_http_function_t> new_pair =
- std::make_pair(file, function);
- if(std::find(
- registrar.begin(),
- registrar.end(),
- new_pair) == registrar.end()){
- registrar.push_back(
- new_pair);
- }else{
- print("attempting to re-register the same function and path, fix references and enforce one-per-program stuff", P_ERR);
- }
- }
- void net_http::file::del(
- std::string file){
- auto iter =
- std::find_if(
- registrar.begin(),
- registrar.end(),
- [&file](const std::pair<std::string, net_http_function_t> elem){
- return elem.first == file;
- });
- if(iter != registrar.end()){
- registrar.erase(
- iter);
- }else{
- print("attempting to erase a non-existant path, fix the function calls", P_ERR);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement