10 #define IMPBASE_FILE_H
12 #include <IMP/base/base_config.h>
14 #include "internal/ifile.h"
19 #include <boost/shared_ptr.hpp>
23 IMPBASE_BEGIN_NAMESPACE
25 #if !defined(IMP_DOXYGEN)
26 template <
class Stream>
29 base::PointerMember<Object> ptr_;
30 TextProxy(Stream *str, Object *ptr) : str_(str), ptr_(ptr) {}
48 boost::shared_ptr<internal::IOStorage<std::ostream> > out_;
55 TextOutput(
const char *c,
bool append =
false);
59 TextOutput(std::string file_name,
bool append =
false);
61 TextOutput(std::ostream &out, std::string name =
"C++ stream");
64 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
65 operator std::ostream &() {
return get_stream(); }
67 std::ostream &get_stream() {
68 IMP_USAGE_CHECK(out_,
"Attempting to write to uninitialized text input");
69 return out_->get_stream();
73 std::string get_name()
const {
return out_->get_name(); }
87 boost::shared_ptr<internal::IOStorage<std::istream> > in_;
100 TextInput(std::istream &out, std::string name =
"C++ stream");
103 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
104 operator std::istream &() {
return get_stream(); }
105 std::istream &get_stream() {
107 IMP_THROW(
"Attempting to read from uninitialized text input",
110 return in_->get_stream();
115 std::string get_name()
const {
return in_->get_name(); }
156 std::string suffix =
"");
165 std::string suffix =
"");
175 std::string relative);
177 IMPBASE_END_NAMESPACE
TextOutput create_temporary_file(std::string prefix="imp_temp", std::string suffix="")
An input/output exception.
A nullptr-initialized pointer to an IMP Object.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
void set_log_target(TextOutput l)
Set the target for the log.
std::string get_relative_path(std::string base, std::string relative)
#define IMP_SAFE_BOOL(Name, expr)
Exception definitions and assertions.
#define IMP_RAII(Name, args, Initialize, Set, Reset, Show)
Declares RAII-style methods in a class.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Various general useful macros for IMP.
Exception definitions and assertions.