// +-------------------------------------------------------------------------+ // | StreamFilters library vers. 0.2.03 | // | Copyright (c) Andrey V. Stolyarov 2022-2025 | // | ----------------------------------------------------------------------- | // | This is free software. Permission is granted to everyone to use, copy | // | or modify this software under the terms and conditions of | // | GNU LESSER GENERAL PUBLIC LICENSE, v. 2.1 | // | as published by Free Software Foundation (see the file LGPL.txt) | // | | // | Please visit http://www.croco.net/software/stfilter to get a fresh copy | // | ----------------------------------------------------------------------- | // | This code is provided strictly and exclusively on the "AS IS" basis. | // | !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! | // +-------------------------------------------------------------------------+ #include "stfilter.hpp" void StreamFilter::AddToEnd(StreamFilter *p) { if(dest) dest->AddToEnd(p); else dest = p; } void StreamFilter::InsertAfter(StreamFilter *p) { p->dest = dest; dest = p; } void StreamFilter::DeleteChain() { if(dest) dest->DeleteChain(); delete this; } void StreamFilter::ChainReset() { Reset(); if(dest) dest->ChainReset(); } void StreamFilter::PutStr(const char *s) { const char *p = s; while(*p) { PutChar(*p); p++; } } void StreamFilter::PutHex(unsigned long long n, int minsigns, bool uppercase) { unsigned long long k = n; int signs = 0; while(k) { signs++; k >>= 4; } if(minsigns > 0 && signs < minsigns) signs = minsigns; int i; for(i = signs-1; i >= 0; i--) { int dig = (n >> (4*i)) & 0x0f; PutChar(dig + (dig < 10 ? '0' : (uppercase ? 'A' : 'a') - 10)); } } StreamFilterDestination::StreamFilterDestination() : StreamFilter(0) { } StreamFilterDestination::~StreamFilterDestination() { } char *StreamFilterDestination::ReleaseBuffer() { return buf.ReleaseBuffer(); } void StreamFilterDestination::FeedChar(int c) { buf.AddChar(c); } void StreamFilterDestination::Reset() { buf.Reset(); }