/*
* simplecpp - A simple and high-fidelity C/C++ preprocessor library
* Copyright (C) 2016-2023 simplecpp team
*/
#define SIMPLECPP_TOKENLIST_ALLOW_PTR 0
#include "simplecpp.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static bool isDir(const std::string& path)
{
struct stat file_stat;
if (stat(path.c_str(), &file_stat) == -1)
return false;
return (file_stat.st_mode & S_IFMT) == S_IFDIR;
}
int main(int argc, char **argv)
{
bool error = false;
const char *filename = nullptr;
enum : std::uint8_t {
File,
Fstream,
Sstream,
CharBuffer
} toklist_inf = File;
bool fail_on_error = false;
bool linenrs = false;
// Settings..
simplecpp::DUI dui;
dui.removeComments = true;
bool quiet = false;
bool error_only = false;
for (int i = 1; i files;
simplecpp::TokenList outputTokens(files);
{
simplecpp::TokenList *rawtokens;
if (toklist_inf == Fstream) {
rawtokens = new simplecpp::TokenList(f,files,filename,&outputList);
}
else if (toklist_inf == Sstream || toklist_inf == CharBuffer) {
std::ostringstream oss;
oss removeComments();
simplecpp::FileDataCache filedata;
simplecpp::preprocess(outputTokens, *rawtokens, files, filedata, dui, &outputList);
simplecpp::cleanup(filedata);
delete rawtokens;
}
// Output
if (!quiet) {
if (!error_only)
std::cout