本文整理汇总了C++中state::next_line方法的典型用法代码示例。如果您正苦于以下问题:C++ state::next_line方法的具体用法?C++ state::next_line怎么用?C++ state::next_line使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state
的用法示例。
在下文中一共展示了state::next_line方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: good_header
/** \brief Parse a line from a version entry.
*
* This function reads the header (one line), a list of logs, and then
* the footer of a version entry.
*
* If a version exists, even if it is wrong, the function returns true.
* The function returns false if the end of the file is reached.
*
* \param[in] s The state to read from.
*
* \return true if the end of the file was not yet reached when this
* version was read in full.
*/
bool changelog_file::version::parse(state& s)
{
f_filename = s.get_filename();
f_line = s.get_line();
// the current line must be the header
if(s.space_count() != 0)
{
wpkg_output::log("changelog:%1:%2: a changelog version entry must start with a valid header")
.arg(f_filename)
.arg(f_line)
.level(wpkg_output::level_error)
.module(wpkg_output::module_build_package)
.action("changelog");
return s.next_line();
}
bool good_header(true);
const std::string& header(s.last_line());
const char *h(header.c_str());
const char *start(h);
// *** Package Name ***
for(; !isspace(*h) && *h != '('; ++h)
{
if(*h == '\0')
{
wpkg_output::log("changelog:%1:%2: invalid header, expected the project name, version, distributions, and urgency information")
.arg(f_filename)
.arg(f_line)
.level(wpkg_output::level_error)
.module(wpkg_output::module_build_package)
.action("changelog");
good_header = false;
break;
}
}
if(good_header)
{
std::string package_name(start, h - start);
if(!wpkg_util::is_package_name(package_name))
{
wpkg_output::log("changelog:%1:%2: the package name %3 is not valid")
.arg(f_filename)
.arg(f_line)
.quoted_arg(package_name)
.level(wpkg_output::level_error)
.module(wpkg_output::module_build_package)
.action("changelog");
}
else
{
f_package = package_name;
}
if(!isspace(*h))
{
// this is just a warning, but the user is expected to put a space
// after the package name and before the version
wpkg_output::log("changelog:%1:%2: the package name %3 is not followed by a space before the version information")
.arg(f_filename)
.arg(f_line)
.quoted_arg(package_name)
.level(wpkg_output::level_warning)
.module(wpkg_output::module_build_package)
.package(f_package)
.action("changelog");
good_header = false;
}
}
// *** Version ***
if(good_header)
{
for(; isspace(*h); ++h);
if(*h != '(')
{
wpkg_output::log("changelog:%1:%2: invalid header, expected the version between parenthesis after the package name")
.arg(f_filename)
.arg(f_line)
.level(wpkg_output::level_error)
.module(wpkg_output::module_build_package)
.package(f_package)
.action("changelog");
good_header = false;
}
//.........这里部分代码省略.........
示例2: log_line
/** \brief Parse one line of log.
*
* This function reads one line of log. Note that one line of log may appear
* on multiple lines in the changelog file. One line ends when there is an
* empty line, a line that does not start with at least 2 spaces, a line
* that starts with an asterisk after the 2 spaces.
*
* \param[in] s The state describing the input parameters.
* \param[in] group Whether this log is a group entry.
*
* \return true if the end of the file was not yet reached.
*/
bool changelog_file::version::log::parse(state& s, bool& group)
{
f_filename = s.get_filename();
f_line = s.get_line();
f_is_group = group;
group = false;
if(s.space_count() != 2)
{
// invalid log entry; must start with 2 spaces
return false;
}
std::string log_line(s.last_line());
if(log_line[0] != '*')
{
// a new log entry must starts with an asterisk
wpkg_output::log("changelog:%1:%2: a changelog log entry must start with an asterisk")
.arg(f_filename)
.arg(f_line)
.level(wpkg_output::level_error)
.module(wpkg_output::module_build_package)
.action("changelog");
return false;
}
for(;;)
{
// right trim the f_log (it automatically is left trimmed)
std::string::size_type p(f_log.find_last_not_of(" \t\n\r\v\f"));
if(p != std::string::npos)
{
f_log = f_log.substr(0, p + 1);
}
// check whether there is more data that should be added to the log
// line; if not, leave it there and return, it should be an empty line
// a new log, or the maintainer information.
if(!s.next_line())
{
break;
}
if(s.has_empty_line())
{
// we bumped in an empty line, we are starting a new group.
group = true;
break;
}
// really we should have exactly 4 spaces...
if(s.space_count() < 2)
{
break;
}
std::string new_line(s.last_line());
if(new_line[0] == '*')
{
break;
}
f_log += " ";
f_log += new_line;
}
f_log = log_line;
// TODO: find the bugs stuff
return true;
}