<commit_before>#include <cstdlib>
#include <fstream>
#include <sstream>
#include "jsmn.h"
#include "jsmn.hpp"

namespace jsmn {

// maximum token size
const int MAX_TOKEN_SIZE = 1000;

Object::Object() {
}
Object::Object(const Object& other) {
  object_ = other.object_;
}
Object& Object::operator=(const Object& other) {
  if (this == &other) return *this;
  object_ = other.object_;
  return *this;
}
Object::~Object() {
}

Value& Object::operator[](const string& key) {
  return object_[key];
}
const Value& Object::operator[](const string& key) const {
  type::const_iterator it = object_.find(key);
  if (it == object_.end()) throw Error("Object key not exists!");
  return it->second;
}

Object::type::iterator Object::begin() {
  return object_.begin();
}
Object::type::iterator Object::end() {
  return object_.end();
}
Object::type::const_iterator Object::begin() const {
  return object_.begin();
}
Object::type::const_iterator Object::end() const {
  return object_.end();
}

Array::Array() {
}
Array::Array(const Array& other) {
  array_ = other.array_;
}
Array& Array::operator=(const Array& other) {
  if (this == &other) return *this;
  array_ = other.array_;
  return *this;
}
Array::~Array() {
}

Value& Array::operator[](int index) {
  if (index >= array_.size()) throw Error("Index out of range!");
  return array_[index];
}
const Value& Array::operator[](int index) const {
  if (index >= array_.size()) throw Error("Index out of range!");
  return array_[index];
}

Array::type::iterator Array::begin() {
  return array_.begin();
}
Array::type::iterator Array::end() {
  return array_.end();
}
Array::type::const_iterator Array::begin() const {
  return array_.begin();
}
Array::type::const_iterator Array::end() const {
  return array_.end();
}

void Array::Push(const Value& value) {
  array_.push_back(value);
}

Value::Value()
  : type_(NIL) {
}
Value::Value(const Object& o)
  : type_(OBJECT), o_(o) {
}
Value::Value(const Array& a)
  : type_(ARRAY), a_(a) {
}
Value::Value(const String& s)
  : type_(STRING), s_(s) {
}
Value::Value(const char* s)
  : type_(STRING), s_(s) {
}
Value::Value(const Number& num)
  : type_(NUMBER), num_(num) {
}
Value::Value(const int num)
  : type_(NUMBER), num_(num) {
}
Value::Value(const Boolean& b)
  : type_(BOOLEAN), b_(b) {
}
Value::Value(const Value& other)
  : type_(other.type_) {
  switch (type_) {
  case jsmn::Value::BOOLEAN:
    b_ = other.b_; break;
  case jsmn::Value::NUMBER:
    num_ = other.num_; break;
  case jsmn::Value::STRING:
    s_ = other.s_;  break;
  case jsmn::Value::ARRAY:
    a_ = other.a_;  break;
  case jsmn::Value::OBJECT:
    o_ = other.o_; break;
  case jsmn::Value::NIL:
  default:
    break;
  }
}
Value& Value::operator=(const Value& other) {
  if (this == &other) return *this;
  type_ = other.type_;
  switch (type_) {
  case jsmn::Value::BOOLEAN:
    b_ = other.b_; break;
  case jsmn::Value::NUMBER:
    num_ = other.num_; break;
  case jsmn::Value::STRING:
    s_ = other.s_;  break;
  case jsmn::Value::ARRAY:
    a_ = other.a_;  break;
  case jsmn::Value::OBJECT:
    o_ = other.o_; break;
  case jsmn::Value::NIL:
  default:
    break;
  }
}
Value::~Value() {
}

// unwrappers

template<>
Number& Value::unwrap<Number>() {
  if (type_ != NUMBER) throw Error("Type is not Number!");
  return num_;
}
template<>
const Number& Value::unwrap<Number>() const {
  if (type_ != NUMBER) throw Error("Type is not Number!");
  return num_;
}
<commit_msg>Undefined behavior due to missing return statement<commit_after>#include <cstdlib>
#include <fstream>
#include <sstream>
#include "jsmn.h"
#include "jsmn.hpp"

namespace jsmn {

// maximum token size
const int MAX_TOKEN_SIZE = 1000;

Object::Object() {
}
Object::Object(const Object& other) {
  object_ = other.object_;
}
Object& Object::operator=(const Object& other) {
  if (this == &other) return *this;
  object_ = other.object_;
  return *this;
}
Object::~Object() {
}

Value& Object::operator[](const string& key) {
  return object_[key];
}
const Value& Object::operator[](const string& key) const {
  type::const_iterator it = object_.find(key);
  if (it == object_.end()) throw Error("Object key not exists!");
  return it->second;
}

Object::type::iterator Object::begin() {
  return object_.begin();
}
Object::type::iterator Object::end() {
  return object_.end();
}
Object::type::const_iterator Object::begin() const {
  return object_.begin();
}
Object::type::const_iterator Object::end() const {
  return object_.end();
}

Array::Array() {
}
Array::Array(const Array& other) {
  array_ = other.array_;
}
Array& Array::operator=(const Array& other) {
  if (this == &other) return *this;
  array_ = other.array_;
  return *this;
}
Array::~Array() {
}

Value& Array::operator[](int index) {
  if (index >= array_.size()) throw Error("Index out of range!");
  return array_[index];
}
const Value& Array::operator[](int index) const {
  if (index >= array_.size()) throw Error("Index out of range!");
  return array_[index];
}

Array::type::iterator Array::begin() {
  return array_.begin();
}
Array::type::iterator Array::end() {
  return array_.end();
}
Array::type::const_iterator Array::begin() const {
  return array_.begin();
}
Array::type::const_iterator Array::end() const {
  return array_.end();
}

void Array::Push(const Value& value) {
  array_.push_back(value);
}

Value::Value()
  : type_(NIL) {
}
Value::Value(const Object& o)
  : type_(OBJECT), o_(o) {
}
Value::Value(const Array& a)
  : type_(ARRAY), a_(a) {
}
Value::Value(const String& s)
  : type_(STRING), s_(s) {
}
Value::Value(const char* s)
  : type_(STRING), s_(s) {
}
Value::Value(const Number& num)
  : type_(NUMBER), num_(num) {
}
Value::Value(const int num)
  : type_(NUMBER), num_(num) {
}
Value::Value(const Boolean& b)
  : type_(BOOLEAN), b_(b) {
}
Value::Value(const Value& other)
  : type_(other.type_) {
  switch (type_) {
  case jsmn::Value::BOOLEAN:
    b_ = other.b_; break;
  case jsmn::Value::NUMBER:
    num_ = other.num_; break;
  case jsmn::Value::STRING:
    s_ = other.s_;  break;
  case jsmn::Value::ARRAY:
    a_ = other.a_;  break;
  case jsmn::Value::OBJECT:
    o_ = other.o_; break;
  case jsmn::Value::NIL:
  default:
    break;
  }
}
Value& Value::operator=(const Value& other) {
  if (this == &other) return *this;
  type_ = other.type_;
  switch (type_) {
  case jsmn::Value::BOOLEAN:
    b_ = other.b_; break;
  case jsmn::Value::NUMBER:
    num_ = other.num_; break;
  case jsmn::Value::STRING:
    s_ = other.s_;  break;
  case jsmn::Value::ARRAY:
    a_ = other.a_;  break;
  case jsmn::Value::OBJECT:
    o_ = other.o_; break;
  case jsmn::Value::NIL:
  default:
    break;
  }
  return *this;
}
Value::~Value() {
}

// unwrappers

template<>
Number& Value::unwrap<Number>() {
  if (type_ != NUMBER) throw Error("Type is not Number!");
  return num_;
}
template<>
const Number& Value::unwrap<Number>() const {
  if (type_ != NUMBER) throw Error("Type is not Number!");
  return num_;
}

{'fraction_non_alphanumeric': 0.1803019410496046, 'fraction_numerical': 0.0011502516175413372, 'mean_word_length': 4.542629482071713, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3325039', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2481, 'n_words': 602}