Exemplo n.º 1
0
int main(int Count, char* Switches[])
{
  bool sound = true;
  int width = 0;
  int height = 0;
  for (int i = 1; i < Count; ++i) {
    const string argument(Switches[i]);
    //screen size
    if (i == 1 && !argument.empty() && isdigit(argument[0])) {
      szt xPos = FindCharacter(argument, 'x');
      if (xPos != string::npos) {
        width = Abs(IntoInt(CutString(argument, 0, xPos)));
        height = Abs(IntoInt(CutString(argument, xPos + 1)));
      }
    }
    if (argument == "-s" || argument == "-silent" || argument == "-no-sound") {
      sound = false;
    }
  }

  Reader reader(width, height, 32, sound);

  if (reader.Init()) {
    ulint lastTime = 0;
    real deltaTime = 0.1;
    while (reader.Tick(deltaTime)) {
      deltaTime = Input::LimitFPS(lastTime);
    }
    return 0;
  } else {
    LOG("Reader initialisation failed.");
    return 1;
  }
}
Exemplo n.º 2
0
Image::Image(MediaManager& Manager,
             const string& AssetName,
             const string& Params)
  : Asset(Manager, AssetName)
{
  string params = GetCleanWhitespace(Params);
  szt xPos = FindCharacter(params, ',');
  Filename = Media.AssetDir + CutString(params, 0, xPos);
  if (xPos != string::npos) {
    Priority = 1;
    szt yPos = FindCharacter(params, ',', ++xPos);
    const string& x = CutString(params, xPos, yPos);
    X = IntoReal(x);
    if (yPos != string::npos) {
      szt zoomPos = FindCharacter(params, ',', ++yPos);
      const string& y = CutString(params, yPos, zoomPos);
      Y = IntoReal(y);
      if (zoomPos != string::npos) {
        szt orderPos = FindCharacter(params, ',', ++zoomPos);
        const string& zoom = CutString(params, zoomPos, orderPos);
        Zoom = IntoReal(zoom);
        if (orderPos != string::npos) {
          const string& order = CutString(params, orderPos);
          Priority = Abs(IntoInt(order)) + 1; //0 reserved for BG
        }
      }
    }
  } else {
    BG = true;
  }
}
Exemplo n.º 3
0
std::string Fonts::CutDoubleString(std::string& ori, const char delim1, const char delim2)
{
	std::string res;
	CutString(ori, delim1);
	res = CutString(ori, delim2);
	return res;
}
Exemplo n.º 4
0
/** @brief Return true only if a non-empty line is returned, remove indentation
  */
