TBTK
Need a break? Support the development by playing Polarity Puzzles
Resource.h
Go to the documentation of this file.
1 /* Copyright 2017 Kristofer Björnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_RESOURCE
24 #define COM_DAFER45_TBTK_RESOURCE
25 
26 #include "TBTK/Serializable.h"
27 
28 #include <string>
29 #include <vector>
30 
31 namespace TBTK{
32 
65 class Resource{
66 public:
68  Resource();
69 
71  ~Resource();
72 
76  void setData(const std::string &data);
77 
81  const std::string& getData() const;
82 
88  void write(const std::string &uri);
89 
94  void read(const std::string &uri);
95 private:
97  std::string data;
98 
100  static size_t writeCallback(
101  void *data,
102  size_t size,
103  size_t nmemb,
104  void *userdata
105  );
106 
108  static size_t readCallback(
109  char *data,
110  size_t size,
111  size_t nmemb,
112  void *userdata
113  );
114 };
115 
116 inline void Resource::setData(const std::string &data){
117  this->data = data;
118 }
119 
120 inline const std::string& Resource::getData() const{
121  return data;
122 }
123 
124 }; //End namespace TBTK
125 
126 #endif
TBTK::Resource::write
void write(const std::string &uri)
TBTK::Resource
Read and write string resources from file, URL, etc.
Definition: Resource.h:65
TBTK::Resource::~Resource
~Resource()
TBTK::Resource::read
void read(const std::string &uri)
Serializable.h
Abstract base class for serializable objects.
TBTK::Resource::Resource
Resource()
TBTK::Resource::setData
void setData(const std::string &data)
Definition: Resource.h:116
TBTK::Resource::getData
const std::string & getData() const
Definition: Resource.h:120