// test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include "sharelib.h" #include #include #ifdef _DEBUG #ifdef WIN64 #pragma comment(lib, "../lib/x64/sharelib_Debug.lib") #else #pragma comment(lib, "../lib/sharelib_Debug.lib") #endif #else #ifdef WIN64 #pragma comment(lib, "../lib/x64/sharelib.lib") #else #pragma comment(lib, "../lib/sharelib.lib") #endif #endif using namespace std; using namespace Common; void test_sharelib(void) { if (1) { // test StrUtil::IsNumber() /* string str = ""; str = "-1"; cout << str << " " << StrUtil::IsNumber(str) << endl; cout << str << " " << StrUtil::IsDigit(str) << endl; str = ""; cout << str << " " << StrUtil::IsNumber(str) << endl; cout << str << " " << StrUtil::IsDigit(str) << endl; str = "1"; cout << str << " " << StrUtil::IsNumber(str) << endl; cout << str << " " << StrUtil::IsDigit(str) << endl; str = "1-"; cout << str << " " << StrUtil::IsNumber(str) << endl; cout << str << " " << StrUtil::IsDigit(str) << endl; //*/ // test File::is_avi_format() /* str = "F:\\case_video\\common\\1-big.avi"; cout << str << " " << File::is_avi_format(str) << endl; str = "F:\\case_video\\common\\1工商银行-140929.avi"; cout << str << " " << File::is_avi_format(str) << endl; str = "F:\\case_video\\common\\avi_ng.avi"; cout << str << " " << File::is_avi_format(str) << endl; str = "F:\\case_video\\common\\test.264"; cout << str << " " << File::is_avi_format(str) << endl; str = "F:\\case_video\\common\\none.avi"; cout << str << " " << File::is_avi_format(str) << endl; //*/ // test File::get_file_list() STRINGLIST file_list; //File::get_file_list("F:\\case_video\\common\\", "264*.avi", file_list); File::get_file_list("E:", "*.*", file_list); std::sort(file_list.begin(), file_list.end()); for (size_t i=0; i p1(new INT(4)); Common::smart_ptr p2(new INT(5)); Common::smart_ptr p3(new INT(6)); vector< Common::smart_ptr > index_list; index_list.push_back(p1); index_list.push_back(p2); index_list.push_back(p3); for(size_t i=0; i() << setfill('0') << setw(2) << hour << ":" << setw(2) << minute << ":" << setw(2) << second; cout << info; } void test_configbox(void) { ///* STRING info_file = STRING("D:\\中文目录 测试\\test.avi") + ".info"; //Common::File::create_file(info_file); CConfigBox configbox; configbox.load(info_file); std::vector ip_list; configbox.get_properties("dispatch_ip", ip_list); cout << ip_list.size() << endl; ip_list.push_back(""); configbox.set_properties("dispatch_ip", ip_list); configbox.save(); //*/ /* // 保存 configbox.set_property("str", "中文测试"); configbox.set_property_as_int("type", 1234); configbox.set_property_as_double("reset", 1234.56789); configbox.save(); cout << configbox.get_property("str") << endl; cout << configbox.get_property_as_int("type") << endl; double db_val = configbox.get_property_as_double("reset"); cout << db_val << endl; //*/ //long num = 123456789; //ostringstream oss; //oss << num; //cout << "中文输出 " << oss.str() << endl; cin.get(); } void test_module_manager(const std::string& dll_file) { #ifndef _DEBUG return; #endif CModuleManager module_manager; IModuleInfoPtr miptr = module_manager.load(dll_file); if (miptr) { if (module_manager.unload(miptr)) { cout << "test_module_manager() ok! \n\tfile=" << dll_file << endl; return; } } cout << "test_module_manager() fail! \n\tfile=" << dll_file << endl; } void test_get_file_size(const std::string& test_file) { cout << "test_file=" << test_file << endl; UINT64 file_size = File::get_file_size(test_file); cout << "\tfile_size=" << file_size << endl; } void test_profile(void) { string job_file = "\\\\10.10.10.171\\viecas_media@10.10.10.171\\13\\common\\user_2\\analyse\\{954462A6-72F1-4520-86CA-0FE6BB2E7CE2}\\1.job"; cout << "job_file=" << job_file << endl; string context_file = Profile::get_profile_str_val("job", "context_file", EMPTY_STRING, job_file.c_str()); cout << "context_file=" << context_file << endl; string input_file = Profile::get_profile_str_val("job", "input_file", EMPTY_STRING, job_file.c_str()); cout << "input_file=" << input_file.size() << endl; string record_file = Profile::get_profile_str_val("input", "record_file", EMPTY_STRING, input_file.c_str()); cout << "record_file=" << record_file << endl; } void test_utility_20140224(void) { cout << "Utility::is_windows_2003_or_later() " << Utility::is_windows_2003_or_later() << endl; cout << Utility::path_remove_backslash(EMPTY_STRING) << endl; cout << Utility::path_remove_backslash("C") << endl; cout << Utility::path_remove_backslash("C:") << endl; cout << Utility::path_remove_backslash("C:\\test") << endl; cout << Utility::path_remove_backslash("C:\\test\\") << endl; cout << Utility::is_local_path(EMPTY_STRING) << endl; cout << Utility::is_local_path("C:") << endl; cout << Utility::is_local_path("C:\\test") << endl; cout << Utility::is_local_path("C:\\test\\") << endl; cout << Utility::is_local_path("\\\\10.10.10.171\\test") << endl; cout << NFS::is_local_client(DEFAULT_LOCAL_IP, DEFAULT_LOCAL_IP) << endl; cout << NFS::is_local_client("10.10.10.171", "10.10.10.171") << endl; cout << NFS::is_local_client("10.10.10.171", "10.10.10.172") << endl; NFS::disconnect("\\\\10.10.10.172\\viecas_media@10.10.10.172"); } int _tmain(int argc, _TCHAR* argv[]) { #ifdef _WIN64 cout << "_WIN64 is defined as " << _WIN64 << endl; #endif #ifdef _WIN32 cout << "_WIN32 is defined as " << _WIN32 << endl; #endif //string uuid = Utility::generate_guid(); //cout << uuid << " " << uuid.length() << endl; //uuid 长度为38字节 //cout << StrUtil::IntToStr(0) << endl; //cout << StrUtil::IntToStr(1) << endl; //cout << StrUtil::IntToStr(-1) << endl; // 测试新增接口20140224 if (0) { test_utility_20140224(); } // 测试获取配置参数 if (0) { test_profile(); } // 测试数值转换 if (0) { int i_val = 0; string i_str = StrUtil::IntToStr(i_val); cout << i_val << "\t" << i_str << endl; float f_val = 1.0 / 3; string f_str = StrUtil::FloatToStr(f_val); cout << f_val << "\t" << f_str << endl; double d_val = 10000.0 / 7; string d_str = StrUtil::DoubleToStr(d_val); cout << d_val << "\t" << d_str << endl; } // 测试获取IP/MAC地址 if (0) { cout << "\ndefault ip=" << Common::NetInfo::get_default_local_ip() << endl; ip_list_t ip_list; Common::NetInfo::get_local_ip_list(ip_list); for (size_t i=0; i