bool File::GetLine(string& Buffer)
{
  if (!Opened || Stream.eof()) {
    return false;
  } else {
    getline(Stream, Buffer);
    if (Buffer.empty()) {
      return false;
    }
    // remove whitespace from start
    szt posStart = 0;
    cszt length = Buffer.size();
    while (posStart < length
           && (Buffer[posStart] == ' ' || Buffer[posStart] == '\t')) {
      ++posStart;
    }
    // remove whitespace from end
    szt posEnd = length;
    while (posEnd > posStart
           && (Buffer[posEnd - 1] == ' ' || Buffer[posEnd - 1] == '\t')) {
      --posEnd;
    }
    if (posStart || posEnd < length) {
      if (posStart == posEnd) {
        Buffer.clear();
        return false;
      } else {
        Buffer = CutString(Buffer, posStart, posEnd);
      }
    }
    return true;
  }
}
Exemplo n.º 5
0
bool CResources::LoadString(CTextFile& file)
{
	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		line.Trim();
		if (line == _T("BEGIN"))
			break;
	}
	if (file.Eof())
		return false;

	int sepcount = 0;

	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		CAtlArray<CString> Words;
		CutString(line, Words);
		CString word = Words[0];

		if(word == _T("END"))
			return true;
		
		ResString item;
		item.m_ID = word;
		if (Words.GetCount() > 1)
		{
			item.m_String = Words[1];
		}
	}
	return false;
}
Exemplo n.º 6
0
void TokenChannels_t::ClearString( const char *in, char *out, int maxlen )
{
	bool bOnlyValidChannels = true;
	TokenChannels_t tmp;
	tmp.Tokenize( in );
	if ( tmp.bHasAnyValues )
		bOnlyValidChannels = false;

	int slot = 0;
	char *writer = out;
	const char *reader = in;
	while ( reader && *reader )
	{
		if ( GetChannelNumFromChar( reader ) >= 0 ||
			( !bOnlyValidChannels && *reader >= '0' && *reader <= '9' ) ||
			( !bOnlyValidChannels && *reader == ' ' ) ||
			( !bOnlyValidChannels && *reader == '.' ) )
		{
			if ( slot >= (maxlen-1) )
				break;
			*writer = *reader;
			writer++;
			slot++;
		}
		reader++;
	}
	Assert( slot < maxlen );
	*writer = '\0';

	RemoveDuplicatedSpaces( out );
	CutString( out );
}
Exemplo n.º 7
0
//截取Section
void CINIsoc::CutString(char* fid, int len, CString& sFile)
{
	char *pline_head = fid;
	int readtotal = 0;
	//纳入内存池,从缓存中申请,更快
	char* buf = theApp.m_memPool.NewMem(KEY_BUF);
	if(NULL==buf)
		return;
	memset(buf,0,KEY_BUF);
	DWORD wRet = 0;
	for(int i=0;i<len;i++)
	{
		if(fid[i] == 0x0)
		{
			CString str ;
			str.Format("%s",pline_head);
			//截取Section中的keys
			wRet = 0;
			wRet = ::GetPrivateProfileSection(str,buf,KEY_BUF,sFile);//某个section的所有内容
			if(wRet > 0){
				ATF_MAP atf_map;
				CutString(buf,wRet,atf_map);
				str.MakeUpper(); //统一大写 2011.10.17
				//插入节点
				m_SectMap.insert( SECT_PAIRMAP( str, atf_map ) );
			}
			if(fid[i+1] == 0x0)
				break;//字段结束;
			pline_head = fid+i+1;
		}
	}
	//纳入内存池
	theApp.m_memPool.FreeMem(buf);
}
Exemplo n.º 8
0
bool CResToolbar::Load(CTextFile& file)
{
	CString line;
	while(!file.Eof())
	{
		file.ReadLine(line);
		if (line == _T("BEGIN"))
			break;
	}
	if (file.Eof())
		return false;
	
	int sepcount = 0;

	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		CAtlArray<CString> Words;
		CutString(line, Words);
		CString word = Words[0];

		if(word == _T("BUTTON") || word == _T("SEPARATOR"))
		{
			ResToolbarItem item;

			item.m_Type = word;

			if(word == _T("BUTTON"))
			{
				if (Words.GetCount() > 1)
				{
					item.m_ID = Words[1];
				}
				m_vItems.Add(item);
			}
						
		}
		else if(word == _T("END"))
			return true;
	}
	return false;
}
Exemplo n.º 9
0
// 启动logUpload上传器
void StartLogUpload( wstring strUrlPath )
{
	wchar_t szBuf[PATH_SIZE];
	GetCurrentDirectory(PATH_SIZE, szBuf);
	wchar_t szCmdLine[PATH_SIZE];
	wcscpy_s(szCmdLine, PATH_SIZE, L"\"");
	wcscat_s(szCmdLine, PATH_SIZE, szBuf);
	wchar_t* ptr = NULL;

	// 拼凑Url.ini路径
	wchar_t szIniPath[PATH_SIZE];
	wcscpy_s(szIniPath, PATH_SIZE, szBuf);
	wcscat_s(szIniPath, PATH_SIZE, L"/");
	wcscat_s(szIniPath, PATH_SIZE, strUrlPath.c_str());

	// 拼凑log目录
	TransferBacklash(szCmdLine);
	CutString(szCmdLine);
	wcscat_s(szCmdLine, PATH_SIZE, L"/var");
	wcscat_s(szCmdLine, PATH_SIZE, L"\"");

	wchar_t szLogHost[PATH_SIZE];
	DWORD dwRet = GetPrivateProfileString(L"Setting", UP_SERVER, NULL, szLogHost, PATH_SIZE, szIniPath);
	if (wcscmp(szLogHost, L"") == 0)
	{
		return;
	}
	if ( dwRet == 0 )
		wprintf(L"Can't read ini file: %s %d\n", szIniPath, GetLastError());
	wcscat_s(szLogHost, PATH_SIZE, L"/");
	wcscat_s(szLogHost, PATH_SIZE, HOST_FILE);

	ptr = szCmdLine + wcslen(szCmdLine);
	*ptr++ = L' ';
	*ptr = L'\0';
	size_t nLeaveSize = PATH_SIZE - wcslen(szCmdLine) - 1;
	wcscat_s(ptr, nLeaveSize, szLogHost);

	ShellExecute(NULL, L"open", L"UploadLog.exe", szCmdLine, NULL, SW_HIDE);
}
Exemplo n.º 10
0
/** @brief create layout based on string
 */
