-1

JSONParser.h

#ifndef UTILITY_CLASSES_JSONPARSER_H_
#define UTILITY_CLASSES_JSONPARSER_H_

#include <iostream>
#include <string>
#include <boost/property_tree/json_parser.hpp>

namespace Parsers {

class JSONParser {
    boost::property_tree::ptree pTree;
public:
    JSONParser();
    virtual ~JSONParser();

    void setJSON(char* JSON);
};

} /* namespace Parsers */

#endif /* UTILITY_CLASSES_JSONPARSER_H_ */

JSONParser.cpp

/*
 * JSONParser.cpp
 *
 *  Created on: 20-May-2016
 *      Author: arjun
 */

#include "JSONParser.h"

namespace Parsers {

JSONParser::JSONParser() {
    // TODO Auto-generated constructor stub

}

JSONParser::~JSONParser() {
    // TODO Auto-generated destructor stub
}
void JSONParser::setJSON(char* JSON){
    std::string temp;

    pTree.put("foo", "bar");
    pTree.put("foor", "bawr");
    std::ostringstream buf;
    write_json (buf, pTree, false);
}
} /* namespace Parsers */

上面定义的是我为 JSONParser 编写的一个 cpp-header 对。但是,当我尝试使用 std::strings 时会引发错误:

std::string 不明确。

似乎每当我 include 时都会发生这种情况boost/property_tree/json_parser.hpp,即每当我删除它的 include 时,都没有错误。当我包含一些东西时,也会发生同样的情况GeographicLib。我在 Ubuntu 16.04 上,我的库在usr/local/lib,并且包含在usr/local/include

错误如下:

说明 资源路径位置类型 'std::string' 不明确 ' 候选者是:' JSONParser.cpp /PSO-PathFinding/Utility Classes 第 14 行语义错误

在 Eclipse 上编程,使用 cdt。

4

1 回答 1

1

解决。不是 C++ 问题,也不是提升库问题。似乎是我正在使用的当前 eclipse 工作区的问题。

于 2016-05-20T08:36:51.057 回答