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


C++ char_type函数代码示例

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


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

示例1: switch

void InsetMathChar::htmlize(HtmlStream & ms) const
{
	std::string entity;
	switch (char_) {
		case '<': entity = "&lt;"; break;
		case '>': entity = "&gt;"; break;
		case '&': entity = "&amp;"; break;
		case ' ': entity = "&nbsp;"; break;
		default: break;
	}
	
	bool have_entity = !entity.empty();
	
	if (ms.inText()) {
		if (have_entity)
			ms << from_ascii(entity);
		else
			ms.os().put(char_);
		return;
	}
	
	if (have_entity) {
		// an operator, so give some space
		ms << ' ' << from_ascii(entity) << ' ';
		return;
	}		

	if (isalpha(char_) || Encodings::isMathAlpha(char_))
		// we don't use MTag and ETag because we do not want the spacing
		ms << MTag("i") << char_type(char_) << ETag("i");
	else
		// an operator, so give some space
		ms << " " << char_type(char_) << " ";
}
开发者ID:rpavlik,项目名称:lyx-lucid-backport,代码行数:34,代码来源:InsetMathChar.cpp

示例2: exprt

string_constantt::string_constantt(const irep_idt &_value):
  exprt(ID_string_constant)
{
  set_value(_value);
  type()=array_typet();
  type().subtype()=char_type();
}
开发者ID:sarnold,项目名称:cbmc,代码行数:7,代码来源:string_constant.cpp

示例3: NS_RUNTIMEABORT

void
nsTSubstring_CharT::StripChars( const char_type* aChars, uint32_t aOffset )
  {
    if (aOffset >= uint32_t(mLength))
      return;

    if (!EnsureMutable()) // XXX do this lazily?
      NS_RUNTIMEABORT("OOM");

    // XXX(darin): this code should defer writing until necessary.

    char_type* to   = mData + aOffset;
    char_type* from = mData + aOffset;
    char_type* end  = mData + mLength;

    while (from < end)
      {
        char_type theChar = *from++;
        const char_type* test = aChars;

        for (; *test && *test != theChar; ++test);

        if (!*test) {
          // Not stripped, copy this char.
          *to++ = theChar;
        }
      }
    *to = char_type(0); // add the null
    mLength = to - mData;
  }
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:30,代码来源:nsTSubstring.cpp

示例4: exprt

string_constantt::string_constantt():
  exprt(ID_string_constant)
{
  set_value(irep_idt());
  type()=typet(ID_array);
  type().subtype()=char_type();
}
开发者ID:ashokkelur,项目名称:CBMC-With-DSP-C,代码行数:7,代码来源:string_constant.cpp

示例5: main

int main(void)
{
	char input[10];
	char letter;
	int result;
	int char_check;

	while(1 == 1) {
		(void)printf("Enter letter, or non letter to quit: ");
		(void)fgets(input, sizeof(input), stdin);
		result = sscanf(input, "%c", &letter);

		if (result != 1) {
			break;
		}

		char_check = char_type(letter);
		if (char_check == 1) {
			(void)printf("You entered a vowel.\n");
		} else if (char_check == -1) {
			(void)printf("You entered a consonant.\n");
		} else {
			(void)printf("You did not enter a letter.  Bye!\n");
			break;
		}
	}

	return 0;
}
开发者ID:akydd,项目名称:practicalc,代码行数:29,代码来源:6.c

示例6: pimpl_

string16_t::string16_t( const char_type *str, std::size_t size) : pimpl_( 0)
{
    init();
    pimpl_->str_.reserve( size + 1);
    pimpl_->str_.assign( str, str + size);
    pimpl_->str_.push_back( char_type( 0));
}
开发者ID:elanifegnirf,项目名称:ramenlibs,代码行数:7,代码来源:string16.cpp

示例7: copy

