~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSStream.cc

  • Committer: Lee Bieber
  • Date: 2010-10-22 16:47:38 UTC
  • mfrom: (1841.1.7 drizzle_pbms)
  • Revision ID: kalebral@gmail.com-20101022164738-vv8w22b8towpb307
Merge Barry - fix bug 657830: PBMS build failure in GCC 4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "CSStream.h"
40
40
#include "CSGlobal.h"
41
41
 
42
 
using namespace std;
43
 
 
44
42
/*
45
43
 * ---------------------------------------------------------------
46
44
 * STREAM UTILITIES
183
181
        return_(size == 0 ? -1 : (int) ch);
184
182
}
185
183
 
186
 
void CSFileInputStream::reset() {iReadOffset = 0;}
 
184
void CSFileInputStream::reset()
 
185
{
 
186
        iReadOffset = 0;
 
187
}
 
188
 
 
189
const char *CSFileInputStream::identify()
 
190
{
 
191
        return iFile->myFilePath->getCString();
 
192
}
187
193
 
188
194
int CSFileInputStream::peek()
189
195
{
267
273
        exit_();
268
274
}
269
275
 
270
 
void CSFileOutputStream::reset() {iWriteOffset = 0;}
 
276
void CSFileOutputStream::reset()
 
277
{
 
278
        iWriteOffset = 0;
 
279
}
 
280
 
 
281
const char *CSFileOutputStream::identify()
 
282
{
 
283
        return iFile->myFilePath->getCString();
 
284
}
271
285
 
272
286
void CSFileOutputStream::close()
273
287
{
344
358
        exit_();
345
359
}
346
360
 
 
361
const char *CSSocketInputStream::identify()
 
362
{
 
363
        return iSocket->identify();
 
364
}
347
365
 
348
366
CSSocketInputStream *CSSocketInputStream::newStream(CSSocket *s)
349
367
{
403
421
        exit_();
404
422
}
405
423
 
 
424
const char *CSSocketOutputStream::identify()
 
425
{
 
426
        return iSocket->identify();
 
427
}
 
428
 
406
429
CSSocketOutputStream *CSSocketOutputStream::newStream(CSSocket *s)
407
430
{
408
431
        CSSocketOutputStream *str;
490
513
        iStream->reset();
491
514
}
492
515
 
 
516
const char *CSBufferedInputStream::identify()
 
517
{
 
518
        return iStream->identify();
 
519
}
 
520
 
493
521
CSBufferedInputStream *CSBufferedInputStream::newStream(CSInputStream* i)
494
522
{
495
523
        CSBufferedInputStream *s;
524
552
{
525
553
        size_t tfer;
526
554
 
 
555
        // If the length of the data being written is greater than half
 
556
        // the buffer size then the data is written directly through
 
557
        // with out buffering.
527
558
        enter_();
528
 
        if (iBuffTotal < CS_STREAM_BUFFER_SIZE) {
 
559
        if (iBuffTotal < CS_STREAM_BUFFER_SIZE/2) {
529
560
                tfer = CS_STREAM_BUFFER_SIZE - iBuffTotal;
530
561
                
531
562
                if (tfer > len)
537
568
        }
538
569
        if (len > 0) {
539
570
                flush();
540
 
                if (len > CS_STREAM_BUFFER_SIZE)
 
571
                if (len > CS_STREAM_BUFFER_SIZE/2)
541
572
                        iStream->write(b, len);
542
573
                else {
543
574
                        memcpy(iBuffer, b, len);
549
580
 
550
581
void CSBufferedOutputStream::flush()
551
582
{
 
583
        size_t len;
 
584
 
552
585
        enter_();
553
 
        if (iBuffTotal > 0) {
554
 
                iStream->write((char *) iBuffer, iBuffTotal);
 
586
        if ((len = iBuffTotal)) {
 
587
                /* Discard the contents of the buffer
 
588
                 * if flush fails, because we do
 
589
                 * not know how much was written anyway!
 
590
                 */
555
591
                iBuffTotal = 0;
 
592
                iStream->write((char *) iBuffer, len);
556
593
        }
557
594
        exit_();
558
595
}
573
610
        iStream->reset();
574
611
}
575
612
 
 
613
const char *CSBufferedOutputStream::identify()
 
614
{
 
615
        return iStream->identify();
 
616
}
 
617
 
576
618
CSBufferedOutputStream *CSBufferedOutputStream::newStream(CSOutputStream* i)
577
619
{
578
620
        CSBufferedOutputStream *s;
658
700
        iMemSpace = iMemTotal;
659
701
}
660
702
 
 
703
const char *CSMemoryOutputStream::identify()
 
704
{
 
705
        return "memory stream";
 
706
}
 
707
 
661
708
/*
662
709
 * ---------------------------------------------------------------
663
710
 * STATIC (user) MEMORY OUTPUT STREAM