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

C++ readShort函数代码示例

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

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



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

示例1: readLong

/** Read an unsigned 32-bit integer from the file. */
inline unsigned readLong(FILE * f, bool_t bigEndian)
{
	if (bigEndian)
		return (readShort(f, bigEndian) << 16) | readShort(f, bigEndian);
	else
		return readShort(f, bigEndian) | (readShort(f, bigEndian) << 16);
}
开发者ID:ziman,项目名称:jpg-recover,代码行数:8,代码来源:tiff.c


示例2: create

CCAFCClipMapping* CCAFCClipMapping::createWithAuroraGT(int tag, const char* data, size_t length) {
	// create empty mapping
	CCAFCClipMapping* m = create(tag);

	/*
	 * parse module mapping data, its format is simple
	 * 1. [SRC CLIP INDEX][DEST CLIP INDEX]
	 * 2. [SRC CLIP INDEX][DEST CLIP INDEX]
	 * 3. [SRC CLIP INDEX][DEST CLIP INDEX]
	 * ...
	 *
	 * index are 2 bytes and in little endian
	 */
	s_data = data;
	s_pos = 0;
	while(s_pos + 4 <= length) {
		/*
		 * Don't use m->mapClip(readShort(), readShort()), it looks ok
		 * at first glance, but the readShort invocation order depends on argument
		 * push priority. If right argument is pushed first, then right readShort
		 * will be called first and it is definitely not what we expect
		 */
		short from = readShort();
		short to = readShort();
		m->mapClip(from, to);
	}

	return m;
}
开发者ID:stanhome,项目名称:cocos2dx-classical,代码行数:29,代码来源:CCAFCClipMapping.cpp


示例3: read2ByteBool

    //---------------------------------------------------------------------
    void
    BackgroundFileSerializer::readObject( Ogre::DataStreamPtr &stream, Page &pDest )
    {
        read2ByteBool( stream, pDest.enabled );
        if( !pDest.enabled ) return;

        readShort( stream, pDest.unknown_02 );
        readShort( stream, pDest.value_size );
        if( pDest.value_size != 1 && pDest.value_size != 2 )
        {
            OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
                ,"Page value_size other then 1 and 2 is not supported"
                ,"BackgroundFileSerializer::readObject" );
        }

        size_t color_count( BackgroundFile::PAGE_DATA_SIZE );
        pDest.colors.clear();
        pDest.data.clear();

        if( pDest.value_size == 2 )
        {
            pDest.colors.reserve( color_count );
            for( size_t i( color_count ); i--; )
            {
                Color colourDest;
                readObject( stream, colourDest );
                pDest.colors.push_back( colourDest );
            }
        }
        else
        {
            pDest.data.resize( color_count );
            stream->read( &pDest.data[0], color_count );
        }
    }
开发者ID:adrielvel,项目名称:q-gears,代码行数:36,代码来源:QGearsBackgroundFileSerializer.cpp


示例4: processDri

void JPEGDecompressor::processDri(void)
	{
	/* Check length of variable: */
	if(readShort(source)!=4)
		Misc::throwStdErr("JPEGDecompressor::processDri: DRI marker has wrong length");
	
	/* Read restart interval: */
	restartInterval=readShort(source);
	}
开发者ID:KeckCAVES,项目名称:3DVisualizer,代码行数:9,代码来源:JPEGDecompressor.cpp


示例5: readFrame