bool Layout::Init(const string& Text)
{
  if (Text.size() != (BOX_TYPE_MAX * 3 + 7)) {
    LOG("mangled layout string");
    return false;
  }
  // read this: 0132 3111 1111 0 00
  //            ----
  szt offset = 0;
  for (szt i = 0, fSz = BOX_TYPE_MAX; i < fSz; ++i) {
    Order[i] = (boxType)IntoInt(Text[offset + i]);
  }
  offset += BOX_TYPE_MAX;
  ++offset;
  // read this: 0132 3111 1111 0 00
  //                 ----
  for (szt i = 0, fSz = BOX_TYPE_MAX; i < fSz; ++i) {
    Side[i] = (side)IntoInt(Text[offset + i]);
  }
  offset += BOX_TYPE_MAX;
  ++offset;
  // read this: 0132 3111 1111 0 00
  //                      ----
  for (szt i = 0, fSz = BOX_TYPE_MAX; i < fSz; ++i) {
    Active[i] = IntoInt(Text[offset + i]);
  }
  offset += BOX_TYPE_MAX;
  ++offset;
  // read this: 0132 3111 1111 0 00
  //                           -
  SizeSpan = IntoInt(Text[offset]);
  offset += 2;
  // read this: 0132 3111 1111 0 00
  //                             --
  Split = IntoReal(CutString(Text, offset, offset + 2)) / (real)100;
  return true;
};
Exemplo n.º 11
0
bool CResMenu::Load(CTextFile &file)
{
	int level = 0;

	CString buffer;//next line
	CString line;
	CAtlArray<CString> Words;

	while(!file.Eof())
	{
		CString word;
		if (buffer.IsEmpty())
		{
			file.ReadLine(line);
		}
		else
		{
			line = buffer;
			buffer.Empty();
		}
		
		CutString(line, Words);
		if (Words[0] == _T("BEGIN"))
		{
			continue;
		}
		if (Words[0] == _T("END"))
		{
			return true;
		}
		if (Words[0] == _T("POPUP"))
		{
			CResMenu SubMenu;
			SubMenu.m_String = Words[1];
			if (!SubMenu.Load(file))
				return false;
			m_SubMenus.Add(SubMenu);
		}
		if (Words[0] == _T("MENUITEM"))
		{
			file.ReadLine(buffer);
			buffer.TrimLeft();
			buffer.TrimRight();
			while (_tcsncmp(buffer, _T("MENUITEM"), 8) &&
				_tcsncmp(buffer, _T("POPUP"), 5) &&
				_tcsncmp(buffer, _T("BEGIN"), 5) &&
				_tcsncmp(buffer, _T("END"), 3))
			{
				//
				line += _T(" ") + buffer;
				CutString(line, Words);
				file.ReadLine(buffer);
				buffer.TrimLeft();
				buffer.TrimRight();
			}
			ResMenuItem newitem;
			if (Words.GetCount() > 1)
			{
				newitem.m_String = Words[1];
				if (newitem.m_String == _T("SEPARATOR") && Words.GetCount() == 2)
				{
				}
				else
				{
					newitem.m_String.Replace(_T("\"\""), _T("\""));
					newitem.m_ID = Words[2];
					if (Words.GetCount() > 3)
					{
						newitem.m_Style = Words[3];
					}
				}
			}
			m_vItems.Add(newitem);
		}
	}
	return false;
}
Exemplo n.º 12
0
bool CResources::Load(LPCTSTR filename, bool bAppend /* = false */)
{
	CTextFile file;
	if (!bAppend)
	{
		m_Dialogs.RemoveAll();
		m_Menus.RemoveAll();
		m_Toolbars.RemoveAll();
		m_Accels.RemoveAll();
		m_Icons.RemoveAll();
		m_Bitmaps.RemoveAll();
		m_Cursors.RemoveAll();
	}
	if(!file.Open(filename))
	{
		return false;
	}

	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		if (line.IsEmpty())
			continue;
		line.TrimLeft();
		if (line.GetLength() >= 2 && line[0] == _T('/') && line[1] == _T('/'))
			continue;
		if (line[0] == _T('#'))
			continue;

		CAtlArray<CString> Words;
		CutString(line, Words);
		{
			CString word;
			if (Words.GetCount() > 1)
			{
				word = Words[1];
			}
			else
			{
				word.Empty();
			}
			if (word == _T("DESIGNINFO"))
			{
				//skip disign info
				while(!file.Eof())
				{
					file.ReadLine(line);
					line.Trim();
					if (line == _T("BEGIN"))
						break;
				}
				if (file.Eof())
					return false;
				int Level = 1;
				while(!file.Eof() && Level)
				{
					file.ReadLine(line);
					line.Trim();
					if (line == _T("BEGIN"))
						Level++;
					if (line == _T("END"))
						Level--;
				}
				if (Level)
					return false;
				else
					continue;
			}

			if(word == _T("MENU"))
			{
				CResMenu newmenu;
				newmenu.m_ID = Words[0];
				newmenu.Load(file);

				m_Menus.Add(newmenu);
			}
			else if( word == _T("TOOLBAR") )
			{
				CResToolbar newtoolbar;
				newtoolbar.m_ID = Words[0];
				newtoolbar.Load(file);

				m_Toolbars.Add(newtoolbar);
			}
			else if( (word == _T("DIALOG"))
				|| word == _T("DIALOGEX")
				)
			{
				CResDialog newdialog;
				newdialog.m_ID = Words[0];
				newdialog.m_Type = word;
				newdialog.Load(file);

				m_Dialogs.Add(newdialog);
			}
			else if( word == _T("BITMAP") || 
				word == _T("ICON") ||
				word == _T("CURSOR")
				)
			{
				ResBinary m_simple;
				m_simple.m_ID = Words[0];

				if(word == _T("BITMAP"))
					m_Bitmaps.Add(m_simple);
				else if(word == _T("ICON"))
					m_Icons.Add(m_simple);
				else
					m_Cursors.Add(m_simple);
			}
			else if(word == _T("ACCELERATORS"))
			{
				CResAccelerators accels;
				accels.m_ID = Words[0];
				accels.Load(file);
				m_Accels.Add(accels);
			}
			else 
			{
				if(Words.GetCount() > 0 && (Words[0] == _T("STRINGTABLE")))
				{
					LoadString(file);
				}
			}
		}
	}
	return true;
}
Exemplo n.º 13
0
/** @brief parses the save file and fills histories (does't load any snapshot)
  */
