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


C++ Stream::Get方法代码示例

本文整理汇总了C++中Stream::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::Get方法的具体用法?C++ Stream::Get怎么用?C++ Stream::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stream的用法示例。


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

示例1: Copy

String Copy(Stream& s, int spos, int ssize, int tpos, dword style) {
    bool lf = dynamic_cast<BlockStream *>(&s);
    if(lf) LOG("<<");
    if(style & T_SEEK)
        s.Seek(spos);
    Buffer<byte> b(ssize);
    int sz = 0;
    if(style & T_READ)
        if(style & T_READGROUP) {
            while(sz < ssize) {
                int c = s.Get();
                if(c < 0)
                    break;
                b[sz++] = c;
            }
            ssize = sz;
        }
        else
            ssize = (int)s.Get(b, ssize);
    if(lf) LOG(">>");
    if(style & T_SEEK)
        s.Seek(tpos);
    if(style & T_WRITE)
        if(style & T_WRITEGROUP)
            for(int i = 0; i < ssize; i++)
                s.Put(b[i]);
        else
            s.Put(b, ssize);
    if(style & T_READ)
        return String(b, ssize);
    return Null;
}
开发者ID:kolyden,项目名称:mirror,代码行数:32,代码来源:Stream.cpp

示例2: BZ2Decompress

