basical elements

This commit is contained in:
Valk Richard Li
2019-08-05 23:12:26 +08:00
committed by GitHub
parent d3b77919e1
commit 7bbd6e9e8f
11 changed files with 835 additions and 63 deletions
+8 -21
View File
@@ -445,35 +445,22 @@ NasalHash& NasalHash::operator=(const NasalHash &Source)
return *this;
}
void NasalHash::SearchElement(std::string &ElementName)
HashUnit NasalHash::SearchElement(std::string &ElementName)
{
HashUnit *temp=head;
while(temp->next)
{
temp=temp->next;
if(temp->VarName==ElementName)
{
if(temp->Type=="int")
std::cout<<*((int *)temp->data);
else if(temp->Type=="float")
std::cout<<*((float *)temp->data);
else if(temp->Type=="double")
std::cout<<*((double *)temp->data);
else if(temp->Type=="char")
std::cout<<*((char *)temp->data);
else if(temp->Type=="long long int")
std::cout<<*((long long int *)temp->data);
else if(temp->Type=="string")
std::cout<<*((std::string *)temp->data);
else if(temp->Type=="array")
((NasalList *)temp->data)->PrintList();
else if(temp->Type=="hash")
((NasalHash *)temp->data)->PrintHash();
return;
}
return *temp;
}
std::cout<<"[Error] Could not find \""<<ElementName<<"\""<<std::endl;
return;
HashUnit nil_hash;
nil_hash.data=NULL;
nil_hash.next=NULL;
nil_hash.Type="null";
nil_hash.VarName="null";
return nil_hash;
}
}