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


C++ readInt函数代码示例

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


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

示例1: handleInterrupt21

/* You must call makeInterrupt21() before
   this function will work. */
void handleInterrupt21(int ax, int bx, int cx, int dx) {
  
  switch(ax) {
    
    case 0:
      printString(bx);
      break;

    case 1:
      readString(bx);
      break;

    case 2:
      readSector(bx,cx);
      break;

    case 3:
      readFile(bx,cx,dx);
      break;

    case 4:
      runProgram(bx,cx);
      break;

    case 5:
      stop();
      break;

    case 6:
      writeSector(bx,cx);
      break;

    case 7:
      deleteFile(bx);
      break;

    case 8:
      writeFile(bx,cx,dx);
      break;

    case 11:
      interrupt(25,0,0,0,0);
      break;
 
    case 12:
      clearScreen(bx, cx);
      break;
  
    case 13:
      writeInt(bx);
      break;

    case 14:
      readInt(bx);
      break;

    case 15:
      error(bx);
      break;    

    default:
      printString("ERROR: Requested service does not exist.");

  }
    
}
开发者ID:mikeweyandt,项目名称:BlackDOS,代码行数:68,代码来源:kernel.c

示例2: readBytes

static void readBytes( gzFile file, std::vector<uint8_t>& bytes )
{
	int count = readInt( file );
	bytes.resize( count );
	gzread( file, bytes.begin(), count );
}
开发者ID:TheRyaz,项目名称:c_reading,代码行数:6,代码来源:zar.cpp

示例3: readShort

