54 std::vector<Common::UString> strings;
58 while (!vis.
eos() && strings.empty()) {
66 if ((strings.size() == 1) && (strings[0] ==
"[Adjacent]"))
70 if (strings.size() > 2)
74 std::vector<Common::UString> visibilityArray;
77 if (strings.size() > 1)
80 int realRoomCount = 0;
82 visibilityArray.reserve(roomCount);
84 size_t lineStart = vis.
pos();
97 if (strings.size() != 1) {
104 visibilityArray.push_back(strings[0]);
108 if (roomCount != realRoomCount)
110 warning(
"Malformed VIS file. Wanted %d rooms, got %d?!?", roomCount, realRoomCount);
112 if (!visibilityArray.empty())
113 _map[room] = visibilityArray;
119 std::map<Common::UString, std::vector<Common::UString> >::const_iterator vRoom =
_map.find(room.
toLower());
120 if (vRoom ==
_map.end())
123 return vRoom->second;
A class holding an UTF-8 string.
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
virtual bool eos() const =0
Returns true if a read failed because the stream has been reached.
void addChunkEnd(uint32 c)
Add a character marking the end of a chunk.
Utility templates and functions for working with strings and streams.
const std::vector< Common::UString > & getVisibilityArray(const Common::UString &room) const
Return the visibility array for a given room.
Exception that provides a stack of explanations.
void load(Common::SeekableReadStream &vis)
Load a VIS file.
void clear()
Clear all information.
Basic exceptions to throw.
Utility templates and functions.
Handling BioWare's VISs (Visibility files).
void addIgnore(uint32 c)
Add a character to ignore.
void warning(const char *s,...)
Basic reading stream interfaces.
virtual size_t pos() const =0
Obtains the current value of the stream position indicator of the stream.
size_t getTokens(SeekableReadStream &stream, std::vector< UString > &list, size_t min=0, size_t max=SIZE_MAX, const UString &def="")
Parse tokens out of the stream.
std::map< Common::UString, std::vector< Common::UString > > _map
UString toLower() const
Return a lowercased copy of the string.
Parse tokens out of a stream.
void nextChunk(SeekableReadStream &stream)
Skip past end of chunk characters.
Ignore all repeated separators.
uint32 readChar()
Reads the next character from stream and returns it as an unsigned char cast to an uint32...
void addSeparator(uint32 c)
Add a character on where to split tokens.
Interface for a seekable & readable data stream.
static const std::vector< Common::UString > emptyRoom
void parseString(const UString &str, T &value, bool allowEmpty)
Parse a string into any POD integer, float/double or bool type.