ARB
wrap.h
Go to the documentation of this file.
1 #ifndef WRAP_H
2 #define WRAP_H
3 
4 class WrapMode : virtual Noncopyable {
5  char *separators;
6 
7  bool allowed_to_wrap() const { return separators; }
8  const char *get_seps() const { ca_assert(allowed_to_wrap()); return separators; }
9  int wrap_pos(const char *str, int wrapCol) const;
10 
11  const char *print_return_wrapped(Writer& write, const char * const content, const int len, const int rest_width) const;
12 
13 public:
14  WrapMode(const char *separators_) : separators(nulldup(separators_)) {}
15  WrapMode(bool allowWrap) : separators(allowWrap ? ARB_strdup(WORD_SEP) : NULp) {} // true->wrap words, false->wrapping forbidden
16  ~WrapMode() { free(separators); }
17 
18  void print(Writer& write, const char *first_prefix, const char *other_prefix, const char *content, int max_width) const;
19 };
20 
21 #else
22 #error wrap.h included twice
23 #endif // WRAP_H
#define ca_assert(cond)
Definition: global.h:33
char * ARB_strdup(const char *str)
Definition: arb_string.h:27
#define WORD_SEP
Definition: global.h:117
Definition: wrap.h:4
Definition: reader.h:95
WrapMode(bool allowWrap)
Definition: wrap.h:15
WrapMode(const char *separators_)
Definition: wrap.h:14
void print(Writer &write, const char *first_prefix, const char *other_prefix, const char *content, int max_width) const
Definition: wrap.cxx:52
~WrapMode()
Definition: wrap.h:16
#define NULp
Definition: cxxforward.h:116