xref: /haiku/src/add-ons/kernel/file_systems/udf/DString.h (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
1 /*
2  * Copyright 2003, Tyler Dauwalder, tyler@dauwalder.net.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef _D_STRING_H
7 #define _D_STRING_H
8 
9 #include "UdfDebug.h"
10 
11 #include "UdfString.h"
12 
13 #include <util/kernel_cpp.h>
14 
15 /*! \brief Fixed-length d-string class that takes a UdfString as input
16 	and provides a properly formatted ECMA-167 d-string of the given
17 	field length as ouput.
18 
19 	For d-string info, see: ECMA-167 1/7.2.12, UDF-2.50 2.1.3
20 */
21 class DString {
22 public:
23 						DString();
24 						DString(const DString &ref);
25 						DString(const UdfString &string, uint8 fieldLength);
26 						DString(const char *utf8, uint8 fieldLength);
27 
28 	uint8				Length() const { return fLength; }
29 
30 	void				SetTo(const DString &ref);
31 	void				SetTo(const UdfString &string, uint8 fieldLength);
32 	void				SetTo(const char *utf8, uint8 fieldLength);
33 
34 	const uint8* 		String() const { return fString; }
35 private:
36 	void 				_Clear();
37 
38 	uint8				fLength;
39 	uint8				*fString;
40 };
41 
42 #endif	// _D_STRING_H
43