vfs: check userland buffers before reading them.
[haiku.git] / src / apps / haikudepot / textview / Paragraph.h
blobf6d953cbecd276ed0c2800a526b8ad546fe5df5c
1 /*
2 * Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #ifndef PARAGRAPH_H
6 #define PARAGRAPH_H
8 #include "List.h"
9 #include "ParagraphStyle.h"
10 #include "TextSpan.h"
13 typedef List<TextSpan, false> TextSpanList;
16 class Paragraph {
17 public:
18 Paragraph();
19 Paragraph(const ParagraphStyle& style);
20 Paragraph(const Paragraph& other);
22 Paragraph& operator=(const Paragraph& other);
23 bool operator==(const Paragraph& other) const;
24 bool operator!=(const Paragraph& other) const;
26 void SetStyle(const ParagraphStyle& style);
27 inline const ParagraphStyle& Style() const
28 { return fStyle; }
30 inline const TextSpanList& TextSpans() const
31 { return fTextSpans; }
33 bool Prepend(const TextSpan& span);
34 bool Append(const TextSpan& span);
35 bool Insert(int32 offset, const TextSpan& span);
36 bool Remove(int32 offset, int32 length);
37 void Clear();
39 int32 Length() const;
40 bool IsEmpty() const;
41 bool EndsWith(BString string) const;
43 BString Text() const;
44 BString Text(int32 start, int32 length) const;
45 Paragraph SubParagraph(int32 start, int32 length) const;
47 void PrintToStream() const;
49 private:
50 void _InvalidateCachedLength();
52 private:
53 ParagraphStyle fStyle;
54 TextSpanList fTextSpans;
55 mutable int32 fCachedLength;
59 #endif // PARAGRAPH_H