当前位置: 首页>>代码示例>>C++>>正文


C++ state::has_empty_line方法代码示例

本文整理汇总了C++中state::has_empty_line方法的典型用法代码示例。如果您正苦于以下问题:C++ state::has_empty_line方法的具体用法?C++ state::has_empty_line怎么用?C++ state::has_empty_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在state的用法示例。


在下文中一共展示了state::has_empty_line方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:Skywalker13,项目名称:unigw,代码行数:80,代码来源:wpkg_changelog.cpp


注:本文中的state::has_empty_line方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。