C++ mapping a type to its header file -


i developing simple programming language creating c++ projects. lets type in short c++-like code , generates .h , .cpp files automatically.

i need way map type, e.g. standard library, to corresponding header file. makes possible use type in language , automatically infer headers include in generated code.

here example of language right now:

class car {     std::string print()      members:         int i, j         std::array<wheel, 4> wheels } 

when processing code find types std::string , std::array need mapped header files. how can achieve mapping?

is there maybe data base publicly available? not want parse headers myself of course (which assume how ides it).

on top of supporting standard library of course useful able support other libraries well, secondary goal.

well there excellent references can use build own database. standards slow-changing can generate map them using references. here c++ reference

it's hard go around searching in header files typically built using back-end bits not want use in code , can't distinguish between them.

if build i'd build basic map using standard library reference rather parsing through header files; example in car example above should #include <string> right?

if parse header file <string> given compiler may find made of back-end bits in-turn include other files;

in g++ version 4.6 <string> looks this:

// copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, // 2005, 2006, 2007, 2009, 2010, 2011 // free software foundation, inc. // gpl version 3.1 or later ... etc...  #ifndef _glibcxx_string #define _glibcxx_string 1  #pragma gcc system_header  #include <bits/c++config.h> #include <bits/stringfwd.h> #include <bits/char_traits.h>  // nb: in turn includes stl_algobase.h #include <bits/allocator.h> #include <bits/cpp_type_traits.h> #include <bits/localefwd.h>    // operators >>, <<, , getline. #include <bits/ostream_insert.h> #include <bits/stl_iterator_base_types.h> #include <bits/stl_iterator_base_funcs.h> #include <bits/stl_iterator.h> #include <bits/stl_function.h> // less #include <ext/numeric_traits.h>  #include <bits/stl_algobase.h>  #include <bits/range_access.h> #include <bits/basic_string.h> #include <bits/basic_string.tcc>   #endif /* _glibcxx_string */ 

the problem becomes evident. example <string> canonical std::ios_base ? lots think about, may have other thoughts on later.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -