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


C++ readWord函数代码示例

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


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

示例1: isSubstitution

////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::substitution
//   / <unquoted-string> / <unquoted-string> / [g]  <EOS> | <isWhitespace>
bool Lexer::isSubstitution (std::string& token, Lexer::Type& type)
{
  std::size_t marker = _cursor;

  std::string word;
  if (readWord (_text, "/", _cursor, word))
  {
    --_cursor;  // Step backwards over the '/'.

    if (readWord (_text, "/", _cursor, word))
    {
      if (_text[_cursor] == 'g')
        ++_cursor;

      // Lookahread: <EOS> | <isWhitespace>
      if (_text[_cursor] == '\0' ||
          isWhitespace (_text[_cursor]))
      {
        token = _text.substr (marker, _cursor - marker);
        type = Lexer::Type::substitution;
        return true;
      }
    }
  }

  _cursor = marker;
  return false;
}
开发者ID:austinwagner,项目名称:task,代码行数:31,代码来源:Lexer.cpp

示例2: getUsrName

void getUsrName(int procUID, char usr[], int size){
   char    etcUser[MAX_LEN] ;
   char    etcPass[MAX_LEN] ;
   char etcUserId[MAX_LEN] ;
   char filename[] = "/etc/passwd";
   int fd, i;
   
    if((fd = open(filename,  O_RDONLY)) < 0){
      printf(1, "login.c:getUsrName: Error cannot open file '%s'\n", filename);
      exit();
    }
    
    // compare the username and password given against each user and password in the file
    for(i  = 0; i < NUM_OF_USERS ; i++){
        
        // zero out buffers
        zeroOutBuffer(etcUser, sizeof(etcUser));
        zeroOutBuffer(etcPass, sizeof(etcPass));
        zeroOutBuffer(etcUserId, sizeof(etcUserId));
        
        // read one user info from file
       readWord(fd, etcUser, sizeof(etcUser));
       readWord(fd, etcPass, sizeof(etcPass));
       readWord(fd, etcUserId, sizeof(etcUserId));

        if(procUID == atoi(etcUserId)){
            strcpy(usr, etcUser);
        }

    }
    close(fd);
	
}
开发者ID:rwhat357,项目名称:XV6-Enhancement,代码行数:33,代码来源:whoami.c

示例3: decomposeSubstitution

////////////////////////////////////////////////////////////////////////////////
// / <from> / <to> / [<flags>]
bool Lexer::decomposeSubstitution (
  const std::string& text,
  std::string& from,
  std::string& to,
  std::string& flags)
{
  std::string parsed_from;
  std::string::size_type cursor = 0;
  if (readWord (text, "/", cursor, parsed_from) &&
      parsed_from.length ())
  {
    --cursor;
    std::string parsed_to;
    if (readWord (text, "/", cursor, parsed_to))
    {
      std::string parsed_flags = text.substr (cursor);
      if (parsed_flags.find ("/") == std::string::npos)
      {
        dequote (parsed_from, "/");
        dequote (parsed_to,   "/");

        from  = parsed_from;
        to    = parsed_to;
        flags = parsed_flags;
        return true;
      }
    }
  }

  return false;
}
开发者ID:austinwagner,项目名称:task,代码行数:33,代码来源:Lexer.cpp

示例4: if

////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::pair
//   <identifier> <separator> [ <string> | <word> ]
//   separator '::' | ':=' | ':' | '='
bool Lexer::isPair (std::string& token, Lexer::Type& type)
{
  std::size_t marker = _cursor;

  std::string ignoredToken;
  Lexer::Type ignoredType;
  if (isIdentifier (ignoredToken, ignoredType))
  {
    // Look for a valid separator.
    std::string separator = _text.substr (_cursor, 2);
    if (separator == "::" || separator == ":=")
      _cursor += 2;
    else if (separator[0] == ':' || separator[0] == '=')
      _cursor++;
    else
    {
      _cursor = marker;
      return false;
    }

    // String, word or nothing are all valid.
    if (readWord (_text, "'\"", _cursor, ignoredToken) ||
        readWord (_text,        _cursor, ignoredToken) ||
        isEOS ()                                       ||
        isWhitespace (_text[_cursor]))
    {
      token = _text.substr (marker, _cursor - marker);
      type = Lexer::Type::pair;
      return true;
    }
  }

  _cursor = marker;
  return false;
}
开发者ID:austinwagner,项目名称:task,代码行数:39,代码来源:Lexer.cpp

