Beispiel #1
0
uint64 htmInterface::lookupIDCmd(char *str) {

  cmd_ = str;
  if(t_)delete t_;
  t_ = new VarStrToken(cmd_);

  float64 v[3];
  cmdCode code = getCode();

  if(code == NAME) {
    VarStr token = t_->next();
    if(token.empty())
      throw SpatialInterfaceError("htmInterface:lookupIDCmd: expected Name");

    return index_->idByName(token.data());
  }

  getDepth();
  if(! parseVec(code, v) )
    throw SpatialInterfaceError("htmInterface:lookupIDCmd: Expect vector in Command. ", cmd_.data());

  if( code == J2000 )
    return lookupID(v[0], v[1]);
  return lookupID(v[0], v[1], v[2]);

}
Beispiel #2
0
void Folder::addDeathDate(string date_death)
{
	Node *temp_node = lookupID(date_death);

	if (temp_node != NULL)
		temp_node->date_death = stoi(date_death);
}
Beispiel #3
0
void Folder::addWeddingDate(string date_wedding)
{
	Node *temp_node = lookupID(date_wedding);

	if (temp_node != NULL)
		temp_node->date_wedding = stoi(date_wedding);
}
Beispiel #4
0
void Folder::addState(string state)
{
	Node *temp_node = lookupID(state);

	if (temp_node != NULL)
	{
		temp_node->state = state;

		cout << "ADDED STATE: " << state << " UID: ID" << setw(3) << setfill('0') << temp_node->id << endl;
	}
}
Beispiel #5
0
void Folder::addZip(string zip)
{
	Node *temp_node = lookupID(zip);

	if (temp_node != NULL)
	{
		temp_node->zip = stoi(zip);

		cout << "ADDED ZIP: " << zip << " UID: ID" << setw(3) << setfill('0') << temp_node->id << endl;
	}
}
Beispiel #6
0
void Folder::addCity(string city)
{
	Node *temp_node = lookupID(city);

	if (temp_node != NULL)
	{
		temp_node->city = city;

		cout << "ADDED CITY: " << city << " UID: ID" << setw(3) << setfill('0') << temp_node->id << endl;
	}
}
Beispiel #7
0
void Folder::addAddress1(string address1)
{
	Node *temp_node = lookupID(address1);

	if (temp_node != NULL)
	{
		temp_node->address1 = address1;

		cout << "ADDED ADDRESS1: " << address1 << " UID: ID" << setw(3) << setfill('0') << temp_node->id << endl;
	}
}
Beispiel #8
0
void Folder::addChild(string name, int& id)
{
	Node *temp_node;
	string first, last;

	temp_node = lookupID(name);

	if (splitName(name, first, last) && temp_node != NULL)
	{
		if (temp_node->numberOfChildren == 0) //first child
		{
			temp_node->numberOfChildren++;

			temp_node->child = new string *[1];
			temp_node->child[0] = new string[2];

			temp_node->child[0][0] = first;
			temp_node->child[0][1] = last;
		}

		else
		{
			temp_node->numberOfChildren++;

			string **temp = new string* [temp_node->numberOfChildren]; //create temporary multidimensional dynamically allocated array of size numberOfChildren

			for (int i = 0; i < temp_node->numberOfChildren - 1; ++i) //populate array with old data
			{
				temp[i] = new string[2];

				temp[i][0] = temp_node->child[i][0];
				temp[i][1] = temp_node->child[i][1];

				delete[] temp_node->child[i];
			}
			delete temp_node->child; //delete old child array

			temp[temp_node->numberOfChildren - 1] = new string[2]; //assign new child to last array position
			temp[temp_node->numberOfChildren - 1][0] = first;
			temp[temp_node->numberOfChildren - 1][1] = last;

			temp_node->child = temp; //assign temp memory address to node
		}
		addName(true, true, name, "", id);
		cout << "ADDED: " << name << " UID: ID" << setw(3) << setfill('0') << temp_node->id << " <as child>" << endl;
	}
}
Beispiel #9
0
void Folder::addSpouse(string name, int& id) //working
{
	Node *temp_node;
	string first, last;

	temp_node = lookupID(name);

	if (splitName(name, first, last))
		if (temp_node != NULL)
		{
			temp_node->spouse[0] = first;
			temp_node->spouse[1] = last;

			addName(true, false, name, temp_node->name[0] + ' ' + temp_node->name[1], id);

			cout << "ADDED: " << name << " UID: ID" << setw(3) << setfill('0') << temp_node->id << " <as spouse>" << endl;
		}
}
Beispiel #10
0
void Folder::printTree(string id_str)
{
	Node *temp_node = NULL;
	Node *child_node[3];
	Node *child2_node[3];

	string temp_name;

	temp_node = lookupID(id_str);

	cout << "Family Tree of ID" << temp_node->id << endl;
	cout << "Note: names in () means spouse" << endl << endl;

	int height_tree = 3;
	// first line, prints root note's first and last name
	// as well as spouse name in ( )
	// tree top spacing (height of tree^max children) * maxlength of names + spacing / position
	cout << setfill(' ') << setw((ceil(pow(height_tree, height_tree - 1) * 7) / 2) + 9);
	cout << temp_node->name[0] + ' ' + temp_node->name[1] << endl;
	cout << setfill(' ') << setw((ceil(pow(height_tree, height_tree - 1) * 7) / 2) + 9);
	cout << '(' + temp_node->spouse[0] + ')' << endl;
	// first generation of children, tree formation
	for (int i = 0; i < temp_node->numberOfChildren; i++) {
		for (int j = 0; j < (pow(height_tree, height_tree - 1) * 7 * 2.3 / 9); j++) {
			if (i > 0 || (temp_node->numberOfChildren == 1 && i != 0)) {
				cout << '-';
			}
			else {
				cout << ' ';
			}
		}
		cout << " + ";
	}
	if (temp_node->numberOfChildren == 1) {
		for (int j = 0; j < (pow(height_tree, height_tree - 1) * 7 * 2.3 / 9); j++) {
			cout << '-';
		}
	}
	cout << endl;
	// children's names, printing out to last child if the exist
	for (int i = 0; i < temp_node->numberOfChildren; i++) {
		for (int j = 0; j < (pow(height_tree, height_tree - 1) * 7 * 2.1 / 9); j++) {
			cout << ' ';
		}
		cout << temp_node->child[i][0];
	}
	cout << endl;
	// if children have spouses, print out first name
	for (int i = 0; i < temp_node->numberOfChildren; i++) {
		for (int j = 0; j < (pow(height_tree, height_tree - 1) * 7 * 2.1 / 9); j++) {
			cout << ' ';
		}
		temp_name = temp_node->child[i][0] + ' ' + temp_node->child[i][1];
		child_node[i] = search(true, temp_name, 0);
		if (child_node[i]->spouse[0].size() > 0) {
			cout << '(' + child_node[i]->spouse[0] + ')';
		}
		else {
			cout << "(    )";
		}
	}
	cout << endl;
	// next level of the tree
	for (int i = 0; i < temp_node->numberOfChildren; i++) {
		for (int j = 0; j < 3; j++) {
			if (child_node[i]->numberOfChildren > j) {
				if (j == 0) {
					cout << "    + ----";
				}
				else if (j == 1 && child_node[i]->numberOfChildren > 2) {
					cout << "---- + ----";
				}
				else if (j == 2) {
					cout << "---- +   ";
				}
			}
			else if (child_node[i]->numberOfChildren == j && j != 0) {
				cout << "---- +   ";
			}
			else {
				cout << "       ";
			}
		}
	}
	cout << endl;
	// prints child's child's info
	for (int i = 0; i < temp_node->numberOfChildren; i++) {
		for (int j = 0; j < 3; j++) {
			if (child_node[i]->numberOfChildren > j) {
				cout << "  " + child_node[i]->child[j][0] + ' ';
			}
			else {
				cout << "       ";
			}
		}
	}
	cout << endl;
	// prints child's child's spouse
	for (int i = 0; i < temp_node->numberOfChildren; i++) {
		for (int j = 0; j < child_node[i]->numberOfChildren; j++) {
			temp_name = child_node[i]->child[j][0] + ' ' + child_node[i]->child[j][1];
			child2_node[j] = search(true, temp_name, 0);
			if (child2_node[j]->spouse[0].size() > 0) {
				cout << " (" + child2_node[j]->spouse[0] + ") ";
			}
			else {
				cout << "  (     )  ";
			}
		}
	}
	return;
}