coResult coCppTypesGeneratorPlugin::GenerateTypes(const coParsedProject& _parsedProject) { coLocalAllocator localAllocator(4048); // Paths coDynamicString mainCxxAbsolutePath(localAllocator); coDynamicString mainCxxRelativePath(localAllocator); { coJoinPaths(mainCxxRelativePath, projectGenerator->GetProjectRelativePath(), "allTypes.cxx"); coASSERT(coIsPathNormalized(mainCxxRelativePath)); coJoinPaths(mainCxxAbsolutePath, projectGenerator->GetOutReferenceDir(), mainCxxRelativePath); coASSERT(coIsPathNormalized(mainCxxAbsolutePath)); } coStringOutputStream stream; coWriteHeader(stream); stream << "\n"; coDynamicString cxxPath(localAllocator); for (const coParsedType* parsedType : _parsedProject.parsedTypes) { coASSERT(parsedType); coTRY(GenerateType(cxxPath, *parsedType), "Failed to generate type: " << parsedType->GetDebugName()); coWriteInclude(stream, cxxPath); } coTRY(stream.GetResult(), "Failed to write to stream: " << stream.GetDebugName()); { coDynamicArray<coByte> output; stream.GetOutput(output); coFileAccess file; coFileAccess::InitConfig c; c.mode = coFileAccess::write; c.path = mainCxxAbsolutePath; coTRY(file.Init(c), "Failed to open for writing: " << file << "."); coTRY(file.Write(output), "Failed to write in: " << file << "."); } projectGenerator->AddGeneratedEntryPath(mainCxxRelativePath); return true; }
bool C2DimensionFile::Generate(wstring& wstrMetaRow, int row, int colounm, list<wstring>& contentStrList) { m_ConvertFunc = (ValueFunc*)malloc(colounm * sizeof(ValueFunc)); m_RowCount = row; m_ColumnCount = colounm; m_wstrMetaRow = wstrMetaRow; m_wstrMetaRow.replace(m_wstrMetaRow.find(L"\r"), 1, L"\t"); GenerateHeader(); wstring* wstrColoumnName = new wstring[colounm]; ASSERT_NOTNULL(wstrColoumnName); GenerateType(wstrColoumnName); GenerateFill(wstrColoumnName, contentStrList); delete[] wstrColoumnName; OutputDebugStringW(m_wstrResultContent.c_str()); return true; }