示例5: while

MessageIn Network::getNextMessage()
{
    while (!messageReady())
    {
        if (mState == NET_ERROR)
            break;
    }

    SDL_mutexP(mMutex);
    int msgId = readWord(0);
    int len;
    if (msgId == SMSG_SERVER_VERSION_RESPONSE)
        len = 10;
    else if (msgId == SMSG_UPDATE_HOST2)
        len = -1;
    else
        len = packet_lengths[msgId];

    if (len == -1)
        len = readWord(2);

#ifdef ENABLEDEBUGLOG
//    logger->dlog(strprintf("Received packet 0x%x of length %d\n",
//        msgId, len));
#endif

    MessageIn msg(mInBuffer, len);
    SDL_mutexV(mMutex);

    return msg;
}
开发者ID:Evonline,项目名称:ManaPlus,代码行数:31,代码来源:network.cpp

示例6: SDL_mutexP

bool Network::messageReady()
{
    int len = -1;

    SDL_mutexP(mMutexIn);
    if (mInSize >= 2)
    {
        const int msgId = readWord(0);
        if (msgId == SMSG_SERVER_VERSION_RESPONSE)
        {
            len = 10;
        }
        else
        {
            if (msgId >= 0 && static_cast<unsigned int>(msgId)
                < packet_lengths_size)
            {
                len = packet_lengths[msgId];
            }
        }

        if (len == -1 && mInSize > 4)
            len = readWord(2);
    }

    const bool ret = (mInSize >= static_cast<unsigned int>(len));
    SDL_mutexV(mMutexIn);

    return ret;
}
开发者ID:Rawng,项目名称:ManaPlus,代码行数:30,代码来源:network.cpp

示例7: while

MessageIn Network::getNextMessage()
{
    while (!messageReady())
    {
        if (mState == NET_ERROR)
            break;
    }

    MutexLocker lock(&mMutex);
    uint16_t msgId = readWord(0);
    uint16_t len = 0;
    if (msgId == SMSG_SERVER_VERSION_RESPONSE)
        len = 10;
    else if (msgId < 0x220)
        len = packet_lengths[msgId];

    if (len == VAR)
        len = readWord(2);

#ifdef DEBUG
    logger->log("Received packet 0x%x of length %d", msgId, len);
#endif

    return MessageIn(mInBuffer, len);
}
开发者ID:TonyRice,项目名称:mana,代码行数:25,代码来源:network.cpp

示例8: getWavFileLength

unsigned int getWavFileLength(char *fileName) { // TBD: This function MUST be fixed - it currently returns an incorrect value, becuase - vals dont always mean it's done.
	unsigned int fileLength = 0;

	short int fileHandle = openFile(fileName);
	if (fileHandle == -1) {
		printf("Error occurred, unable to open file in 'getFileLength' with name: %s", fileName);
	}

	readPastWavHeader(fileHandle); // to get wav file length, dont bypass header i think..

	short int wordRead = readWord(fileHandle);
	//unsigned char firstByte = 0x0000FFFF | wordRead;
	//unsigned char secondByte = 0x0000FFFF | (wordRead >> 8);
	while ((short int)wordRead >= 0) {
		//printf("%c", (unsigned char)byteRead);
		fileLength += 2;
		wordRead = readWord(fileHandle);
	}
	if ((short int)wordRead <= -1) {
		printf("Error reading bytes from %s\n", fileName);
	}

	closeFile(fileHandle);
	return fileLength;
}
开发者ID:jordenh,项目名称:LaserSharknadoSW,代码行数:25,代码来源:sd_card.c

