Commit d035fa58 authored by Niels's avatar Niels

- added missing headers

parent ff41ca8f
...@@ -7,11 +7,9 @@ ...@@ -7,11 +7,9 @@
#include <iostream> #include <iostream>
#include <streambuf> #include <streambuf>
#include <sstream> #include <sstream>
#ifndef __cplusplus11
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#endif #include <cstddef>
#ifdef __cplusplus11 #ifdef __cplusplus11
using std::to_string; using std::to_string;
...@@ -576,8 +574,8 @@ std::string JSON::_typename() const { ...@@ -576,8 +574,8 @@ std::string JSON::_typename() const {
JSON::parser::parser(char* s) : _pos(0) { JSON::parser::parser(char* s) : _pos(0) {
_buffer = new char[strlen(s) + 1]; _buffer = new char[std::strlen(s) + 1];
strcpy(_buffer, s); std::strcpy(_buffer, s);
// read first character // read first character
next(); next();
...@@ -585,7 +583,7 @@ JSON::parser::parser(char* s) : _pos(0) { ...@@ -585,7 +583,7 @@ JSON::parser::parser(char* s) : _pos(0) {
JSON::parser::parser(std::string& s) : _pos(0) { JSON::parser::parser(std::string& s) : _pos(0) {
_buffer = new char[s.length() + 1]; _buffer = new char[s.length() + 1];
strcpy(_buffer, s.c_str()); std::strcpy(_buffer, s.c_str());
// read first character // read first character
next(); next();
...@@ -626,7 +624,7 @@ bool JSON::parser::next() { ...@@ -626,7 +624,7 @@ bool JSON::parser::next() {
std::string JSON::parser::parseString() { std::string JSON::parser::parseString() {
// get position of closing quotes // get position of closing quotes
char* p = strchr(_buffer + _pos, '\"'); char* p = std::strchr(_buffer + _pos, '\"');
// if the closing quotes are escaped (viz. *(p-1) is '\\'), // if the closing quotes are escaped (viz. *(p-1) is '\\'),
// we continue looking for the "right" quotes // we continue looking for the "right" quotes
...@@ -634,7 +632,7 @@ std::string JSON::parser::parseString() { ...@@ -634,7 +632,7 @@ std::string JSON::parser::parseString() {
// length of the string so far // length of the string so far
const size_t length = p - _buffer - _pos; const size_t length = p - _buffer - _pos;
// continue checking after escaped quote // continue checking after escaped quote
p = strchr(_buffer + _pos + length + 1, '\"'); p = std::strchr(_buffer + _pos + length + 1, '\"');
} }
// check if closing quotes were found // check if closing quotes were found
...@@ -645,7 +643,7 @@ std::string JSON::parser::parseString() { ...@@ -645,7 +643,7 @@ std::string JSON::parser::parseString() {
// copy string to return value // copy string to return value
const size_t length = p - _buffer - _pos; const size_t length = p - _buffer - _pos;
char* tmp = new char[length + 1]; char* tmp = new char[length + 1];
strncpy(tmp, _buffer + _pos, length); std::strncpy(tmp, _buffer + _pos, length);
std::string result(tmp); std::string result(tmp);
delete [] tmp; delete [] tmp;
...@@ -659,7 +657,7 @@ std::string JSON::parser::parseString() { ...@@ -659,7 +657,7 @@ std::string JSON::parser::parseString() {
} }
void JSON::parser::parseTrue() { void JSON::parser::parseTrue() {
if (strncmp(_buffer + _pos, "rue", 3)) { if (std::strncmp(_buffer + _pos, "rue", 3)) {
error("expected true"); error("expected true");
} }
...@@ -670,7 +668,7 @@ void JSON::parser::parseTrue() { ...@@ -670,7 +668,7 @@ void JSON::parser::parseTrue() {
} }
void JSON::parser::parseFalse() { void JSON::parser::parseFalse() {
if (strncmp(_buffer + _pos, "alse", 4)) { if (std::strncmp(_buffer + _pos, "alse", 4)) {
error("expected false"); error("expected false");
} }
...@@ -681,7 +679,7 @@ void JSON::parser::parseFalse() { ...@@ -681,7 +679,7 @@ void JSON::parser::parseFalse() {
} }
void JSON::parser::parseNull() { void JSON::parser::parseNull() {
if (strncmp(_buffer + _pos, "ull", 3)) { if (std::strncmp(_buffer + _pos, "ull", 3)) {
error("expected null"); error("expected null");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment