cpp-include
Collect path of #include
directive on C/C++ source code.
const cppInclude = ; cppInclude;/* [ { path: "myapp.h", local: true },]*/cppInclude;/* [ { path: "iostream", local: false }, { path: "mylib.h", local: true },]*/
local
represents whether include directive is quoted-form (local: true
) or
angle-bracket form (local: false
)
If want to input source code string rather than path, use
getIncludeFilesFromString
var src = "#include <iostream>\n#include \"mylib.h\"";cppInclude;/* [ { path: "iostream", local: false }, { path: "mylib.h", local: true },]*/
Find the actual full path of include file
Return items of getIncludeFiles
and getIncludeFilesFromString
respectively
has two additional members: find
and origin
.
origin
represents the path of the C/C++ source code that was passed togetIncludeFiles
.- This value can be changed at any time, changing it affects the
find
method. - NOTE: Semantically this value MUST be file path rather than
directory path. But
find
method can work fine as long as specified directory exist. SeeensureDirname
internal function to learn why.
- This value can be changed at any time, changing it affects the
find
is the method to accuire the actual location on the machine.- When
local
istrue
, this method try to find from the following directories:origin
- 1st argument of this method (string, or Array of string)
CPATH
(Linux/Mac) orINCLUDE
(Windows)
- Otherwise (
local
isfalse
)- 1st argument of this method (string, or Array of string)
CPATH
(Linux/Mac) orINCLUDE
(Windows)
- When
cppInclude 0 ;// C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream cppInclude 0 ;// C:\Users\retorillo\include\mylib.h
License
Distirubted under the MIT license
Copyright (C) 2017 Retorillo