JWS C++ Library
C++ language utility library
|
00001 /* 00002 * This work is licensed under a Creative Commons 00003 * Attribution-Noncommercial-Share Alike 3.0 United States License. 00004 * 00005 * http://creativecommons.org/licenses/by-nc-sa/3.0/us/ 00006 * 00007 * You are free: 00008 * 00009 * to Share - to copy, distribute, display, and perform the work 00010 * to Remix - to make derivative works 00011 * 00012 * Under the following conditions: 00013 * 00014 * Attribution. You must attribute the work in the manner specified by the 00015 * author or licensor (but not in any way that suggests that they endorse you 00016 * or your use of the work). 00017 * 00018 * Noncommercial. You may not use this work for commercial purposes. 00019 * 00020 * Share Alike. If you alter, transform, or build upon this work, you may 00021 * distribute the resulting work only under the same or similar license to 00022 * this one. 00023 * 00024 * For any reuse or distribution, you must make clear to others the license 00025 * terms of this work. The best way to do this is by including this header. 00026 * 00027 * Any of the above conditions can be waived if you get permission from the 00028 * copyright holder. 00029 * 00030 * Apart from the remix rights granted under this license, nothing in this 00031 * license impairs or restricts the author's moral rights. 00032 */ 00033 00034 00046 #ifndef READABLE_H 00047 #define READABLE_H 00048 00049 00050 #include <jwsc++/config.h> 00051 00052 #include <iostream> 00053 00054 #include <jwsc++/base/exception.h> 00055 00056 00057 namespace jwscxx { 00058 namespace base { 00059 00060 00066 class Readable 00067 { 00068 public: 00069 00071 virtual ~Readable() { } 00072 00073 00075 virtual void read(std::istream& in) throw (jwscxx::base::IO_error, 00076 jwscxx::base::Arg_error) = 0; 00077 00078 00080 virtual void read(const char* fname) throw (jwscxx::base::IO_error, 00081 jwscxx::base::Arg_error); 00082 00083 00088 static const char* read_field_value 00089 ( 00090 std::istream& in, 00091 const char* field_name, 00092 char* field_buf, 00093 size_t buf_len, 00094 char separator=':' 00095 ) 00096 throw (jwscxx::base::Arg_error, jwscxx::base::IO_error); 00097 00098 00103 static const char* read_field_value 00104 ( 00105 std::istream& in, 00106 const char* field_name, 00107 char separator=':' 00108 ) 00109 throw (jwscxx::base::Arg_error, jwscxx::base::IO_error); 00110 }; 00111 00112 00113 }} 00114 00115 00116 #endif