Created
October 6, 2014 13:39
-
-
Save mlcollard/0d3fc51f75934f058a3c to your computer and use it in GitHub Desktop.
srcML - Example of extracting source from a single-unit srcML file using the libsrcml API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
libsrcml_extract.cpp | |
Demonstrates use of libsrcml functions for reading | |
a srcML file | |
Error handling removed for clarity | |
*/ | |
#include <srcml.h> | |
int main() { | |
// setup the overall srcML input | |
srcml_archive* srcml_arch = srcml_create_archive(); | |
srcml_read_open_filename(srcml_arch, "main.cpp.xml"); | |
// read the unit and write to filesystem | |
srcml_unit* unit = srcml_read_unit(srcml_arch); | |
srcml_unparse_unit_filename(unit, "newmain.cpp"); | |
srcml_free_unit(unit); | |
// cleanup | |
srcml_close_archive(srcml_arch); | |
srcml_free_archive(srcml_arch); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment