J
jakash3
I've made In and Out abstract base classes which I plan to have File,
Socket, and Console classes base some of their methods on. These
interfaces will have method names like those from the C library as
well as formatted insertion and extraction streams. Please give
feedback and suggestions on how I can add to or improve this
interface.
class In {
public:
virtual int getc() = 0;
virtual char* gets(char* s, int size) = 0;
virtual int scanf(const char* format, ...) = 0;
virtual size_t read(void* ptr, size_t size, size_t nmemb) = 0;
virtual In& operator>> (bool& val) = 0;
virtual In& operator>> (short& val) = 0;
virtual In& operator>> (unsigned short& val) = 0;
virtual In& operator>> (int& val) = 0;
virtual In& operator>> (unsigned int& val) = 0;
virtual In& operator>> (long& val) = 0;
virtual In& operator>> (unsigned long& val) = 0;
virtual In& operator>> (float& val) = 0;
virtual In& operator>> (double& val) = 0;
virtual In& operator>> (long double& val) = 0;
virtual In& operator>> (const void*& val) = 0;
virtual In& operator>> (char& c) = 0;
virtual In& operator>> (signed char& c) = 0;
virtual In& operator>> (unsigned char& c) = 0;
virtual In& operator>> (char*& s) = 0;
virtual In& operator>> (String& s) = 0;
virtual In& operator>> (Charp& s) = 0;
};
class Out {
public:
virtual int putc(int c) = 0;
virtual int puts(const char* s) = 0;
virtual int printf(const char* format, ...) = 0;
virtual size_t write(const void* ptr, size_t size, size_t nmemb) = 0;
virtual Out& operator<< (bool val) = 0;
virtual Out& operator<< (short val) = 0;
virtual Out& operator<< (unsigned short val) = 0;
virtual Out& operator<< (int val) = 0;
virtual Out& operator<< (unsigned int val) = 0;
virtual Out& operator<< (long val) = 0;
virtual Out& operator<< (unsigned long val) = 0;
virtual Out& operator<< (float val) = 0;
virtual Out& operator<< (double val) = 0;
virtual Out& operator<< (long double val) = 0;
virtual Out& operator<< (const void* val) = 0;
virtual Out& operator<< (char c) = 0;
virtual Out& operator<< (signed char c) = 0;
virtual Out& operator<< (unsigned char c) = 0;
virtual Out& operator<< (const char* s) = 0;
virtual Out& operator<< (String s) = 0;
virtual Out& operator<< (Charp s) = 0;
};
Socket, and Console classes base some of their methods on. These
interfaces will have method names like those from the C library as
well as formatted insertion and extraction streams. Please give
feedback and suggestions on how I can add to or improve this
interface.
class In {
public:
virtual int getc() = 0;
virtual char* gets(char* s, int size) = 0;
virtual int scanf(const char* format, ...) = 0;
virtual size_t read(void* ptr, size_t size, size_t nmemb) = 0;
virtual In& operator>> (bool& val) = 0;
virtual In& operator>> (short& val) = 0;
virtual In& operator>> (unsigned short& val) = 0;
virtual In& operator>> (int& val) = 0;
virtual In& operator>> (unsigned int& val) = 0;
virtual In& operator>> (long& val) = 0;
virtual In& operator>> (unsigned long& val) = 0;
virtual In& operator>> (float& val) = 0;
virtual In& operator>> (double& val) = 0;
virtual In& operator>> (long double& val) = 0;
virtual In& operator>> (const void*& val) = 0;
virtual In& operator>> (char& c) = 0;
virtual In& operator>> (signed char& c) = 0;
virtual In& operator>> (unsigned char& c) = 0;
virtual In& operator>> (char*& s) = 0;
virtual In& operator>> (String& s) = 0;
virtual In& operator>> (Charp& s) = 0;
};
class Out {
public:
virtual int putc(int c) = 0;
virtual int puts(const char* s) = 0;
virtual int printf(const char* format, ...) = 0;
virtual size_t write(const void* ptr, size_t size, size_t nmemb) = 0;
virtual Out& operator<< (bool val) = 0;
virtual Out& operator<< (short val) = 0;
virtual Out& operator<< (unsigned short val) = 0;
virtual Out& operator<< (int val) = 0;
virtual Out& operator<< (unsigned int val) = 0;
virtual Out& operator<< (long val) = 0;
virtual Out& operator<< (unsigned long val) = 0;
virtual Out& operator<< (float val) = 0;
virtual Out& operator<< (double val) = 0;
virtual Out& operator<< (long double val) = 0;
virtual Out& operator<< (const void* val) = 0;
virtual Out& operator<< (char c) = 0;
virtual Out& operator<< (signed char c) = 0;
virtual Out& operator<< (unsigned char c) = 0;
virtual Out& operator<< (const char* s) = 0;
virtual Out& operator<< (String s) = 0;
virtual Out& operator<< (Charp s) = 0;
};