示例9: readWord

void SX1509::writePin(byte pin, byte highLow)
{
	unsigned int tempRegDir = readWord(REG_DIR_B);
	
	if ((0xFFFF^tempRegDir)&(1<<pin))	// If the pin is an output, write high/low
	{
		unsigned int tempRegData = readWord(REG_DATA_B);
		if (highLow)	tempRegData |= (1<<pin);
		else			tempRegData &= ~(1<<pin);
		writeWord(REG_DATA_B, tempRegData);
	}
	else	// Otherwise the pin is an input, pull-up/down
	{
		unsigned int tempPullUp = readWord(REG_PULL_UP_B);
		unsigned int tempPullDown = readWord(REG_PULL_DOWN_B);
		
		if (highLow)	// if HIGH, do pull-up, disable pull-down
		{
			tempPullUp |= (1<<pin);
			tempPullDown &= ~(1<<pin);
			writeWord(REG_PULL_UP_B, tempPullUp);
			writeWord(REG_PULL_DOWN_B, tempPullDown);
		}
		else	// If LOW do pull-down, disable pull-up
		{
			tempPullDown |= (1<<pin);
			tempPullUp &= ~(1<<pin);
			writeWord(REG_PULL_UP_B, tempPullUp);
			writeWord(REG_PULL_DOWN_B, tempPullDown);
		}
	}
}
开发者ID:brucetsao,项目名称:LIB_for_MCU,代码行数:32,代码来源:SparkFunSX1509.cpp

示例10: gusload

struct GPatch * gusload(char * filename)
{
    struct GPatch * gp = (struct GPatch *)malloc(sizeof(struct GPatch));
    rb->memset(gp, 0, sizeof(struct GPatch));

    int file = rb->open(filename, O_RDONLY);

    if(file < 0)
    {
        char message[50];
        rb->snprintf(message, 50, "Error opening %s", filename);
        rb->splash(HZ*2, message);
        return NULL;
    }

    gp->header=readData(file, 12);
    gp->gravisid=readData(file, 10);
    gp->desc=readData(file, 60);
    gp->inst=readChar(file);
    gp->voc=readChar(file);
    gp->chan=readChar(file);
    gp->numWaveforms=readWord(file);
    gp->vol=readWord(file);
    gp->datSize=readDWord(file);
    gp->res=readData(file, 36);

    gp->instrID=readWord(file);
    gp->instrName=readData(file,16);
    gp->instrSize=readDWord(file);
    gp->layers=readChar(file);
    gp->instrRes=readData(file,40);


    gp->layerDup=readChar(file);
    gp->layerID=readChar(file);
    gp->layerSize=readDWord(file);
    gp->numWaves=readChar(file);
    gp->layerRes=readData(file,40);


/*    printf("\nFILE: %s", filename); */
/*    printf("\nlayerSamples=%d", gp->numWaves); */

    int a=0;
    for(a=0; a<gp->numWaves; a++)
        gp->waveforms[a] = loadWaveform(file);


/*    printf("\nPrecomputing note table"); */

    for(a=0; a<128; a++)
    {
        gp->noteTable[a] = selectWaveform(gp, a);
    }
    rb->close(file);

    return gp;
}
开发者ID:victor2002,项目名称:rockbox_victor_clipplus,代码行数:58,代码来源:guspat.c

示例11: parseBmp

