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

C++ readChar函数代码示例

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

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



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

示例1: MQTTDeserialize_suback

/**
  * Deserializes the supplied (wire) buffer into suback data
  * @param packetid returned integer - the MQTT packet identifier
  * @param maxcount - the maximum number of members allowed in the grantedQoSs array
  * @param count returned integer - number of members in the grantedQoSs array
  * @param grantedQoSs returned array of integers - the granted qualities of service
  * @param buf the raw buffer data, of the correct length determined by the remaining length field
  * @param buflen the length in bytes of the data in the supplied buffer
  * @return error code.  1 is success, 0 is failure
  */
int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int buflen)
{
	MQTTHeader header = {0};
	unsigned char* curdata = buf;
	unsigned char* enddata = NULL;
	int rc = 0;
	int mylen;

	FUNC_ENTRY;
	header.byte = readChar(&curdata);
	if (header.bits.type != SUBACK)
		goto exit;

	curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
	enddata = curdata + mylen;
	if (enddata - curdata < 2)
		goto exit;

	*packetid = readInt(&curdata);

	*count = 0;
	while (curdata < enddata)
	{
		if (*count > maxcount)
		{
			rc = -1;
			goto exit;
		}
		grantedQoSs[(*count)++] = readChar(&curdata);
	}

	rc = 1;
exit:
	FUNC_EXIT_RC(rc);
	return rc;
}
开发者ID:GrandviewIoT,项目名称:Industrial_IoT_Projects,代码行数:46,代码来源:MQTTSubscribeClient.c


示例2: GetByte

int GetByte(void)     /* get one byte */
{
  unsigned i;

  while (getlen <= 8)
  {
    if ((i = readChar()) == -1) i = 0;
    getbuf |= i << (8 - getlen);
    getlen += 8;
  }
  i = getbuf;
  getbuf <<= 8;
  getlen -= 8;
  return (i >> 8) & 0xFF;
}
开发者ID:VWarlock,项目名称:zx-evo,代码行数:15,代码来源:wldr_td0.cpp


示例3: readConstChar

Token* readConstChar(void) {
  Token* token = makeToken(TK_CHAR, lineNo, colNo);

  // Read next character
  readChar();

  if (currentChar == -1) { // End of File
    error(ERR_INVALIDCHARCONSTANT, token->lineNo, token->colNo);
  } else {
	switch(charCodes[currentChar]) {
	// Escape character for Single Quote:
	case CHAR_SINGLEQUOTE:
		// Read next character
		readChar();

		if (charCodes[currentChar] == CHAR_SINGLEQUOTE) {
		    token->string[0] = currentChar;

		    readChar();
		    if (charCodes[currentChar] == CHAR_SINGLEQUOTE) {
		        token->string[1] = '\0';

		        readChar();
		        return token;
		    } else {
		        error(ERR_INVALIDCHARCONSTANT, token->lineNo, token->colNo);
		    }

		} else {
			error(ERR_INVALIDCHARCONSTANT, token->lineNo, token->colNo);
		}
		break;
	default:
	    // Add the character to token string
        token->string[0] = currentChar;

		// Read next character
		readChar();

		switch(charCodes[currentChar]) {
		case CHAR_SINGLEQUOTE:
			// End token
			token->string[1] = '\0';

			readChar();
			return token;
		default:
			error(ERR_INVALIDCHARCONSTANT, token->lineNo, token->colNo);
			break;
		}
		break;
	}

  }
  return token;
}
开发者ID:AnhTran1,项目名称:kpl-compiler,代码行数:56,代码来源:scanner.c


示例4: GetBit

int GetBit(void)      /* get one bit */
{
  int i;

  while (getlen <= 8)
  {
    if ((i = readChar()) == -1) i = 0;
    getbuf |= i << (8 - getlen);
    getlen += 8;
  }
  i = getbuf;
  getbuf <<= 1;
  getlen--;
  return ((i>>15) & 1);
}
开发者ID:VWarlock,项目名称:zx-evo,代码行数:15,代码来源:wldr_td0.cpp


示例5: while

bool GLECSVData::isComment(GLEBYTE ch) {
	int currentPos = m_pos;
	size_t commentPos = 0;
	while (commentPos < m_comment.size() && ch == m_comment[commentPos]) {
		ch = readChar();
		commentPos++;
	}
	if (commentPos == m_comment.size()) {
		goBack();
		return true;
	} else {
		m_pos = currentPos;
		return false;
	}
}
开发者ID:pnkfelix,项目名称:glx-gle,代码行数:15,代码来源:glearray.cpp