BOOL readFrame(unsigned short *frame_size,unsigned short *checksum,unsigned char frame[],HANDLE *hdlr)
{

    unsigned char byte=0;

    if(!readByte(&byte,hdlr))
        return FALSE;

    if(byte==0x55)
    {
        if(!readShort(frame_size,hdlr))
            return FALSE;
    }
    else
    {
        while(byte!=0x55)
        {
            if(!readByte(&byte,hdlr))
                return FALSE;
        }
        if(!readShort(frame_size,hdlr))
            return FALSE;
    }

    unsigned char t_frame[*frame_size];
    t_frame[0] = byte;
    t_frame[1] = *frame_size&0x00FF;
    t_frame[2] = (*frame_size&0xFF00)>>8;

    //printf("__Frame size: %d bytes \r\n",*frame_size);
    int i = 3;
    do
    {
        if(!readByte(&byte,hdlr))
            return FALSE;
        //printf("%d:%x  ",i+1,byte);
        t_frame[i]=byte;
        i=i+1;
    }while(i<*frame_size);

    memcpy(frame,t_frame,*frame_size);

    #ifdef _DEBUG
    printf("[DEBUG] ");
    printf("Frame  received: \n");
    printf("[DEBUG] ");
    printf("_Frame size: %d \n",*frame_size);
    printf("[DEBUG] ");
    printf("_Frame type: 0x%x \n",frame[3]);
    #endif

    return TRUE;
}
开发者ID:A-Nesh,项目名称:FSi6_updater,代码行数:53,代码来源:serial.c


示例6: main

int main() {
	short n, menor1 = 101, menor2 = 102, mayor1, mayor2;
	int cont;

	writeLnString("Ingrese valores positivos para encontrar los 2 menores y los 2 mayores, finalice el ingreso de datos con 0");

	cont = 0;
	writeString("Ingrese un número entero: ");
	readShort(n);

	while (n != 0) {
		if (n < menor1  || cont == 1) {
			menor2 = menor1;
			menor1 = n;
		} else if (n < menor2 || cont == 2) {
			menor2 = n;
		}

		if (n > mayor1  || cont == 1) {
			mayor2 = mayor1;
			mayor1 = n;
		} else if (n > mayor2 || cont == 2) {
			mayor2 = n;
		}

		cont++;
		writeString("Ingrese un número entero: ");
		readShort(n);
	}

	if(cont < 3){
		writeLnString("No hay suficientes valores para determinar 3 menores, los resultados parciales son: ");
	}

	if(cont >= 1)
	{
		writeString("El menor es: ");
		writeLnShort(menor1);

		writeString("El mayor es: ");
		writeLnShort(mayor1);

	}

	if(cont >= 2)
	{
		writeString("El segundo menor es: ");
		writeLnShort(menor2);

		writeString("El segundo mayor es: ");
		writeLnShort(mayor2);
	}
}
开发者ID:WEREMSOFT,项目名称:universidad,代码行数:53,代码来源:ej159.cpp


示例7: storeBitmap

Snap* storeBitmap(const char* fname) 
{
	// Open the file to read the bitmap snap content
	std::ifstream in;
	in.open(fname, std::ifstream::binary);
	assert(!in.fail() || !"Could not find file");

	char store[2];
	in.read(store, 2);

	// Check for the first two characters of the snap file, if it has 
	// "B" and "M" then its a bmp file
	assert(store[0] == 'B' && store[1] == 'M' || !"Not a bitmap file");
	in.ignore(8);
	int info = readInteger(in);
	
	// Fetch the header content
	int sizeH = readInteger(in);
	int w, h;
	
	w = readInteger(in);
	h = readInteger(in);
	in.ignore(2);
	assert(readShort(in) == 24 || !"Image is not 24 bits per pixel");
	assert(readShort(in) == 0 || !"Image is compressed");
	
	int BPerRCount = ((w * 3 + 3) / 4) * 4 - (w * 3 % 4);
	int sizeA = BPerRCount * h;
	
	vishakArray<char> pixelArrayObj(new char[sizeA]);
	
	in.seekg(info, std::ios_base::beg);
	in.read(pixelArrayObj.get(), sizeA);
	
	//Get the data into the right format
	vishakArray<char> pixelArrayObj2(new char[w * h * 3]);

	for(int y = 0; y < h; y++) {
		for(int x = 0; x < w; x++) {
			for(int c = 0; c < 3; c++) {
				pixelArrayObj2[3 * (w * y + x) + c] =
					pixelArrayObj[BPerRCount * y + 3 * x + (2 - c)];
			}
		}
	}
	
	in.close();
	return new Snap(pixelArrayObj2.release(), w, h);
}
开发者ID:vishaknag,项目名称:Simulation-constrainedParticleSystem,代码行数:49,代码来源:texture.cpp


示例8: readByte

