本文整理汇总了C++中Char类的典型用法代码示例。如果您正苦于以下问题:C++ Char类的具体用法?C++ Char怎么用?C++ Char使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Char类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool Uri::Private::parsePchar()
{
const Char curr = m_uri[m_parserPos];
const iuint32 currValue = curr.value();
if (!currValue) {
return false;
}
if (currValue < 128 && isUnreserved[currValue]) {
m_parserAux += curr;
++m_parserPos;
return true;
}
const size_t parserOldPos = m_parserPos;
if (parsePctEncoded()) {
return true;
}
m_parserPos = parserOldPos;
if (currValue < 128 && isSubdelim[currValue]) {
m_parserAux += curr;
++m_parserPos;
return true;
}
if (curr == ':' || curr == '@') {
m_parserAux += curr;
++m_parserPos;
return true;
}
return false;
}
示例2: while
bool Uri::Private::parseSegmentNzNc()
{
bool res = false;
while (true) {
const Char curr = m_uri[m_parserPos];
const iuint32 currValue = curr.value();
if (currValue < 128 && isUnreserved[currValue]) {
m_parserAux += curr;
++m_parserPos;
res = true;
continue;
}
const size_t parserOldPos = m_parserPos;
if (parsePctEncoded()) {
res = true;
continue;
}
m_parserPos = parserOldPos;
if (currValue < 128 && isSubdelim[currValue]) {
m_parserAux += curr;
++m_parserPos;
res = true;
continue;
}
if (curr == '@') {
m_parserAux += '@';
++m_parserPos;
res = true;
continue;
}
return res;
}
}
示例3: TEST
TEST(VersionTest, SelfAssignmentAfterOperations) {
Int a = 3;
Int b = any_int("B");
Char c = 'c';
EXPECT_EQ(0, a.get_version());
EXPECT_EQ(0, b.get_version());
EXPECT_EQ(0, c.get_version());
// some operations
a = a + b + c;
b = a + b + c;
b = 5;
c = c + 'x';
c = 'y';
c = 'z' + c;
EXPECT_EQ(1, a.get_version());
EXPECT_EQ(2, b.get_version());
EXPECT_EQ(3, c.get_version());
a = a;
b = b;
c = c;
EXPECT_EQ(1, a.get_version());
EXPECT_EQ(2, b.get_version());
EXPECT_EQ(3, c.get_version());
}
示例4: switch
bool JsonParser::JsonStringParser::advance(Char ch)
{
switch (_state)
{
case state_0:
if (ch == '\\')
_state = state_esc;
else if (ch == '"')
return true;
else
_str += ch;
break;
case state_esc:
_state = state_0;
if (ch == '"' || ch == '\\' || ch == '/')
_str += ch;
else if (ch == 'b')
_str += '\b';
else if (ch == 'f')
_str += '\f';
else if (ch == 'n')
_str += '\n';
else if (ch == 'r')
_str += '\r';
else if (ch == 't')
_str += '\t';
else if (ch == 'u')
{
_value = 0;
_count = 4;
_state = state_hex;
}
else
_jsonParser->doThrow(std::string("invalid character '") + ch.narrow() + "' in string");
break;
case state_hex:
if (ch >= '0' && ch <= '9')
_value = (_value << 4) | (ch.value() - '0');
else if (ch >= 'a' && ch <= 'f')
_value = (_value << 4) | (ch.value() - 'a' + 10);
else if (ch >= 'A' && ch <= 'F')
_value = (_value << 4) | (ch.value() - 'A' + 10);
else
_jsonParser->doThrow(std::string("invalid character '") + ch.narrow() + "' in hex sequence");
if (--_count == 0)
{
_str += Char(static_cast<wchar_t>(_value));
_state = state_0;
}
break;
}
return false;
}
示例5: Char
void Line::SetText( string _character )
{
Char * character = new Char();
vector<Char *>::iterator it = characters.begin() + active;
character->SetText( _character );
characters.insert( it, character );
IncrementParams( 1 );
}
示例6: ISError
Char* Line::Delete(int x) {
if ((size_t)x >= m_chars.size()) {
throw ISError("Cannot insert; x out of bounds");
}
Char* c = m_chars.at(x);
c->Unlink();
m_charpool.Unlink(*c);
m_chars.erase(m_chars.begin() + x);
return c;
}
示例7:
void EpsilonNFA::NFAGenerator::visit(Char& node)
{
_pool.push_back(std::make_unique<Node>());
auto newNode = _pool.back().get();
start->edges.push_back(Edge{ node.ch(), newNode });
end = newNode;
end->stateInfo = _info;
}
示例8: sizeof
void EntityResolver::getEntity(std::basic_ostream<Char>& os, Char ch) const
{
unsigned u = 0;
unsigned o = sizeof(rent)/sizeof(Ent) - 1;
while (o - u > 1)
{
unsigned m = (o + u) / 2;
if (rent[m].charValue == ch.value())
{
printEntity(os, rent[m].entity);
return;
}
if (ch.value() < rent[m].charValue)
o = m;
else
u = m;
}
if (rent[u].charValue == ch.value())
printEntity(os, rent[u].entity);
else if (rent[o].charValue == ch.value())
printEntity(os, rent[o].entity);
else if (ch.value() >= ' ' && ch.value() <= 0x7F)
os << ch;
else
os << Char('&') << Char('#') << static_cast<uint32_t>(ch.value()) << Char(';');
}
示例9: ch
void DocState::Deserialize(std::ifstream & ifs){
// Dummy objects
Char ch(logger);
Graph g(logger);
Table t(logger);
Eof e(logger);
uint32 magic;
while(!ifs.eof()){
DESER_OBJ(magic);
if(magic == offset_magic){
// offset is placed at the end of the serialized record
DESER_OBJ(glyphAttrib);
DESER_OBJ(lineAttrib);
return;
}
else if (magic == e.GetMagic()){
Eof * pe = new Eof(logger);
buffer.push_back(pe);
pe->Deserialize(ifs);
}
else if (magic == ch.GetMagic()){
Char* pch = new Char(logger);
buffer.push_back(pch);
pch->Deserialize(ifs);
}
else if (magic == g.GetMagic()){
Graph* pg = new Graph(logger);
buffer.push_back(pg);
pg->Deserialize(ifs);
}
else if (magic == t.GetMagic()){
Table* pt = new Table(logger);
buffer.push_back(pt);
pt->Deserialize(ifs);
}
else{
LOG_ERROR("Unsupported class magic.");
}
}
}
示例10: if
bool Uri::Private::parsePctEncoded()
{
if (expectChar('%')) {
Char curr = m_uri[m_parserPos];
size_t currValue = curr.value();
if (!currValue || currValue > 127 || !isHexdig[currValue]) {
return false;
}
m_parserAux += curr;
++m_parserPos;
curr = m_uri[m_parserPos];
currValue = curr.value();
if (!currValue || currValue > 127 || !isHexdig[currValue]) {
return false;
}
m_parserAux += curr;
++m_parserPos;
} else {
const Char curr = m_uri[m_parserPos];
const iuint32 currValue = curr.value();
if (curr.octetsRequired() > 1) {
m_parserAux += curr;
++m_parserPos;
} else if (currValue && currValue < 128 && (!isUnreserved[currValue] && !isGendelim[currValue] &&
!isSubdelim[currValue] && curr != ':' && curr != '@')) {
m_parserTrick = true;
m_parserAux += getHex(curr);
++m_parserPos;
} else {
return false;
}
}
return true;
}
示例11: apply
void ByLevelUseEffect::apply(Char& target) const
{
if (effects.empty())
return;
uint16_t level = target.get_level();
auto iter = effects.begin();
for (; iter != effects.end() && level > iter->first; ++iter) {}
if (iter != effects.begin())
iter--;
iter->second.apply(target);
}
示例12: dirToVec2
//.........这里部分代码省略.........
// Out of the world
if(!rtc)return false;
if( rtc && rtc->gt == GT_JUNGLE && range(0,100) < 1 ) {
createLeafEffect(loc);
}
updateIndex();
if( isRemote() ) return true;
if(tgtc) {
int consumed;
BLOCKTYPE orig_bt = tgtc->bt;
if( g_fld->damage(tgtat,ene,&consumed,this) ) {
createSparkEffect();
if( orig_bt == BT_CELL || orig_bt == BT_FLYGEN ) {
soundPlayAt(g_wormdamage_sound,loc,1);
} else if( orig_bt != BT_SNOW && orig_bt != BT_IVY && orig_bt != BT_TREE && orig_bt != BT_BOMBFLOWER ) {
soundPlayAt(g_beamhithard_sound,loc,1);
}
if( orig_bt == BT_BARRIER && tgtc->hyper_count > 0 ) {
Vec2 tgt;
if( g_fld->findEnemyAttackTarget(loc,&tgt, MACHINE_SHOOT_DISTANCE ) ) {
int n = irange(1,4);
for(int i=0;i<n;i++) Bullet::shootAt( BLT_SPARIO, loc, tgt );
}
}
ene -= consumed;
if( ene <= 0 ) return false; else return true;
}
} else {
// Immutable cells
Cell *cells[4];
g_fld->getCorner4( loc, 1, &cells[0], &cells[1], &cells[2], &cells[3] );
for(int i=0;i<4;i++) {
if(cells[i] && cells[i]->isImmutableAgainstBeam()) {
soundPlayAt(g_beamhithard_sound,loc,1);
createSparkEffect();
return false;
}
}
}
if( type == BEAMTYPE_BLASTER ) {
float s = PPC;
g_fld->meltSnow(loc + Vec2(-s,-s) );
g_fld->meltSnow(loc + Vec2(-s,s) );
g_fld->meltSnow(loc + Vec2(s,-s) );
g_fld->meltSnow(loc + Vec2(s,s) );
} else {
if( range(0,100) < (float)(ene)/2.0 ) {
g_fld->meltSnow(loc);
}
}
// Shoot on enemies
Char *cur = (Char*) g_char_layer->prop_top;
while(cur) {
if( cur->isEnemyCategory() ) {
Enemy *e = (Enemy*) cur;
if( e->hitWithFlyHeight(this,PPC/2) && e->beam_hits ) {
int dmg = ene;
if( dmg > e->hp ) dmg = e->hp;
e->notifyHitBeam(this, dmg);
createSparkEffect();
//
ene -= dmg;
if(ene<=0) to_clean = true;
g_fld->meltSnow(loc);
}
} else if( cur->category == CAT_PC ) {
// recharging other player characters
PC *pc = (PC*) cur;
if( pc->hit(this,PPC/2)) {
// print("pcid:%d shooter:%d ene:%d/%d", pc->id, shooter_id, pc->ene, pc->maxene );
if( pc->id != shooter_id && shooter_id == g_pc->id ) {
// print("PC:E:%d id:%d max:%d", pc->ene, pc->id, pc->maxene );
int charged = pc->charge(ene);
if(charged>0) {
pc->energy_chain_heat_count ++;
// print("sending E-chain e:%d(%d>%d) to: %d-%d heat:%d",
// ene, charged, pc->ene, pc->client_id, pc->internal_id ,pc->energy_chain_heat_count );
realtimeEnergyChainSend(pc,charged);
return false;
}
}
}
}
cur = (Char*) cur->next;
}
return true;
}
示例13: switch
Pt::String RegexSMatch::format(const Pt::String& str) const
{
enum state_type
{
state_0,
state_esc,
state_var0,
state_var1,
state_1
} state;
state = state_0;
Pt::String ret;
for (Pt::String::const_iterator it = str.begin(); it != str.end(); ++it)
{
Char ch = *it;
switch (state)
{
case state_0:
if (ch == '$')
state = state_var0;
else if (ch == '\\')
state = state_esc;
break;
case state_esc:
ret += ch;
state = state_1;
break;
case state_var0:
if( isdigit(ch) )
{
ret = Pt::String(str.begin(), it - 1);
unsigned n = ch.value() - '0';
if(n < _size)
{
const Pt::Char* s = _match->startp[n];
const Pt::Char* e = _match->endp[n];
assert(s && e);
ret.append(s, e-s);
}
state = state_1;
}
else
state = state_0;
break;
case state_1:
if (ch == '$')
state = state_var1;
else if (ch == '\\')
state = state_esc;
else
ret += ch;
break;
case state_var1:
if( isdigit(ch) )
{
unsigned n = ch.value() - '0';
if(n < _size)
{
const Pt::Char* s = _match->startp[n];
const Pt::Char* e = _match->endp[n];
assert(s && e);
ret.append(s, e-s);
}
state = state_1;
}
else if (ch == '$')
ret += '$';
else
{
ret += '$';
ret += ch;
}
break;
}
}
switch (state)
{
case state_0:
case state_var0:
return str;
case state_esc:
return ret + '\\';
case state_var1:
return ret + '$';
//.........这里部分代码省略.........
示例14: setChar
void Font::setChar(const Char& character)
{
allCharacters[character.getId()] = character;
}