34 { |
34 { |
35 } |
35 } |
36 |
36 |
37 void CCdlTkWriteInstance::Process() |
37 void CCdlTkWriteInstance::Process() |
38 { |
38 { |
39 string implName = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + CdlTkUtil::StripPath(iInstance.Name())); |
39 string implName = CdlTkUtil::ToLower( CdlTkUtil::StripPath(iInstance.Name())); |
|
40 implName = CdlTkUtil::Replace("\r","",implName); |
|
41 implName = CdlTkUtil::Replace("\n","",implName); |
40 string headerName(implName + ".h"); |
42 string headerName(implName + ".h"); |
41 InitReplace(headerName); |
43 InitReplace(headerName); |
42 ProcessCdl(); |
44 ProcessCdl(); |
43 |
45 |
44 CCdlTkFileCleanup tempFile; |
46 CCdlTkFileCleanup tempFile; |
45 |
47 |
46 ofstream hrhStream; |
48 ofstream hrhStream; |
47 CdlTkUtil::OpenTempOutput(hrhStream, tempFile); |
49 CdlTkUtil::OpenTempOutput(hrhStream, tempFile); |
48 ProcessInstanceHrh(hrhStream, headerName+"rh"); |
50 ProcessInstanceHrh(hrhStream, headerName+"rh"); |
49 hrhStream.close(); |
51 hrhStream.close(); |
50 CdlTkUtil::ExportFileIfWritable(tempFile, headerName+"rh"); |
52 CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::OutputPath() + headerName+"rh"); |
51 |
53 |
52 ofstream headerStream; |
54 ofstream headerStream; |
53 CdlTkUtil::OpenTempOutput(headerStream, tempFile); |
55 CdlTkUtil::OpenTempOutput(headerStream, tempFile); |
54 ProcessInstanceHeader(headerStream, headerName); |
56 ProcessInstanceHeader(headerStream, headerName); |
55 headerStream.close(); |
57 headerStream.close(); |
56 CdlTkUtil::ExportFileIfWritable(tempFile, headerName); |
58 CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::OutputPath() + headerName); |
57 |
59 |
58 ofstream cppStream; |
60 ofstream cppStream; |
59 CdlTkUtil::OpenTempOutput(cppStream, tempFile); |
61 CdlTkUtil::OpenTempOutput(cppStream, tempFile); |
60 ProcessInstance(cppStream, headerName); |
62 ProcessInstance(cppStream, headerName); |
61 cppStream.close(); |
63 cppStream.close(); |
62 CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::CorrectFilenameCase(implName + ".cpp")); |
64 |
|
65 CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::OutputPath() + CdlTkUtil::CorrectFilenameCase(implName + ".cpp")); |
63 } |
66 } |
64 |
67 |
65 void CCdlTkWriteInstance::InitReplace(const std::string& aHeaderName) |
68 void CCdlTkWriteInstance::InitReplace(const std::string& aHeaderName) |
66 { |
69 { |
67 iReplace.clear(); |
70 iReplace.clear(); |
68 iReplace.Add("$INSTNAME", iInstance.Name()); |
71 string instanceName = iInstance.Name(); |
|
72 instanceName = CdlTkUtil::Replace("\r", "", instanceName); |
|
73 instanceName = CdlTkUtil::Replace("\n", "", instanceName); |
|
74 iReplace.Add("$INSTNAME", instanceName); |
69 iReplace.Add("$CDLNAME", CdlTkUtil::StripPath(iCdl.FileName())); |
75 iReplace.Add("$CDLNAME", CdlTkUtil::StripPath(iCdl.FileName())); |
70 iReplace.Add("$CDLINCNAME", CdlTkUtil::ToLower(CdlTkUtil::StripPath(iCdl.FileName()))); |
76 iReplace.Add("$CDLINCNAME", CdlTkUtil::ToLower(CdlTkUtil::StripPath(iCdl.FileName()))); |
71 iReplace.Add("$HEADERNAME", CdlTkUtil::ToLower(CdlTkUtil::StripPath(aHeaderName))); |
77 iReplace.Add("$HEADERNAME", CdlTkUtil::ToLower(CdlTkUtil::StripPath(aHeaderName))); |
72 iReplace.Add("$EXTRA", iInstance.ExtraCpp()); |
78 iReplace.Add("$EXTRA", iInstance.ExtraCpp()); |
73 iReplace.Add("$INSTNS", CdlTkUtil::ToCpp(iInstance.Name())); |
79 iReplace.Add("$INSTNS", CdlTkUtil::ToCpp(iInstance.Name())); |
|
80 |
74 iReplace.Add("$CDLNS", iCdl.NamespaceName()); |
81 iReplace.Add("$CDLNS", iCdl.NamespaceName()); |
75 iReplace.Add("$CDLGUARD", HeaderGuardName(iCdl.FileName() + ".custom.h")); |
82 iReplace.Add("$CDLGUARD", HeaderGuardName(iCdl.FileName() + ".custom.h")); |
76 iReplace.Add("$INSTGUARD", HeaderGuardName(aHeaderName)); |
83 iReplace.Add("$INSTGUARD", HeaderGuardName(aHeaderName)); |
77 iReplace.Add("$CMDLINE", CdlTkUtil::CommandLine()); |
84 iReplace.Add("$CMDLINE", CdlTkUtil::CommandLine()); |
78 if (iInstance.Id() == KCdlTkGetInstanceIdFromHostDll) |
85 if (iInstance.Id() == KCdlTkGetInstanceIdFromHostDll) |