//purpose: parse a BMP file and package in a BMP structure
void parseBmp (char *fileName, BMP *bmp) {
	int i, j, k;
	char b, g, r;
	int pixels, rowOffset, offset;
	short int fh;

	fh = openFile(fileName);

	bmp->header.type = readWord(fh);
	bmp->header.size = readDWord(fh);
	bmp->header.reserved1 = readWord(fh);
	bmp->header.reserved2 = readWord(fh);
	bmp->header.offset = readDWord(fh);

	bmp->infoheader.size = readDWord(fh);
	bmp->infoheader.width = readDWord(fh);
	bmp->infoheader.height = readDWord(fh);
	bmp->infoheader.planes = readWord(fh);
	bmp->infoheader.bits = readWord(fh);
	bmp->infoheader.compression = readDWord(fh);
	bmp->infoheader.imagesize = readDWord(fh);
	bmp->infoheader.xresolution = readDWord(fh);
	bmp->infoheader.yresolution = readDWord(fh);
	bmp->infoheader.ncolors = readDWord(fh);
	bmp->infoheader.importantcolors = readDWord(fh);

	pixels = bmp->infoheader.width * bmp->infoheader.height;
	bmp->color = malloc(BYTES_PER_PIXEL * pixels);

	for(i = 0; i < bmp->infoheader.height; i++) {
		rowOffset = i*bmp->infoheader.width;
		for(j = 0; j < bmp->infoheader.width; j++ ){
			offset = pixels - rowOffset - j - 1;

			b = (readByte(fh) & 0xF1) >> 3;
			g = (readByte(fh) & 0xFC) >> 2;
			r = (readByte(fh) & 0xF1) >> 3;

			//Filter out the pink pixels
			if(b == 0x1E && g == 0 && r == 0x1E) {
				bmp->color[offset] = 0x0;
			} else {
				bmp->color[offset] = (r << 11) | (g << 5) | b;
			}
		}

		if((BYTES_PER_PIXEL*bmp->infoheader.width) % 4 != 0) {
			for (k = 0; k <  (4 - ((BYTES_PER_PIXEL*bmp->infoheader.width) % 4)); k++) {
				readByte(fh);
			}
		}
	}

	closeFile(fh);
}
开发者ID:jordenh,项目名称:DE2VTT,代码行数:56,代码来源:bmp.c

示例12: readReplica

void readReplica(Uint32 &index, Uint32 *buf)
{
  Uint32 i;
  Uint32 procNode = readWord(index, buf);
  Uint32 initialGci = readWord(index, buf);
  Uint32 numCrashedReplicas = readWord(index, buf);
  Uint32 nextLcp = readWord(index, buf);

  ndbout << "Replica node is: " << procNode;
  ndbout << " initialGci: " << initialGci;
  ndbout << " numCrashedReplicas = " << numCrashedReplicas;
  ndbout << " nextLcpNo = " << nextLcp << endl;
  for (i = 0; i < 3; i++)
  {
    Uint32 maxGciCompleted = readWord(index, buf);
    Uint32 maxGciStarted = readWord(index, buf);
    Uint32 lcpId = readWord(index, buf);
    Uint32 lcpStatus = readWord(index, buf);

    if (i == 2)
      continue;

    ndbout << "LcpNo[" << i << "]: ";
    ndbout << "maxGciCompleted: " << maxGciCompleted;
    ndbout << " maxGciStarted: " << maxGciStarted;
    ndbout << " lcpId: " << lcpId;
    ndbout << " lcpStatus: ";
    if (lcpStatus == 1)
    {
      ndbout << "valid";
    }
    else if (lcpStatus == 2)
    {
      ndbout << "invalid";
    }
    else
    {
      ndbout << "error: set to " << lcpStatus;
    }
    ndbout << endl;
  }
  for (i = 0; i < 8; i++)
  {
    Uint32 createGci = readWord(index, buf);
    Uint32 replicaLastGci = readWord(index, buf);
    
    if (i < numCrashedReplicas)
    {
      ndbout << "Crashed_replica[" << i << "]: ";
      ndbout << "CreateGci: " << createGci;
      ndbout << " replicaLastGci:" << replicaLastGci << endl;
    }
  }
}
开发者ID:carrotli,项目名称:ansql,代码行数:54,代码来源:printFragfile.cpp

示例13: internalizeOneObjectFile

  bool
