Commit 612f663a authored by garciay's avatar garciay
Browse files

GeoNetworking codecs & Layers ongoing

parent 0e66cc91
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -4,7 +4,8 @@
#include <map>
#include <vector>

typedef std::map<std::string, std::string> Params;
#include "Params.hh"

class OCTETSTRING;

class Layer {
+14 −0
Original line number Diff line number Diff line
#pragma once

#include <map>

//typedef std::map<std::string, std::string> Params;

class Params : public std::map<std::string, std::string> {
  public:
    Params() : std::map<std::string, std::string>() {};
    virtual ~Params() {};
    void log();
    static void convert(Params& p_param, const std::string p_parameters);
};

ccsrc/Framework/params.hh

deleted100644 → 0
+0 −5
Original line number Diff line number Diff line
#pragma once

#include <map>

typedef std::map<std::string, std::string> params;
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ Layer* LayerStackBuilder::createLayerStack(const char* s)

            l->addUpperLayer(up);
            up = l;
        }
        } // End of 'for' statement
    }
    catch(const std::logic_error& e){
        if(up){
+34 −0
Original line number Diff line number Diff line
#include <stdexcept>
#include <regex>

#include "Params.hh"
#include "loggers.hh"

void Params::convert(Params& p_param, const std::string p_parameters) {
    loggers::loggers::log(">>> Params::convert: '%s'", p_parameters.c_str());
    // Sanity checks
    if (p_parameters.length() == 0) {
        return;
    }
    // Extract parameters
    try {
        std::regex rgx ("((\\.*)\\s*=\\s*(\\.*))(,((\\.*)\\s*=\\s*(\\.*)))*");
        std::sregex_iterator begin(p_parameters.cbegin(), p_parameters.cend(), rgx);
        std::sregex_iterator end = std::sregex_iterator();
        for (std::sregex_iterator it = begin; it != end; ++it) {
            std::smatch m = *it;
            loggers::loggers::log("Params::convert: %d - %s - %s - %s - %s - %s", m.size(), m[0].str().c_str(), m[1].str().c_str(), m[2].str().c_str(), m[3].str().c_str(), m[4].str().c_str());
            p_param.insert(std::pair<std::string, std::string>(m[1].str(), m[2].str()));
        } // End of 'for' statement
    }
    catch(const std::logic_error& e){
        p_param.clear();
    }
}

void Params::log() {
    loggers::loggers::log("Params::log");
    for (const_iterator it = cbegin(); it != cend(); ++it) {
        loggers::loggers::log("\t(%s, %s)", it->first.c_str(), it->second.c_str());
    } // End of 'for' statement
}