10 #define IMPBASE_FILE_H
12 #include <IMP/base/base_config.h>
14 #include "internal/ifile.h"
22 #include <boost/shared_ptr.hpp>
26 IMPBASE_BEGIN_NAMESPACE
28 #if !defined(IMP_DOXYGEN)
29 template <
class Stream>
32 base::PointerMember<Object> ptr_;
33 TextProxy(Stream *str, Object *ptr) : str_(str), ptr_(ptr) {}
51 boost::shared_ptr<internal::IOStorage<std::ostream> > out_;
58 TextOutput(
const char *c,
bool append =
false);
62 TextOutput(std::string file_name,
bool append =
false);
64 TextOutput(std::ostream &out, std::string name =
"C++ stream");
67 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
68 operator std::ostream &() {
return get_stream(); }
70 std::ostream &get_stream() {
71 IMP_USAGE_CHECK(out_,
"Attempting to write to uninitialized text input");
72 return out_->get_stream();
76 std::string get_name()
const {
return out_->get_name(); }
90 boost::shared_ptr<internal::IOStorage<std::istream> > in_;
103 TextInput(std::istream &out, std::string name =
"C++ stream");
106 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
107 operator std::istream &() {
return get_stream(); }
108 std::istream &get_stream() {
110 IMP_THROW(
"Attempting to read from uninitialized text input",
113 return in_->get_stream();
118 std::string get_name()
const {
return in_->get_name(); }
159 std::string suffix =
"");
168 std::string suffix =
"");
178 std::string relative);
180 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.
Various general useful macros for IMP.
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.
A shared base class to help in debugging and things.