Skip to content
Snippets Groups Projects
Commit 28e4ac01 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri :speech_balloon:
Browse files

Allow vtkEncodeString to create header without any export info

This allows the generated header to be added to executables.
parent d5729f86
No related branches found
No related tags found
No related merge requests found
......@@ -151,12 +151,14 @@ int main(int argc,
{
std::string option;
if(argc==7)
if(argc==5 || argc == 7)
{
option=argv[4];
}
if(argc<4 || argc>7 || (argc==7 && option.compare("--build-header")!=0))
bool buildHeader = false;
if(argc<4 || argc>7 ||
((argc==7 || argc == 5) && option.compare("--build-header")!=0))
{
cout << "Encode a string in a C or C++ file from a text file." << endl;
cout << "Usage: " << argv[0] << " <output-file> <input-path> <stringname>"
......@@ -164,6 +166,10 @@ int main(int argc,
<< "Example: " << argv[0] << " MyString.cxx MyString.txt MyGeneratedString --build-header MYSTRING_EXPORT MyHeaderDefiningExport.h" << endl;
return 1;
}
else if (argc > 4)
{
buildHeader = true;
}
Output ot;
ot.Stream << "/* DO NOT EDIT." << endl
<< " * Generated by " << argv[0] << endl
......@@ -173,8 +179,7 @@ int main(int argc,
std::string input = argv[2];
bool outputIsC=output.find(".c",output.size()-2)!=std::string::npos;
bool buildHeader=argc==7;
std::string fileName=GetFilenameWithoutLastExtension(output);
if(!ot.ProcessFile(input.c_str(), argv[3],buildHeader,fileName))
......@@ -202,10 +207,13 @@ int main(int argc,
<< " */" << endl
<< "#ifndef __"<<fileName<<"_h"<<endl
<< "#define __"<<fileName<<"_h"<<endl
<< endl
<< "#include \"" << argv[6] << "\"" <<endl // extra header file
<< endl;
if (argc > 5)
{
hs.Stream << "#include \"" << argv[6] << "\"" <<endl // extra header file
<< endl;
}
if(outputIsC)
{
hs.Stream << "#ifdef __cplusplus" <<endl
......@@ -213,7 +221,11 @@ int main(int argc,
<< "#endif /* #ifdef __cplusplus */" <<endl
<< endl;
}
hs.Stream << argv[5] <<" extern const char *" << argv[3] << ";"<< endl
if (argc > 5)
{
hs.Stream << argv[5] << " ";
}
hs.Stream <<"extern const char *" << argv[3] << ";"<< endl
<< endl;
if(outputIsC)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment