Files
Sourcetrail/src/lib/data/location/TokenLocationCollection.h
T
Eberhard Graether 9bcf7d2f0f data: cleaned up TokenLocation classes
* removed self assiged locationId
* show errors after parse again
2015-08-27 22:14:12 +02:00

64 lines
2.0 KiB
C++

#ifndef TOKEN_LOCATION_COLLECTION_H
#define TOKEN_LOCATION_COLLECTION_H
#include <functional>
#include <map>
#include <memory>
#include <ostream>
#include <string>
#include "utility/file/FilePath.h"
#include "utility/types.h"
class TokenLocation;
class TokenLocationFile;
class TokenLocationLine;
class TokenLocationCollection
{
public:
typedef std::map<FilePath, std::shared_ptr<TokenLocationFile> > TokenLocationFileMapType;
typedef std::pair<FilePath, std::shared_ptr<TokenLocationFile> > TokenLocationFilePairType;
TokenLocationCollection();
~TokenLocationCollection();
const TokenLocationFileMapType& getTokenLocationFiles() const;
size_t getTokenLocationFileCount() const;
size_t getTokenLocationLineCount() const;
const std::map<Id, TokenLocation*>& getTokenLocations() const;
size_t getTokenLocationCount() const;
TokenLocation* addTokenLocation(
Id locationId, Id tokenId, const FilePath& filePath,
unsigned int startLineNumber, unsigned int startColumnNumber,
unsigned int endLineNumber, unsigned int endColumnNumber);
void removeTokenLocation(TokenLocation* location);
TokenLocation* findTokenLocationById(Id id) const;
TokenLocationFile* findTokenLocationFileByPath(const FilePath& filePath) const;
void forEachTokenLocationFile(std::function<void(std::shared_ptr<TokenLocationFile>)> func) const;
void forEachTokenLocationLine(std::function<void(TokenLocationLine*)> func) const;
void forEachTokenLocation(std::function<void(TokenLocation*)> func) const;
void removeTokenLocationFile(TokenLocationFile* file);
TokenLocationFile* addTokenLocationFileAsPlainCopy(const TokenLocationFile* locationFile);
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
void clear();
private:
TokenLocationFile* createTokenLocationFile(const FilePath& filePath);
TokenLocationFileMapType m_files;
std::map<Id, TokenLocation*> m_locations;
};
std::ostream& operator<<(std::ostream& ostream, const TokenLocationCollection& base);
#endif // TOKEN_LOCATION_COLLECTION_H