/usr/include/sp/Text.h is in libsp1-dev 1.3.4-1.2.1-47.3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | // Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#ifndef Text_INCLUDED
#define Text_INCLUDED 1
#ifdef __GNUG__
#pragma interface
#endif
#include "types.h"
#include "StringC.h"
#include "Vector.h"
#include "Location.h"
#include "SubstTable.h"
#include <stddef.h>
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
struct SP_API TextItem {
TextItem();
enum Type {
data,
cdata,
sdata,
nonSgml,
entityStart,
entityEnd,
startDelim,
endDelim,
endDelimA,
ignore
};
Type type;
// char that was ignored
Char c;
// location of this item
// data - location of first char
// (c/sdata)entityStart - location of first char of entity
// (c/sdata)entityEnd - location of entity end in entity
// ignore - location of ignored character
// startDelim - location of first char of delimiter
// endDelim(A) - location of first char of delimiter
Location loc;
// index of character in chars_ to which this applies
size_t index;
};
// This is used to represent literals and attribute values.
class SP_API Text {
public:
Text();
void clear();
void swap(Text &to);
void addChar(Char c, const Location &);
void addChars(const StringC &, const Location &);
void addChars(const Char *, size_t, const Location &);
void insertChars(const StringC &, const Location &);
void ignoreChar(Char, const Location &);
void ignoreLastChar();
void addNonSgmlChar(Char c, const Location &);
void addEntityStart(const Location &);
void addEntityEnd(const Location &);
void addCdata(const StringC &, const ConstPtr<Origin> &);
void addSdata(const StringC &, const ConstPtr<Origin> &);
void addStartDelim(const Location &loc);
void addEndDelim(const Location &loc, Boolean lita);
void subst(const SubstTable<Char> &, Char space);
void addCharsTokenize(const Char *, size_t, const Location &loc, Char space);
void addCharsTokenize(const StringC &, const Location &loc, Char space);
void tokenize(Char space, Text &text) const;
Location charLocation(size_t i) const;
Boolean charLocation(size_t, const Origin *&, Index &) const;
Boolean charLocation(size_t i, const ConstPtr<Origin> *&, Index &) const;
size_t size() const;
Char lastChar() const;
const StringC &string() const;
size_t normalizedLength(size_t normsep) const;
Boolean fixedEqual(const Text &) const;
// Location of first char of start delimiter.
Boolean startDelimLocation(Location &) const;
// Location of first char of end delimiter
Boolean endDelimLocation(Location &) const;
// Is delimiter a lit or lita?
Boolean delimType(Boolean &lita) const;
private:
void addSimple(TextItem::Type, const Location &);
StringC chars_;
Vector<TextItem> items_;
friend class TextIter;
};
class SP_API TextIter {
public:
TextIter(const Text &);
void rewind();
Boolean next(TextItem::Type &, const Char *&, size_t &,
const Location *&);
// Alternative interface to next()
Boolean valid() const;
void advance();
TextItem::Type type() const;
const Location &location() const;
const Char *chars(size_t &length) const;
private:
const TextItem *ptr_;
const Text *text_;
};
inline
size_t Text::size() const
{
return chars_.size();
}
inline
Char Text::lastChar() const
{
return chars_[chars_.size() - 1];
}
inline
const StringC &Text::string() const
{
return chars_;
}
inline
void Text::addEntityStart(const Location &loc)
{
addSimple(TextItem::entityStart, loc);
}
inline
void Text::addEntityEnd(const Location &loc)
{
addSimple(TextItem::entityEnd, loc);
}
inline
void Text::addChars(const StringC &s, const Location &loc)
{
addChars(s.data(), s.size(), loc);
}
inline
void Text::addStartDelim(const Location &loc)
{
addSimple(TextItem::startDelim, loc);
}
inline
void Text::addEndDelim(const Location &loc, Boolean lita)
{
addSimple(lita ? TextItem::endDelimA : TextItem::endDelim,
loc);
}
inline
void Text::addCharsTokenize(const StringC &str, const Location &loc,
Char space)
{
addCharsTokenize(str.data(), str.size(), loc, space);
}
inline
Location Text::charLocation(size_t i) const
{
const ConstPtr<Origin> *originP;
Index index;
if (charLocation(i, originP, index))
return Location(*originP, index);
else
return Location();
}
inline
Boolean Text::charLocation(size_t i, const Origin *&origin, Index &index) const
{
const ConstPtr<Origin> *originP;
if (charLocation(i, originP, index)) {
origin = originP->pointer();
return 1;
}
else
return 0;
}
inline
void TextIter::rewind()
{
ptr_ = text_->items_.begin();
}
inline
void TextIter::advance()
{
ptr_++;
}
inline
Boolean TextIter::valid() const
{
return ptr_ != (text_->items_.begin() + text_->items_.size());
}
inline
const Location &TextIter::location() const
{
return ptr_->loc;
}
inline
TextItem::Type TextIter::type() const
{
return ptr_->type;
}
#ifdef SP_NAMESPACE
}
#endif
#endif /* not Text_INCLUDED */
|