diff --git a/src/Core/Project.cs b/src/Core/Project.cs new file mode 100644 index 00000000..a2f4523a --- /dev/null +++ b/src/Core/Project.cs @@ -0,0 +1,114 @@ +using System.Collections.Generic; +using CppSharp.AST; +using CppSharp.Parser; + +namespace CppSharp +{ + /// + /// Represents a reference to a source file. + /// + public class SourceFile + { + /// + /// Gets the file name. + /// + public string Name + { + get { return System.IO.Path.GetFileName(Path); } + } + + /// + /// Gets the file path. + /// + public string Path { get; private set; } + + /// + /// Gets/sets the parser options for the file. + /// + public ParserOptions Options { get; set; } + + /// + /// Gets/sets the AST representation of the file. + /// + public TranslationUnit Unit { get; set; } + + public SourceFile(string path) + { + Path = path; + } + + public override string ToString() + { + return Path; + } + } + + /// + /// Represents a C++ project with source and library files. + /// + public class Project + { + /// + /// List of per-project C/C++ preprocessor defines. + /// + public IList Defines { get; private set; } + + /// + /// List of per-project C/C++ include directories. + /// + public IList IncludeDirs { get; private set; } + + /// + /// List of per-project C/C++ system include directories. + /// + public IList SystemIncludeDirs { get; private set; } + + /// + /// List of source files in the project. + /// + public IList Sources { get; private set; } + + /// + /// Main AST context with translation units for the sources. + /// + public ASTContext ASTContext { get; private set; } + + public Project() + { + Defines = new List(); + IncludeDirs = new List(); + SystemIncludeDirs = new List(); + + Sources = new List(); + } + + /// + /// Adds a new source file to the project. + /// + public SourceFile AddFile(string path) + { + var sourceFile = new SourceFile(path); + Sources.Add(sourceFile); + + return sourceFile; + } + + /// + /// Adds a group of source files to the project. + /// + public void AddFiles(IEnumerable paths) + { + foreach (var path in paths) + AddFile(path); + } + + /// + /// Adds a new source file to the project. + /// + public void AddFolder(string path) + { + var sourceFile = new SourceFile(path); + Sources.Add(sourceFile); + } + } +}