NSVD Reader  0.0.1
normalizer.hpp
Go to the documentation of this file.
1 
5 /*
6  * These codes are licensed under CC0.
7  * http://creativecommons.org/publicdomain/zero/1.0/
8  */
9 
10 #ifndef __NODAMUSHI_SVD_NORMALIZED_NORMALIZER_HPP__
11 #define __NODAMUSHI_SVD_NORMALIZED_NORMALIZER_HPP__
12 
13 # include <vector>
14 # include <memory>
15 # include <type_traits>
16 # include <tuple>
17 # include <sstream>
18 # include <unordered_set>
19 
20 
21 # include "nodamushi/refhash.hpp"
22 # include "nodamushi/svd/path.hpp"
23 # include "nodamushi/string_type.hpp"
24 # include "nodamushi/boxvec.hpp"
25 
29 
36 
37 
38 namespace nodamushi {
39 namespace svd {
40 namespace normalized {
41 
42 
43 namespace details{
44 template<typename T1,typename T2,bool b>struct if_same_type_of;
45 template<typename T1,typename T2> struct if_same_type_of<T1,T2,true>
46 {
47  static constexpr const T1 *of(const T2 *t) { return t; }
48 };
49 template<typename T1,typename T2> struct if_same_type_of<T1,T2,false>
50 {
51  static constexpr const T1 *of(const T2 *t) { return nullptr; }
52 };
53 }
54 
55 template <typename T1, typename T2>
57 {
58  static constexpr const T1 *value(const T2 *ptr)
59  {
61  }
62 };
63 
64 template<typename STRREF,typename STR,typename V>
65 struct normalizer
66 {
67  using names = std::unordered_set<::nodamushi::ref<std::string>,
70  using did_t = typename dim_info::id_t;
71  //--------------------------------------------------------------------------------
78  //--------------------------------------------------------------------------------
79  using SD = const ::nodamushi::svd::Device<STR,V>;
80  using SP = const ::nodamushi::svd::Peripheral<STR>;
81  using SC = const ::nodamushi::svd::Cluster<STR>;
82  using SR = const ::nodamushi::svd::Register<STR>;
83  using SF = const ::nodamushi::svd::Field<STR>;
84  using SE = const ::nodamushi::svd::Enumeration<STR>;
85  //--------------------------------------------------------------------------------
86  // temporary object class
87  //--------------------------------------------------------------------------------
88  template<typename SVD> struct base
89  {
90  const SVD& svd;
91  std::string name;
93  bool resolved;
94  base(const SVD& s,const std::string& n,const dim_info& di):
95  svd(s),name(n),dim(di),
96  resolved(!s.derivedFrom)
97  {}
98 
99  base(const SVD& s,const std::string& n):
100  svd(s),name(n),dim(),
101  resolved(!s.derivedFrom)
102  {}
103 
104  base(const base<SVD>&) = default;
105  };
106 
107  struct d;
108  struct p;
109  struct c;
110  struct r;
111  struct f;
112  struct e;
113 
114 
115  //-------------------------------------------------------------
116  // create children
117  //-------------------------------------------------------------
118  template <typename ChildType, typename Parent, typename SVD, typename PTR, typename ERROR>
119  static void emplace_child(
120  Parent &p, const SVD &s,
122  did_t g,
123  names &n, ERROR &e)
124 
125  {
126  auto dimh = make_dim_helper(s);
127  auto base_info =dimh.get_base_info();
128  for(size_t i = 0;i < dimh.size;i++){
129  std::string ni = dimh.name(i);
130  if(n.count(ni)){
131  e.fail();
132  ChildType::print_name(e);
133  e << " " << ni << " already defined in " << p;
134  e.endl();
135  }else{
136  size_t size = v.size();
137  base_info.index = i;
138  base_info.id= g;
139  v.emplace_back(p,s,ni,base_info,e);
140  n.emplace(v[size].name);
141  }
142  }
143  }
144 
145  template <typename ChildType, typename Parent,typename PTR, typename ERROR>
147  Parent &p, const ChildType &c,
149  did_t g,
150  names &n, ERROR &e)
151  {
152  if (n.count(c.name)){
153  e.fail();
154  ChildType::print_name(e);
155  e<< " " << c.name << " already defined in " << p;
156  e.endl();
157  return 0;
158  }else{
159  size_t s = v.size();
160  v.emplace_back(c);
161  auto& vs = v[s];
162  n.emplace(vs.name);
163  did_t r =vs.dim.id + g;
164  vs.dim.id = r;
165  return r;
166  }
167  }
168 
169  template <typename ChildType, typename Parent, typename SVDChildren, typename PTR, typename ERROR>
170  static did_t emplace_children(Parent &p,const SVDChildren &vec, boxvec<ChildType,PTR> &dst, ERROR &e)
171  {
172  names n; // name list
173  did_t g = 0;//group id
174  for(const auto& svd:vec){
175  emplace_child<ChildType>(p, svd, dst,g, n, e);
176  g++;
177  }
178  return g;
179  }
180 
181  //-----------------------------------------------------------------
182  // Define tempolary classes
183  //-----------------------------------------------------------------
184  struct e:public base<SE>
185  {
186  template<typename T>
187  static void print_name(T& o)
188  {
189  o << "Enumeration";
190  }
191  const f* parent;
192  const e* derivedFrom;
193 
194  e(const f &r, const SE &s) :
195  base<SE>(s, std::string(s.name?*s.name:"")),
196  parent(&r), derivedFrom(nullptr) {}
197  e(const e &) = default;
198  e(e&&)=default;
199  template <typename ERROR>
200  void set_derivedFrom(const e &df,const std::vector<e*>&,ERROR& e)
201  {
202  derivedFrom = &df;
203  this->resolved = true;
204  }
205  template <typename T>
206  void collect_unresolved(std::vector<T *> &v){}
207  void collect_unresolved(std::vector<e *> &v)
208  {
209  if (!this->resolved)
210  v.push_back(this);
211  }
212  };
213  struct f:public base<SF>
214  {
215  template<typename T>
216  static void print_name(T& o)
217  {
218  o << "Field";
219  }
220 
221  const r* parent;
222  const f* derivedFrom;
224 
225  template <typename ERROR>
226  f(const r &r, const SF &s, const std::string& n,const dim_info& i, ERROR &e)
227  :base<SF>(s, n, i),
228  parent(&r), derivedFrom(nullptr),
230  s.enumeratedValues?s.enumeratedValues.get().size():0)
231  {
232  if(s.enumeratedValues){
233  for(const SE& v: s.enumeratedValues.get())
234  enumeratedValues.emplace_back(*this,v);
235  }
236  }
237  f(const f &) = default;
238  f(f&&)=default;
239  template<typename ERROR>
240  void set_derivedFrom(const f& df,const std::vector<f*>&,ERROR & e){
241  this->resolved = true;
242  names n;
243  for (const auto &c : enumeratedValues) n.emplace(c.name);
244 
245  for (const auto &c : df.enumeratedValues){
246  copy_child(*this, c, enumeratedValues, 0,n, e);
247  }
248  }
249 
250  template <typename T>
251  void collect_unresolved(std::vector<T *> &v){}
252 
253  void collect_unresolved(std::vector<f *> &v)
254  {
255  if (!this->resolved)
256  v.push_back(this);
257  }
258  };
259  struct r:public base<SR>
260  {
261  template<typename T>
262  static void print_name(T& o)
263  {
264  o << "Register";
265  }
266 
267  const p* parentp;
268  const c* parentc;
269  const r* derivedFrom;
272 
273  template<typename P,typename ERROR>
274  r(const P &r,const SR& s,const std::string& n,const dim_info& i,ERROR &e):
275  base<SR>(s,n,i)
276  ,parentp(if_same_type<p,P>::value(&r))
277  ,parentc(if_same_type<c,P>::value(&r))
278  ,derivedFrom(nullptr)
279  ,last_group_id(0)
280  ,fields()
281  {
282  if(s.fields && s.fields.get().field){
283  size_t c = 0;
284  const auto& v = s.fields.get().field.get();
285  for(const auto& f:v)
286  c += get_dim_count(f);
287  if(c!=0){
288  fields.reserve(c);
290  }
291  }
292  }
293  r(const r &) = default;
294  r(r&&)=default;
295  template <typename ERROR>
296  void set_derivedFrom(const r &df, const std::vector<r*>&, ERROR &e)
297  {
298  derivedFrom = &df;
299  this->resolved = true;
300  names n;
301  for (const auto &c : fields)
302  n.emplace(c.name);
303  did_t ll = last_group_id;
304  for (const auto &c : df.fields)
305  {
306  did_t l = copy_child(*this, c, fields,last_group_id, n, e);
307  if(ll < l)ll = l;
308  }
309  last_group_id = ll;
310  }
311  template <typename T>
312  void collect_unresolved(std::vector<T *> &v)
313  {
314  for (auto &c : fields)
316  }
317  void collect_unresolved(std::vector<r *> &v)
318  {
319  if(!this->resolved)
320  v.push_back(this);
321  }
322  };
323  struct c:public base<SC>
324  {
325  template<typename T>
326  static void print_name(T& o)
327  {
328  o << "Cluster";
329  }
330 
331  const p* parentp;
332  const c* parentc;
333  const c* derivedFrom;
337 
338  template<typename P,typename ERROR>
339  c(const P& r,const SC& s,const std::string& n,const dim_info& i,ERROR &e):
340  base<SC>(s,n,i),
342  derivedFrom(nullptr),
343  last_group_id(0),
344  registers(),clusters()
345  {
346  size_t rc=0,cc=0;
347  for(const auto& _rc : s.registers.registers){
348  if(_rc.is_register())
349  rc += get_dim_count(_rc.get_register());
350  else
351  cc += get_dim_count(_rc.get_cluster());
352  }
353  registers.reserve(rc);
354  clusters.reserve(cc);
355 
356  names ns;
357  did_t gi=0;
358  for(const auto& _rc:s.registers.registers){
359  if(_rc.is_register()){
360  auto& ss = _rc.get_register();
361  emplace_child(*this,ss,registers,gi,ns,e);
362  }else{
363  auto& ss = _rc.get_cluster();
364  emplace_child(*this,ss,clusters,gi,ns,e);
365  }
366  gi++;
367  }
368  last_group_id = gi;
369  }
370  c(const c &) = default;
371  c(c&&)=default;
372 
373  template <typename ERROR>
374  void set_derivedFrom(const c &df,std::vector<c*>& unresolved, ERROR &e)
375  {
376  derivedFrom = &df;
377  this->resolved = true;
378  names n;
379  for (const auto &c : registers)
380  n.emplace(c.name);
381  for (const auto &c : clusters)
382  n.emplace(c.name);
383  did_t ll = last_group_id;
384  for (const auto &c : df.registers){
385  did_t l = copy_child(*this, c, registers,last_group_id, n, e);
386  if(ll < l)ll = l;
387  }
388  for (const auto &c : df.clusters){
389  did_t l = copy_child(*this, c, clusters, last_group_id, n, e);
390  if(ll < l)ll = l;
391  if(!c.resolved){
392  size_t i = clusters.size() - 1;
393  unresolved.push_back(&clusters[i]);
394  }
395  }
396  last_group_id = ll;
397  }
398 
399  template <typename T>
400  void collect_unresolved(std::vector<T *> &v)
401  {
402  for (auto &c : registers)
404  for (auto &c : clusters)
406  }
407  void collect_unresolved(std::vector<c *> &v)
408  {
409  if(!this->resolved)
410  v.push_back(this);
411  for (auto &c : registers)
413  }
414  };
415 
416  struct p:public base<SP>
417  {
418  template<typename T>
419  static void print_name(T& o)
420  {
421  o << "Peripheral";
422  }
423 
424  const d* parent;
425  const p* derivedFrom;
429 
430  template<typename ERROR>
431  p(const d& r,const SP& s,const std::string& n,const dim_info& i,ERROR& e):
432  base<SP>(s,n,i),
433  parent(&r),
434  derivedFrom(nullptr),
435  last_group_id(0),
436  registers(),clusters()
437  {
438  size_t rc=0,cc=0;
439  if(s.registers){
440  for(const auto& _rc : s.registers.get().registers){
441  if(_rc.is_register())
442  rc += get_dim_count(_rc.get_register());
443  else
444  cc += get_dim_count(_rc.get_cluster());
445  }
446  registers.reserve(rc);
447  clusters.reserve(cc);
448 
449  names ns;
450  did_t gi=0;
451  for(const auto& _rc:s.registers.get().registers){
452  if(_rc.is_register()){
453  const auto& ss = _rc.get_register();
454  emplace_child(*this,ss,registers,gi,ns,e);
455  }else{
456  const auto& ss = _rc.get_cluster();
457  emplace_child(*this,ss,clusters,gi,ns,e);
458  }
459  gi++;
460  }
461  last_group_id = gi;
462  }
463  }
464  p(const p&)=default;
465  p(p&&)=default;
466 
467  template <typename ERROR>
468  void set_derivedFrom(const p &df,std::vector<p*>&, ERROR &e)
469  {
470  derivedFrom = &df;
471  this->resolved=true;
472  names n;
473  for (const auto &c : registers)
474  n.emplace(c.name);
475  for (const auto &c : clusters)
476  n.emplace(c.name);
477  did_t ll = last_group_id;
478  for (const auto &c : df.registers){
479  did_t l = copy_child(*this, c, registers,last_group_id, n, e);
480  if(ll < l)ll = l;
481  }
482  for (const auto &c : df.clusters){
483  did_t l =copy_child(*this, c, clusters,last_group_id, n, e);
484  if(ll < l)ll = l;
485  }
486  last_group_id = ll;
487  }
488  template<typename T>
489  void collect_unresolved(std::vector<T*>& v)
490  {
491  for (auto &c : registers)
493  for (auto &c : clusters)
495  }
496  void collect_unresolved(std::vector<p *> &v)
497  {
498  if (!this->resolved)
499  v.push_back(this);
500  }
501  };
502 
503  struct d
504  {
505  const SD& svd;
507  template<typename ERROR>
508  d(const SD& s,ERROR &e):svd(s), peripherals{}
509  {
510  size_t c=0;
511  if(s.peripherals && s.peripherals.get().peripheral)
512  for(const auto& p:s.peripherals.get().peripheral.get())
513  c += get_dim_count(p);
514  if(c!=0){
515  peripherals.reserve(c);
516  emplace_children<p>(*this,s.peripherals.get().peripheral.get(),peripherals,e);
517  }
518  }
519  d(const d&)=delete;
520  d(d&&)=default;
521 
522  template <typename ERROR>
523  void set_derivedFrom(const d &,const std::vector<d*>&, ERROR &){}
524  };
525 
526  //--------------------------------------------------------------------------------
527  // path of node
528  //--------------------------------------------------------------------------------
529  static path<substring> get_path(const p& p){
530  return {p.name};
531  }
532  static path<substring> get_path(const c& c){
533  if(c.parentc)
534  return get_path(*c.parentc).append(path<substring>(c.name));
535  else
536  return get_path(*c.parentp).append(path<substring>(c.name));
537  }
538  static path<substring> get_path(const r& r){
539  if(r.parentc)
540  return get_path(*r.parentc).add(path<substring>(r.name));
541  else
542  return get_path(*r.parentp).add(path<substring>(r.name));
543  }
544  static path<substring> get_path(const f& f){
545  return get_path(*f.parent).append(path<substring>(f.name));
546  }
547  static path<substring> get_path(const e& e){
548  return get_path(*e.parent).append(path<substring>(e.name));
549  }
550 
551  //--------------------------------------------------------------------------------
552  // find node
553  //--------------------------------------------------------------------------------
554 
555  template<typename T1,typename T2>
556  static void find(string_ref name,const T1& t,const T2** ret){}
557 
558  // helper implements
559  template<typename LIST,typename T> static void _find(string_ref name,const LIST& list,const T** ret)
560  {
561  for(const T& o:list)
562  if(o.name == name){
563  if(o.resolved)
564  *ret = &o;
565  return;
566  }
567  }
568  static void find(string_ref n,const d& s,const p** r){_find(n,s.peripherals,r);}
569  static void find(string_ref n,const p& s,const c** r){_find(n,s.clusters,r);}
570  static void find(string_ref n,const p& s,const r** r){_find(n,s.registers,r);}
571  static void find(string_ref n,const c& s,const c** r){_find(n,s.clusters,r);}
572  static void find(string_ref n,const c& s,const r** r){_find(n,s.registers,r);}
573  static void find(string_ref n,const r& s,const f** r){_find(n,s.fields,r);}
574  static void find(string_ref n,const f& s,const e** r){_find(n,s.enumeratedValues,r);}
575 
576  // find name in parent of t, and set to ret
577  template<typename P>
578  static void findp(string_ref name,const P& t,const P** ret){
579  if(t.parent)find(name,*t.parent,ret);
580  }
581  static void findp(string_ref name,const r& t,const r** ret){
582  if(t.parentp)find(name,*t.parentp,ret);
583  else find(name,*t.parentc,ret);
584  }
585  static void findp(string_ref name,const c& t,const c** ret){
586  if(t.parentp)find(name,*t.parentp,ret);
587  else find(name,*t.parentc,ret);
588  }
589 
590  //--------------------------------------------------------------------------------
591  // find derivedFrom
592  //--------------------------------------------------------------------------------
593 
594  // name is single path
595  template<typename PSTR,typename T>
596  static const T* find_derivedFrom_s(const ::nodamushi::svd::path<PSTR>& name,const T& t)
597  {
598  const T *ret = nullptr;
599  findp(name[0],t,&ret);
600  return ret;
601  }
602 
603  // PARENT is peripheral or cluster
604  template<typename PSTR,typename PARENT,typename T>
605  static void find_derivedFrom_r(const ::nodamushi::svd::path<PSTR>& p,
606  const PARENT& parent,const T** ret)
607  {
608  const auto s = p.size();
609  if(s > 3) return;
610 
611  if(s == 1){
612  find(p[0],parent,ret);
613  return;
614  }
615 
616  const r* reg = nullptr;
617  find(p[0],parent,&reg);
618  if(!reg)return; // not found
619 
620  if(s == 2){
621  find(p[1],reg,ret);
622  return;
623  }
624 
625  const f* fe = nullptr;
626  find(p[1],reg,&fe);
627  if(!fe)return;
628 
629  find(p[2],fe,ret); // TODO
630  }
631 
632  // multi path
633  template<typename PSTR,typename T>
634  static void find_derivedFrom_m(const ::nodamushi::svd::path<PSTR>& path,
635  const d& d,const T& t,const T** ret)
636  {
637  const auto s = path.size();
638  const p* peri = nullptr;
639  find(path[0],d,&peri);
640  if(!peri) return; // not found
641  if(s == 2){
642  find(path[1],*peri,ret);
643  return;
644  }
645 
646  const c* clu = nullptr;
647  find(path[1],*peri,&clu);
648  if(!clu) find_derivedFrom_r(path.subpath(1),*peri,ret);
649  else{
650  size_t i = 2;
651  const c* cp;
652  while(!clu){
653  cp = clu;
654  clu = nullptr;
655 
656  if(i == s){
657  find(path[i],*cp,ret);
658  return;
659  }
660 
661  find(path[i],*cp,&clu);
662  i++;
663  }
664  find_derivedFrom_r(path.subpath(i),*cp,ret);
665  }
666  }
667 
668  //--------------------------------------------------------------------------------
669  // derivedFrom
670  //--------------------------------------------------------------------------------
671  template <typename T,typename ERROR>
672  static bool set_derivedFrom(d &d, T &t, std::vector<T*>& unresolved, ERROR &e)
673  {
674  if(t.svd.derivedFrom){
675  const auto& dp = *t.svd.derivedFrom;
676  const T *ret = nullptr;
677  if(dp.single())ret = find_derivedFrom_s(dp,t);
678  else find_derivedFrom_m(dp,d,t,&ret);
679  if(!ret)return false;
680  const T& df = *ret;
681  t.set_derivedFrom(df, unresolved, e);
682  }
683  return true;
684  }
685  template <typename T, typename ERROR>
686  static bool set_derivedFrom_all(d &d, std::vector<T *>& unresolved, ERROR &e)
687  {
688  if(unresolved.empty())
689  return true;
690  bool found=false;
691  do{
692  found = false;
693  auto it = unresolved.begin();
694  while(it != unresolved.end()){
695  T& t=**it;
696  if(set_derivedFrom(d,t,unresolved,e)){
697  found = true;
698  it = unresolved.erase(it);
699  }else
700  ++it;
701  }
702  } while (found && unresolved.size() > 0);
703  return unresolved.empty();
704  }
705 
706  template <typename T,typename ERROR>
707  static bool _set_derivedFrom(d &d, ERROR &err)
708  {
709  std::vector<T *> v;
710  for (auto &c : d.peripherals){
712  }
713 
714  if (!set_derivedFrom_all(d, v, err)){
715  for (const auto *c : v){
716  err.fail()
717  << (*c)
718  << " derivedFrom:"
719  << (c->svd.derivedFrom.get())
720  << " is not found"
721  ;
722  err.endl();
723  }
724  return false;
725  }
726  return true;
727  }
728 
729  template <typename ERROR>
730  static bool set_derivedFrom(d &d, ERROR &err)
731  {
732  bool ret = true;
733  ret |= _set_derivedFrom<p>(d, err);
734  ret |= _set_derivedFrom<c>(d, err);
735  ret |= _set_derivedFrom<r>(d, err);
736  ret |= _set_derivedFrom<f>(d, err);
737  ret |= _set_derivedFrom<e>(d, err);
738  return ret;
739  }
740 
741  //--------------------------------------------------------------------------------
742  // Build
743  //--------------------------------------------------------------------------------
744 
745  struct error
746  {
747  bool failed;
748  std::stringstream ss;
749  error():failed(false),ss(){}
750  error& fail() { failed = true; return *this;}
751 
752  template<typename T>
753  error& operator<< (const T& t)
754  {
755  ss << t;
756  return *this;
757  }
759  ss << std::endl;
760  return *this;
761  }
762  error& operator<< (const p &p)
763  {
764  ss << "peripheral: " << get_path(p);
765  return *this;
766  }
767  error& operator<< (const c &p)
768  {
769  ss << "cluster: " << get_path(p);
770  return *this;
771  }
772  error& operator<< (const f &p)
773  {
774  ss << "field:" << get_path(p);
775  return *this;
776  }
777  error& operator<<(const r &p)
778  {
779  ss << "register:" << get_path(p);
780  return *this;
781  }
782  error& operator<<(const e &p)
783  {
784  ss << "enumerate:" << get_path(p);
785  return *this;
786  }
787  error& operator<<(const d &)
788  {
789  ss << "device:";
790  return *this;
791  }
792 
793  };
794 
795  normalizer(const SD &s) :
796  err(),
797  device(s, err),
798  ok(set_derivedFrom(device, err) && !err.failed)
799  {
800  }
801 
802  explicit operator bool() const { return ok; }
803  std::string get_error() const { return err.ss.str(); }
804 
807  bool ok;
808 };
809 
810 }// normalized
811 
812 // // nodamushi::svd::normalize::normalize(svd)
813 
823 template<
824 # if __cplusplus >= 201703
825  typename STRREF=std::string_view,
826 # else
827  typename STRREF=std::string,
828 # endif
829 typename STR,typename V>
830 static ::nodamushi::svd::normalized::node_ptr<::nodamushi::svd::normalized::Device<STRREF>>
831 normalize(const ::nodamushi::svd::Device<STR,V>& d)
832 {
833  namespace norm=::nodamushi::svd::normalized;
834  using D = norm::Device<STRREF>;
835  norm::normalizer<STRREF,STR,V> n(d);
836  if(n){
837  auto ptr = norm::make_node_ptr<D>(n.device);
838  ptr->update_parent(ptr);
839  return ptr;
840  }else{
841  return {};
842  }
843 }
844 
845 
846 
847 }} // nodamushi::svd
848 #endif // __NODAMUSHI_SVD_NORMALIZED_NORMALIZER_HPP__
boxvec. vector<pointer<X>>
Normalized enumerationValues element.
normalized peripheral element
static ::nodamushi::svd::normalized::node_ptr<::nodamushi::svd::normalized::Device< STRREF > > normalize(const ::nodamushi::svd::Device< STR, V > &d)
normalize nodamushi::svd::Device.
Definition: normalizer.hpp:831
void set_derivedFrom(const d &, const std::vector< d * > &, ERROR &)
Definition: normalizer.hpp:523
typename dim_info::id_t did_t
dim_info.id type
Definition: normalizer.hpp:70
static void find(string_ref n, const r &s, const f **r)
Definition: normalizer.hpp:573
base(const SVD &s, const std::string &n)
Definition: normalizer.hpp:99
void collect_unresolved(std::vector< f * > &v)
Definition: normalizer.hpp:253
static void _find(string_ref name, const LIST &list, const T **ret)
Definition: normalizer.hpp:559
base(const SVD &s, const std::string &n, const dim_info &di)
indicate that the derivedFrom property is resolved
Definition: normalizer.hpp:94
value< path< std::string >,ATTR > derivedFrom
derivedFrom attribute
Definition: Cluster.hpp:98
void collect_unresolved(std::vector< r * > &v)
Definition: normalizer.hpp:317
static void findp(string_ref name, const c &t, const c **ret)
Definition: normalizer.hpp:585
size_t size() const noexcept
Definition: path.hpp:218
value< Fields< STR >,ELEMENT > fields
<fields>
Definition: Register.hpp:90
<cluster> element
Definition: Cluster.hpp:36
size_type size() const noexcept
Definition: boxvec.hpp:137
<register> element
Definition: Register.hpp:42
void set_derivedFrom(const f &df, const std::vector< f * > &, ERROR &e)
Definition: normalizer.hpp:240
void collect_unresolved(std::vector< c * > &v)
Definition: normalizer.hpp:407
dim_helper< NODE > make_dim_helper(const NODE &n)
Definition: dim_helper.hpp:163
Definition: Access.hpp:143
const std::string & string_ref
Definition: string_type.hpp:44
void set_derivedFrom(const e &df, const std::vector< e * > &, ERROR &e)
Definition: normalizer.hpp:200
void set_derivedFrom(const p &df, std::vector< p * > &, ERROR &e)
Definition: normalizer.hpp:468
<peripheral> element
Definition: Peripheral.hpp:45
C++17/14 string type.
value< std::vector< Enumeration< STR > >,ELEMENT > enumeratedValues
<enumeration> minOccurs=0,maxOccurs=2
Definition: Field.hpp:77
static void find(string_ref n, const c &s, const r **r)
Definition: normalizer.hpp:572
normalized field element
<enumeratedValues> element. iterable
Definition: Enumeration.hpp:35
id_t id
dimension group id.this value is unique in the parent.
Definition: dim_info.hpp:37
static path< substring > get_path(const c &c)
Definition: normalizer.hpp:532
static bool set_derivedFrom(d &d, T &t, std::vector< T * > &unresolved, ERROR &e)
Definition: normalizer.hpp:672
normalized cluster
normalized register
path< STR > subpath(size_t from, size_t end=0) const
Definition: path.hpp:222
iterator emplace(const_iterator position, ARGS &&... args)
Definition: boxvec.hpp:192
static void emplace_child(Parent &p, const SVD &s, boxvec< ChildType, PTR > &v, did_t g, names &n, ERROR &e)
enumerate
Definition: normalizer.hpp:119
static bool set_derivedFrom_all(d &d, std::vector< T * > &unresolved, ERROR &e)
Definition: normalizer.hpp:686
container class decralation
static const T * find_derivedFrom_s(const ::nodamushi::svd::path< PSTR > &name, const T &t)
Definition: normalizer.hpp:596
size_t get_dim_count(const NODE &n)
get dim size. when dim is empty return 1.
Definition: dim_helper.hpp:21
static void find(string_ref n, const f &s, const e **r)
Definition: normalizer.hpp:574
static void find_derivedFrom_m(const ::nodamushi::svd::path< PSTR > &path, const d &d, const T &t, const T **ret)
Definition: normalizer.hpp:634
svd element path
void collect_unresolved(std::vector< T * > &v)
Definition: normalizer.hpp:400
static constexpr const T1 * value(const T2 *ptr)
Definition: normalizer.hpp:58
f(const r &r, const SF &s, const std::string &n, const dim_info &i, ERROR &e)
Definition: normalizer.hpp:226
void collect_unresolved(std::vector< T * > &v)
Definition: normalizer.hpp:251
static path< substring > get_path(const e &e)
Definition: normalizer.hpp:547
static void find(string_ref n, const p &s, const r **r)
Definition: normalizer.hpp:570
static void find(string_ref n, const p &s, const c **r)
Definition: normalizer.hpp:569
void collect_unresolved(std::vector< T * > &v)
Definition: normalizer.hpp:312
static path< substring > get_path(const p &p)
Definition: normalizer.hpp:529
static bool _set_derivedFrom(d &d, ERROR &err)
Definition: normalizer.hpp:707
static bool set_derivedFrom(d &d, ERROR &err)
Definition: normalizer.hpp:730
This class reperesents SVD(xml) element / attribute.
Definition: value.hpp:53
dim,dimIndex,array information object.
Definition: dim_info.hpp:27
static void find(string_ref name, const T1 &t, const T2 **ret)
Definition: normalizer.hpp:556
void collect_unresolved(std::vector< e * > &v)
Definition: normalizer.hpp:207
<field> element
Definition: Field.hpp:41
static void find_derivedFrom_r(const ::nodamushi::svd::path< PSTR > &p, const PARENT &parent, const T **ret)
Definition: normalizer.hpp:605
void collect_unresolved(std::vector< p * > &v)
Definition: normalizer.hpp:496
static void findp(string_ref name, const P &t, const P **ret)
Definition: normalizer.hpp:578
normalized peripheral element
c(const P &r, const SC &s, const std::string &n, const dim_info &i, ERROR &e)
Definition: normalizer.hpp:339
std::unordered_set<::nodamushi::ref< std::string >, ::nodamushi::refhash< std::string > > names
Definition: normalizer.hpp:68
vector<pointer<T>>.
Definition: boxvec.hpp:75
Registers< STR > registers
<register> or <cluster>
Definition: Cluster.hpp:137
value< Registers< STR >,ELEMENT > registers
Definition: Peripheral.hpp:85
static void findp(string_ref name, const r &t, const r **ret)
Definition: normalizer.hpp:581
static path< substring > get_path(const r &r)
Definition: normalizer.hpp:538
normalized Device
names,dispalyNames->name0,displayName1
hash of ref<T>
Definition: refhash.hpp:63
normalized field element
Definition: Field.hpp:32
dot '.' separeted path.
Definition: path.hpp:16
void collect_unresolved(std::vector< T * > &v)
Definition: normalizer.hpp:206
static path< substring > get_path(const f &f)
Definition: normalizer.hpp:544
r(const P &r, const SR &s, const std::string &n, const dim_info &i, ERROR &e)
Definition: normalizer.hpp:274
void set_derivedFrom(const r &df, const std::vector< r * > &, ERROR &e)
Definition: normalizer.hpp:296
dimension information
static did_t copy_child(Parent &p, const ChildType &c, boxvec< ChildType, PTR > &v, did_t g, names &n, ERROR &e)
Definition: normalizer.hpp:146
void collect_unresolved(std::vector< T * > &v)
Definition: normalizer.hpp:489
static void find(string_ref n, const d &s, const p **r)
Definition: normalizer.hpp:568
void set_derivedFrom(const c &df, std::vector< c * > &unresolved, ERROR &e)
Definition: normalizer.hpp:374
static did_t emplace_children(Parent &p, const SVDChildren &vec, boxvec< ChildType, PTR > &dst, ERROR &e)
Definition: normalizer.hpp:170
reference hash (pointer hasn)
normalized <enumeratedValues> element. iterable
Definition: Enumeration.hpp:27
static void find(string_ref n, const c &s, const c **r)
Definition: normalizer.hpp:571
p(const d &r, const SP &s, const std::string &n, const dim_info &i, ERROR &e)
Definition: normalizer.hpp:431
void emplace_back(ARGS &&... args)
Definition: boxvec.hpp:187