示例6: skipBlanks

	bool UtlXMLStream::readObjectReference(std::string& sTypeName, std::string& sIDAttrName, std::string& sIdentifier) {

		int iChar;
		skipBlanks( getInputStream() );
		iChar=readChar(  getInputStream() );
		if (iChar != '<')  {
			return false;
		}
		
		std::string sTrash;
		// reference
		if (!readString( getInputStream(), sTrash)) 
			return false;
		if (strcmp(sTrash.c_str(),"reference"))
			return false;

		// type 
		if (!readAttribute(sTrash, sTypeName))
			return false;

		// ID
		if (!readAttribute( sIDAttrName, sIdentifier)) 
			return false;
		
		iChar=readChar(  getInputStream() );
		if (iChar != '/')  {
			return false;
		}
		
		iChar=readChar(  getInputStream() );
		if (iChar != '>')  {
			return false;
		}

		return true;	
	}
开发者ID:canercandan,项目名称:codeworker,代码行数:36,代码来源:UtlXMLStream.cpp


示例7: readNumber

Token* readNumber(void) {
  //TO DO doc khi van con la so, luu vao toke
  Token *token = makeToken(TK_NUMBER, lineNo, colNo);
  int count = 0;
      token->string[count++]='0'; 
      token->string[count++]='.';
      while ((currentChar != EOF) && (charCodes[currentChar] == CHAR_DIGIT)) {
	token->string[count++] = (char)currentChar;
	readChar();
      }
    
     token->string[count] = '\0';
      //token->value = atoi(token->string);
    return token;
    }
开发者ID:BichVN,项目名称:week2,代码行数:15,代码来源:scanner.c


示例8: while

char dmtcp::Util::readDec (int fd, VA *value)
{
  char c;
  unsigned long int v;

  v = 0;
  while (1) {
    c = readChar (fd);
    if ((c >= '0') && (c <= '9')) c -= '0';
    else break;
    v = v * 10 + c;
  }
  *value = (VA)v;
  return (c);
}
开发者ID:BruceABeitman,项目名称:DMTCP-Android-CM9.1,代码行数:15,代码来源:util_gen.cpp


示例9: watchdog

WifiMessage ESP8266wifi::listenForIncomingMessage(int timeout){
    watchdog();
    char buf[16] = {'\0'};
    msgIn[0] = '\0';
    
    static WifiMessage msg;
    
    msg.hasData = false;
    msg.channel = '-';
    msg.message = msgIn;

    //TODO listen for unlink etc...
    byte msgOrRestart = readCommand(timeout, IPD, READY);
    
    //Detected a esp8266 restart
    if (msgOrRestart == 2){
        restart();
        return msg;
    }
    //Message received..
    else if (msgOrRestart == 1) {
        char channel = readChar();
        if (channel == SERVER)
            flags.connectedToServer = true;
        readChar(); // removing comma
        readBuffer(&buf[0], sizeof(buf) - 1, ':'); // read char count
        readChar(); // removing ':' delim
        byte length = atoi(buf);
        readBuffer(&msgIn[0], min(length, sizeof(msgIn) - 1));
        msg.hasData = true;
        msg.channel = channel;
        msg.message = msgIn;
        readCommand(10, OK); // cleanup after rx
    }
    return msg;
}
开发者ID:aaronj314,项目名称:ESP8266wifi,代码行数:36,代码来源:ESP8266wifi.cpp


示例10: readChar

bool CssTokenizer::readComment () {
  if (!lastReadEq('*'))
    return false;
  currentToken.add(lastRead);
  readChar();
  while (in != NULL) {
    if (lastReadEq('*')) {
      currentToken.add(lastRead);
      readChar();
      
      if (lastReadEq('/')) {
        currentToken.add(lastRead);
        readChar();
        return true;
      }
      continue;
    }
    currentToken.add(lastRead);
    readChar();
  }
  throw new ParseException(&lastRead,
                           "end of comment (*/)");
  return false;
}
开发者ID:smalyshev,项目名称:clessc,代码行数:24,代码来源:CssTokenizer.cpp


示例11: lastReadInRange

bool CssTokenizer::readNMChar () {
  if (in == NULL)
    return false;
  
  if (lastReadEq('_') ||
      lastReadInRange('a', 'z') ||
      lastReadInRange('A', 'Z') ||
      lastReadIsDigit() ||
      lastReadEq('-')) {
    currentToken.add(lastRead);
    readChar();
    return true;
  } else
    return (readNonAscii() || readEscape());
}
开发者ID:smalyshev,项目名称:clessc,代码行数:15,代码来源:CssTokenizer.cpp


示例12: MQTTSNDeserialize_advertise