void BZ2Decompress(Stream& out, Stream& in, Gate2<int, int> progress)
{
	enum { BUF_SIZE = 65536 };
	Buffer<char> input(BUF_SIZE), output(BUF_SIZE);
	int avail = in.Get(input, BUF_SIZE);
	if(avail == 0)
		return;
	bz_stream z;
	Zero(z);
	z.bzalloc = bzalloc_new;
	z.bzfree = bzfree_new;
	z.opaque = 0;
	if(BZ2_bzDecompressInit(&z, 0, 0) != BZ_OK)
	{
		out.SetError();
		return;
	}
	z.next_in = input;
	z.avail_in = avail;
	z.next_out = output;
	z.avail_out = BUF_SIZE;
	int code;
	bool running = true;
	int64 total = in.GetLeft();
	int done = 0;
	do
	{
		if(z.avail_in == 0 && running)
		{
			if((z.avail_in = in.Get(z.next_in = input, BUF_SIZE)) == 0)
				running = false;
			done += z.avail_in;
			if(progress(done, (int)total) || in.IsError())
			{
				BZ2_bzDecompressEnd(&z);
				out.SetError();
				return;
			}
		}
		code = BZ2_bzDecompress(&z);
		if(z.avail_out == 0)
		{
			out.Put(z.next_out = output, z.avail_out = BUF_SIZE);
			if(out.IsError())
			{
				BZ2_bzDecompressEnd(&z);
				return;
			}
		}
	}
	while(code == BZ_OK);
	if(z.avail_out < BUF_SIZE)
		out.Put(output, BUF_SIZE - z.avail_out);
	BZ2_bzDecompressEnd(&z);
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:55,代码来源:bz2upp.cpp

示例3: sSkipZ

static int sSkipZ(Stream& stream)
{
	int q = 0;
	while(stream.Get() > 0)
		q++;
	return q;
}
开发者ID:pedia,项目名称:raidget,代码行数:7,代码来源:z.cpp

示例4: sLoadBom

NAMESPACE_UPP

static void sLoadBom(Stream& in, String *t, WString *wt, byte def_charset) 
{
	if(in.IsOpen()) {
		String s;
		if(in.GetLeft() > 3) {
			word header = in.Get16le();
			if(header == 0xfffe || header == 0xfeff) {
				int n = (int)in.GetLeft() / 2;
				WStringBuffer ws(n);
				ws.SetLength(in.Get(~ws, 2 * n) / 2);
				if(header == 0xfffe)
					EndianSwap((word *)~ws, ws.GetCount());
				if(wt)
					*wt = ws;
				else
					*t = FromUnicode(ws);
				return;
			}
			int c = in.Get();
			if(c < 0)
				return;
			byte *h = (byte *)&header;
			if(h[0] == 0xef && h[1] == 0xbb && c == 0xbf) {
				if(wt)
					*wt = FromUtf8(LoadStream(in));
				else
					*t = ToCharset(CHARSET_DEFAULT, LoadStream(in), CHARSET_UTF8);
				return;
			}
			s.Cat(h, 2);
			s.Cat(c);
		}
		s.Cat(LoadStream(in));
		if(wt)
			*wt = ToUnicode(s, def_charset);
		else
			*t = ToCharset(CHARSET_DEFAULT, s, def_charset);
		return;
	}
	return;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:43,代码来源:Bom.cpp

示例5: sZpress

static int sZpress(Stream& out, Stream& in, int size, Gate2<int, int> progress, bool nohdr, dword *crc,
                    bool compress)
{
	const int BUF_SIZE = 65536;
	Buffer<Bytef> input(BUF_SIZE), output(BUF_SIZE);
	z_stream z;
	z.zalloc = zalloc_new;
	z.zfree = zfree_new;
	z.opaque = 0;
	if(compress ? deflateInit2(&z, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
	                          nohdr ? -MAX_WBITS : MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY)
	            : inflateInit2(&z, nohdr ? -MAX_WBITS : +MAX_WBITS) != Z_OK) {
		out.SetError();
		return -1;
	}
	int code;
	int flush;
	int done = 0;
	int outsz = 0;
	if(crc)
		*crc = crc32(0, NULL, 0);
	do {
		z.avail_in = in.Get(z.next_in = input, min(size - done, BUF_SIZE));
		if(progress(done += z.avail_in, size) || in.IsError())
			goto error;
		if(!compress && z.avail_in == 0)
			break;
		flush = z.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH;
		if(crc && compress)
			*crc = crc32(*crc, input, z.avail_in);
		do {
			z.avail_out = BUF_SIZE;
			z.next_out = output;
			code = (compress ? deflate : inflate)(&z, flush);
			if(code == Z_STREAM_ERROR)
				goto error;
			int count = BUF_SIZE - z.avail_out;
			if(crc && !compress)
			    *crc = crc32(*crc, output, count);
			out.Put(output, count);
			if(out.IsError())
				goto error;
			outsz += count;
	    }
		while(z.avail_out == 0);
    }
	while(compress ? flush != Z_FINISH : code != Z_STREAM_END);
	if(!compress || code == Z_STREAM_END) {
		(compress ? deflateEnd : inflateEnd)(&z);
		return outsz;
	}
error:
	(compress ? deflateEnd : inflateEnd)(&z);
	return -1;
}
开发者ID:pedia,项目名称:raidget,代码行数:55,代码来源:z.cpp

示例6: main

int main() {
  Stream stream;

  stream.Set();
  cout << stream.Get() << endl;

  InputStream istream;
  cout << "> " << flush;
  istream.Set();
  cout << istream.Get() << endl;
}
开发者ID:DaisukeYamato,项目名称:book,代码行数:11,代码来源:Override3.cpp

示例7: StreamUnpackPoints

static void StreamUnpackPoints(Stream& stream, Point *out, int count)
{
	ASSERT(sizeof(Point) >= 8);
	if(count == 0)
		return;
#ifdef CPU_LITTLE_ENDIAN
	if(sizeof(Point) == 8) {
		stream.Get(out, count * 8);
		return;
	}
#endif
	Point *end = out + count;
	byte *top = reinterpret_cast<byte *>(end) - count * 8;
	stream.Get(top, count * 8);
	for(; out < end; out++, top += 8)
	{
		out -> x = Peek32le(top + 0);
		out -> y = Peek32le(top + 4);
	}
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:20,代码来源:util.cpp

示例8: SkipRow

void VfkStream::SkipRow(Stream& strm)
{
	RTIMING("VfkStream::SkipRow");
	enum { BATCH = 100 };
	char buffer[BATCH + 1];
	int count = strm.Get(buffer, BATCH);
	buffer[count] = '\n';
	const char *p = buffer;
	for(;;)
		if(*p == '\n') {
			if(p - buffer < count) {
				strm.SeekCur((p - buffer) - count  + 1);
				return;
			}
			buffer[count = strm.Get(buffer, BATCH)] = '\n';
			p = buffer;
			if(!count)
				return;
		}
		else if(*p++ == '\"') {
			for(;;) {
				if(*p == '\n' && p - buffer >= count) {
					buffer[count = strm.Get(buffer, BATCH)] = '\n';
					p = buffer;
					if(!count)
						return;
				}
				else if(*p++ == '\"') {
					if(*p == '\n' && p - buffer >= count) {
						buffer[count = strm.Get(buffer, BATCH)] = '\n';
						p = buffer;
						if(!count)
							return;
					}
					if(*p != '\"')
						break;
					p++;
				}
			}
		}
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:41,代码来源:vfkstrm.cpp

示例9: BZ2Compress

void BZ2Compress(Stream& out, Stream& in, Gate2<int, int> progress)
{
	enum { BUF_SIZE = 65536 };
	Buffer<char> input(BUF_SIZE), output(BUF_SIZE);
	bz_stream z;
	z.bzalloc = bzalloc_new;
	z.bzfree = bzfree_new;
	z.opaque = 0;
	if(BZ2_bzCompressInit(&z, 9, 0, 30) != BZ_OK)
	{
		out.SetError();
		return;
	}
	z.avail_in = 0;
	z.avail_out = BUF_SIZE;
	z.next_out = output;
	int code;
	int flush = BZ_RUN;
	int64 total = in.GetLeft();
	int done = 0;
	do
	{
		if(z.avail_in == 0 && flush == BZ_RUN)
		{
			z.next_in = input;
			if((z.avail_in = in.Get(z.next_in = input, BUF_SIZE)) == 0)
				flush = BZ_FINISH;
			done += z.avail_in;
			if(progress(done, (int)total) || in.IsError())
			{
				BZ2_bzCompressEnd(&z);
				out.SetError();
				return;
			}
		}
		code = BZ2_bzCompress(&z, flush);
		if(z.avail_out == 0)
		{
			out.Put(z.next_out = output, z.avail_out = BUF_SIZE);
			if(out.IsError())
			{
				BZ2_bzCompressEnd(&z);
				return;
			}
		}
	}
	while(code == BZ_RUN_OK || code == BZ_FINISH_OK);
	if(z.avail_out < BUF_SIZE)
		out.Put(output, BUF_SIZE - z.avail_out);
	BZ2_bzCompressEnd(&z);
	if(code != BZ_STREAM_END)
		out.SetError();
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:53,代码来源:bz2upp.cpp

示例10: Average

bool Average(Stream& stream) {
	int count;
	double average = 0;

	for (count = 0; stream.Set(); count++) {
		average += stream.Get();
	}
	if (count == 0) {
		return false;
	}

	average /= count;
	cout << "average = " << average << endl;
	return true;
}
开发者ID:HVisionSensing,项目名称:sandbox,代码行数:15,代码来源:Override2.cpp

示例11: Average

bool Average(Stream& stream){
	int count;
	double avr = 0;

	for( count = 0; stream.Set();  ++count ){
		avr += stream.Get();
	}

	if( count == 0 ){
		return false;
	}

	avr /= count;
	cout << "Average is " << avr << "." << endl;
	return true;
}
开发者ID:tsuyopon,项目名称:cpp,代码行数:16,代码来源:Override2.cpp

示例12: StreamUnpackInts

static void StreamUnpackInts(Stream& stream, int *out, int count)
{
	ASSERT(sizeof(int) >= 4);
	int *end = out + count;
	byte *top = reinterpret_cast<byte *>(end) - count * 4;
	stream.Get(top, count * 4);
	if(sizeof(int) > 4)
	{
		for(; out < end; out++, top += 4)
			*out = Peek32le(top);
	}
	else
	{
#ifndef CPU_LITTLE_ENDIAN
		BltSwapEndian4(out, out, count);
#endif
	}
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:18,代码来源:util.cpp

示例13: UnpackParts

void RichPara::UnpackParts(Stream& in, const RichPara::CharFormat& chrstyle,
                           Array<RichPara::Part>& part, const Array<RichObject>& obj,
                           int& oi) {
	part.Add();
	part.Top().format = format;
	int c;
	while((c = in.Term()) >= 0)
		if(c < 31 && c != 9 && c != FIELD) {
			do
				switch(in.Get()) {
				case BOLD0:
					format.NoBold();
					break;
				case BOLD1:
					format.Bold();
					break;
				case BOLDS:
					format.Bold(chrstyle.IsBold());
					break;
				case ITALIC0:
					format.NoItalic();
					break;
				case ITALIC1:
					format.Italic();
					break;
				case ITALICS:
					format.Italic(chrstyle.IsItalic());
					break;
				case UNDERLINE0:
					format.NoUnderline();
					break;
				case UNDERLINE1:
					format.Underline();
					break;
				case UNDERLINES:
					format.Underline(chrstyle.IsUnderline());
					break;
				case STRIKEOUT0:
					format.NoStrikeout();
					break;
				case STRIKEOUT1:
					format.Strikeout();
					break;
				case STRIKEOUTS:
					format.Strikeout(chrstyle.IsStrikeout());
					break;
				case CAPITALS0:
					format.capitals = false;
					break;
				case CAPITALS1:
					format.capitals = true;
					break;
				case CAPITALSS:
					format.capitals = chrstyle.capitals;
					break;
				case DASHED0:
					format.dashed = false;
					break;
				case DASHED1:
					format.dashed = true;
					break;
				case DASHEDS:
					format.dashed = chrstyle.dashed;
					break;
				case SSCRIPT:
					format.sscript = in.Get();
					if(format.sscript == 3)
						format.sscript = chrstyle.sscript;
					break;
				case FACE:
					c = in.Get16();
					format.Face(c == 0xffff ? chrstyle.GetFace() : c);
					break;
				case HEIGHT:
					c = in.Get16();
					format.Height(c == 0xffff ? chrstyle.GetHeight() : c);
					break;
				case LINK:
					in % format.link;
					break;
				case INDEXENTRY:
					in % format.indexentry;
					break;
				case INK:
					in % format.ink;
					break;
				case PAPER:
					in % format.paper;
					break;
				case LANGUAGE:
					format.language = in.Get32();
					break;
				case EXT:
					switch(in.Get()) {
					case NONAA0:
						format.NonAntiAliased(false);
						break;
					case NONAA1:
						format.NonAntiAliased(true);
						break;
//.........这里部分代码省略.........
开发者ID:pedia,项目名称:raidget,代码行数:101,代码来源:ParaData.cpp


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