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


C++ readChar函数代码示例

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


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


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