/**
  * Deserializes the supplied (wire) buffer into advertise data
  * @param gatewayid the returned gateway id
  * @param duration the returned duration - the time interval until the next advertise will be sent
  * @param buf the raw buffer data, of the correct length determined by the remaining length field
  * @param buflen the length in bytes of the data in the supplied buffer
  * @return error code.  1 is success
  */
int MQTTSNDeserialize_advertise(unsigned char* gatewayid, unsigned short* duration,	unsigned char* buf, int buflen)
{
	unsigned char* curdata = buf;
	unsigned char* enddata = NULL;
	int rc = 0;
	int mylen = 0;

	FUNC_ENTRY;
	curdata += (rc = MQTTSNPacket_decode(curdata, buflen, &mylen)); /* read length */
	enddata = buf + mylen;
	if (enddata - curdata > buflen)
		goto exit;

	if (readChar(&curdata) != MQTTSN_ADVERTISE)
		goto exit;

	*gatewayid = readChar(&curdata);
	*duration = readInt(&curdata);

	rc = 1;
exit:
	FUNC_EXIT_RC(rc);
	return rc;
}
开发者ID:0x1abin,项目名称:LinuxLearn,代码行数:32,代码来源:MQTTSNSearchClient.c


示例13: readHex

	long readHex()
	{
		if ( err )
			return 0;

		skipWhitespace();

		// hex must start with alphanumeric character
		char ch;
		if ( !peekChar(&ch) || !isalnum(ch) )
		{
			err = TextFile::ERROR_PARSE;
			return 0;
		}

		long x = 0;
		while ( peekChar(&ch) )
		{
			switch ( ch )
			{
			case '0':	x <<= 4; x += 0; break;
			case '1':	x <<= 4; x += 1; break;
			case '2':	x <<= 4; x += 2; break;
			case '3':	x <<= 4; x += 3; break;
			case '4':	x <<= 4; x += 4; break;
			case '5':	x <<= 4; x += 5; break;
			case '6':	x <<= 4; x += 6; break;
			case '7':	x <<= 4; x += 7; break;
			case '8':	x <<= 4; x += 8; break;
			case '9':	x <<= 4; x += 9; break;
			case 'a':
			case 'A':	x <<= 4; x += 0xA; break;
			case 'b':
			case 'B':	x <<= 4; x += 0xB; break;
			case 'c':
			case 'C':	x <<= 4; x += 0xC; break;
			case 'd':
			case 'D':	x <<= 4; x += 0xD; break;
			case 'e':
			case 'E':	x <<= 4; x += 0xE; break;
			case 'f':
			case 'F':	x <<= 4; x += 0xF; break;
			default:	return x;
			}
			readChar( &ch );
		}
		return x;
	}
开发者ID:Naqvamp,项目名称:Underworld_Core,代码行数:48,代码来源:TextFile.cpp


示例14: getData

int getData(FILE *in, Student list[]) {
	char temp[MaxNameBuffer];
	void getString(FILE *, char[]);
	char readChar(FILE *);

  int n = 0;
  getString(in, temp);
	while (n < MaxStudents && strcmp(temp, "END") != 0) {
		strcpy(list[n].name, temp);
		fscanf(in, "%d", &list[n].age);
		list[n].gender = readChar(in);
		n++;
		getString(in, temp);
	}
	return n;
} //end getData
开发者ID:vrnss,项目名称:MachineLearningAlgorithms,代码行数:16,代码来源:P21SortSearchStruct.c


示例15: while

void PgnStream::parseComment(char opBracket)
{
	int level = 1;
	char clBracket = (opBracket == '(') ? ')' : '}';

	char c;
	while ((c = readChar()) != 0)
	{
		if (c == opBracket)
			level++;
		else if (c == clBracket && --level <= 0)
			break;

		m_tokenString.append(c);
	}
}
开发者ID:coyotte508,项目名称:cutechess,代码行数:16,代码来源:pgnstream.cpp


示例16: makeToken

  Token *readFloat (void){
    Token *token = makeToken(TK_NUMBER, lineNo, colNo);
    int count = 0;
 
    while ((currentChar != EOF) && ((charCodes[currentChar] == CHAR_DIGIT) || (charCodes[currentChar] == CHAR_PERIOD))) {
      if((charCodes[currentChar] == CHAR_PERIOD)&&(count==0))   token->string[count++]='0';   
      token->string[count++] = (char)currentChar;
      if((charCodes[currentChar]== CHAR_PERIOD)&& (count>0))    token->string[count++]='0';
      readChar();
    }

    token->string[count] = '\0';
    token->value = atoi(token->string);

  return token;
}
开发者ID:BichVN,项目名称:week2,代码行数:16,代码来源:scanner.c


示例17: readChar