void
nsACString::StripChars(const char *aSet)
{
  nsCString copy(*this);

  const char_type *source, *sourceEnd;
  copy.BeginReading(&source, &sourceEnd);

  char_type *dest;
  BeginWriting(&dest);
  if (!dest)
    return;

  char_type *curDest = dest;

  for (; source < sourceEnd; ++source) {
    const char *test;
    for (test = aSet; *test; ++test) {
      if (*source == char_type(*test))
        break;
    }

    if (!*test) {
      // not stripped, copy this char
      *curDest = *source;
      ++curDest;
    }
  }

  SetLength(curDest - dest);
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:31,代码来源:nsStringAPI.cpp

示例8:

_LIBCPP_CONSTEXPR_AFTER_CXX11 size_t
constexpr_char_traits<_CharT>::length(const char_type* __s)
{
    size_t __len = 0;
    for (; !eq(*__s, char_type(0)); ++__s)
        ++__len;
    return __len;
}
开发者ID:0xDEC0DE8,项目名称:ndk,代码行数:8,代码来源:constexpr_char_traits.hpp

示例9: function_to_call

code_function_callt function_to_call(
  symbol_tablet &symbol_table,
  const irep_idt &id,
  const irep_idt &argument)
{
  // already there?

  symbol_tablet::symbolst::const_iterator s_it=
    symbol_table.symbols.find(id);

  if(s_it==symbol_table.symbols.end())
  {
    // not there
    pointer_typet p(char_type());
    p.subtype().set(ID_C_constant, true);

    code_typet function_type;
    function_type.return_type()=empty_typet();
    function_type.parameters().push_back(
      code_typet::parametert(p));

    symbolt new_symbol;
    new_symbol.name=id;
    new_symbol.base_name=id;
    new_symbol.type=function_type;

    symbol_table.move(new_symbol);

    s_it=symbol_table.symbols.find(id);
    assert(s_it!=symbol_table.symbols.end());
  }

  // signature is expected to be
  // (type *) -> ...
  if(s_it->second.type.id()!=ID_code ||
     to_code_type(s_it->second.type).parameters().size()!=1 ||
     to_code_type(s_it->second.type).parameters()[0].type().id()!=ID_pointer)
  {
    std::string error="function `"+id2string(id)+"' has wrong signature";
    throw error;
  }

  string_constantt function_id_string(argument);

  code_function_callt call;
  call.lhs().make_nil();
  call.function()=
    symbol_exprt(s_it->second.name, s_it->second.type);
  call.arguments().resize(1);
  call.arguments()[0]=
    typecast_exprt(
      address_of_exprt(
        index_exprt(
          function_id_string, from_integer(0, index_type()))),
      to_code_type(s_it->second.type).parameters()[0].type());

  return call;
}
开发者ID:dcattaruzza,项目名称:cbmc,代码行数:58,代码来源:function.cpp

示例10: main

main()
{
  char ch;
			/* get a character from the keyboard 	*/
  printf(" Please enter a charcater => ");
  ch = getc(stdin);

  char_type(ch);	/* Figure out the character type 	*/
}
开发者ID:DouglasAllen,项目名称:C-Programming-Refference,代码行数:9,代码来源:is_examp.c

示例11: theFontMetrics

void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
{
	frontend::FontMetrics const & fm =
		theFontMetrics(mi.base.font);
	dim.asc = fm.maxAscent();
	dim.des = 0;
	dim.wid = 0;

	docstring s;
	switch (kind_) {
		case ALLOWBREAK:
			dim.asc = fm.xHeight();
			dim.des = fm.descent('g');
			dim.wid = fm.em() / 8;
			break;
		case LIGATURE_BREAK:
			s = from_ascii("|");
			break;
		case END_OF_SENTENCE:
			s = from_ascii(".");
			break;
		case LDOTS:
			s = from_ascii(". . .");
			break;
		case MENU_SEPARATOR:
			// ▹  U+25B9 WHITE RIGHT-POINTING SMALL TRIANGLE
			// There is a \thinspace on each side of the triangle
			dim.wid = 2 * fm.em() / 6 + fm.width(char_type(0x25B9));
			break;
		case HYPHENATION:
			dim.wid = fm.width(from_ascii("-"));
			if (dim.wid > 5)
				dim.wid -= 2; // to make it look shorter
			break;
		case SLASH:
			s = from_ascii("/");
			dim.des = fm.descent(s[0]);
			break;
		case NOBREAKDASH:
			s = from_ascii("-");
			break;
		case PHRASE_LYX:
		case PHRASE_TEX:
		case PHRASE_LATEX2E:
		case PHRASE_LATEX:
			dim.asc = fm.maxAscent();
			dim.des = fm.maxDescent();
			frontend::NullPainter np;
			PainterInfo pi(mi.base.bv, np);
			pi.base.font = mi.base.font;
			drawLogo(pi, dim.wid, 0, kind_);
			break;
	}
	if (dim.wid == 0)
		dim.wid = fm.width(s);
}
开发者ID:cburschka,项目名称:lyx,代码行数:56,代码来源:InsetSpecialChar.cpp

示例12: char_type

hdf5_oprimitive::write_hdf5_dataset
(
    signed char const* t,
    std::size_t data_count,
    std::size_t object_number
)
{
    hdf5_datatype char_type(H5T_NATIVE_SCHAR);
    write_dataset_basic(t, data_count, char_type, object_number);
}
开发者ID:bingzhang00,项目名称:serialization,代码行数:10,代码来源:hdf5_oprimitive.cpp

示例13: make_expr_1

void make_expr_1( MethodWriter &mw, const String &op ) {
    // resulting type
    String op_type;
    op_type << "Op_" << op << '_' << char_type( mw.get_type( 0 )->constructor );
    mw.add_type_decl( op_type );

    // default behavior -> op( a, b, ... )
    mw.n << "Type *type = &metil_type_bas_" << op_type << ";";
    mw.ret() << "MO( NEW( Owcp<1>, type, " << mw.arg[ 0 ] << " ), type );";
}
开发者ID:hleclerc,项目名称:Metil,代码行数:10,代码来源:TypeConstructor_SymbolicExpression.cpp

示例14: char_type

hdf5_iprimitive::read_hdf5_dataset
(
    signed char* t,
    std::size_t data_count,
    std::size_t object_number
)
{
    hdf5_datatype char_type(H5T_NATIVE_SCHAR);
    read_dataset_basic(t, data_count, char_type, object_number);
}
开发者ID:warn-naught,项目名称:serialization,代码行数:10,代码来源:hdf5_iprimitive.cpp

示例15: assert

void string16_t::push_back( char_type c)
{
    assert( pimpl_);

    if( !pimpl_->str_.empty())
        pimpl_->str_.pop_back();

    pimpl_->str_.push_back( c);
    pimpl_->str_.push_back( char_type( 0));
}
开发者ID:elanifegnirf,项目名称:ramenlibs,代码行数:10,代码来源:string16.cpp


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