summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/container.hpp
blob: 461261236011a4a3778751f14216fb82ed6bdd12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef EOLIAN_CXX_CONTAINER_HH
#define EOLIAN_CXX_CONTAINER_HH

#include "grammar/generator.hpp"
#include "grammar/klass_def.hpp"
#include "grammar/case.hpp"
#include "grammar/type.hpp"

namespace efl { namespace eolian { namespace grammar {

struct container_subtype_modify
{
  typedef void result_type;
  void operator()(attributes::complex_type_def& /*x*/) const
  {
  }

  void operator()(attributes::regular_type_def& x) const
  {
    if(x.base_type == "string")
      remove_own(x.base_qualifier);
    else if(!x.pointers.empty())
      x.pointers.pop_back();
  }
  
  template <typename T>
  void operator()(T& /*x*/) const
  {
  }
};
      
template <typename OutputIterator, typename Context>
void generate_container(OutputIterator sink, attributes::complex_type_def const& complex, Context const& context
                        , std::string const& name)
{
  if(!complex.subtypes.empty())
    {
      attributes::type_def subtype = complex.subtypes[0];
      subtype.original_type.visit(container_subtype_modify{});
      as_generator(" "<< name << "<" << type << ">").generate(sink, subtype, context);
    }
}

} } }

#endif