本文整理汇总了C++中file::is_of_phylum方法的典型用法代码示例。如果您正苦于以下问题:C++ file::is_of_phylum方法的具体用法?C++ file::is_of_phylum怎么用?C++ file::is_of_phylum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::is_of_phylum方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_copyright
void check_copyright(file const& f)
{
if
( f.is_of_phylum(e_gpl)
|| f.is_of_phylum(e_md5)
|| f.is_of_phylum(e_patch)
|| f.is_of_phylum(e_touchstone)
|| f.is_of_phylum(e_xml_input)
)
{
return;
}
std::time_t const t0 = std::time(nullptr);
std::tm const*const t1 = std::localtime(&t0);
LMI_ASSERT(nullptr != t1);
int const year = 1900 + t1->tm_year;
std::ostringstream oss;
oss << "Copyright \\(C\\)[^\\n]*" << year;
require(f, oss.str(), "lacks current copyright.");
if(f.is_of_phylum(e_html) && !f.phyloanalyze("^COPYING"))
{
std::ostringstream oss;
oss << "Copyright ©[^\\n]*" << year;
require(f, oss.str(), "lacks current secondary copyright.");
}
}
示例2: assay_whitespace
void assay_whitespace(file const& f)
{
if(contains(f.data(), '\r'))
{
throw std::runtime_error("File contains '\\r'.");
}
if(contains(f.data(), '\v'))
{
throw std::runtime_error("File contains '\\v'.");
}
if
( !f.is_of_phylum(e_gpl)
&& !f.is_of_phylum(e_touchstone)
&& contains(f.data(), '\f')
)
{
throw std::runtime_error("File contains '\\f'.");
}
if
( !f.is_of_phylum(e_gpl)
&& !f.is_of_phylum(e_make)
&& !f.is_of_phylum(e_patch)
&& !f.is_of_phylum(e_script)
&& contains(f.data(), '\t')
)
{
throw std::runtime_error("File contains '\\t'.");
}
static boost::regex const postinitial_tab("[^\\n]\\t");
if(f.is_of_phylum(e_make) && boost::regex_search(f.data(), postinitial_tab))
{
throw std::runtime_error("File contains postinitial '\\t'.");
}
if
( !f.is_of_phylum(e_gpl)
&& !f.is_of_phylum(e_touchstone)
&& contains(f.data(), "\n\n\n")
)
{
complain(f, "contains '\\n\\n\\n'.");
}
if
( !f.is_of_phylum(e_patch)
&& contains(f.data(), " \n")
)
{
complain(f, "contains ' \\n'.");
}
}
示例3: check_reserved_names
void check_reserved_names(file const& f)
{
// Remove this exception once this file has been reworked.
if(f.phyloanalyze("^ledger_xml_io.cpp$"))
{
return;
}
if(f.is_of_phylum(e_log))
{
return;
}
static boost::regex const r("(\\b\\w*__\\w*\\b)");
boost::sregex_iterator i(f.data().begin(), f.data().end(), r);
boost::sregex_iterator const omega;
for(; i != omega; ++i)
{
boost::smatch const& z(*i);
std::string const s = z[0];
static boost::regex const not_all_underscore("[A-Za-z0-9]");
if
( !check_reserved_name_exception(s)
&& boost::regex_search(s, not_all_underscore)
)
{
std::ostringstream oss;
oss << "contains reserved name '" << s << "'.";
complain(f, oss.str());
}
}
}
示例4: check_label_indentation
void check_label_indentation(file const& f)
{
if(!f.is_of_phylum(e_c_or_cxx))
{
return;
}
static boost::regex const r("\\n( *)([A-Za-z][A-Za-z0-9_]*)( *:)(?!:)");
boost::sregex_iterator i(f.data().begin(), f.data().end(), r);
boost::sregex_iterator const omega;
for(; i != omega; ++i)
{
boost::smatch const& z(*i);
if
( "default" != z[2]
&& " " != z[1]
&& " " != z[1]
)
{
std::ostringstream oss;
oss << "has misindented label '" << z[1] << z[2] << z[3] << "'.";
complain(f, oss.str());
}
}
}
示例5: check_preamble
void check_preamble(file const& f)
{
if
( f.is_of_phylum(e_gpl)
|| f.is_of_phylum(e_md5)
|| f.is_of_phylum(e_patch)
|| f.is_of_phylum(e_rates)
|| f.is_of_phylum(e_touchstone)
|| f.is_of_phylum(e_xml_input)
)
{
return;
}
static std::string const url("http://savannah.nongnu.org/projects/lmi");
require(f, url, "lacks lmi URL.");
}
示例6: check_config_hpp
void check_config_hpp(file const& f)
{
static std::string const loose ("# *include *[<\"]config.hpp[>\"]");
static std::string const strict ("\\n(#include \"config.hpp\")\\n");
static std::string const indent ("\\n(# include \"config.hpp\")\\n");
if
( f.is_of_phylum(e_log)
|| f.phyloanalyze("^test_coding_rules_test.sh$")
|| f.phyloanalyze("^GNUmakefile$")
|| f.phyloanalyze("^pchfile(_.*)?\\.hpp$")
)
{
return;
}
else if(f.is_of_phylum(e_header) && f.phyloanalyze("^pchlist(_.*)?\\.hpp$"))
{
require(f, loose , "must include 'config.hpp'.");
require(f, indent, "lacks line '# include \"config.hpp\"'.");
boost::smatch match;
static boost::regex const first_include("(# *include[^\\n]*)");
boost::regex_search(f.data(), match, first_include);
if("# include \"config.hpp\"" != match[1])
{
complain(f, "must include 'config.hpp' first.");
}
}
else if(f.is_of_phylum(e_header) && !f.phyloanalyze("^config(_.*)?\\.hpp$"))
{
require(f, loose , "must include 'config.hpp'.");
require(f, strict, "lacks line '#include \"config.hpp\"'.");
boost::smatch match;
static boost::regex const first_include("(# *include[^\\n]*)");
boost::regex_search(f.data(), match, first_include);
if("#include \"config.hpp\"" != match[1])
{
complain(f, "must include 'config.hpp' first.");
}
}
else
{
forbid(f, loose, "must not include 'config.hpp'.");
}
}
示例7: check_cxx
void check_cxx(file const& f)
{
// Remove this once these files have been rewritten.
if(f.phyloanalyze("^md5.[ch]pp$"))
{
return;
}
if(!f.is_of_phylum(e_c_or_cxx))
{
return;
}
{
static boost::regex const r("(\\w+)( +)([*&])(\\w+\\b)([*;]?)([^\\n]*)");
boost::sregex_iterator i(f.data().begin(), f.data().end(), r);
boost::sregex_iterator const omega;
for(; i != omega; ++i)
{
boost::smatch const& z(*i);
if
( "return" != z[1] // 'return *p'
&& "nix" != z[4] // '*nix'
&& !('*' == z[3] && '*' == z[5]) // '*emphasis*' in comment
&& !('&' == z[3] && ';' == z[5]) // ' '
)
{
std::ostringstream oss;
oss << "should fuse '" << z[3] << "' with type: '" << z[0] << "'.";
complain(f, oss.str());
}
}
}
{
static boost::regex const r("\\bconst +([A-Za-z][A-Za-z0-9_:]*) *[*&]");
boost::sregex_iterator i(f.data().begin(), f.data().end(), r);
boost::sregex_iterator const omega;
for(; i != omega; ++i)
{
boost::smatch const& z(*i);
if
( "volatile" != z[1] // 'const volatile'
)
{
std::ostringstream oss;
oss
<< "should write 'const' after the type it modifies: '"
<< z[0]
<< "'."
;
complain(f, oss.str());
}
}
}
}
示例8: check_include_guards
void check_include_guards(file const& f)
{
if(!f.is_of_phylum(e_cxx_header))
{
return;
}
std::string const guard = boost::regex_replace
(f.leaf_name()
,boost::regex("\\.hpp$")
,"_hpp"
);
std::string const guards =
"\\n#ifndef " + guard
+ "\\n#define " + guard + "\\n"
+ ".*"
+ "\\n#endif // " + guard + "\\n+$"
;
require(f, guards, "lacks canonical header guards.");
}
示例9: check_logs
void check_logs(file const& f)
{
if(!f.is_of_phylum(e_log))
{
return;
}
std::string entries = f.data();
entries.erase(0, entries.find("\nMAINTENANCE\n"));
if(entries.empty())
{
complain(f, "lacks expected 'MAINTENANCE' line.");
entries = f.data();
}
static boost::regex const r("\\n(?!\\|)(?! *https?:)([^\\n]{71,})(?=\\n)");
boost::sregex_iterator i(entries.begin(), entries.end(), r);
boost::sregex_iterator const omega;
if(omega == i)
{
return;
}
std::ostringstream oss;
oss
<< "violates seventy-character limit:\n"
<< "0000000001111111111222222222233333333334444444444555555555566666666667\n"
<< "1234567890123456789012345678901234567890123456789012345678901234567890"
;
for(; i != omega; ++i)
{
boost::smatch const& z(*i);
oss << '\n' << z[1];
}
complain(f, oss.str());
}
示例10: analyze_file
statistics statistics::analyze_file(file const& f)
{
statistics z;
if
( f.is_of_phylum(e_binary)
|| f.is_of_phylum(e_expungible)
|| f.is_of_phylum(e_gpl)
|| f.is_of_phylum(e_log)
|| f.is_of_phylum(e_md5)
|| f.is_of_phylum(e_patch)
|| f.is_of_phylum(e_touchstone)
|| f.is_of_phylum(e_xml_input)
|| f.phyloanalyze("^INSTALL")
|| f.phyloanalyze("^README")
)
{
return z;
}
++z.files_;
std::string const& s = f.data();
for(std::string::size_type i = 1; i < s.size(); ++i)
{
if('\n' == s[i])
{
++z.lines_;
}
if('?' == s[i - 1] && '?' == s[i])
{
++z.defects_;
}
}
return z;
}
示例11: enforce_taboos
void enforce_taboos(file const& f)
{
if
( f.phyloanalyze("test_coding_rules")
|| f.phyloanalyze("^md5sums$")
)
{
return;
}
// ASCII copyright symbol requires upper-case 'C'.
taboo(f, "\\(c\\) *[0-9]");
// Former addresses of the Free Software Foundation.
taboo(f, "Cambridge");
taboo(f, "Temple");
// Patented.
taboo(f, "\\.gif", boost::regex::icase);
// Obsolete email address.
taboo(f, "[email protected]");
// Obscured email address.
taboo(f, "[email protected]");
// Certain proprietary libraries.
taboo(f, "\\bowl\\b", boost::regex::icase);
taboo(f, "vtss", boost::regex::icase);
// Suspiciously specific to msw.
taboo(f, "Microsoft");
taboo(f, "Visual [A-Z]");
taboo(f, "\\bWIN\\b");
taboo(f, "\\bExcel\\b");
// Insinuated by certain msw tools.
taboo(f, "Microsoft Word");
taboo(f, "Stylus Studio");
taboo(f, "Sonic Software");
// This IANA-approved charset is still useful for html.
if(!f.is_of_phylum(e_html))
{
taboo(f, "windows-1252");
}
taboo(f, "Arial");
if
( !f.is_of_phylum(e_log)
&& !f.is_of_phylum(e_make)
&& !f.is_of_phylum(e_synopsis)
)
{
taboo(f, "\\bexe\\b", boost::regex::icase);
}
if
( !f.is_of_phylum(e_make)
&& !f.is_of_phylum(e_patch)
&& !f.phyloanalyze("config.hpp")
&& !f.phyloanalyze("configure.ac") // GNU libtool uses 'win32-dll'.
)
{
taboo(f, "WIN32", boost::regex::icase);
}
if
( !boost::regex_search(f.data(), boost::regex(my_taboo_indulgence()))
&& !contains(f.data(), "Automatically generated from custom input.")
)
{
// Unspeakable private taboos.
std::map<std::string, bool> const z = my_taboos();
typedef std::map<std::string, bool>::const_iterator mci;
for(mci i = z.begin(); i != z.end(); ++i)
{
boost::regex::flag_type syntax =
i->second
? boost::regex::ECMAScript | boost::regex::icase
: boost::regex::ECMAScript
;
taboo(f, i->first, syntax);
}
}
}