📄 snip5.cpp
字号:
/* * * Copyright (c) 1998-2000 * Dr John Maddock * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Dr John Maddock makes no representations * about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * */#include <string>#include <map>#include <regex>// purpose:// takes the contents of a file in the form of a string// and searches for all the C++ class definitions, storing// their locations in a map of strings/int'stypedef std::map<std::string, int, std::less<std::string> > map_type;regex expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?(\\{|:[^;\\{()]*\\{)");map_type class_index;std::string::const_iterator base;bool grep_callback(const reg_match<std::string::const_iterator, regex::alloc_type>& what){ // what[0] contains the whole string // what[5] contains the class name. // what[6] contains the template specialisation if any. // add class name and position to map: class_index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] = what[5].first - base; return true;}void IndexClasses(const std::string& file){ std::string::const_iterator start, end; start = file.begin(); end = file.end(); base = start; reg_grep(grep_callback, start, end, expression, match_default);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -