summaryrefslogblamecommitdiff
path: root/src/user/lib/fwik/include/String.h
blob: 59fa0b6a54ac352f337917311d4556b2008c05cc (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13


                         









                                                                                 

                                         


                                             
                                        
 
                                  
 


                                                   
                                  
                                       
 


                                                  
 
                                                    




                                             
                                                       
  

      
#ifndef DEF_FWIK_STRING_H
#define DEF_FWIK_STRING_H

#include <cpp.h>

class String {
	private:
	char *ptr;			// zero-terminated for internal purposes.
	int len;

	public:
	String();
	String(const String& other);
	String(const char* ptr);
	String(const char* ptr, int len);
	String(char c, int count);
	~String();
	void operator=(const String &string);
	void operator=(const char* ptr);

	const char* c_str() const;

	bool operator==(const String& other) const;
	bool operator==(const char* other) const;
	bool operator<(const String& other) const;
	char &operator[](int pos);
	char operator[](int pos) const;

	int size() const { return len; }
	operator bool() const { return len != 0; }
	String substr(int start, int count) const;

	String operator+(const String& other) const;
	void operator+=(const String& other);
	void operator+=(char c);

	static String dec(int i);
	static String hex(uint32_t v);
	static String sprintf(const char* format, ...);
};

#endif