internalizeOneObjectFile(objectFileListType *objectFile)
{
	FILE		*objectFildes;
	int		 magic;
	int		 mode;
	addressType	 startAddress;
	addressType	 endAddress;

	currentFileName = objectFile->name;
	if ((objectFildes = fopen(objectFile->name, "r")) == NULL) {
		error(CANT_OPEN_OBJECT_FILE_ERROR, objectFile->name);
		perror("Unix says");
		return(FALSE);
	}
	if (verbose)
		printf("internalizing %s:\n", objectFile->name);
	if ((magic = readWord(objectFildes, objectFile->name)) != 0xFFFF) {
		error(BAD_OBJECT_FILE_ERROR, objectFile->name);
		return(FALSE);
	}
	mode = MODE_ABSOLUTE;
	for (;;) {
		startAddress = readWord(objectFildes, objectFile->name);
		if (startAddress == 0xFFFF) {
			if (mode == MODE_ABSOLUTE) {
				mode = MODE_RELOCATABLE;
				continue;
			} else {
				break;
			}
		}
		endAddress = readWord(objectFildes, objectFile->name);
		readCode(startAddress, endAddress, mode, objectFile,
			objectFildes);
	}
	readReservations(objectFile, objectFildes);
	readReferences(objectFile, objectFildes);
	readSymbols(objectFile, objectFildes);
	readExpressions(objectFile, objectFildes);
	readFunctions(objectFile, objectFildes);
	instantiateExpressionAndSymbolPointers(objectFile);
	if (readExpressionEntryPoint) {
		pc = entryPointExpression;
		putSymbolPointersIntoExpression();
		readExpressionEntryPoint = FALSE;
		haveExpressionEntryPoint = TRUE;
	}
	qsort(objectFile->symbolTable, objectFile->symbolCount,
		sizeof(symbolType *), compareSymbolValues);
	fclose(objectFildes);
	return(TRUE);
}
开发者ID:Museum-of-Art-and-Digital-Entertainment,项目名称:macross,代码行数:53,代码来源:link.c

示例14: readWord

/*------------------------------------------------------------------
 * Create a BinaryGraphLoader reading from a binary istream.
 * NOTE: the input stream must be open with the 
 * ios::binary | ios::in mode.
 -----------------------------------------------------------------*/
BinaryGraphLoader::BinaryGraphLoader(istream &in)
  { unsigned n, ne, dest;
    unsigned i,j;

    n = readWord(in);
    for(i=0; i<n; i++)
      InsertNode(NULL);
    for(i=0; i<n; i++)
      { ne = readWord(in);
        for(j=0; j<ne; j++)
	  { dest=readWord(in);
	    InsertEdge(i, dest, NULL);
	  }
       }
   }
开发者ID:chubbymaggie,项目名称:libv,代码行数:20,代码来源:argloader.cpp

示例15: readInt

void SATParser::read(istream *s)
{
    string name;

    m_stream = s;

    m_header.version = readInt();
    m_header.n_data_records = readInt();
    m_header.n_entities = readInt();
    m_header.has_history = readBool();
    finishLine();

    m_header.product_id = readString();
    m_header.acis_version = readString();
    m_header.date = readString();
    finishLine();

    m_header.unit = readDouble();
    m_header.resabs = readDouble();
    m_header.resnor = readDouble();
    MSG_DEBUG("SATParser::read", "resnor = " << m_header.resnor);
    finishLine();

    //    cout << readString() << endl;

    name = readWord();
    while (!m_stream->eof() && name != END_OF_DATA_STR) {
        SATEntity *e;

        if (SATEntity_Factory::exists(name)) {
            e = SATEntity_Factory::byName(name).instantiate();
        } else {
            MSG_DEBUG("SATParser::read", "Unknown entity: '" << name << "'");

            e = new SATUnknown();
        }

        e->read(this);

        m_entities.push_back(e);

        finishLine();

        name = readWord();
    }

    fixPointers();
}
开发者ID:argreiner,项目名称:sympler,代码行数:48,代码来源:sat_parser.cpp


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