大概可以拿来方便拉模板

变量名、语法都是瞎整的你感觉有用随便用好了..

#include<bits/stdc++.h>
using namespace std;
map<string,int>fp;
inline bool is_space(char c){return c==' '||c=='\t';}
bool Strike(char*t,int len,const char*strpat){
for(int i=0;i<len;++i)
if(t[i]!=strpat[i])
return 0;
return 1;
}
void Copy_File(const char*filename,char*intd){
FILE*inFile=fopen(filename,"r");
char*Line_Buffer=new char[1<<20];
while(!feof(inFile)&&fgets(Line_Buffer,1<<20,inFile)){
// process line
printf("%s%s",intd,Line_Buffer);
}puts("");
}
void Process_File(const char*filename){
int len=strlen(filename);
string filename_string(filename,len);
if(fp[filename])return;
fp[filename]=1; FILE*inFile=fopen(filename,"r");
char*Line_Buffer=new char[1<<20];
char*Intend_Buffer=new char[1<<20]; while(!feof(inFile)&&fgets(Line_Buffer,1<<20,inFile)){
// process line
int len=strlen(Line_Buffer),int_siz=0,i=0;
for(;i<len;++i)
if(is_space(Line_Buffer[i]))
Intend_Buffer[int_siz++]=Line_Buffer[i];
else break;
if(Strike(Line_Buffer+i,5,"//cp_")){
// cp detected
if(Strike(Line_Buffer+i+5,8,"REQUIRE<")){
int t=i+13,z=0;
while(t<len&&Line_Buffer[t]!='>')++t,++z;
char*FileName=new char[z+2];
memcpy(FileName,Line_Buffer+i+13,z);
FileName[z]=0;
Process_File(FileName);
}else if(Strike(Line_Buffer+i+5,7,"INJECT<")){
int t=i+12,z=0;
while(t<len&&Line_Buffer[t]!='>')++t,++z;
char*FileName=new char[z+2];
memcpy(FileName,Line_Buffer+i+12,z);
FileName[z]=0;
Copy_File(FileName,Intend_Buffer);
}else printf("%s",Line_Buffer);
}else printf("%s",Line_Buffer);
}puts("");
}
int main(int argc,const char**argv){
if(argc<=1)
return puts("Usage: [exec_name] \"FileName\""),0;
Process_File(argv[1]);
// Process_File("cppptest1.cpp");
return 0;
}

C++ Contest Code preprocessor的更多相关文章

  1. WAVE文件格式解析

    WAVE 文件作为Windows多媒体中使用的声音波形文件格式之一,它是以RIFF(Resource Interchange File Format)格式为标准的.这里不针对RIFF文件格式做介绍,不 ...

  2. HDU 2096 小明A+B(%的运用)

    传送门: 小明A+B Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  3. 推荐一篇讲arm架构gcc内联汇编的文章

    这是来自ethernut网站的一篇文章,原文链接: http://www.ethernut.de/en/documents/arm-inline-asm.html 另外,据说nut/os是个不错的开源 ...

  4. YASM User Manual

    This document is the user manual for the Yasm assembler. It is intended as both an introduction and ...

  5. IOCCC(The International Obfuscated C Code Contest)

    国际 C 语言混乱代码大赛(IOCCC, The International Obfuscated C Code Contest)是一项国际编程赛事,从 1984 年开始,每年举办一次(1997年.1 ...

  6. 2015 Multi-University Training Contest 7 hdu 5375 Gray code

    Gray code Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  7. DISCO Presents Discovery Channel Code Contest 2020 Qual Task E. Majority of Balls

    Not able to solve this problem during the contest (virtual participation). The first observation is ...

  8. The North American Invitational Programming Contest 2018 E. Prefix Free Code

    Consider nn initial strings of lower case letters, where no initial string is a prefix of any other ...

  9. hdu 3461 Code Lock(并查集)2010 ACM-ICPC Multi-University Training Contest(3)

    想不到这还可以用并查集解,不过后来证明确实可以…… 题意也有些难理解—— 给你一个锁,这个所由n个字母组成,然后这个锁有m个区间,每次可以对一个区间进行操作,并且区间中的所有字母要同时操作.每次操作可 ...

随机推荐

  1. 漫谈Ajax在.Net中的使用

    引用地址:http://birdshover.cnblogs.com/archive/2006/07/03/441439.html AJAX出来的时间也不短了.虽然它在某些方面很受争议,但是瑕不掩瑜. ...

  2. centos7上基于kubernetes的docker集群管理

    kubernetes和docker的作用这里就不作介绍了,直接进入主题. 本文的目的是搭建docker集群,并使用kubernetes管理它们. 文中的软件环境除了kubernetes和docker, ...

  3. 十、Shell 函数

    Shell 函数 linux shell 可以用户定义函数,然后在shell脚本中可以随便调用. shell中函数的定义格式如下: [ function ] funname [()] { action ...

  4. 一、Shell 教程

    Shell 教程 Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 既是一种命令语言,又是一种程序设计语言. Shell 是指一种应用程序,这个应用程序提供了一个 ...

  5. 十、MySQL 删除数据表

    MySQL 删除数据表 MySQL中删除数据表是非常容易操作的, 但是你再进行删除表操作时要非常小心,因为执行删除命令后所有数据都会消失. 语法 以下为删除MySQL数据表的通用语法: DROP TA ...

  6. php扩展开发-函数

    我们首先找到快速上手文章里面关于函数定义的代码,以此说明然后开发PHP的函数 //php_myext.h PHP_FUNCTION(myext_hello);//函数申明,所有在myext.c文件定义 ...

  7. PHP 作用域

  8. 笔记1 python入门学习笔记

    目录 官方手册 菜鸟站手册地址: python的运行方法 注释 小技巧: input()接收用户输入的内容(默认为字符串) print() 运算符 is 是判断两个标识符是不是引用自一个对象 all和 ...

  9. Android中级教程之Android应用程序的生命周期

    Android应用程序的生命周期图 在大部分情况下,每个Android应用都将运行在自己的Linux进程中.当这个应用的某些代码需要执行时,进程就会被创建,并且将保持运行,直到该进程不再需要,而系统需 ...

  10. python之格式化

    python有两种方式可以格式化一种是用%s,一种使用format(2.6)进入的,从下面的代码可以看出,效果差不多. name = 'edward' age = 27 print("My ...