split.py 876 B

123456789101112131415161718192021222324
  1. import os
  2. border = '// ----------------------------------------------------------------------------'
  3. with open('httplib.h') as f:
  4. lines = f.readlines()
  5. inImplementation = False
  6. os.makedirs('out', exist_ok=True)
  7. with open('out/httplib.h', 'w') as fh:
  8. with open('out/httplib.cc', 'w') as fc:
  9. fc.write('#include "httplib.h"\n')
  10. fc.write('namespace httplib {\n')
  11. for line in lines:
  12. isBorderLine = border in line
  13. if isBorderLine:
  14. inImplementation = not inImplementation
  15. else:
  16. if inImplementation:
  17. fc.write(line.replace('inline ', ''))
  18. pass
  19. else:
  20. fh.write(line)
  21. pass
  22. fc.write('} // namespace httplib\n')