<commit_before>#include <map>
#include <iostream>
#include <stdexcept>
#include <sstream>
#include "Cxml.h"
#include "element.h"
#include "MinVRDataIndex.h"
#include "MinVRDataQueue.h"

#define HELPMESSAGE  std::cout << "l get the list of data names" << std::endl; \
      std::cout << "p <name> print a value from the list" << std::endl; \
      std::cout << "f <filename> read an XML file" << std::endl; \
      std::cout << "a <newname> <type> <value> add a primitive value" << std::endl; \
      std::cout << "c <namespace> set a default namespace (use 'none' for blank)" << std::endl; \
      std::cout << "q quit" << std::endl; \
      std::cout << "? print this message." << std::endl;

// This is just a test program meant to be a vague illustration of the
// use of the MinVRDataIndex type system.  The program is essentially
// a really dumb interpreter with a few commands implemented, such as
// look at a program, read a data file, add a data value and change
// the namespace.  Use the operation of the program to learn about
// namespaces and use the code below as a way to learn how to use the
// data index. It's just hacked together, so don't read too much into
// it.
int main() {
  MinVRDataIndex *index = new MinVRDataIndex;
  MinVRDataQueue *queue = new MinVRDataQueue;

  // Set up some sample data names and values.
  int a = 4;
  int b = 6;
  double f = 3.1415926;
  double g = 2.71828;
  std::string s1 = std::string("wowie!");
  std::string s2 = std::string("shazam!");

  index->addValue(std::string("henry"), a);
  index->addValue(std::string("ralph"), b);

  index->addValue(std::string("george"), f);
  index->addValue(std::string("mary"), g);

  index->addValue(std::string("billy"), s1);
  index->addValue(std::string("johnny"), s2);

  index->addSerializedValue(std::string("<bob type=\"container\"><flora type=\"int\">3274</flora><morton type=\"float\">34.5</morton><cora type=\"container\"><flora type=\"int\">1234</flora><nora type=\"float\">23.45</nora></cora></bob>"));

  index->addSerializedValue(std::string("<chester type=\"vecfloat\">32.7@44.56@22.3@78.2@99.134@</chester>"));

  queue->push(index->getDatum("billy")->serialize());
  queue->push(index->getDatum("george")->serialize());
  queue->printQueue();

  std::vector<std::string> elems;
  std::string elem;
  std::string line;
  std::string nameSpace("");

  HELPMESSAGE

  while ((std::cout << "> ") && std::getline(std::cin, line)) {

    elems.clear();
    std::stringstream ss(line);
    while (std::getline(ss, elem, ' ')) {
      elems.push_back(elem);
    }

    ////// command: ? (help)
    if (elems[0].compare("?") == 0) {
      HELPMESSAGE

    ////// command: f (open file)
    } else if (elems[0].compare("f") == 0) {

      index->processXMLFile(elems[1]);

    ////// command: c (set namespace)
    } else if (elems[0].compare("c") == 0) {

      if (elems.size() > 1) {
        if (elems[1].compare("none") == 0) {
          nameSpace = std::string("");
        } else {
          nameSpace = elems[1];
        }
      } else {<commit_msg>fixed namespace usage in exercz<commit_after>#include <map>
#include <iostream>
#include <stdexcept>
#include <sstream>
#include "Cxml.h"
#include "element.h"
#include "MinVRDataIndex.h"
#include "MinVRDataQueue.h"

#define HELPMESSAGE  std::cout << "l get the list of data names" << std::endl; \
      std::cout << "p <name> print a value from the list" << std::endl; \
      std::cout << "f <filename> read an XML file" << std::endl; \
      std::cout << "a <newname> <type> <value> add a primitive value" << std::endl; \
      std::cout << "c <namespace> set a default namespace (use 'none' for blank)" << std::endl; \
      std::cout << "q quit" << std::endl; \
      std::cout << "? print this message." << std::endl;

// This is just a test program meant to be a vague illustration of the
// use of the MinVRDataIndex type system.  The program is essentially
// a really dumb interpreter with a few commands implemented, such as
// look at a program, read a data file, add a data value and change
// the namespace.  Use the operation of the program to learn about
// namespaces and use the code below as a way to learn how to use the
// data index. It's just hacked together, so don't read too much into
// it.
int main() {
  MinVRDataIndex *index = new MinVRDataIndex;
  MinVRDataQueue *queue = new MinVRDataQueue;

  // Set up some sample data names and values.
  int a = 4;
  int b = 6;
  double f = 3.1415926;
  double g = 2.71828;
  std::string s1 = std::string("wowie!");
  std::string s2 = std::string("shazam!");

  index->addValue(std::string("/henry"), a);
  index->addValue(std::string("/ralph"), b);

  index->addValue(std::string("/george"), f);
  index->addValue(std::string("/mary"), g);

  index->addValue(std::string("/billy"), s1);
  index->addValue(std::string("/johnny"), s2);

  index->addSerializedValue(std::string("<bob type=\"container\"><flora type=\"int\">3274</flora><morton type=\"float\">34.5</morton><cora type=\"container\"><flora type=\"int\">1234</flora><nora type=\"float\">23.45</nora></cora></bob>"));

  index->addSerializedValue(std::string("<chester type=\"vecfloat\">32.7@44.56@22.3@78.2@99.134@</chester>"));

  std::vector<std::string> elems;
  std::string elem;
  std::string line;
  std::string nameSpace("/");

  queue->push(index->getDatum("billy", nameSpace)->serialize());
  queue->push(index->getDatum("george", nameSpace)->serialize());
  queue->printQueue();

  HELPMESSAGE

  while ((std::cout << "> ") && std::getline(std::cin, line)) {

    elems.clear();
    std::stringstream ss(line);
    while (std::getline(ss, elem, ' ')) {
      elems.push_back(elem);
    }

    ////// command: ? (help)
    if (elems[0].compare("?") == 0) {
      HELPMESSAGE

    ////// command: f (open file)
    } else if (elems[0].compare("f") == 0) {

      index->processXMLFile(elems[1]);

    ////// command: c (set namespace)
    } else if (elems[0].compare("c") == 0) {

      if (elems.size() > 1) {
        if (elems[1].compare("none") == 0) {
          nameSpace = std::string("");
        } else {
          nameSpace = elems[1];
        }
      } else {
{'fraction_non_alphanumeric': 0.19298815127414382, 'fraction_numerical': 0.02077584807661094, 'mean_word_length': 3.504385964912281, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6390837', 'n_tokens_mistral': 2163, 'n_tokens_neox': 2061, 'n_words': 564}