package common.tags;

class SizeTracker {
	public static final SizeTracker INFINITE = new SizeTracker(0) {
		public void read(int bytes) {
		}
	};
	
	private final int max;
	
	private int read;

	public SizeTracker(int max) {
		this.max = max;
	}

	public void read(int bytes) {
		this.read += bytes;
		if(this.read > this.max)
			throw new RuntimeException("Versuchte einen Tag zu lesen, der zu groß war: Habe " + this.read + " Bytes, " + this.max + " Bytes maximal erlaubt");
	}
}
