librime 1.2
Rime Input Method Engine, the core library
resource.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5
6#ifndef RIME_RESOURCE_H_
7#define RIME_RESOURCE_H_
8
9#include <rime_api.h>
10#include <rime/common.h>
11
12namespace rime {
13
15
17 string name;
18 string prefix;
19 string suffix;
20};
21
23 public:
24 explicit ResourceResolver(const ResourceType type) : type_(type) {}
25 virtual ~ResourceResolver() {}
26 virtual path ResolvePath(const string& resource_id);
27 string ToResourceId(const string& file_path) const;
28 string ToFilePath(const string& resource_id) const;
30 path root_path() const { return root_path_; }
31
32 protected:
35};
36
37// try fallback path if target file doesn't exist in root path
39 public:
41 : ResourceResolver(type) {}
42 path ResolvePath(const string& resource_id) override;
43 void set_fallback_root_path(path fallback_root_path) {
44 fallback_root_path_ = fallback_root_path;
45 }
46
47 private:
48 path fallback_root_path_;
49};
50
51} // namespace rime
52
53#endif // RIME_RESOURCE_H_
#define RIME_DLL
Definition rime_api.h:33
Definition algebra.cc:12
Definition common.h:84
Definition resource.h:16
string prefix
Definition resource.h:18
string suffix
Definition resource.h:19
string name
Definition resource.h:17
Definition resource.h:22
ResourceResolver(const ResourceType type)
Definition resource.h:24
const ResourceType type_
Definition resource.h:33
virtual ~ResourceResolver()
Definition resource.h:25
void set_root_path(path root_path)
Definition resource.h:29
path root_path_
Definition resource.h:34
path root_path() const
Definition resource.h:30
FallbackResourceResolver(const ResourceType &type)
Definition resource.h:40
void set_fallback_root_path(path fallback_root_path)
Definition resource.h:43