[ create a new paste ] login | about

Link: http://codepad.org/EtlJaUI3    [ raw code | fork ]

PiotrLegnica - Python, pasted on Sep 26:
import re, string

with open('cstdint.hpp', 'rb') as fp:
 stdint = fp.read()

typedef = re.compile('typedef\s+.*?\s+(?P<type>u?int.*?_t);', re.I)
types = set()
for type in typedef.finditer(stdint):
    type = type.group('type')
    if re.search('\s', type) is not None:
        continue
    types.add(type)

headerTpl = string.Template(u'''\
#ifndef GEN_CSTDINT
#define GEN_CSTDINT

#include <boost/cstdint.hpp>

$typedefs

#endif // GEN_CSTDINT
''')

usingTpl = string.Template(u'using boost::$type;')

print headerTpl.substitute(typedefs = '\n'.join([usingTpl.substitute(type = x) for x in sorted(types)]))


Create a new paste based on this one


Comments: