#include <epm/epm.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <ict/ict_userservice.h>
#include <tccore/item.h>
#include <ae/ae.h>
#include <tc/folder.h>
#include <tccore/aom.h>
#include <sa/sa.h>
#include <tccore/aom_prop.h>
#include <property/prop_errors.h>
#include <tccore/workspaceobject.h>
#include <tc/preferences.h>
#include <tccore//grm.h>
#include <tccore/grmtype.h>
#include <sa/am.h>
#include <cfm/cfm.h>
#include <bom/bom.h>
#include <tccore/uom.h>
#include <ps/ps.h>
#include <epm/signoff.h>
#include <fclasses/tc_date.h>
#include <form/form.h>
#include <form/formtype.h>
#include <schmgt_bridge\libschmgt_bridge_exports.h>
#include <schmgt_bridge\libschmgt_bridge_undef.h>
#include <schmgt\libschmgt_exports.h>
#include <schmgt\libschmgt_undef.h>
#include <schmgt\schmgt_bridge_itk.h>
#include <schmgt\schmgt_itk.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <iostream>
#include <algorithm>
// #include "metaframework/BusinessObjectRef.hxx"
// #include "tccore/ItemRevision.hxx"
// #include "tccore/Item.hxx"
#include <sstream>
#include <stdlib.h>
//#include <io.h>
#include <time.h>
using namespace std;


#define DOFREE(obj)								\
{												\
	if(obj)										\
	{											\
		MEM_free(obj);							\
		obj = NULL;								\
	}											\
}
bool isTypeOf(tag_t objtag, const char * type_name);
extern "C" int POM_AM__set_application_bypass(logical bypass);

int hasElement(vector<string> v, string element);
void ECHO(char *format, ...);
int getPrefStrings1(const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec);
void nowTime();
#define SAFECALL( argument )                                             \
{                                                                       \
	int retcode = argument;                                             \
	if ( retcode != ITK_ok ) {                                          \
	const char* *err;												\
	const int *e1,*e2;											\
	int e;														\
	EMH_ask_errors(&e,&e1,&e2,&err);							\
	stringstream err_ss;\
	for(auto e_i=0;e_i<e;e_i++){\
		err_ss<<err[e_i];\
		}\
	if(e){															\
	LERROR<<"func:"<<__func__<<"line:"<<__LINE__<<" ERROR:"<<err_ss.str();\
		}																\
		}                                                                   \
}  