wyArcticFileData* wyArcticLoader::load(const char* data, size_t length, float resScale) {
	wyArcticFileData* afd = wyArcticFileData::make();
	s_data = data;
	s_pos = 0;

	// set scale
	afd->m_resScale = resScale;

	// version
	afd->m_version = readShort();

	// skip id for other editor
	if(afd->m_version > 0x30)
		skip(4);

	// flags
	afd->m_flags = readInt();

	// read all modules
	if((afd->m_flags & AS_MODULES) != 0) {
		// module count
		afd->m_moduleCount = readShort();

		if(afd->m_moduleCount > 0) {
			// allocate memory
			afd->m_modules = (wyArcticModule*)wyCalloc(afd->m_moduleCount, sizeof(wyArcticModule));

			for(int i = 0; i < afd->m_moduleCount; i++) {
				wyArcticModule* module = afd->m_modules + i;

				// image index
				if((afd->m_flags & AS_MODULES_IMG) != 0) {
					module->imageIndex = readByte();
				}

				// location
				if((afd->m_flags & AS_MODULES_XY) != 0) {
					if((afd->m_flags & AS_MODULES_XY_SHORT) != 0) {
						module->x = readShort();
						module->y = readShort();
					} else {
						module->x = readByte();
						module->y = readByte();
					}
				}

				// size
				if((afd->m_flags & AS_MODULES_WH_SHORT) != 0) {
					module->w = readShort();
					module->h = readShort();
				} else {
					module->w = readByte();
					module->h = readByte();
				}
			}
		}
	}

	// read all frames
	if((afd->m_flags & AS_FRAMES) != 0) {
		// count of frame modules
		afd->m_frameModuleCount = readShort();

		// read all frame modules
		if(afd->m_frameModuleCount > 0) {
			afd->m_frameModules = (wyArcticFrameModule*)wyCalloc(afd->m_frameModuleCount, sizeof(wyArcticFrameModule));
			for(int i = 0; i < afd->m_frameModuleCount; i++) {
				wyArcticFrameModule* fm = afd->m_frameModules + i;
				fm->index = readByte();
				if((afd->m_flags & AS_FM_OFF_SHORT) != 0) {
					fm->x = readShort();
					fm->y = readShort();
				} else {
					fm->x = readByte();
					fm->y = readByte();
				}
				fm->flags = readByte();
			}
		}

		// count of frames
		afd->m_frameCount = readShort();

		// read all frames
		if(afd->m_frameCount > 0) {
			afd->m_frames = (wyArcticFrame*)wyCalloc(afd->m_frameCount, sizeof(wyArcticFrame));
			for(int i = 0; i < afd->m_frameCount; i++) {
				wyArcticFrame* f = afd->m_frames + i;
				f->moduleCount = readByte();
				f->firstModuleIndex = readShort();
			}
		}
		
		// read collision rect of this frame
		if((afd->m_flags & AS_FRAME_COL_RC) != 0) {
			for(int i = 0; i < afd->m_frameCount; i++) {
				wyArcticFrame* f = afd->m_frames + i;
				f->collisionRectCount = readByte();
				if(f->collisionRectCount > 0) {
					f->collisionRects = (wyRect*)wyCalloc(f->collisionRectCount, sizeof(wyRect));
//.........这里部分代码省略.........
开发者ID:Adoni,项目名称:WiEngine,代码行数:101,代码来源:wyArcticLoader.cpp

示例4: readInfo

void GuitarPro5::read(QFile* fp)
      {
      f = fp;
      readInfo();
      readLyrics();
      readPageSetup();

      previousDynamic = -1;
      previousTempo = -1;
      //previousDynamic = new int [staves * VOICES];
      // initialise the dynamics to 0
      //for (int i = 0; i < staves * VOICES; i++)
      //      previousDynamic[i] = 0;

      tempo = readInt();
      if (version > 500)
            skip(1);

      key    = readInt();
      /* int octave =*/ readChar();    // octave

      readChannels();
      skip(42);

      measures = readInt();
      staves  = readInt();

      slurs = new Slur*[staves];
      for (int i = 0; i < staves; ++i)
            slurs[i] = 0;

      int tnumerator   = 4;
      int tdenominator = 4;
      for (int i = 0; i < measures; ++i) {
            if (i > 0)
                  skip(1);
            GpBar bar;
            uchar barBits = readUChar();
            if (barBits & SCORE_TIMESIG_NUMERATOR)
                  tnumerator = readUChar();
            if (barBits & SCORE_TIMESIG_DENOMINATOR)
                  tdenominator = readUChar();
            if (barBits & SCORE_REPEAT_START)
                  bar.repeatFlags = bar.repeatFlags | Repeat::START;
            if (barBits & SCORE_REPEAT_END) {                // number of repeats
                  bar.repeatFlags = bar.repeatFlags |Repeat::END;
                  bar.repeats = readUChar();
                  }
            if (barBits & SCORE_MARKER) {
                  bar.marker = readDelphiString();     // new section?
                  /*int color =*/ readInt();    // color?
                  }
            if (barBits & SCORE_VOLTA) {                      // a volta
                  uchar voltaNumber = readUChar();
                  while (voltaNumber > 0) {
                        // voltas are represented as flags
                        bar.volta.voltaType = GP_VOLTA_FLAGS;
                        bar.volta.voltaInfo.append(voltaNumber & 1);
                        voltaNumber >>= 1;
                        }
                  }
            if (barBits & SCORE_KEYSIG) {
                  int currentKey = readUChar();
                  /* key signatures are specified as
                   * 1# = 1, 2# = 2, ..., 7# = 7
                   * 1b = 255, 2b = 254, ... 7b = 249 */
                  bar.keysig = currentKey <= 7 ? currentKey : -256+currentKey;
                  readUChar();        // specified major/minor mode
                  }
            if (barBits & SCORE_DOUBLE_BAR)
                  bar.barLine = BarLineType::DOUBLE;
            if (barBits & 0x3)
                  skip(4);
            if ((barBits & 0x10) == 0)
                  skip(1);

            readChar();             // triple feel  (none, 8, 16)
            bar.timesig = Fraction(tnumerator, tdenominator);
            bars.append(bar);
            }
开发者ID:jpirie,项目名称:MuseScore,代码行数:80,代码来源:importgtp-gp5.cpp

示例5: main

int main(void) {
  unsigned int bcd_max = BCDCapacity;

  unsigned framestream = 0; // Números de frames a executar

  unsigned int dma_t_ok; // Transferência RAM para DMA_VGA finalizado em 0

  unsigned int pixel;       // pixel lido da RAM

  unsigned int l, c;        // indexadores de linhas e colunas

  // Divide por 4 pois ponteiro é por palavra (?)
  img = (int*) dataImgAddressI/4;
  
  for (framestream = 0; framestream < frameStream; framestream++){

    readInt(&zoomCfg);
    readInt(&contrastecfg);


    if (zoomCfg == ZINACTIVE) { // Zoom inativo

        // escrita em memória sem ZOOM
		    for(l = 0; l < totalPixelImagem; l++){
		        bcd_max = bcdRSt();         
		        while(bcd_max <= 0){  // pooling?
		          bcd_max = bcdRSt();
		        }  

		        // leitura do buffer
		        pixel = bcdRRd();
		        
		        // escrita em memória
		        mem = img + l;
		        *mem = (int) pixel;
          }

    } else {                    // Zoom Ativo

      for(l = 0; l < alturaImagem; l++){
        for(c = 0; c < larguraImagem; c++){

            bcd_max = bcdRSt();         
            while(bcd_max <= 0){  // pooling?
              bcd_max = bcdRSt();
            }       

            // leitura do buffer
            pixel = bcdRRd();        

            // Replica para posição original
            mem = img + l*larguraImagem + c;
            *mem = (int) pixel;

            // Replica para posição original+1
            mem = img + l*larguraImagem + (c+1);
            *mem = (int) pixel;
          
            // Replica para próxima linha na posição original
            mem = img + (l+1)*larguraImagem + c;
            *mem = (int) pixel;

            // Replica para próxima linha na posição original+1
            mem = img + (l+1)*larguraImagem + (c+1);
            *mem = (int) pixel;

            c++;
        }
        l++;
      }

    } // if (zoomCfg == ZINACTIVE) else

    // Envio para VGA
  //  dmaVGA_init(a, w, s);
    dmaVGA_init(dataImgAddressI, 4, totalPixelImagem);
    dma_t_ok = dmaVGA_st();
    while(dma_t_ok != 0){
      dma_t_ok = dmaVGA_st();
    }

  } // for (framestream = 0; framestream < frameStream; framestream++){

  dmaVGA_closeFile();

//  while(1){
    // dumb core
//  }

  return 0;
}
开发者ID:memphis47,项目名称:TG,代码行数:91,代码来源:core1.c

示例6: readInt

int Page::getLocalDepth(){
	return readInt( 0,3 );
}
开发者ID:apir8181,项目名称:hash,代码行数:3,代码来源:Page.cpp

示例7: readUChar

int GuitarPro5::readBeat(int tick, int voice, Measure* measure, int staffIdx, Tuplet** tuplets, bool /*mixChange*/)
      {
      uchar beatBits = readUChar();
      bool dotted    = beatBits & BEAT_DOTTED;

      slide = -1;
      int track = staffIdx * VOICES + voice;
      if (slides.contains(track))
            slide = slides.take(track);

      int pause = -1;
      if (beatBits & BEAT_PAUSE)
            pause = readUChar();

      // readDuration
      int len   = readChar();
      int tuple = 0;
      if (beatBits & BEAT_TUPLET)
            tuple = readInt();

      Segment* segment = measure->getSegment(Segment::Type::ChordRest, tick);
      if (beatBits & BEAT_CHORD) {
            int numStrings = score->staff(staffIdx)->part()->instr()->stringData()->strings();
            skip(17);
            QString name = readPascalString(21);
            skip(4);
            // no header to be read in the GP5 format - default to true.
            readChord(segment, staffIdx * VOICES, numStrings, name, true);
            skip(32);
            }
      Lyrics* lyrics = 0;
      if (beatBits & BEAT_LYRICS) {
            QString txt = readDelphiString();
            lyrics = new Lyrics(score);
            lyrics->setText(txt);
            }
      gpLyrics.beatCounter++;
      if (gpLyrics.beatCounter >= gpLyrics.fromBeat && gpLyrics.lyricTrack == staffIdx+1) {
            int index = gpLyrics.beatCounter - gpLyrics.fromBeat;
            if (index < gpLyrics.lyrics.size()) {
                  lyrics = new Lyrics(score);
                  lyrics->setText(gpLyrics.lyrics[index]);
                  }
            }
      int beatEffects = 0;
      if (beatBits & BEAT_EFFECTS)
            beatEffects = readBeatEffects(track, segment);

      if (beatBits & BEAT_MIX_CHANGE)
            readMixChange(measure);

      int strings = readUChar();   // used strings mask

      Fraction l    = len2fraction(len);

      // Some beat effects could add a Chord before this
      ChordRest* cr = segment->cr(track);
      if (voice != 0 && pause == 0 && strings == 0)
            cr = 0;
      else {
            if (strings == 0) {
                  if (cr) {
                        segment->remove(cr);
                        delete cr;
                        cr = 0;
                        }
                  cr = new Rest(score);
                  }
            else  {
                  if (!cr)
                        cr = new Chord(score);
                  }
            cr->setTrack(track);

            TDuration d(l);
            d.setDots(dotted ? 1 : 0);

            if (dotted)
                  l = l + (l/2);

            if (tuple) {
                  Tuplet* tuplet = tuplets[staffIdx * 2 + voice];
                  if ((tuplet == 0) || (tuplet->elementsDuration() == tuplet->baseLen().fraction() * tuplet->ratio().numerator())) {
                        tuplet = new Tuplet(score);
                        // int track = staffIdx * 2 + voice;
                        tuplets[staffIdx * 2 + voice] = tuplet;
                        tuplet->setTrack(cr->track());
                        setTuplet(tuplet, tuple);
                        tuplet->setParent(measure);
                        }
                  tuplet->setTrack(cr->track());
                  tuplet->setBaseLen(l);
                  tuplet->setDuration(l * tuplet->ratio().denominator());
                  cr->setTuplet(tuplet);
                  tuplet->add(cr);
                  }

            cr->setDuration(l);
            if (cr->type() == Element::Type::REST && (pause == 0 || l == measure->len()))
                  cr->setDurationType(TDuration::DurationType::V_MEASURE);
//.........这里部分代码省略.........
开发者ID:jpirie,项目名称:MuseScore,代码行数:101,代码来源:importgtp-gp5.cpp

示例8: maybeReadWhitespace

void ParseOBJ::readFace() {
    // Ensure that we have a material
    if (isNull(m_currentMaterial)) {
        m_currentMaterial = m_currentMaterialLibrary.materialTable["default"];
    }

    // Ensure that we have a group
    if (isNull(m_currentGroup)) {
        // Create a group named "default", per the OBJ specification
        m_currentGroup = Group::create();
        m_currentGroup->name = "default";
        groupTable.set(m_currentGroup->name, m_currentGroup);

        // We can't have a mesh without a group, but conservatively reset this anyway
        m_currentMesh.reset();
    }

    // Ensure that we have a mesh
    if (isNull(m_currentMesh)) {
        bool created = false;
        shared_ptr<Mesh>& m = m_currentGroup->meshTable.getCreate(m_currentMaterial, created);

        if (created) {
            m = Mesh::create();
            m->material = m_currentMaterial;
        }
        m_currentMesh = m;
    }

    Face& face = m_currentMesh->faceArray.next();

    const int vertexArraySize   = vertexArray.size();
    const int texCoordArraySize = texCoord0Array.size();
    const int normalArraySize   = normalArray.size();

    // Consume leading whitespace
    bool done = maybeReadWhitespace();
    while (! done) {
        Index& index = face.next();

        // Read index
        index.vertex = readInt();
        if (index.vertex > 0) {
            // Make 0-based
            --index.vertex;
        } else {
            // Negative; make relative to the current end of the array.
            // -1 will be the last element, so just add the size of the array.
            index.vertex += vertexArraySize;
        }

        if ((remainingCharacters > 0) && (*nextCharacter == '/')) {
            // Read the slash
            consumeCharacter();

            if (remainingCharacters > 0) {
                if (*nextCharacter != '/') {
                    // texcoord index
                    index.texCoord = readInt();
                    if (index.texCoord > 0) {
                        // Make 0-based
                        --index.texCoord;
                    } else {
                        // Negative; make relative to the current end
                        // of the array.  -1 will be the last element,
                        // so just add the size of the array.
                        index.texCoord += texCoordArraySize;
                    }
                }

                if ((remainingCharacters > 0) && (*nextCharacter == '/')) {
                    // Consume the slash
                    consumeCharacter();

                    // normal index
                    index.normal = readInt();
                    if (index.normal > 0) {
                        // Make 0-based
                        --index.normal;
                    } else {
                        // Negative; make relative to the current
                        // end of the array.  -1 will be the last
                        // element, so just add the size of the
                        // array.
                        index.normal += normalArraySize;
                    }       
                }
            }
        }

        // Read remaining whitespace
        done = maybeReadWhitespace();
    }
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:94,代码来源:ParseOBJ.cpp

示例9: TreeNode

void BPlusTree::insertInParent(TreeNode *node,
        int startKeyInSplitNode,
        int splitNodeId,
        TreeNode** trace, int level) {

    BufferManager *bm = BufferManager::getInstance(dbName);
    //cout<<endl<<"level: "<<level<<"startKeyInSplitNode: "<<startKeyInSplitNode<<endl;
    if (level == 0) {
        //cout<<"parent is root"<<endl;
        int newId = StorageManager::allocateBlock(dbName);
        char* newNodeBuff = bm->pinPage(newId);
        TreeNode *newNode = new TreeNode(newNodeBuff);

        //copying the content of old root to new node
        moveBytes(root->getBuffPage(), newNode->getBuffPage(),
                BLOCK_SIZE);

        root->setNoPairs(1);
        root->setIsLeaf(0);

        writeInt(root->getBuffPage(), 2 * SIZE_INT, newId);

        writeInt(root->getBuffPage(),
                2 * SIZE_INT + PTR_SIZE, startKeyInSplitNode);

        writeInt(root->getBuffPage(),
                2 * SIZE_INT + PAIR_SIZE, splitNodeId);

        bm->unpinPage(newId, true);
        delete newNode;
        cout << "parent is root: done" << endl;
    } else {
        //cout<<"else case entered"<<endl;
        TreeNode *parentNode = trace[level - 1];
        int noPairs = parentNode->getNoPairs();
        cout << "no of pairs" << noPairs << endl;
        if (noPairs < maxNoPairs) {
            //int childId = getDiskBlockId( node->getBuffPage() );
            int firstKeyInNode = readInt(node->getBuffPage(),
                    2 * SIZE_INT + PTR_SIZE);

            int keyCount;
            int ithKey = readInt(parentNode->getBuffPage(),
                    2 * SIZE_INT + PTR_SIZE);

            for (keyCount = 0; keyCount < noPairs &&
                    firstKeyInNode >= ithKey; keyCount++) {

                ithKey = readInt(parentNode->getBuffPage(),
                        2 * SIZE_INT + (keyCount + 1) * PAIR_SIZE + PTR_SIZE);
            }

            cout << " keycount: " << keyCount << " stop Key " << ithKey << endl;

            if (keyCount < noPairs) {

                moveBytes(parentNode->getBuffPage() + 2 * SIZE_INT +
                        keyCount * PAIR_SIZE + PTR_SIZE,
                        parentNode->getBuffPage() + 2 * SIZE_INT +
                        (keyCount + 1) * PAIR_SIZE + PTR_SIZE,
                        (noPairs - keyCount) * PAIR_SIZE);

                //writes split key	
                writeInt(parentNode->getBuffPage(),
                        2 * SIZE_INT + keyCount * PAIR_SIZE +
                        PTR_SIZE, startKeyInSplitNode);

                //writes split node id just after split key
                writeInt(parentNode->getBuffPage(),
                        2 * SIZE_INT + (keyCount + 1) * PAIR_SIZE, splitNodeId);
            } else {

                //writes split key to k of nth pair(new apir)
                writeInt(parentNode->getBuffPage(),
                        2 * SIZE_INT + noPairs * PAIR_SIZE + PTR_SIZE,
                        startKeyInSplitNode);

                //writes splitNodeId to p(n)( at the end) 
                writeInt(parentNode->getBuffPage(),
                        2 * SIZE_INT + (noPairs + 1) * PAIR_SIZE, splitNodeId);
            }
            parentNode->setNoPairs(noPairs + 1);

            bm->unpinPage(trace[level]->getBuffPage(), true);
            delete trace[level];
            for (int i = level - 1; i >= 1; i--) {
                bm->unpinPage(trace[i]->getBuffPage(), false);
                delete trace[i];
            }
        } else {
            cout << "parent splitting" << endl;
            int newNodeId = StorageManager::allocateBlock(dbName);
            char* newNodeBuff = bm->pinPage(newNodeId);
            TreeNode *newNode = new TreeNode(newNodeBuff);

            char temp[BLOCK_SIZE + 1];
            moveBytes(parentNode->getBuffPage() + 2 * SIZE_INT,
                    temp, BLOCK_SIZE - 2 * SIZE_INT);

            int keyCount;
//.........这里部分代码省略.........
开发者ID:rathodsachin20,项目名称:mubase,代码行数:101,代码来源:bt.cpp

示例10: readSubspace

void
readSubspace (Subspace *s, const char* trainingFile, int quiet)
{
    int i, j, headerSize, rowDim, colDim;
    char junk[FILE_LINE_LENGTH], text[FILE_LINE_LENGTH];
    char** header;
    float ftemp;
    FILE* file;

    headerSize = 255;
    header = (char**) malloc (sizeof(char*) * headerSize);
    assert (header);
    for (i = 0; i < headerSize; i++) {
        header[i] = (char*) malloc(sizeof(char) * FILE_LINE_LENGTH);
        assert (header[i]);
    }

    file = fopen (trainingFile, "rb");

    if (!file) {
        printf("Error: could not open file <%s>\n", trainingFile);
        exit(1);
    }

    for (i = 0; i < headerSize; i++)
        fgets(header[i], FILE_LINE_LENGTH, file);

    if (!quiet) {
        printf("\nTraining Header File is:\n");
        for (i = 0; i < TRAINING_HEADER_ENTRIES; i++)
            printf("   Line %d: %s", i, header[i]);
    }

    sscanf(header[7], "%s%s%d", junk, junk, &s->basisDim);
    sscanf(header[4], "%s%*s%s", junk, text);

    if (strcmp(text, "NO") == 0)
        s->useLDA = 0;
    else
        s->useLDA = 1;


    /*START: Changed by Zeeshan: for LPP*/
    sscanf(header[10], "%s%*s%s", junk, text);

    if (strcmp(text, "NO") == 0)
        s->useLPP = 0;
    else
        s->useLPP = 1;

    sscanf(header[11], "%s%s%d", junk, junk, &s->neighbourCount);
    sscanf(header[12], "%s%*s%s", junk, text);
    s->lppDistance = strdup(text);
    sscanf(header[13], "%s%s%d", junk, junk, &s->lppKeepNVectors);
    sscanf(header[14], "%s%s%d", junk, junk, &s->useAdaptiveK);
    /*END: Changed by Zeeshan: for LPP*/

    /*START: 	Changed by Zeeshan: for ICA*/
    sscanf(header[15], "%s%*s%s", junk, text);

    if (strcmp(text, "NO") == 0)
        s->useICA = 0;
    else
        s->useICA = 1;

    sscanf(header[16], "%s%s%d", junk, junk, &s->blockSize);
    sscanf(header[17], "%s%s%e", junk, junk, &ftemp);
    s->learningRate = (double)ftemp;
    sscanf(header[18], "%s%s%d", junk, junk, &s->iterations);
    sscanf(header[19], "%s%s%d", junk, junk, &s->arch);
    /*END: 		Changed by Zeeshan: for ICA*/


    readInt (file,&rowDim);
    s->numPixels = rowDim;
    DEBUG_INT (3, "Vector size", rowDim);
    s->mean = makeMatrix(rowDim, 1);
    for (i = 0; i < (s->mean)->row_dim; i++) {
        readDouble (file, &ME(s->mean,i,0));
    }

    readInt (file,&rowDim);
    s->values = makeMatrix (rowDim, 1);
    for (i = 0; i < (s->values)->row_dim; i++) {
        readDouble (file, &ME(s->values,i,0));
    }

    rowDim = s->numPixels;
    readInt (file,&colDim);
    s->basis = makeMatrix (rowDim, colDim);
    for (i = 0; i < (s->basis)->col_dim; i++) {
        for (j = 0; j < (s->basis)->row_dim; j++) {
            readDouble (file, &ME(s->basis, j, i));
        }
    }

    if(s->useICA)
    {
        /*START: 	Changed by Zeeshan: for ICA*/
        readInt (file,&rowDim);
//.........这里部分代码省略.........
开发者ID:prashanthbuv,项目名称:facerec,代码行数:101,代码来源:csuCommonSubspace.c

示例11: DO_RETURN_R

unsigned int CCBuffer::readUInt()
{
	DO_RETURN_R(TO_UINT(readInt()));
}
开发者ID:Ajention,项目名称:codestore,代码行数:4,代码来源:CCBuffer.cpp

示例12: readInt

GLuint Model::loadTexture(const std::string& strFilename)
{
  GLuint pId=0;
  if(stricmp(strrchr(strFilename.c_str(),'.'),".raw")==0)
  {

     // open the texture file
     std::ifstream file;
     file.open(strFilename.c_str(), std::ios::in | std::ios::binary);
     if(!file)
     {
       std::cerr << "Texture file '" << strFilename << "' not found." << std::endl;
       return 0;
     }

     // load the dimension of the texture
     int width = readInt(&file);     
     int height = readInt(&file);     
     int depth = readInt(&file);     

     // allocate a temporary buffer to load the texture to
    unsigned char *pBuffer;
    pBuffer = new unsigned char[width * height * depth];
    if(pBuffer == 0)
    {
      std::cerr << "Memory allocation for texture '" << strFilename << "' failed." << std::endl;
      return 0;
    }

    // load the texture
    file.read((char *)pBuffer, width * height * depth);

    // explicitely close the file
    file.close();

    // generate texture
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glGenTextures(1, &pId);
    glBindTexture(GL_TEXTURE_2D, pId);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, (depth == 3) ? GL_RGB : GL_RGBA, width, height, 0, (depth == 3) ? GL_RGB : GL_RGBA, GL_UNSIGNED_BYTE, &pBuffer[0]);
  
    // free the allocated memory
    delete [] pBuffer;
  
  }
  else if (stricmp(strrchr(strFilename.c_str(),'.'),".tga")==0)
  {

    CTga *Tga;
    Tga = new CTga();

    //Note: This will always make a 32-bit texture
    if(Tga->ReadFile(strFilename.c_str())==0)
    {
      Tga->Release();
      return false;
    }

    //Bind texture
    int width = Tga->GetSizeX();
    int height = Tga->GetSizeY();
    int depth = Tga->Bpp() / 8;

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glGenTextures(1, &pId);
      
    glBindTexture(GL_TEXTURE_2D, pId);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     
    glTexImage2D(GL_TEXTURE_2D, 0, ((depth == 3) ? GL_RGB : GL_RGBA), width, height, 0, ((depth == 3) ? GL_RGB : GL_RGBA) , GL_UNSIGNED_BYTE, (char*)Tga->GetPointer() );

	 Tga->Release();
  }


  return pId;
}
开发者ID:bsmr-opengl,项目名称:cal3d,代码行数:85,代码来源:model.cpp

示例13: parseBitmapFontGeneratorFile

	int parseBitmapFontGeneratorFile(MAHandle file, int end, Charset *charset) {
		char ident[4];
		// read magic
		//maReadData(file, ident, filePtr, 4); 
		readChars(ident, 4);
		int version = ident[3];
		if(ident[0] != 'B' || ident[1] != 'M' || ident[2] != 'F' || version < 2 || version > 3) {
			//PANIC_MESSAGE("Wrong .fnt format!");
			//printf("Wrong .fnt format!\n");
			return 0;
		}

		for(int i = 0; i < 255; i++) {
			charset->chars[i].x	= 0xffff;
		}

		while(sFilePos != end) {
			// read block type and block size
			unsigned char id = readByte();
			unsigned int blockSize = readInt();
			unsigned int skipValue = blockSize;
			if(version == 2) skipValue -= 4;
			switch(id) {
				case 1:
					{
						int initialFilePos = sFilePos;
						skipBytes(14);

						int i = readChars(charset->name, CHARSET_MAX_NAME_LEN);
						charset->name[i-1] = 0;
						skipBytes((skipValue+initialFilePos)-sFilePos);
					}
					break;
				case 2:
					// type common
					//#pragma pack(1)
					//struct commonBlock
					//{
					//    int  blockSize;
					//    WORD lineHeight;
					//    WORD base;
					//    WORD scaleW;
					//    WORD scaleH;
					//    WORD pages;
					//    BYTE packed  :1;
					//    BYTE encoded :1;      // Added with version 2
					//    BYTE reserved:6;
					//}; 
					//int blockSize = readInt(file, &filePtr);
					{
						//int filePtrBefore = filePtr;
						//printf("Reading common block!\n");
						charset->lineHeight		= readShort();
						charset->base			= readShort();
						charset->width			= readShort();
						charset->height			= readShort();
						charset->pages			= readShort();
						if(version==2)
							skipBytes(1);
						else
							skipBytes(5);

						//int currentBlockSize = (filePtr-filePtrBefore)+4;	
						//printf("blockSize: %d, currentBlockSize: %d\n", blockSize, currentBlockSize);
					}
					break;
				case 4:
					// type char
					//struct charsBlock
					//{
					//    int blockSize;
					//    struct charInfo
					//    {
					//        WORD  id;
					//        WORD  x;
					//        WORD  y;
					//        WORD  width;
					//        WORD  height;
					//        short xoffset;
					//        short yoffset;
					//        short xadvance;
					//        BYTE  page;
					//        BYTE  chnl;
					//    } chars[1];
					//};
					//int blockSize = readInt(file, &filePtr);
					{
						//int filePtrBefore = filePtr;
						int numBytesPerChar = 18;
						if(version == 3) numBytesPerChar = 20;

						int numTimes = skipValue/numBytesPerChar;
						while(numTimes--) {
							//printf("Reading char block! filePtr: %d\n", filePtr);
							
							unsigned int c;
							if(version == 2)
								c = readShort();
							else
								c = readInt();
//.........这里部分代码省略.........
开发者ID:NeqHealthcare,项目名称:MoSync,代码行数:101,代码来源:Font.cpp

示例14: MQTTSPacket_Factory

void* MQTTSPacket_Factory(int sock, char** clientAddr, struct sockaddr* from, int* error)
{
	static MQTTSHeader header;
	int ptype;
	void* pack = NULL;
	/*struct sockaddr_in cliAddr;*/
	int n;
	char* data = &msg[0];
	socklen_t len = sizeof(struct sockaddr_in6);

	FUNC_ENTRY;
/* #if !defined(NO_BRIDGE)
	client = Protocol_getoutboundclient(sock);
	FUNC_ENTRY;
	if (client!=NULL)
		n = recv(sock,msg,512,0);
	else
 #endif */

	/* max message size from global parameters, as we lose the packet if we don't receive it.  Default is
	 * 65535, so the parameter can be used to decrease the memory usage.
	 * The message memory area must be allocated on the heap so that this memory can be not allocated
	 * on reduced-memory systems.
	 */
	n = recvfrom(sock, msg, max_packet_size, 0, from, &len);
	if (n == SOCKET_ERROR)
	{
		int en = Socket_error("UDP read error", sock);
		if (en == EINVAL)
			Log(LOG_WARNING, 0, "EINVAL");

		*error = SOCKET_ERROR;
		goto exit;
	}

	*clientAddr = Socket_getaddrname(from, sock);
/*
	printf("%d bytes of data on socket %d from %s\n",n,sock,*clientAddr);
	if (n>0) {
		for (i=0;i<n;i++) {
			printf("%d ",msg[i]);
		}
		printf("\n");
	}
*/
	*error = SOCKET_ERROR;  // indicate whether an error occurred, or not
	if (n < 2)
		goto exit;

	if (msg[0] == 1)
	{
		++data;
		header.len = readInt(&data);
	}
	else
		header.len = *(unsigned char*)data++;
	header.type = *data++;
	//printf("header.type is %d, header.len is %d, n is %d\n", header.type, header.len, n);
    if (header.len != n)
    {
		*error = UDPSOCKET_INCOMPLETE;
		goto exit;
    }
	else
	{
		ptype = header.type;
		if (ptype < MQTTS_ADVERTISE || ptype > MQTTS_WILLMSGRESP || new_mqtts_packets[ptype] == NULL)
			Log(TRACE_MAX, 17, NULL, ptype);
		else if ((pack = (*new_mqtts_packets[ptype])(header, data)) == NULL)
			*error = BAD_MQTTS_PACKET;
	}
exit:
   	FUNC_EXIT_RC(*error);
   	return pack;
}
开发者ID:daviddeng,项目名称:org.eclipse.mosquitto.rsmb,代码行数:75,代码来源:MQTTSPacket.c

示例15: getLeaf

void BPlusTree::insertEntry(int key, int rid) {

    BufferManager *bm = BufferManager::getInstance(dbName);
    int height;
    TreeNode **trace = new TreeNode *[10];
    for (int i = 0; i < 10; i++)
        trace[i] = NULL;

    TreeNode *leafNode = getLeaf(key, trace, &height);
    //cout<<endl<<"height of the tree: "<<height<<endl;
    if (leafNode == NULL)
        cout << "exception null node" << endl;

    cout << "lookup " << lookUpWithoutUnpin(key, leafNode) << endl;
    if (lookUpWithoutUnpin(key, leafNode) != -1) {
        cout << "key already exists" << endl;
        for (int i = height; i >= 1; i--) {
            //cout<<"unpinning trace:"<<endl;
            bm->unpinPage(trace[i]->getBuffPage(), false);
            delete trace[i];
        }
    }
    else {

        int nofPairs = readInt(leafNode->getBuffPage(), 0);
        //if num of pairs less than n-1
        if (nofPairs < maxNoPairs) {

            insertInLeaf(leafNode, key, rid);
            if (height != 0) {

                bm->unpinPage(leafNode->getBuffPage(), true);
                //cout<<"unpinning the leaf node which is not a root"<<endl;
            }
            //delete leafNode;			

            for (int i = height - 1; i >= 1; i--) {
                //cout<<"unpinning trace:"<<endl;
                bm->unpinPage(trace[i]->getBuffPage(), false);
                delete trace[i];
            }

        } else {
            int newLeafId = StorageManager::allocateBlock(dbName);
            char* newLeafNodeBuff = bm->pinPage(newLeafId);
            TreeNode *newLeafNode = new TreeNode(newLeafNodeBuff);

            int divideKeyOffset = maxNoPairs / 2;
            //cout<<"divideKeyOffset: "<<divideKeyOffset<<endl;
            int divideKey = readInt(leafNode->getBuffPage(),
                    2 * SIZE_INT + divideKeyOffset * PAIR_SIZE + PTR_SIZE);

            cout << "divideKey: " << divideKey << endl;
            if (key < divideKey) {

                moveBytes(leafNode->getBuffPage() +
                        2 * SIZE_INT + divideKeyOffset*PAIR_SIZE,
                        newLeafNode->getBuffPage() + 2 * SIZE_INT,
                        (maxNoPairs - divideKeyOffset) * PAIR_SIZE);

                //writing "nofPairs" into new leaf				
                //writeInt(newLeafNode->getBuffPage(),0,(maxNoPairs+1)/2);
                newLeafNode->setNoPairs((maxNoPairs + 1) / 2);

                //writing "isLeaf" into new leaf
                //writeInt(newLeafNode->getBuffPage(),SIZE_INT,1);
                newLeafNode->setIsLeaf(1);

                //copying P(n) of leaf to P(n) of new leaf
                moveBytes(leafNode->getBuffPage() +
                        BLOCK_SIZE - PTR_SIZE,
                        newLeafNode->getBuffPage() +
                        BLOCK_SIZE - PTR_SIZE, PTR_SIZE);

                //make p(n) of leaf to point to new leaf
                writeInt(leafNode->getBuffPage(),
                        BLOCK_SIZE - PTR_SIZE, newLeafId);

                leafNode->setNoPairs(maxNoPairs / 2);

                insertInLeaf(leafNode, key, rid);
                bm->unpinPage(newLeafId, true);

                insertInParent(leafNode, divideKey,
                        newLeafId, trace, height);
            } else {

                moveBytes(leafNode->getBuffPage() +
                        2 * SIZE_INT + (divideKeyOffset + 1) * PAIR_SIZE,
                        newLeafNode->getBuffPage() + 2 * SIZE_INT,
                        (maxNoPairs - divideKeyOffset - 1) * PAIR_SIZE);

                //writing "nofPairs" into new leaf				
                //writeInt(newLeafNode->getBuffPage(),0,maxNoPairs-divideKeyOffset-1);
                newLeafNode->setNoPairs(maxNoPairs - divideKeyOffset - 1);

                //writing "isLeaf" into new leaf
                //writeInt(newLeafNode->getBuffPage(),SIZE_INT,1);
                newLeafNode->setIsLeaf(1);

//.........这里部分代码省略.........
开发者ID:rathodsachin20,项目名称:mubase,代码行数:101,代码来源:bt.cpp


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