• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ cstring类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: while

void
config_file_iterator::Impl::substitute_macros( cstring& where )
{
    m_post_subst_line.clear();
    cstring::size_type pos;

    while( (pos = where.find( m_macro_ref_begin )) != cstring::npos ) {
        m_post_subst_line.append( where.begin(), pos );

        where.trim_left( where.begin() + pos + m_macro_ref_begin.size() );

        pos = where.find( m_macro_ref_end );

        BOOST_RT_PARAM_VALIDATE_LOGIC( pos != cstring::npos, BOOST_RT_PARAM_LITERAL( "incomplete macro reference" ) );

        cstring value = *get_macro_value( where.substr( 0, pos ), false );
        m_post_subst_line.append( value.begin(), value.size() );

        where.trim_left( where.begin() + pos + m_macro_ref_end.size() );
    }

    if( !m_post_subst_line.empty() ) {
        m_post_subst_line.append( where.begin(), where.size() );
        where = m_post_subst_line;
    }
}
开发者ID:jinby,项目名称:autoupdate,代码行数:26,代码来源:config_file_iterator.cpp


示例2: m_parent

include_level::include_level( cstring file_name, cstring path_separators, include_level* parent_ )
: m_parent( parent_ )
{
    if( file_name.is_empty() )
        return;

    assign_op( m_curr_location.first, file_name, 0 );
    m_curr_location.second = 0;

    m_stream.open( m_curr_location.first.c_str() );

    if( !m_stream.is_open() && !!m_parent.get() ) {
        cstring            parent_path = m_parent->m_curr_location.first;
        cstring::iterator  it          = unit_test::find_last_of( parent_path.begin(), parent_path.end(),
                                                                  path_separators.begin(),
                                                                  path_separators.end() );

        if( it != parent_path.end() ) {
            assign_op( m_curr_location.first, cstring( parent_path.begin(), it+1 ), 0 );
            m_curr_location.first.append( file_name.begin(), file_name.end() );
            m_stream.clear();
            m_stream.open( m_curr_location.first.c_str() );
        }
    }

    BOOST_RT_PARAM_VALIDATE_LOGIC( m_stream.is_open(), BOOST_RT_PARAM_LITERAL( "couldn't open file " ) << file_name );
}
开发者ID:jinby,项目名称:autoupdate,代码行数:27,代码来源:config_file_iterator.cpp


示例3: _

    static bool _( cstring source, boost::optional<bool>& res )
    {
        BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<bool>" );

        static literal_cstring YES( BOOST_RT_PARAM_CSTRING_LITERAL( "YES" ) );
        static literal_cstring Y( BOOST_RT_PARAM_CSTRING_LITERAL( "Y" ) );
        static literal_cstring NO( BOOST_RT_PARAM_CSTRING_LITERAL( "NO" ) );
        static literal_cstring N( BOOST_RT_PARAM_CSTRING_LITERAL( "N" ) );
        static literal_cstring one( BOOST_RT_PARAM_CSTRING_LITERAL( "1" ) );
        static literal_cstring zero( BOOST_RT_PARAM_CSTRING_LITERAL( "0" ) );

        source.trim();

        if( case_ins_eq( source, YES ) || case_ins_eq( source, Y ) || case_ins_eq( source, one ) ) {
            res = true;
            return true;
        }
        else if( case_ins_eq( source, NO ) || case_ins_eq( source, N ) || case_ins_eq( source, zero ) ) {
            res = false;
            return true;
        }
        else {
            res = true;
            return source.is_empty();
        }
    }
开发者ID:ksundberg,项目名称:boost-svn,代码行数:26,代码来源:interpret_argument_value.hpp


示例4: putenv_impl

inline void
putenv_impl( cstring name, cstring value )
{
    using namespace std;
    // !! this may actually fail. What should we do?
    setenv( name.begin(), value.begin(), 1 );
}
开发者ID:argv0,项目名称:riak-cxx,代码行数:7,代码来源:config.hpp


示例5: interpret

    bool    interpret( cstring param_name, cstring source ) const
    {
        static cstring const s_YES( "YES" );
        static cstring const s_Y( "Y" );
        static cstring const s_NO( "NO" );
        static cstring const s_N( "N" );
        static cstring const s_TRUE( "TRUE" );
        static cstring const s_FALSE( "FALSE" );
        static cstring const s_one( "1" );
        static cstring const s_zero( "0" );

        source.trim();

        if( source.is_empty() ||
            case_ins_eq( source, s_YES ) ||
            case_ins_eq( source, s_Y ) ||
            case_ins_eq( source, s_one ) ||
            case_ins_eq( source, s_TRUE ) )
            return true;

        if( case_ins_eq( source, s_NO ) ||
            case_ins_eq( source, s_N ) ||
            case_ins_eq( source, s_zero ) ||
            case_ins_eq( source, s_FALSE ) )
            return false;

        BOOST_TEST_I_THROW( format_error( param_name ) << source << " can't be interpreted as bool value." );
    }
