Update path to xapp descriptor. Add schema parser library
[ric-app/mc.git] / schemaparser / mc_extract_string.cc
1 #include<stdlib.h>
2 #include<stdio.h>
3 #include<string.h>
4
5 #include <sdl/syncstorage.hpp>
6
7
8 //      data type definitions from sdl
9 using Namespace = std::string;
10 using Key = std::string;
11 using Data = std::vector<uint8_t>;
12 using DataMap = std::map<Key, Data>;
13 using Keys = std::set<Key>;
14
15 int main(int argc, char **argv){
16
17         Namespace ns("mcnib");  
18         std::string prefix = "";
19         if(argc>1){
20                 prefix = argv[1];
21         }
22
23         std::unique_ptr<shareddatalayer::SyncStorage> sdl(shareddatalayer::SyncStorage::create());
24
25         Keys K = sdl->findKeys(ns, prefix);     // just the prefix
26         
27         DataMap Dk = sdl->get(ns, K);
28         for(auto si=K.begin();si!=K.end();++si){
29                 std::vector<uint8_t> val_v = Dk[(*si)]; // 4 lines to unpack a string
30                 char val[val_v.size()+1];                               // from Data
31                 int i;
32                 for(i=0;i<val_v.size();++i) val[i] = (char)(val_v[i]);
33                 val[i]='\0';
34                 printf("%s = %s\n",(*si).c_str(), val);
35         }
36
37 }