1 // Written in the D programming language.
2 
3 /**
4 A type for representing the count object of the 9P / Styx protocol. 
5 
6 Copyright: LightHouse Software, 2021
7 License:   $(HTTP https://github.com/aquaratixc/ESL-License, Experimental Software License 1.0).
8 Authors:   Oleg Bakharev,
9 		   Ilya Pertsev
10 */
11 module styx2000.protobj.count;
12 
13 private {
14 	import std..string : format;
15 	
16 	import styx2000.protobj.styxobject;
17 	
18 	import styx2000.protobj.size;
19 }
20 
21 /**
22 	A class that provides a type for the count field in some Styx messages. Inherits methods from the Size class and the StyxObject class. 
23 	See_Also:
24 		https://web.archive.org/web/20201029184954/https://powerman.name/Inferno/man/5/0intro.html
25 */
26 class Count : Size
27 {
28 	/**
29 	A constructor that creates an object of the Count class with the given parameter in the form of unsigned value. 
30 	If called without parameters, then the default parameter is zero.
31 	Params:
32     size = Number of unsigned bytes.
33     
34     Typical usage:
35     ----
36     Count count = new Count(0);
37     ----
38     */
39 	this(uint size = 0)
40 	{
41 		super(size);
42 	}
43 	
44 	/// An alias that allows you to call a getter method without accessing the base Size class
45 	alias getCount = getSize;
46 	/// An alias that allows you to call a setter method without accessing the base Size class
47 	alias setCount = setSize;
48 	
49 	/// Convenient string representation of an object for printing 
50 	override string toString()
51 	{
52 		return format(`Count(size=%d)`, _size);
53 	}
54 	
55 	/// An alias for easier packing into a byte array without having to manually call the pack() method
56 	alias pack this;
57 }