开发者ID:betajippity,项目名称:Nuparu,代码行数:28,代码来源:argument_factory.hpp


示例6: fromstringhex

bool fromstringhex(cstring s, arrayvieww<byte> val)
{
	if (val.size()*2 != s.length()) return false;
	bool ok = true;
	for (size_t i=0;i<val.size();i++)
	{
		ok &= fromstringhex(s.substr(i*2, i*2+2), val[i]);
	}
	return ok;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:10,代码来源:stringconv.cpp


示例7: translateRk86

string translateRk86(cstring in) {
  string out;
  out.resize(in.size());
  const char* inp = in.c_str();
  char* o = (char*)out.c_str();
  while(*inp) {
    char c = translateRk86c(*inp++);
    if(c==0) raise("Имя файла "+in+" содержит неподдерживаемый РК86 символ.");
    *o++ = c;
  }
  return out;
}
开发者ID:VWarlock,项目名称:Apogey_BK01_Rom_Disk,代码行数:12,代码来源:translaterk86.cpp


示例8: type_core

bmlwriter::mode bmlwriter::type_core(cstring val)
{
	if (val == "") return anon;
	
	char first = val[0];
	char last = val[val.length()-1];
	
	if (val.contains("\n") || first==' ' || first=='\t' || last==' ' || last=='\t') return multiline;
	if (val.contains("\"")) return col;
	if (val.contains(" ") || val.contains("\t")) return quote;
	return eq;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:12,代码来源:bmlwrite.cpp


示例9: escape

string bmlwriter::escape(cstring val)
{
	string esc = "-";
	bool needescape = (val.startswith("-"));
	for (byte c : val.bytes())
	{
		if (isalnum(c) || c=='.') esc+=c;
		else if (c=='-') esc+="--";
		else { esc+="-"+tostringhex<2>((uint8_t)c); needescape=true; }
	}
	if (needescape) return esc;
	else return val;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:13,代码来源:bmlwrite.cpp


示例10: fromstring

bool fromstring(cstring s, double& out)
{
	out = 0;
	auto tmp_s = s.c_str();
	const char * tmp_cp = tmp_s;
	if (*tmp_cp != '-' && !isdigit(*tmp_cp)) return false;
	char * tmp_cpo;
	double ret = strtod(drop0x(tmp_cp), &tmp_cpo);
	if (tmp_cpo != tmp_cp + s.length()) return false;
	if (!isdigit(tmp_cpo[-1])) return false;
	if (ret==HUGE_VAL || ret==-HUGE_VAL) return false;
	out = ret;
	return true;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:14,代码来源:stringconv.cpp


示例11: basic_param

 basic_param( cstring name, bool is_optional, bool is_repeatable, Modifiers const& m )
 : p_name( name.begin(), name.end() )
 , p_description( nfp::opt_get( m, description, std::string() ) )
 , p_help( nfp::opt_get( m, runtime::help, std::string() ) )
 , p_env_var( nfp::opt_get( m, env_var, std::string() ) )
 , p_value_hint( nfp::opt_get( m, value_hint, std::string() ) )
 , p_optional( is_optional )
 , p_repeatable( is_repeatable )
 , p_has_optional_value( m.has( optional_value ) )
 , p_has_default_value( m.has( default_value ) || is_repeatable )
 , p_callback( nfp::opt_get( m, callback, callback_type() ) )
 {
     add_cla_id( help_prefix, name, ":" );
 }
开发者ID:betajippity,项目名称:Nuparu,代码行数:14,代码来源:parameter.hpp


示例12: linelen

static size_t linelen(const cstring& input)
{
	//pointers are generally a bad idea, but this is such a hotspot it's worth it
	const uint8_t * inputraw = input.bytes().ptr();
	size_t nlpos = 0;
	if (input.bytes_hasterm())
	{
		while (!isendl(inputraw[nlpos])) nlpos++;
	}
	else
	{
		size_t inputlen = input.length();
		while (nlpos < inputlen && !isendl(inputraw[nlpos])) nlpos++;
	}
	return nlpos;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:16,代码来源:bmlparse.cpp


示例13: bml_size_white

//returns size of leading whitespace and comments
static size_t bml_size_white(const cstring& data)
{
	int i = 0;
	while (data[i]==' ' || data[i]=='\t') i++;
	if (data[i]=='#' || (data[i]=='/' && data[i+1]=='/')) return data.length();
	else return i;
}
开发者ID:Alcaro,项目名称:Arlib,代码行数:8,代码来源:bmlparse.cpp


示例14: is_valid_identifier

static bool
is_valid_identifier( cstring const& source )
{
    if( source.is_empty() )
        return false;

    cstring::const_iterator it = source.begin();

    if( !std::isalpha( *it ) )
        return false;

    while( ++it < source.end() ) {
        if( !std::isalnum( *it ) && *it != BOOST_RT_PARAM_LITERAL( '_' ) && *it != BOOST_RT_PARAM_LITERAL( '-' ) )
            return false;
    }

    return true;
}
开发者ID:esoobservatory,项目名称:fitsliberator,代码行数:18,代码来源:config_file_iterator.cpp


示例15: while

cstring ReferenceMap::newName(cstring base) {
    // Maybe in the future we'll maintain information with per-scope identifiers,
    // but today we are content to generate globally-unique identifiers.

    // If base has a suffix of the form _(\d+), then we discard the suffix.
    // under the assumption that it is probably a generated suffix.
    // This will not impact correctness.
    unsigned len = base.size();
    const char digits[] = "0123456789";
    const char* s = base.c_str();
    while (len > 0 && strchr(digits, s[len-1])) len--;
    if (len > 0 && base[len - 1] == '_')
        base = base.substr(0, len - 1);

    cstring name = cstring::make_unique(usedNames, base, '_');
    usedNames.insert(name);
    return name;
}
开发者ID:ederollora,项目名称:p4c,代码行数:18,代码来源:referenceMap.cpp


示例16: replace

static string replace(char c1, char c2, cstring s) {
	StringBuffer buf;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == c1)
			buf << c2;
		else
			buf << s[i];
	}
	return buf.toString();
}
开发者ID:alexjordan,项目名称:otawa,代码行数:10,代码来源:cfgio_Output.cpp


示例17:

void
config_file_iterator::Impl::process_else( cstring line )
{
    BOOST_RT_PARAM_VALIDATE_LOGIC( m_conditional_states.size() > 0 && m_conditional_states.back(),
                                   BOOST_RT_PARAM_LITERAL( "else without matching if" ) );

    m_inactive_ifdef_level = m_conditional_states.size() == m_inactive_ifdef_level ? 0 : m_conditional_states.size();

    BOOST_RT_PARAM_VALIDATE_LOGIC( line.is_empty(), BOOST_RT_PARAM_LITERAL( "unexpected tokens at the end of else command" ) );
}
开发者ID:esoobservatory,项目名称:fitsliberator,代码行数:10,代码来源:config_file_iterator.cpp


示例18: targetif

messagewin::messagewin(cstring p, cstring opt):
	  targetif(targetif::query_target), 
	  toplevel(p.lower(), opt)
{
	sessionid = 0;
	info = false;
	serverentry = NULL;
	build_messagewindow(this);
	bindings();
}
开发者ID:iivvoo-abandoned,项目名称:circus,代码行数:10,代码来源:querywin.c


示例19: interpret_argument_value

inline bool
interpret_argument_value( cstring source, hexerboost::optional<std::list<T> >& res, int )
{
    BOOST_RT_PARAM_TRACE( "In interpret_argument_value<std::list<T>>" );

    res = std::list<T>();

    while( !source.is_empty() ) {
        // !! should we use token_iterator
        cstring::iterator single_value_end = std::find( source.begin(), source.end(), BOOST_RT_PARAM_LITERAL( ',' ) );

        hexerboost::optional<T> value;
        interpret_argument_value( cstring( source.begin(), single_value_end ), value, 0 );

        res->push_back( *value );

        source.trim_left( single_value_end + 1 );
    }

    return true;
}
开发者ID:gijs,项目名称:hexer,代码行数:21,代码来源:interpret_argument_value.hpp


示例20: flatten

void StructTypeReplacement::flatten(const P4::TypeMap* typeMap,
                                    cstring prefix,
                                    const IR::Type* type,
                                    IR::IndexedVector<IR::StructField> *fields) {
    if (auto st = type->to<IR::Type_Struct>()) {
        structFieldMap.emplace(prefix, st);
        for (auto f : st->fields)
            flatten(typeMap, prefix + "." + f->name, f->type, fields);
        return;
    }
    cstring fieldName = prefix.replace(".", "_") +
                        cstring::to_cstring(fieldNameRemap.size());
    fieldNameRemap.emplace(prefix, fieldName);
    fields->push_back(new IR::StructField(IR::ID(fieldName), type->getP4Type()));
}
开发者ID:ederollora,项目名称:p4c,代码行数:15,代码来源:flattenInterfaceStructs.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ctkLogger类代码示例发布时间:2022-05-31
下一篇:
C++ csString类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap