当前位置: 首页>>代码示例>>C++>>正文


C++ Project::HasSourceFile方法代码示例

本文整理汇总了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
}
开发者ID:Lizard-13,项目名称:GD,代码行数:40,代码来源:CppCodeEvent.cpp

示例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 );
    }
}
开发者ID:heyuqi,项目名称:GD,代码行数:30,代码来源:SourceFiles.cpp


注:本文中的gd::Project::HasSourceFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。