bool Session::Load()
{
  File Save;
  const string& savePath = STORY_DIR + SLASH + BookName + SLASH
                           + Filename + SESSION_EXT;
  if (!Disk::Exists(savePath) || !Save.Read(savePath)) {
    LOG(savePath + " - save file missing");
    return false;
  }

  string buffer;
  Save.GetLine(buffer); // session name:
  Save.GetLine(Name);
  Save.GetLine(buffer); // book title:
  Save.GetLine(BookName);
  Save.GetLine(buffer);
  Save.GetLine(buffer); // steps taken:
  Save.GetLine(buffer); // #
  Save.GetLine(buffer);

  // queue
  while (Save.GetLine(buffer)) {
    QueueHistory.push_back(buffer);
  }

  // assets
  Save.GetLine(buffer); // asset states:
  Save.GetLine(buffer); // #
  Save.GetLine(buffer);
  while (Save.GetLine(buffer)) {
    string historyEntry = buffer;
    while (Save.GetLine(buffer)) {
      historyEntry += "\n";
      historyEntry += buffer;
    }
    AssetsHistory.push_back(historyEntry);
  }

  // values
  Save.GetLine(buffer); // tracked values:
  Save.GetLine(buffer); // #
  // resize the array to fit all the values tracked
  ValuesHistories.resize(IntoSizeT(buffer));
  Save.GetLine(buffer);
  while (Save.GetLine(buffer)) {
    string indexBuffer;
    Save.GetLine(indexBuffer);
    cszt index = IntoSizeT(indexBuffer);
    ValuesHistoryNames[buffer] = IntoSizeT(index);
    while (Save.GetLine(buffer)) {
      ValuesHistories[index].push_back(buffer);
    }
  }

  // changes
  while (Save.GetLine(buffer)) {
    cszt pos = FindCharacter(buffer, VALUE_SEPARATOR);
    const string& valueIndex = CutString(buffer, 0, pos);
    const string& changeIndex = CutString(buffer, pos + 1);
    cszt_pair change(IntoSizeT(valueIndex), IntoSizeT(changeIndex));
    ValuesChanges.push_back(change);
  }

  // snapshots
  while (Save.GetLine(buffer)) {
    cszt pos = FindCharacter(buffer, VALUE_SEPARATOR);
    cszt pos2 = FindCharacter(buffer, VALUE_SEPARATOR, pos + 1);
    const string& queueIndex = CutString(buffer, 0, pos);
    const string& assetIndex = CutString(buffer, pos + 1, pos2);
    const string& changeIndex = CutString(buffer, pos2 + 1);
    const Snapshot loadedSnapshot(IntoSizeT(queueIndex),
                                  IntoSizeT(assetIndex),
                                  IntoSizeT(changeIndex));
    Snapshots.push_back(loadedSnapshot);
  }

  // bookmarks
  while (Save.GetLine(buffer)) {
    cszt index = IntoSizeT(buffer);
    string bookmarkDescription;
    while (Save.GetLine(buffer)) {
      bookmarkDescription += buffer;
    }
    Bookmarks[index].Description = bookmarkDescription;
  }

  // repeat last snapshot
  LoadSnapshot(Snapshots.size() - 1);
  return true;
}
Exemplo n.º 14
0
//装载INI配置文件
void CINIsoc::Loadini()
{
	if( !m_SectMap.empty() )
	{
		//清理列表
		Clear();
	}

	//纳入内存池,从缓存中申请,更快
	char* buf = theApp.m_memPool.NewMem(SECTION_BUF);
	if(NULL==buf)
		return;
	memset(buf,0,SECTION_BUF);

	//日志标记
	UINT uiRet = ::GetPrivateProfileInt("System", "IsLog", 0, theApp.m_sPathDll+"s_tztredis.ini");
	if( uiRet > 0 )
		theApp.m_logMgt.m_bStartlog = true;

	//数据库相关信息
	{
		CString sGlobleFile = theApp.m_sPath+_T("server.ini");
		char chTemp[50] = {0};
#ifdef XWB_SQL_LINK //2013.06.06 xuwb SQL版
		::GetPrivateProfileString("connect", "address", "", chTemp, 50, sGlobleFile);
		m_DataSource = chTemp; m_DataSource.Trim();
#else//Oracle版
		::GetPrivateProfileString("connect", "sysdb", "", chTemp, 50, sGlobleFile);
		m_DataSource = chTemp; m_DataSource.Trim();
#endif
		memset(chTemp,0,50);
		::GetPrivateProfileString("connect", "username", "", chTemp, 50, sGlobleFile);
		m_UserID = chTemp; m_UserID.Trim();

		memset(chTemp,0,50);
		::GetPrivateProfileString("connect", "password", "", chTemp, 50, sGlobleFile);
		m_Password = chTemp; m_Password.Trim();
        //增加多APP支持,2015.09.07
		memset(chTemp,0,50);
		::GetPrivateProfileString("HSCOMM", "IsMultiApp", "", chTemp, 50, sGlobleFile);
		m_isMultiApp = chTemp; m_Password.Trim();
		//2013.06.06 增加sql数据库配置 InitialCatalog
		memset(chTemp,0,50);
		::GetPrivateProfileString("connect", "sysdb", "", chTemp, 50, sGlobleFile);
		m_InitialCatalog = chTemp; m_InitialCatalog.Trim();
 
		memset(chTemp,0,50);
		::GetPrivateProfileString("comm", "systype", "0", chTemp, 50, sGlobleFile);
		m_SysType = chTemp; 
		m_SysType.Trim();

		memset(chTemp,0,50);
		::GetPrivateProfileString("HSCOMM", "centerNo", "", chTemp, 50, sGlobleFile);
		m_center_no = chTemp; 
		m_center_no.Trim();

		::GetPrivateProfileString("HSCOMM", "IsCluster", "N", chTemp, 50, sGlobleFile);  //2015.07.30
		m_isCluster = chTemp; 
		m_isCluster.Trim();   

		m_PageSize = ::GetPrivateProfileInt("connect", "Page_size", 50, sGlobleFile);
		m_centerCount = ::GetPrivateProfileInt("HSCOMM", "centerCount", 1, sGlobleFile);
		memset(chTemp, 0, 50);
		::GetPrivateProfileString("HSCOMM", "Port", "", chTemp, 50, sGlobleFile); //外壳监听端口
		m_MainPort = chTemp; m_MainPort.Trim();
	}

	CString sFile = theApp.m_sPathDll+_T("s_tztredis.ini");
	char chTemp[50] = {0};
	::GetPrivateProfileString("alarm", "StockBgnTime", "", chTemp, 50, sFile);//开始同步股票市场号时间2015.06.27
	m_StockBgnTime = chTemp;
	m_StockBgnTime.Trim();
	memset(chTemp, 0, 50);
	::GetPrivateProfileString("alarm", "StockEndTime", "", chTemp, 50, sFile);//结束同步股票市场号时间2015.06.27
	m_StockEndTime = chTemp;
	m_StockEndTime.Trim();
	m_AlarmThreadNo = ::GetPrivateProfileInt("alarm", "AlarmThreadNo", 10, sFile); //预警线程数
	m_msgTimeOut = ::GetPrivateProfileInt("comm", "MsgTimeOut", 30, sFile); //消息超时删除时间(默认30天)
	memset(chTemp, 0, 50);
	::GetPrivateProfileString("alarm", "AlarmMenu", "203", chTemp, 50, sFile);//预警栏目2016.03.04
	m_alarmMenu = chTemp;
	m_alarmMenu.Trim();
	memset(chTemp, 0, 50);
	::GetPrivateProfileString("alarm", "MenuType", "2", chTemp, 50, sFile);//预警栏目类型
	m_alarmType = chTemp;
	m_alarmType.Trim();
	
	memset(chTemp, 0, 50);
	::GetPrivateProfileString("account", "ShowAlert", "0", chTemp, 50, sFile);//是否弹框
	m_ShowAlert = chTemp;
	m_ShowAlert.Trim();
	
	//获取所有的[section] 
	memset(buf,0,SECTION_BUF);
	DWORD wRet = ::GetPrivateProfileSectionNames(buf,SECTION_BUF,sFile);
	if(wRet > 0){
		//从文件配置
		CutString(buf,wRet,sFile);
	}
	m_zjjip = FindCode("comm", "zjjip");
	m_zjjport = FindCode("comm", "zjjport");
	m_gjip = FindCode("comm", "gjip");
	m_gjport = FindCode("comm", "gjport");
	m_isForGj = FindCode("comm", "IsForGJ");   //是否供国金使用
	m_hqAddr   = FindCode("comm", "hqAddr");   // 行情服务器地址
	m_hqPort   = FindCode("comm", "hqPort");   // 行情服务器端口
	m_XJTAddr  = FindCode("comm", "XJTAddr");  // 中山证券 现金通服务器地址
	m_XJTPort  = FindCode("comm", "XJTPort");  // 中山证券 现金通服务器端口
	m_SyncTime = FindCode("comm", "SyncTime"); // 同步现金通数据的时间
	m_noDelMenu = FindCode("comm", "NoDelMenu"); //不做历史消息清理的栏目
	m_NewStockMsg = FindCode("comm", "NewStockMsg"); // 当日有新股时推送的内容
	m_isForHt=FindCode("comm","IsForHt");//是否供华泰使用
	m_ipoBgnTime = FindCode("IPO","IpoBgnTime");//新股提醒开始时间
	m_ipoBgnTime.Format("%06s",m_ipoBgnTime);
	m_ipoEndTime = FindCode("IPO","IpoEndTime");//新股提醒结束时间
	m_ipoEndTime.Format("%06s",m_ipoEndTime);
	m_alarmFrom=FindCode("alarm","AlarmFrom");//预警消息来源
	m_alarmMode=FindCode("alarm","AlarmMode");//预警模式
	m_mobileSupport = FindCode("comm","MobileSupport"); //是否支持手机号发送(2016.01.19)
	m_ipoPush = FindCode("IPO","IpoPush"); //是否支持新股提醒推送(2016.02.02)
	m_ipoMenu = FindCode("IPO","IpoMenu"); //新股提醒推送栏目id(2016.02.02)
	m_InfoServerIp = FindCode("IPO","InfoServerIp"); //资讯服务器地址(用于获取当日新股)
	m_InfoServerPort = FindCode("IPO","InfoServerPort"); 
	m_PushServerIp = FindCode("IPO","PushServerIp"); //推送服务器地址(用于消息群推)
	m_PushServerPort = FindCode("IPO","PushServerPort"); 
	m_ipoMsgFrom = FindCode("IPO","IpoMsgFrom"); 
	m_ipoTimeOutMin = FindCode("IPO","TimeOutMin");
	m_ipoMsgMark = FindCode("IPO","MsgMark");
	m_queryip = FindCode("account","AccQueryIp"); //账号权限查询ip
	m_queryport = FindCode("account","AccQueryPort"); //账号权限查询端口
	m_accNotice = FindCode("account","AccNotice");//账号绑定提醒
	m_accType = FindCode("account","AccType");//唯一登录推送的消息类型
}
Exemplo n.º 15
0
/** @brief you need to init system nouns beforehand
  */
