mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
38 lines
662 B
C++
38 lines
662 B
C++
#ifndef _STRINGCACHE_H_
|
|
#define _STRINGCACHE_H_
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
/**
|
|
* A simple cache that allows for caching the mapping of one string to another calculated one
|
|
*
|
|
* @author Mitchell
|
|
*
|
|
*/
|
|
class StringCache {
|
|
private:
|
|
std::map<std::string, std::string> cache;
|
|
|
|
|
|
/**
|
|
* @param input
|
|
* @return the value for a given input
|
|
*/
|
|
public:
|
|
StringCache();
|
|
virtual ~StringCache();
|
|
|
|
|
|
std::string& Get(const std::string& input);
|
|
|
|
/**
|
|
* Will only be called if a value has not already been calculated
|
|
* @param input
|
|
* @return the calculated value for a given input
|
|
*/
|
|
virtual std::string Calc(const std::string& input) = 0;
|
|
};
|
|
|
|
#endif
|