本文整理汇总了C++中gd::Project::HasSourceFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Project::HasSourceFile方法的具体用法?C++ Project::HasSourceFile怎么用?C++ Project::HasSourceFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::Project
的用法示例。
在下文中一共展示了Project::HasSourceFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnsureAssociatedSourceFileIsUpToDate
void CppCodeEvent::EnsureAssociatedSourceFileIsUpToDate(
gd::Project& project) const {
#if !defined(GD_NO_WX_GUI)
gd::String outputFile(CodeCompiler::Get()->GetOutputDirectory() + "GD" +
gd::String::From(this) + "SourceFile.cpp");
gd::SourceFile* sourceFile;
// First check if the associated source file exists in the GD project.
if (project.HasSourceFile(associatedGDManagedSourceFile, "C++"))
sourceFile = &project.GetSourceFile(associatedGDManagedSourceFile);
else {
// If there is no associated source file existing, then create a new one
sourceFile = &project.InsertNewSourceFile(outputFile, "C++");
sourceFile->SetGDManaged(true);
}
// Then check if the associated source file is up to date
associatedGDManagedSourceFile = outputFile;
if (sourceFile->GetFileName() != outputFile) {
sourceFile->SetFileName(outputFile);
} else if (wxFileExists(outputFile)) {
wxFileName sourceFileInfo(outputFile);
if (sourceFileInfo.GetModificationTime().GetTicks() >= lastChangeTimeStamp)
return;
}
// The associated source file is non existing or not up to date: Regenerate
// it. It will be compiled ( see CodeCompilationHelpers ) as it will be
// detected ( by DependenciesAnalyzer ) as a SourceFile dependency which is
// not up to date.
gd::FileStream file;
file.open(outputFile, std::ios_base::out);
file << GenerateAssociatedFileCode();
file.close();
#else
gd::LogError(
"BAD USE: C++ Code event not supported when wxWidgets support is "
"disabled");
#endif
}
示例2: SECTION
/*
* GDevelop Core
* Copyright 2008-2014 Florian Rival ([email protected]). All rights reserved.
* This project is released under the MIT License.
*/
/**
* @file Tests covering common features of GDevelop Core.
*/
#include "catch.hpp"
#include "GDCore/CommonTools.h"
#include "GDCore/PlatformDefinition/Project.h"
#include "GDCore/PlatformDefinition/SourceFile.h"
TEST_CASE( "SourceFile", "[common]" ) {
SECTION("Basics") {
gd::Project project;
project.InsertNewSourceFile("test.cpp", "C++");
project.InsertNewSourceFile("test.js", "Javascript");
REQUIRE( project.HasSourceFile("test.cpp", "C++") == true );
REQUIRE( project.HasSourceFile("test.cpp", "JS") == false );
REQUIRE( project.HasSourceFile("test.cpp") == true );
gd::SourceFile & cppSourceFile = project.GetSourceFile("test.cpp");
REQUIRE( cppSourceFile.GetFileName() == "test.cpp" );
REQUIRE( cppSourceFile.GetLanguage() == "C++" );
project.RemoveSourceFile("test.cpp");
REQUIRE( project.HasSourceFile("test.cpp") == false );
REQUIRE( project.HasSourceFile("test.js") == true );
}
}