unsigned long chunkArchive::readAny(unsigned char *type, unsigned long *size)
{
	unsigned char id = readByte();
	if (type)
		*type = id;
	switch ((atoms) (id)) {
	case CHUNK_BYTE:
		if (size)
			*size = 1;
		return readByte();
		break;
	case CHUNK_SHORT:
		if (size)
			*size = 2;
		return readShort();
		break;
	case CHUNK_LONG:
		if (size)
			*size = 4;
		return readLong();
		break;
	case CHUNK_STRING:
		return (unsigned long) readString(size);
		break;
	case CHUNK_BINARY:
		return (unsigned long) readBinary(size);
		break;
	default:
		if (size)
			*size = 0;
		return 0;
	}
}
开发者ID:itadinanta,项目名称:emufxtool,代码行数:33,代码来源:chunkfile.C


示例9: return

uint16
GfxFeatureMapRequestPacket::getEndOffset() const
{
   int pos = endOffset_POS;

   return ( readShort( pos ) );
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:7,代码来源:GfxFeatureMapPacket.cpp


示例10: readShort

/*! \sa PacketProcessor
 */
unsigned short PacketProcessor::calculateCheckSum(unsigned char *ptr_PacketBuffer)
{
    //checksum temp-store
    unsigned short l_16b=0;
    unsigned l_32b=0;
    //sum the header fields in chunks of short
    for (int i = 1; i < HEADER_LENGTH; i += 2)
        {
            //read next short from the header
            l_16b = readShort(&ptr_PacketBuffer[i]);

            //add it with the previous short
            l_32b += l_16b;            
        }


    //Store low order bits
    l_16b = 0;
    l_16b |= l_32b;

    //shift the carry bits
    l_32b >>= 16;

    //add the carry bits and low order bits
    l_16b += l_32b;
    return l_16b;    

}
开发者ID:Keepalive-PP,项目名称:ProtocolProcessing_Group2,代码行数:30,代码来源:PacketProcessor.cpp


示例11: va_start

void ByteStream::readFormat(const char *fmt, ...) {
	va_list ap;

	va_start(ap, fmt);

	while (*fmt) {
		const char typeID = *fmt++;
		switch (typeID) {
		case 'b':
			*va_arg(ap, int *) = readByte();
			break;
		case 's':
			*va_arg(ap, int *) = readShort();
			break;
		case 'i':
			*va_arg(ap, int *) = readInt();
			break;
		case 'l':
			*va_arg(ap, long *) = readLong();
			break;
		default:
			core_assert(false);
		}
	}

	va_end(ap);
}
开发者ID:mgerhardy,项目名称:engine,代码行数:27,代码来源:ByteStream.cpp


示例12: readShort

void BufferedReader::readAndInternStringVector(std::vector<InternedString>& v) {
    int num_elts = readShort();
    if (VERBOSITY("parsing") >= 3)
        printf("%d elts to read\n", num_elts);
    for (int i = 0; i < num_elts; i++) {
        v.push_back(readAndInternString());
    }
}
开发者ID:lyzardiar,项目名称:pyston,代码行数:8,代码来源:parser.cpp


示例13: incReadShort

void 
GfxFeatureMapRequestPacket::getScreenSize(uint16& screenSizeX, 
                                    uint16& screenSizeY) const
{
   int position = screenSizeX_POS;
   screenSizeX = incReadShort(position);
   screenSizeY = readShort(position);
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:8,代码来源:GfxFeatureMapPacket.cpp


示例14: readLong

bool ZLZipHeader::readFrom(ZLInputStream &stream) {
	size_t startOffset = stream.offset();
	Signature = readLong(stream);
	switch (Signature) {
		default:
			return false;
		case SignatureLocalFile:
			Version = readShort(stream);
			Flags = readShort(stream);
			CompressionMethod = readShort(stream);
			ModificationTime = readShort(stream);
			ModificationDate = readShort(stream);
			CRC32 = readLong(stream);
			CompressedSize = readLong(stream);
			UncompressedSize = readLong(stream);
			if (CompressionMethod == 0 && CompressedSize != UncompressedSize) {
				ZLLogger::Instance().println("zip", "Different compressed & uncompressed size for stored entry; the uncompressed one will be used.");
				CompressedSize = UncompressedSize;
			}
			NameLength = readShort(stream);
			ExtraLength = readShort(stream);
			return stream.offset() == startOffset + 30 && NameLength != 0;
		case SignatureData:
			CRC32 = readLong(stream);
			CompressedSize = readLong(stream);
			UncompressedSize = readLong(stream);
			NameLength = 0;
			ExtraLength = 0;
			return stream.offset() == startOffset + 16;
	}
}
开发者ID:raghavkc,项目名称:fbreaderj2,代码行数:31,代码来源:ZLZipHeader.cpp


示例15: readShort

void
RouteStorageGetRouteReplyPacket::getDriverPrefs( 
   DriverPref& driverPref ) const 
{
   int pos = endStatic_POS;
   pos += readShort( strlenExtraUserinfo_POS ) + 1;
   pos += readLong( routePackLength_POS );
   driverPref.load( this, pos );
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:9,代码来源:RouteStoragePacket.cpp


示例16:

static unsigned char *loadSound_wav( String path,int *plength,int *pchannels,int *pformat,int *phertz ){

	if( FILE *f=fopenFile( path,"rb" ) ){
		if( !strcmp( readTag( f ),"RIFF" ) ){
			int len=readInt( f )-8;len=len;
			if( !strcmp( readTag( f ),"WAVE" ) ){
				if( !strcmp( readTag( f ),"fmt " ) ){
					int len2=readInt( f );
					int comp=readShort( f );
					if( comp==1 ){
						int chans=readShort( f );
						int hertz=readInt( f );
						int bytespersec=readInt( f );bytespersec=bytespersec;
						int pad=readShort( f );pad=pad;
						int bits=readShort( f );
						int format=bits/8;
						if( len2>16 ) skipBytes( len2-16,f );
						for(;;){
							const char *p=readTag( f );
							if( feof( f ) ) break;
							int size=readInt( f );
							if( strcmp( p,"data" ) ){
								skipBytes( size,f );
								continue;
							}
							unsigned char *data=(unsigned char*)malloc( size );
							if( fread( data,size,1,f )==1 ){
								*plength=size/(chans*format);
								*pchannels=chans;
								*pformat=format;
								*phertz=hertz;
								fclose( f );
								return data;
							}
							free( data );
						}
					}
				}
			}
		}
		fclose( f );
	}
	return 0;
}
开发者ID:JochenHeizmann,项目名称:monkey,代码行数:44,代码来源:main.cpp


示例17: MALLOC

static inline unsigned short *readShorts(spSkeletonBinary *self, size_t length)
{
    unsigned short *arr = MALLOC(unsigned short, length);
    for (int i = 0; i < length; i++)
    {
        arr[i] = readShort(self);
    }

    return arr;
}
开发者ID:zhongfq,项目名称:spine-binaryreader,代码行数:10,代码来源:SkeletonBinary.c


示例18: readShortFromStack

unsigned short readShortFromStack(void) {
	unsigned short value = readShort(registers.sp);
	registers.sp += 2;
	
	#ifdef DEBUG_STACK
		printf("Stack read 0x%04x\n", value);
	#endif
	
	return value;
}
开发者ID:NanoCoaster,项目名称:Cinoop,代码行数:10,代码来源:memory.c


示例19: readShort

bool ByteReader::readThree(unsigned int& value) {
	if (currPos+3>numBytesInBuffer) return false;
	unsigned short shrt;
	byte byt;
	readShort(shrt);
	readByte(byt);
	
	value=(unsigned int) ((shrt*0x100)+byt);
	return true;
}
开发者ID:Kamilll,项目名称:LRCS,代码行数:10,代码来源:ByteReader.cpp


示例20: readBytes

QString DataReader::readString(){
    QByteArray bstr = readBytes(readShort());
    QString str;
    int i = 0;
    while(i != bstr.size())
    {
        str.append(bstr.at(i));
        i++;
    }
    return (str);
}
开发者ID:anthony974,项目名称:DofusD2oReader,代码行数:11,代码来源:datareader.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ readSocket函数代码示例发布时间:2022-05-30
下一篇:
C++ readSelectorValue函数代码示例发布时间: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