You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.4 KiB

#include "util.h"
bool isTypeOf(tag_t objtag, const char * type_name) {
tag_t type = NULLTAG;
TCTYPE_ask_object_type(objtag, &type);
tag_t item_type = NULLTAG;
TCTYPE_find_type(type_name, "", &item_type);
bool is_type = false;
if (item_type != NULLTAG) {
logical isok = FALSE;
TCTYPE_is_type_of(type, item_type, &isok);
if (isok) {
is_type = true;
}
}
return is_type;
}
string ConvertToString(System::String^ str)
{
char* p = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str);
return p;
}
System::String ^ convert_to_cstring(const char *p)
{
return System::Runtime::InteropServices::Marshal::PtrToStringAnsi((System::IntPtr)(char *)p);
}
char * get_val(tag_t tag, char *name)
{
char *val;
AOM_UIF_ask_value(tag, name, &val);
return val;
}
char * get_real_val(tag_t tag, char *name)
{
char *val;
AOM_ask_value_string(tag, name, &val);
return val;
}
Value get_jldw(const char *str, Document::AllocatorType &al,Value &config)
{
Value val(kObjectType);
if(config.HasMember(str))
{
val.AddMember("FName", Value().SetString(str,al), al);
val.AddMember("FNumber",Value().SetString(config[str]["id"].GetString(),al), al);
}
return val;
}
Value get_wlsx(string str, Document::AllocatorType &al,Value &config)
{
Value val(kObjectType);
char *name = "", *id = "";
if(config.HasMember(str.c_str()))
{
val.AddMember("FID", Value().SetString(config[str.c_str()].GetString(), al), al);
val.AddMember("FName", Value().SetString(str.c_str(), al), al);
}
return val;
}
Value get_acct(string str, Document::AllocatorType &al,int type,Value &config)
{
Value val(kObjectType);
if(config.HasMember(str.c_str()))
{
val.AddMember("FName",Value().SetString(config[str.c_str()]["name"].GetString(),al), al);
if (type == 0)
{
val.AddMember("FNumber", Value().SetString(config[str.c_str()]["acct"].GetString(), al), al);
}
else if (type == 1)
{
val.AddMember("FNumber", Value().SetString(config[str.c_str()]["sale"].GetString(), al), al);
}
else
{
val.AddMember("FNumber", Value().SetString(config[str.c_str()]["cost"].GetString(), al), al);
}
}
return val;
}
string getTime()
{
stringstream ss;
time_t t = time(0);
tm* local = localtime(&t);
ss << local->tm_year + 1900 << '-';
ss << local->tm_mon + 1 << '-';
ss << local->tm_mday << ' ';
ss << local->tm_hour << ':';
ss << local->tm_min << ':';
ss << local->tm_sec;
return ss.str();
}