Exemple #1
0
        public int Feed(IBytesConsumer consumer, int maxbytes)
        {
            int n = 0;

            if (pendinglen == 0)
            {
                RefillBuffer();
            }
            int tofeed = maxbytes > 0 && maxbytes < pendinglen ? maxbytes : pendinglen;

            if (tofeed > 0)
            {
                n = consumer.Consume(buf, offset, tofeed);
                if (n > 0)
                {
                    offset     += n;
                    pendinglen -= n;
                }
            }
            if (n < 1 && failIfNoFeed)
            {
                throw new PngjInputException("failed feed bytes");
            }
            return(n);
        }
Exemple #2
0
        public bool FeedFixed(IBytesConsumer consumer, int nbytes)
        {
            int remain = nbytes;

            while (remain > 0)
            {
                int n = Feed(consumer, remain);
                if (n < 1)
                {
                    return(false);
                }
                remain -= n;
            }
            return(true);
        }
 public int feed(IBytesConsumer consumer, int maxbytes)
 {
     int n = 0;
     if (pendinglen == 0)
     {
         refillBuffer();
     }
     int tofeed = maxbytes > 0 && maxbytes < pendinglen ? maxbytes : pendinglen;
     if (tofeed > 0)
     {
         n = consumer.consume(buf, offset, tofeed);
         if (n > 0)
         {
             offset += n;
             pendinglen -= n;
         }
     }
     if (n < 1 && failIfNoFeed)
         throw new PngjInputException("failed feed bytes");
     return n;
 }
 public bool feedFixed(IBytesConsumer consumer, int nbytes)
 {
     int remain = nbytes;
     while (remain > 0)
     {
         int n = feed(consumer, remain);
         if (n < 1)
             return false;
         remain -= n;
     }
     return true;
 }
 /// <summary>
 /// Feeds bytes to the consumer 
 ///  Returns bytes actually consumed
 ///  This should return 0 only if the stream is EOF or the consumer is done
 /// </summary>
 /// <param name="consumer"></param>
 /// <returns></returns>
 public int feed(IBytesConsumer consumer)
 {
     return feed(consumer, -1);
 }
Exemple #6
0
 /// <summary>
 /// Feeds bytes to the consumer
 ///  Returns bytes actually consumed
 ///  This should return 0 only if the stream is EOF or the consumer is done
 /// </summary>
 /// <param name="consumer"></param>
 /// <returns></returns>
 public int Feed(IBytesConsumer consumer)
 {
     return(Feed(consumer, -1));
 }
 /// <summary> Feeds bytes to the consumer </summary>
 /// <returns> Bytes actually consumed. Should return 0 only if the stream is EOF or the consumer is done </returns>
 public int Feed(IBytesConsumer consumer) => Feed(consumer, -1);