I asked this question yesterday and thought I got to the bottom of the problem... But alas it seems to be something else. I haven't the faintest idea what the issue could be, but this error is being thrown using the the following code:
Error:
a2main.cpp:36:21: error: no member named 'readJSON' in namespace 'json'
out = json::readJSON(data_dir + "a2-empty_object.json", e, debug);
~~~~~~^
main.cpp
#include <iostream>
#include <string>
#include "Object.h"
int main(){
std::string out;
out = json::readJSON(data_dir + "a2-empty_object.json", e, debug);
}
Object.h
#ifndef _JSON_READER_H_
#define _JSON_READER_H_
namespace json{
enum JSON_TYPE {
UNKNOWN, EMPTY, ARRAY_OPEN, ARRAY_CLOSE, OBJECT_OPEN, OBJECT_CLOSE, NV_PAIR
};
std::string trim(const std::string& str);
std::string trim(const std::string& str, char c);
std::string getName(const std::string& str);
std::string getValue(const std::string& str);
JSON_TYPE get_json_type(std::string s);
template<typename T>
List <T, OBJECTS_PER_JSON_FILE>* deserializeJSON(std::string filename, T obj, bool debug) {
std::ifstream fin(filename);
if (fin.fail()){
throw std::string("Couldn't open: " + filename);
}
std::string fline, line, n,v;
bool done=false;
auto list = new List <T, OBJECTS_PER_JSON_FILE>();
return list;
}
template<typename T>
std::string readJSON(std::string jsonFile, T& object, bool debug = false, char delimiter = ',') {
std::string string_of_values = "test";
return string_of_values;
}
}
#endif
Why is it throwing an error that the function is not in the namespace? It seems rather odd. Could it be a template issue? Thanks!
EDIT:
In file included from a2main.cpp:13:
./JSONReader.h:60:2: error: unknown type name 'List'
List <T, OBJECTS_PER_JSON_FILE>* deserializeJSON(std::string filename, T obj, bool debug) {
^
./JSONReader.h:60:7: error: expected unqualified-id
List <T, OBJECTS_PER_JSON_FILE>* deserializeJSON(std::string filename, T obj, bool debug) {
^