bool Parser::parseName( std::string &name )
{
    if( !isInSet( firstNameSet, current ) )
        return false;

    name = "";

    do
    {
        name += current;
        readChar( true );
    }
    while( isInSet( nameSet, current ) );

    return true;
}
开发者ID:BackupTheBerlios,项目名称:iris-svn,代码行数:16,代码来源:xml.cpp


示例18: while

/*!  \brief Read a string from the serial device
     \param string : string read on the serial device
     \param finalChar : final char of the string
     \param maxChars : maximum allowed number of chars read
     \return >0 success, return the number of chars read
     \return -1 error while reading the char
     \return -2 maxChars is reached
 */
int LibSerial::readString (char * string, char finalChar, unsigned int maxChars) {
   unsigned int  nbChars = 0;                   // Number of chars read
   int           ret;                           // Returned value from read
   while (nbChars < maxChars) {                 // While the buffer is not full
      ret = readChar (&string[nbChars]);        // Read a char with the restant time
      if (ret == 1) {                           // If a char has been read
         if (string[nbChars] == finalChar) {    // Check if it is the final char
            string [++nbChars] = '\0';          // Yes : add the end character '\0'
            return nbChars;                     // Return the number of chars read
         }
         nbChars++;                             // If not, just increase the number of chars read
      }
      if (ret < 0) return ret;                  // Error while reading : return the error number
    }
    return -2;                                  // Buffer is full : return -3
}
开发者ID:Ban-aan,项目名称:THO78-Roborescue,代码行数:24,代码来源:LibSerial.cpp


示例19: while

bool Parser::parseCharData( Node *node )
{
    std::string data;

    while( !isInSet( "<&\0", current ) )
    {
        data += current;
        readChar();
    }

    if( data.find( "]]>" ) != 0xffffffff )
        reportError( "Character data cannot contain ']]>'" );

    node->setData( node->data() + data );
    return ( data.length() > 0 );
}
开发者ID:BackupTheBerlios,项目名称:iris-svn,代码行数:16,代码来源:xml.cpp


示例20: readChar

void ConvertGtp::readColumnEffects(vector<TabTrack>::iterator &trk, int x)
{
	char fx_bitmask1 = 0, fx_bitmask2 = 0, num;

	fx_bitmask1 = readChar();
	if (versionMajor >= 4) {
		fx_bitmask2 = readChar();
		//osg::notify(osg::INFO) << "column-wide fx: " << (int) fx_bitmask1 << "/" << (int) fx_bitmask2 << "\n";
	} else {
		//osg::notify(osg::INFO) << "column-wide fx: " << (int) fx_bitmask1 << "\n";
	}

	if (fx_bitmask1 & 0x20) {      // GREYFIX: string torture
		num = readChar();
		switch (num) {
		case 0:                    // GREYFIX: tremolo bar
			if (versionMajor < 4)  readDelphiInteger();
			break;
		case 1:                    // GREYFIX: tapping
			if (versionMajor < 4)  readDelphiInteger(); // ?
			break;
		case 2:                    // GREYFIX: slapping
			if (versionMajor < 4)  readDelphiInteger(); // ?
			break;
		case 3:                    // GREYFIX: popping
			if (versionMajor < 4)  readDelphiInteger(); // ?
			break;
		default:
			throw string("Unknown string torture effect: %1");
		}
	}
	if (fx_bitmask1 & 0x04) {      // GP3 column-wide natural harmonic
		//osg::notify(osg::INFO) << "GP3 column-wide natural harmonic\n";
		for (int y = 0; y < trk->strings; y++)
			trk->c[x].e[y] |= EFFECT_HARMONIC;
	}
	if (fx_bitmask1 & 0x08) {      // GP3 column-wide artificial harmonic
		//osg::notify(osg::INFO) << "GP3 column-wide artificial harmonic\n";
		for (int y = 0; y < trk->strings; y++)
			trk->c[x].e[y] |= EFFECT_ARTHARM;
        }
	if (fx_bitmask2 & 0x04)
		readChromaticGraph(trk->c[x]);  // GREYFIX: tremolo graph
	if (fx_bitmask1 & 0x40) {
		num = readChar();      // GREYFIX: down stroke length
		num = readChar();      // GREYFIX: up stroke length
	}
	if (fx_bitmask2 & 0x02) {
		num = readChar();      // GREYFIX: stroke pick direction
	}
	if (fx_bitmask1 & 0x01) {      // GREYFIX: GP3 column-wide vibrato
	}
	if (fx_bitmask1 & 0x02) {      // GREYFIX: GP3 column-wide wide vibrato (="tremolo" in GP3)
	}
}
开发者ID:owenwp,项目名称:guitarstorm,代码行数:55,代码来源:convertgtp.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ readConfig函数代码示例发布时间:2022-05-30
下一篇:
C++ readBytes函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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