bool Session::LoadSnapshot(cszt Index)
{
  if (Index >= Snapshots.size() || !Index) {
    // if it's not within the history or is the start of the story
    // there's nothing to load and the story is ready to go from the init
    return false;
  }
  CurrentSnapshot = Index;
  szt queueI = Snapshots[Index].QueueIndex;
  szt assetI = Snapshots[Index].AssetsIndex;
  szt changeI = Snapshots[Index].ChangesIndex;

  // load the current queue
  if (queueI > 0) {
    const string& queueValue = QueueHistory[--queueI];
    *QueueNoun = Properties(queueValue);
  } else {
    // this is at the start of the book, no loading needed
    return false;
  }

  // find the most up to date positions of value histories for each history
  vector<szt> currentIndex;
  currentIndex.resize(ValuesHistories.size(), 0);
  for (szt i = 0; i < changeI; ++i) {
    cszt_pair& change = ValuesChanges[i];
    currentIndex[change.X] = change.Y;
  }

  for (const auto& value : ValuesHistoryNames) {
    const string& name = value.first;
    cszt i = value.second;
    // all indeces here are 1-based, 0 meaning book values should be used
    if (currentIndex[i]) {
      // it's safe to decrement as it's a temporary
      const string& oldValue = ValuesHistories[i][--currentIndex[i]];
      UserValues[name] = Properties(oldValue);
    } else {
      // remove user values that are the same as in the book
      // because we don't have a record of the initial state
      auto it = UserValues.find(name);
      if (it != UserValues.end()) {
        // but don't remove system nouns, they are initialised
        bool nonSystem = true;
        for (const Properties* systemNoun : SystemNouns) {
          if (&(it->second) == systemNoun) {
            nonSystem = false;
            break;
          }
        }
        if (nonSystem) {
          UserValues.erase(it);
        }
      }
    }
  }

  AssetStates.clear();
  // assetI 0 means all assets are off
  if (assetI > 0) {
    const string& assets = AssetsHistory[--assetI];
    szt lastPos = 0;
    szt pos = FindCharacter(assets, '\n', lastPos);

    while (pos != string::npos && pos > lastPos) {
      const string& assetName = CutString(assets, lastPos, pos);
      AssetStates[assetName] = true;
      lastPos = ++pos;
      pos = FindCharacter(assets, '\n', lastPos);
    }
    if (lastPos < assets.size()) {
      // last value doesn't have a \n at the end
      const string& assetName = CutString(assets, lastPos);
      AssetStates[assetName] = true;
    }
  }

  return true;
}
Exemplo n.º 16
0
bool Fonts::LoadTxtFontFile(const char* fileName)
{
	size_t fileSize;
	float scaleW;
	float scaleH;
	int charactCount;
	unsigned char* buff = Utility::FileReadAll(fileName,&fileSize);
	if (buff==nullptr)
	{
		return false;
	}

	std::string buffString = "";
	for (size_t i = 0; i < fileSize; i++)
	{
		buffString += buff[i];
	}

	std::string res = CutString(buffString, '"');
	m_fontName =CutString(buffString, '"');
	res = CutString(buffString, '\r');
	//res = CutString(buffString, '=');
	//res = CutString(buffString, ' ');
	res = CutDoubleString(buffString, '=', ' ');
	m_lineHeight = (float)atof(res.c_str());
	res = CutDoubleString(buffString, '=', ' ');
	m_base = (float)atof(res.c_str());
	res = CutDoubleString(buffString, '=', ' ');
	scaleW = (float)atof(res.c_str());
	res = CutDoubleString(buffString, '=', ' ');
	scaleH = (float)atof(res.c_str());
	res = CutString(buffString, '\r');
	res = CutString(buffString, '\r');
	res = CutDoubleString(buffString, '=', ' ');
	charactCount = (int)atof(res.c_str());

	for (int i = 0; i < charactCount; i++)
	{
		short ID;
		Vector2 XY;
		Vector2 WH;
		Vector2 OffsetXY;
		Vector2 GLYPHWH;
		float XAdvance;
		res = CutDoubleString(buffString, '=', ' ');		
		ID = (short)atof(res.c_str());
		res = CutDoubleString(buffString, '=', ' ');
		XY.x = (float)atof(res.c_str()) / scaleW;
		res = CutDoubleString(buffString, '=', ' ');
		XY.y = (float)atof(res.c_str()) / scaleH;
		res = CutDoubleString(buffString, '=', ' ');
		WH.x = (float)atof(res.c_str()) / scaleW;
		GLYPHWH.x = (float)atof(res.c_str()) / m_lineHeight;
		res = CutDoubleString(buffString, '=', ' ');
		WH.y = (float)atof(res.c_str()) / scaleH;
		GLYPHWH.y = (float)atof(res.c_str()) / m_lineHeight;
		res = CutDoubleString(buffString, '=', ' ');
		OffsetXY.x = (float)atof(res.c_str()) / m_lineHeight;
		res = CutDoubleString(buffString, '=', ' ');
		OffsetXY.y = (float)atof(res.c_str()) / m_lineHeight;
		res = CutDoubleString(buffString, '=', ' ');
		XAdvance = (float)atof(res.c_str()) / m_lineHeight;
		res = CutString(buffString, '\r');
		Character newCharacter(ID, XY, WH,GLYPHWH, OffsetXY, XAdvance);
		m_characters.push_back(newCharacter);
	}	
	return true;
}
Exemplo n.º 17
0
bool CParsingConfig::Run(std::string strFileName)
{
    if(m_pConfigBox == NULL)
    {
        m_eParsingError = PE_NOT_SETTING_CONTAINER;
        return false;
    }

    std::ifstream inFile(strFileName);
    if(!inFile)
    {
        MakeDefaultConfigFile(strFileName);
        inFile.open(strFileName);
        
        if(!inFile.is_open())
        {
            m_eParsingError = PE_INCORRECT_FILE_PATH;
            return false;
        }
    }

    char szLine[500], szName[100], szValue[100], szTemp[100];
    char *pValue;
    int i;

    m_bLoading = true;

    m_nErrorLine = 0;
    while(!inFile.eof())
    {
        if(m_bLoading == false)
        {
            inFile.close();
            m_eParsingError = PE_STOP_BY_USER;
            return false;
        }

        m_nErrorLine++;
        inFile.getline(szLine, 500);

        for(i = 0; i < 500; i++) 
        {
            if(szLine[i] != ' ' && szLine[i] != '\t') break;
        }

        if(szLine[i] == '\n' || szLine[i] == '\0') continue;

        pValue = strtok(szLine, "=");
        if(!pValue) 
        {
            goto ParsingConfigFinish;
        }

        strncpy(szName, pValue, 100);

        pValue = strtok(NULL, "=");
        if(!pValue) 
        {
            goto ParsingConfigFinish;
        }

        while(*pValue != '\n' && *pValue != '\0')
        {
            if(*pValue == '"')
            {
                pValue++;
                if(CutString(pValue, szValue, '"') == false)
                {
                    goto ParsingConfigFinish;
                }
                break;
            }
            pValue++;
        }

        if(*pValue == '\n' || *pValue == '\0')
        {
            goto ParsingConfigFinish;
        }

        if(strstr(szName, NAME_OF_VALUE_COLUMN))
        {
            if(szValue[0] == '\0') m_pConfigBox->nValueCol = 1;
            else if(StringToNumber(szValue, m_pConfigBox->nValueCol) == false)
            {
                goto ParsingConfigFinish;
            }
        }
        else if(strstr(szName, NAME_OF_LEGEND_COLUMN))
        {
            if(szValue[0] == '\0') m_pConfigBox->nLegendCol = 0;
            else if(StringToNumber(szValue, m_pConfigBox->nLegendCol) == false)
            {
                goto ParsingConfigFinish;
            }
        }
        else if(strstr(szName, NAME_OF_X_MAG))
        {
            U32 nXmagLevel;
            if(szValue[0] == '\0') m_pConfigBox->eXmag = ML_1x;
            else if(StringToNumber(szValue, nXmagLevel) == false)
            {
                goto ParsingConfigFinish;
            }
            m_pConfigBox->eXmag = (MAG_LEVEL)nXmagLevel;
        }
        else if(strstr(szName, NAME_OF_Y_MAG))
        {
            U32 nYmagLevel;
            if(szValue[0] == '\0') m_pConfigBox->eYmag = ML_1x;
            else if(StringToNumber(szValue, nYmagLevel) == false)
            {
                goto ParsingConfigFinish;
            }
            m_pConfigBox->eYmag = (MAG_LEVEL)nYmagLevel;
        }
        else if(strstr(szName, NAME_OF_GRAPH_TYPE))
        {
            U32 nGraphType;
            if(szValue[0] == '\0') m_pConfigBox->eGraphType = GT_LINE;
            else if(StringToNumber(szValue, nGraphType) == false)
            {
                goto ParsingConfigFinish;
            }
            m_pConfigBox->eGraphType = (GRAPH_TYPE)nGraphType;
        }
        else if(pValue = strstr(szName, NAME_OF_PARAM))
        {
            // This must be like 'PARAM3_5 = "TestName"'.
            // 3 is parameter number and 5 is the real value of the parameter. 
            // "TestName" is alias of value 5.
            U32 nParamNum, nParamValue;
            pValue += strlen(NAME_OF_PARAM);

            // Get parameter number. 
            if(CutString(pValue, szTemp, '_') == false)
            {
                goto ParsingConfigFinish;
            }

            if(StringToNumber(szTemp, nParamNum) == false)
            {
                goto ParsingConfigFinish;
            }

            if(nParamNum >= MAX_NUM_OF_PARAM)
            {
                goto ParsingConfigFinish;
            }

            while(*pValue != '_') pValue++;
            pValue++;

            if(StringToNumber(pValue, nParamValue) == false)
            {
                goto ParsingConfigFinish;
            }

            m_pConfigBox->mapParamName[nParamNum][nParamValue] = szValue;                     
        }
    }

    m_bLoading = false;
    inFile.close();
    return true;

ParsingConfigFinish:
    m_bLoading = false;
    inFile.close();
    m_eParsingError = PE_LOG_FORMAT_ERROR;
    return false;
}