示例#1
0
void RunOperation(char operation, const std::vector<std::string>& arguments,  MinHeap<T>& heap, std::ostream& file)
{
	if(operation == 'I')
	{
		auto value = ToInt(arguments[1]);
		heap.Insert(value);
	}
	else if(operation == 'D')
	{
		auto value = ToInt(arguments[1]);
		heap.Delete(value);
	}
	else if(operation == 'C')
	{
		auto oldValue = ToInt(arguments[1]);
		auto newValue = ToInt(arguments[2]);
		heap.Change(oldValue, newValue);
	}
	else if(operation == 'P')
	{
		heap.PrintPostOrder(file);
		file << std::endl;
	}

}
示例#2
0
void GD_EXTENSION_API CreateSFMLTexture( RuntimeScene & scene, const std::string & imageName, unsigned int width, unsigned int height, const std::string & colorStr )
{
    //Get or create the texture in memory
    std::shared_ptr<SFMLTextureWrapper> newTexture;
    if ( !scene.GetImageManager()->HasLoadedSFMLTexture(imageName) )
        newTexture = std::shared_ptr<SFMLTextureWrapper>(new SFMLTextureWrapper);
    else
        newTexture = scene.GetImageManager()->GetSFMLTexture(imageName);

    //Get the color
    sf::Color color;
    bool colorIsOk = false;
    std::vector < std::string > colors = SplitString<std::string>(colorStr, ';');
    if ( colors.size() == 3 )
    {
        colorIsOk = true;
        color = sf::Color(ToInt(colors[0]), ToInt(colors[1]), ToInt(colors[2]));
    }

    //Create the SFML image and the SFML texture
    if ( width != 0 && height != 0 && colorIsOk )
        newTexture->image.create(width, height, color);

    newTexture->texture.loadFromImage(newTexture->image); //Do not forget to update the associated texture

    scene.GetImageManager()->SetSFMLTextureAsPermanentlyLoaded(imageName, newTexture); //Otherwise
}
示例#3
0
void SemanticVersion::Parse(const string_t& version) {
  std::vector<string_t> identifiers;
  std::wstring last_one;

  Split(version, L".", identifiers);

  if (identifiers.empty())
    return;

  last_one = identifiers.back();
  identifiers.pop_back();
  Split(last_one, L"-", identifiers);

  last_one = identifiers.back();
  identifiers.pop_back();
  Split(last_one, L"+", identifiers);

  if (identifiers.size() > 0)
    major = ToInt(identifiers.at(0));
  if (identifiers.size() > 1)
    minor = ToInt(identifiers.at(1));
  if (identifiers.size() > 2)
    patch = ToInt(identifiers.at(2));
  if (identifiers.size() > 3)
    prerelease_identifiers = identifiers.at(3);
  if (identifiers.size() > 4)
    build_metadata = identifiers.at(4);
}
示例#4
0
文件: list.cpp 项目: Hydro8182/taiga
int SortAsEpisodeRange(const std::wstring& str1, const std::wstring& str2) {
  auto is_volume = [](const std::wstring& str) {
    return !str.empty() && !IsNumericChar(str.front());
  };
  auto get_last_number_in_range = [](const std::wstring& str) {
    auto pos = InStr(str, L"-");
    return pos > -1 ? ToInt(str.substr(pos + 1)) : ToInt(str);
  };
  auto get_volume = [&](const std::wstring& str) {
    auto pos = InStr(str, L" ");
    return pos > -1 ? get_last_number_in_range(str.substr(pos + 1)) : 0;
  };

  bool is_volume1 = is_volume(str1);
  bool is_volume2 = is_volume(str2);

  if (is_volume1 && is_volume2) {
    return CompareValues<int>(get_volume(str1), get_volume(str2));
  } else if (!is_volume1 && !is_volume2) {
    return CompareValues<int>(get_last_number_in_range(str1),
                              get_last_number_in_range(str2));
  } else {
    return is_volume1 ? base::kLessThan : base::kGreaterThan;
  }
}
void CCEMPatientStatistic::OnSetWindowEvents(){
	CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd();
	//m_wndYear.SetEvent(WE_CHANGE, _OnYearChangeFnc);
	//m_wndYear.SetEvent(WE_SETFOCUS, _OnYearSetfocusFnc);
	//m_wndYear.SetEvent(WE_KILLFOCUS, _OnYearKillfocusFnc);
	m_wndYear.SetEvent(WE_CHECKVALUE, _OnYearCheckValueFnc);
	m_wndReportPeriod.SetEvent(WE_SELENDOK, _OnReportPeriodSelendokFnc);
	//m_wndReportPeriod.SetEvent(WE_SETFOCUS, _OnReportPeriodSetfocusFnc);
	//m_wndReportPeriod.SetEvent(WE_KILLFOCUS, _OnReportPeriodKillfocusFnc);
	m_wndReportPeriod.SetEvent(WE_SELCHANGE, _OnReportPeriodSelectChangeFnc);
	m_wndReportPeriod.SetEvent(WE_LOADDATA, _OnReportPeriodLoadDataFnc);
	//m_wndReportPeriod.SetEvent(WE_ADDNEW, _OnReportPeriodAddNewFnc);
	//m_wndFromDate.SetEvent(WE_CHANGE, _OnFromDateChangeFnc);
	//m_wndFromDate.SetEvent(WE_SETFOCUS, _OnFromDateSetfocusFnc);
	//m_wndFromDate.SetEvent(WE_KILLFOCUS, _OnFromDateKillfocusFnc);
	m_wndFromDate.SetEvent(WE_CHECKVALUE, _OnFromDateCheckValueFnc);
	//m_wndToDate.SetEvent(WE_CHANGE, _OnToDateChangeFnc);
	//m_wndToDate.SetEvent(WE_SETFOCUS, _OnToDateSetfocusFnc);
	//m_wndToDate.SetEvent(WE_KILLFOCUS, _OnToDateKillfocusFnc);
	m_wndToDate.SetEvent(WE_CHECKVALUE, _OnToDateCheckValueFnc);
	m_wndPrintPreview.SetEvent(WE_CLICK, _OnPrintPreviewSelectFnc);
	m_wndExport.SetEvent(WE_CLICK, _OnExportSelectFnc);
	CString szSysDate = pMF->GetSysDate();
	m_nYear = ToInt(szSysDate.Left(4));
	m_szReportPeriodKey.Format(_T("%d"), ToInt(szSysDate.Mid(5, 2)));
	m_szFromDate = m_szToDate = pMF->GetSysDate();
	m_szFromDate += _T("00:00");
	m_szToDate += _T("23:59");
	UpdateData(false);

}
示例#6
0
void GD_API ChangeSceneBackground( RuntimeScene & scene, std::string newColor )
{
    vector < string > colors = SplitString <string> (newColor, ';');
    if ( colors.size() > 2 ) scene.SetBackgroundColor( ToInt(colors[0]), ToInt(colors[1]), ToInt(colors[2]) );

    return;
}
示例#7
0
// * ================================================================================ *
// @ _appserver_initial
// * ================================================================================ *
t_int _appserver_initial()
{
	nsocket_env_init();

	g_appserver.m_iport_shortmsg = ToInt(myconfig["SMSSERVER_PORT"][1]);
	g_appserver.m_sip_shortmsg = myconfig["SMSSERVER_IP"][1];
	g_appserver.m_iresendtimes_shortmsg = ToInt(myconfig["SMSSERVER_RESEND_TIMES"][1]);
	g_appserver.m_iresendtmout_shortmsg = ToInt(myconfig["SMSSERVER_RESEND_INTERVAL"][1]);
	g_appserver.m_imaxsendpersec_shortmsg = ToInt(myconfig["SMSSERVER_MAX_SEND_PER_SECOND"][1]);

	g_appserver.m_sdb_ip = myconfig["DATABASE_IP"][1];
	g_appserver.m_sdb_name = myconfig["DATABASE_NAME"][1];
	g_appserver.m_sdb_uname = myconfig["DATABASE_USER_NAME"][1];
	g_appserver.m_sdb_upwd = myconfig["DATABASE_PASSWD"][1];

	g_appserver.m_suser_shortmsg = myconfig["SMSSERVER_USER"][1];
	g_appserver.m_spwd_shortmsg = myconfig["SMSSERVER_PASS"][1];	//MD5
	
	g_appserver.p_index_terminal.Initial(MAXNUM_REALTEST);
	
	g_appserver.p_buf_smsg_snd = CBasicBuffer::CreateInstance(64*1024);
	g_appserver.p_buf_smsg_rcv = CBasicBuffer::CreateInstance(64*1024);

	appserver_opendb(g_appserver.m_sdb_name.c_str(), g_appserver.m_sdb_ip.c_str(), g_appserver.m_sdb_uname.c_str(), g_appserver.m_sdb_upwd.c_str());
	
	create_db_tables();
	insert_db_default_data();
	
	//appserver_execute("UPDATE BUSSOP SET STATUS='Y', RES_CODE=111 WHERE STATUS='B';");
	//appserver_execute("UPDATE CONFIG_TERMINAL_ROUTINE_CONTENT_EXTRA_PESQ SET EXEC_DATE='19000101';");

	g_appserver.m_runing = 1;
	
	return 0;
}
示例#8
0
bool Params::Load(string FileName){
	int BufferSize = 4096;
	char* theLine = new char[BufferSize];
	ifstream theFile(FileName.c_str());
	if (theFile.fail()) {
		mstrErrorMessage = "Failed to open the description file!";
		return false;
	}

	int nLineCount = 0;
	while (!theFile.eof()) {
		theFile.getline(theLine, BufferSize);
		nLineCount++;
		string theline(theLine);
		string Name(""), Value("");
		theline = trim(theline);
		if (theline.length() && (theline.c_str()[0] != '#'))
		{
			int pos = 0;
			if ((pos = theline.find("=")) != -1) {
				Name = theline.substr(0, pos);
				Value = theline.substr(pos + 1);
			}
			if (Name == "" && Value == "") {
			} else if (Name == "" || Value == "") {
				mstrErrorMessage = "Invalid <Name = Value> pair format";
				cout << theLine << endl;
				return false;
			} else {
				string name = ToLower(Name);
				string value = ToLower(Value);
				if (name == "numberofvariables") {
					mnNumberOfGenes = ToInt(value);
				} else if (name == "traindatafile") {
					mstrTrainDataFile = Value;
				} else if (name == "trainsamplesize") {
					mnTrainSampleSize = ToInt(value);
				} else if (name == "testdatafile") {
					mstrTestDataFile = Value;
				} else if (name == "testsamplesize") {
					mnTestSampleSize = ToInt(value);	
				} else if (name == "maxregressors") {
					mnMaxRegressors = ToInt(value);
				} else if (name == "modelsfile") {
					mstrModelsFile = Value;
				} else if (name == "chainiterations") {
					mnChainIterations = ToInt(value);										
				} else {
					mstrErrorMessage = "Unknown <Name = Value> pair!"; //to be refined later
					cout << theLine << endl;
					return false;
				}
				//cout << theLine << endl;	
			}
		}
	}
	delete[] theLine;
	mstrErrorMessage = "";
	return true;
}
示例#9
0
int main() {
	freopen("1810.in" , "r", stdin );
	freopen("1810.out", "w", stdout);
	
	scanf("%d %d", &n, &m);
	for (int i=0; i<n; i++)
		scanf("%s", nor[i]);
	for (int i=0; i<n; i++)
		scanf("%s", ill[i]);

	power[0] = 1;
	for (int i=1; i<=m; i++)
		power[i] = (power[i-1] * 4) % PRIME1;
	for (int i=0; i<n; i++)
		for (int j=1; j<=m; j++) {
			sum[i][j] = (sum[i][j-1] * 4 + ToInt(nor[i][j-1])) % PRIME1;
			kum[i][j] = (kum[i][j-1] * 4 + ToInt(ill[i][j-1])) % PRIME1;
		}

	int l=0, r=m+1, mid;
	while (l + 1 < r) {
		mid = (l + r) / 2;
		if (TryLen(mid)) r = mid;
		else             l = mid;
	}
	printf("%d\n", r);


	return 0;
}
示例#10
0
episode_number_range_t Episode::episode_number_range() const {
  auto numbers = elements_.get_all(anitomy::kElementEpisodeNumber);
  episode_number_range_t range{
    numbers.empty() ? 0 : ToInt(numbers.front()),
    numbers.empty() ? 0 : ToInt(numbers.back())
  };
  return range;
}
示例#11
0
文件: time.cpp 项目: IamKenshin/taiga
Date::Date(const std::wstring& date)
    : year(0), month(0), day(0) {
  // Convert from YYYY-MM-DD
  if (date.length() >= 10) {
    year = ToInt(date.substr(0, 4));
    month = ToInt(date.substr(5, 2));
    day = ToInt(date.substr(8, 2));
  }
}
示例#12
0
// メモリデバッグメニュー
void MemoryDebugMenu()
{
    char tmp[MAX_SIZE];
    TOKEN_LIST *t;
    char *cmd;
    Print("Mayaqua Kernel Memory Debug Tools\n"
          "Copyright (C) SoftEther Corporation. All Rights Reserved.\n\n");
    g_memcheck = false;
    while (true)
    {
        Print("debug>");
        GetLine(tmp, sizeof(tmp));
        t = ParseToken(tmp, " \t");
        if (t->NumTokens == 0)
        {
            FreeToken(t);
            DebugPrintAllObjects();
            continue;
        }
        cmd = t->Token[0];
        if (!StrCmpi(cmd, "?"))
        {
            DebugPrintCommandList();
        }
        else if (!StrCmpi(cmd, "a"))
        {
            DebugPrintAllObjects();
        }
        else if (!StrCmpi(cmd, "i"))
        {
            if (t->NumTokens == 1)
            {
                Print("Usage: i <obj_id>\n\n");
            }
            else
            {
                DebugPrintObjectInfo(ToInt(t->Token[1]));
            }
        }
        else if (!StrCmpi(cmd, "q"))
        {
            break;
        }
        else if (ToInt(cmd) != 0)
        {
            DebugPrintObjectInfo(ToInt(t->Token[0]));
        }
        else
        {
            Print("Command Not Found,\n\n");
        }
        FreeToken(t);
    }
    FreeToken(t);
    g_memcheck = true;
}
示例#13
0
void RuntimeSpriteObject::SetColor(const std::string & colorStr)
{
    std::vector < std::string > colors = SplitString<std::string>(colorStr, ';');

    if ( colors.size() < 3 ) return; //La couleur est incorrecte

    SetColor(  ToInt(colors[0]),
               ToInt(colors[1]),
               ToInt(colors[2]) );
}
示例#14
0
int MaxPathSum(BinTree r, int &res) {
	if (r == NULL)
		return 0;
	int left = MaxPathSum(r->lchild, res);  //左子树叶节点到根结点最大路径和
	int right = MaxPathSum(r->rchild, res);  //右子树叶节点到根结点最大路径和
	int sum = max(ToInt(r), ToInt(r) + max(left, right)); // sum记录叶节点到根结点的最大路径和
	res = max(res, ToInt(r) + left + right);
	res = max(res, sum);  //最大路径和
	return sum;
}
示例#15
0
BOOL FeedConditionDialog::OnInitDialog() {
  // Set title
  if (condition.element != 0 || condition.op != 0 || !condition.value.empty()) {
    SetText(L"Edit Condition");
  }

  // Initialize
  element_combo_.Attach(GetDlgItem(IDC_COMBO_FEED_ELEMENT));
  operator_combo_.Attach(GetDlgItem(IDC_COMBO_FEED_OPERATOR));
  value_combo_.Attach(GetDlgItem(IDC_COMBO_FEED_VALUE));

  // Add elements
  for (int i = 0; i < FEED_FILTER_ELEMENT_COUNT; i++) {
    element_combo_.AddItem(Aggregator.filter_manager.TranslateElement(i).c_str(), i);
  }
  
  // Set element
  element_combo_.SetCurSel(condition.element);
  ChooseElement(condition.element);
  // Set operator
  operator_combo_.SetCurSel(operator_combo_.FindItemData(condition.op));
  // Set value
  switch (condition.element) {
    case FEED_FILTER_ELEMENT_META_ID: {
      value_combo_.SetCurSel(0);
      for (int i = 0; i < value_combo_.GetCount(); i++) {
        int anime_id = static_cast<int>(value_combo_.GetItemData(i));
        if (anime_id == ToInt(condition.value)) {
          value_combo_.SetCurSel(i);
          break;
        }
      }
      break;
    }
    case FEED_FILTER_ELEMENT_USER_STATUS: {
      int value = ToInt(condition.value);
      if (value == 6) value--;
      value_combo_.SetCurSel(value);
      break;
    }
    case FEED_FILTER_ELEMENT_META_STATUS:
    case FEED_FILTER_ELEMENT_META_TYPE:
      value_combo_.SetCurSel(ToInt(condition.value) - 1);
      break;
    case FEED_FILTER_ELEMENT_LOCAL_EPISODE_AVAILABLE:
      value_combo_.SetCurSel(condition.value == L"True" ? 1 : 0);
      break;
    default:
      value_combo_.SetText(condition.value);
  }

  return TRUE;
}
示例#16
0
/**
 * Apply changes
 */
void EditLink::OnOkBtClick(wxCommandEvent& event)
{
    editedEvent.SetTarget(ToString(linkedNameEdit->GetValue()));
    if ( AllEventsCheck->GetValue() == true )
        editedEvent.SetIncludeAllEvents(true);
    else
    {
        editedEvent.SetIncludeAllEvents(false);
        editedEvent.SetIncludeStartAndEnd(ToInt(ToString(StartEdit->GetValue()))-1, ToInt(ToString(EndEdit->GetValue()))-1);
    }
    EndModal(1);
}
示例#17
0
int main(void)
{
    int re;

    scanf("%d", &re);
    while(re--) {
        scanf("%s%s", a, b);
        printf("%s\n", ToStr(ToInt(a) + ToInt(b)));
    }

    return 0;
}
示例#18
0
BOOL FeedConditionDialog::OnInitDialog() {
  // Set title
  if (condition.element != 0 ||
      condition.op != 0 ||
      !condition.value.empty())
    SetText(L"Edit Condition");

  // Initialize
  element_combo_.Attach(GetDlgItem(IDC_COMBO_FEED_ELEMENT));
  operator_combo_.Attach(GetDlgItem(IDC_COMBO_FEED_OPERATOR));
  value_combo_.Attach(GetDlgItem(IDC_COMBO_FEED_VALUE));

  // Add elements
  for (int i = 0; i < kFeedFilterElement_Count; i++)
    element_combo_.AddItem(Aggregator.filter_manager.TranslateElement(i).c_str(), i);

  // Set element
  element_combo_.SetCurSel(condition.element);
  ChooseElement(condition.element);
  // Set operator
  operator_combo_.SetCurSel(operator_combo_.FindItemData(condition.op));
  // Set value
  switch (condition.element) {
    case kFeedFilterElement_Meta_Id: {
      value_combo_.SetCurSel(0);
      for (int i = 0; i < value_combo_.GetCount(); i++) {
        int anime_id = static_cast<int>(value_combo_.GetItemData(i));
        if (anime_id == ToInt(condition.value)) {
          value_combo_.SetCurSel(i);
          break;
        }
      }
      break;
    }
    case kFeedFilterElement_User_Status: {
      int value = ToInt(condition.value);
      value_combo_.SetCurSel(value);
      break;
    }
    case kFeedFilterElement_Meta_Status:
    case kFeedFilterElement_Meta_Type:
      value_combo_.SetCurSel(ToInt(condition.value) - 1);
      break;
    case kFeedFilterElement_Local_EpisodeAvailable:
      value_combo_.SetCurSel(condition.value == L"True" ? 1 : 0);
      break;
    default:
      value_combo_.SetText(condition.value);
  }

  return TRUE;
}
示例#19
0
bool IndentNode::SetProperty(std::string szProperty, std::string szValue) {
	if (strcmpi(szProperty.c_str(),"Indent")==0) {
		m_nIndent=ToInt(szValue);
		SetChildrenProperty("MinWidth",FromInt(m_nMinWidth-m_nIndent));
		return true;
	}
	if (strcmpi(szProperty.c_str(),"MinWidth")==0) {
		m_nMinWidth=ToInt(szValue);
		SetChildrenProperty(szProperty,FromInt(m_nMinWidth-m_nIndent));
		return true;
	}
	return SettingNode::SetProperty(szProperty,szValue);
}
示例#20
0
void CEMQtyAtExam::OnSetWindowEvents(){
	CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd();
	//m_wndYear.SetEvent(WE_CHANGE, _OnYearChangeFnc);
	//m_wndYear.SetEvent(WE_SETFOCUS, _OnYearSetfocusFnc);
	//m_wndYear.SetEvent(WE_KILLFOCUS, _OnYearKillfocusFnc);
	m_wndYear.SetEvent(WE_CHECKVALUE, _OnYearCheckValueFnc);
	m_wndReportPeriod.SetEvent(WE_SELENDOK, _OnReportPeriodSelendokFnc);
	//m_wndReportPeriod.SetEvent(WE_SETFOCUS, _OnReportPeriodSetfocusFnc);
	//m_wndReportPeriod.SetEvent(WE_KILLFOCUS, _OnReportPeriodKillfocusFnc);
	m_wndReportPeriod.SetEvent(WE_SELCHANGE, _OnReportPeriodSelectChangeFnc);
	m_wndReportPeriod.SetEvent(WE_LOADDATA, _OnReportPeriodLoadDataFnc);
	//m_wndReportPeriod.SetEvent(WE_ADDNEW, _OnReportPeriodAddNewFnc);
	//m_wndFromDate.SetEvent(WE_CHANGE, _OnFromDateChangeFnc);
	//m_wndFromDate.SetEvent(WE_SETFOCUS, _OnFromDateSetfocusFnc);
	//m_wndFromDate.SetEvent(WE_KILLFOCUS, _OnFromDateKillfocusFnc);
	m_wndFromDate.SetEvent(WE_CHECKVALUE, _OnFromDateCheckValueFnc);
	//m_wndToDate.SetEvent(WE_CHANGE, _OnToDateChangeFnc);
	//m_wndToDate.SetEvent(WE_SETFOCUS, _OnToDateSetfocusFnc);
	//m_wndToDate.SetEvent(WE_KILLFOCUS, _OnToDateKillfocusFnc);
	m_wndToDate.SetEvent(WE_CHECKVALUE, _OnToDateCheckValueFnc);
	m_wndRoom.SetEvent(WE_SELENDOK, _OnRoomSelendokFnc);
	//m_wndRoom.SetEvent(WE_SETFOCUS, _OnRoomSetfocusFnc);
	//m_wndRoom.SetEvent(WE_KILLFOCUS, _OnRoomKillfocusFnc);
	m_wndRoom.SetEvent(WE_SELCHANGE, _OnRoomSelectChangeFnc);
	m_wndRoom.SetEvent(WE_LOADDATA, _OnRoomLoadDataFnc);
	//m_wndRoom.SetEvent(WE_ADDNEW, _OnRoomAddNewFnc);
	m_wndDoctor.SetEvent(WE_SELENDOK, _OnDoctorSelendokFnc);
	//m_wndDoctor.SetEvent(WE_SETFOCUS, _OnDoctorSetfocusFnc);
	//m_wndDoctor.SetEvent(WE_KILLFOCUS, _OnDoctorKillfocusFnc);
	m_wndDoctor.SetEvent(WE_SELCHANGE, _OnDoctorSelectChangeFnc);
	m_wndDoctor.SetEvent(WE_LOADDATA, _OnDoctorLoadDataFnc);
	//m_wndDoctor.SetEvent(WE_ADDNEW, _OnDoctorAddNewFnc);
	m_wndPrint.SetEvent(WE_CLICK, _OnPrintSelectFnc);
	m_wndExport.SetEvent(WE_CLICK, _OnExportSelectFnc);
	/*AddEvent(1, _T("Add	Ctrl+A"), _OnAddEMQtyAtExamFnc, 0, 'A', VK_CONTROL);
	AddEvent(2, _T("Edit	Ctrl+E"), _OnEditEMQtyAtExamFnc, 0, 'E', VK_CONTROL);
	AddEvent(3, _T("Delete	Ctrl+D"), _OnDeleteEMQtyAtExamFnc, 0, 'D', VK_CONTROL);
	AddEvent(4, _T("Save	Ctrl+S"), _OnSaveEMQtyAtExamFnc, 0, 'S', VK_CONTROL);
	AddEvent(0, _T("-"));
	AddEvent(5, _T("Cancel	Ctrl+T"), _OnCancelEMQtyAtExamFnc, 0, 'T', VK_CONTROL);*/
//	SetMode(VM_NONE);
	CString szSysDate = pMF->GetSysDate();
	m_nYear = ToInt(szSysDate.Left(4));
	m_szReportPeriodKey.Format(_T("%d"), ToInt(szSysDate.Mid(5, 2)));
	m_szFromDate = m_szToDate = pMF->GetSysDate();
	m_szFromDate += _T("00:00");
	m_szToDate += _T("23:59");
	UpdateData(false);
	SetMode(VM_EDIT);
	
}
示例#21
0
文件: time.cpp 项目: IamKenshin/taiga
time_t ConvertIso8601(const std::wstring& datetime) {
  // e.g.
  // "2015-02-20T04:43:50"
  // "2015-02-20T04:43:50.016Z"
  // "2015-02-20T06:43:50.016+02:00"
  static const std::wregex pattern(
      L"(\\d{4})-(\\d{2})-(\\d{2})"
      L"T(\\d{2}):(\\d{2}):(\\d{2})(?:[.,]\\d+)?"
      L"(?:(?:([+-])(\\d{2}):(\\d{2}))|Z)?");

  std::match_results<std::wstring::const_iterator> m;
  time_t result = -1;

  if (std::regex_match(datetime, m, pattern)) {
    tm t = {0};
    t.tm_year = ToInt(m[1].str()) - 1900;
    t.tm_mon = ToInt(m[2].str()) - 1;
    t.tm_mday = ToInt(m[3].str());
    t.tm_hour = ToInt(m[4].str());
    t.tm_min = ToInt(m[5].str());
    t.tm_sec = ToInt(m[6].str());

    if (m[7].matched) {
      int sign = m[7].str() == L"+" ? 1 : -1;
      t.tm_hour += sign * ToInt(m[8].str());
      t.tm_min += sign * ToInt(m[9].str());
    }
    NeutralizeTimezone(t);
    t.tm_isdst = -1;

    result = std::mktime(&t);
  }

  return result;
}
示例#22
0
void RuntimeSpriteObject::MakeColorTransparent( const std::string & colorStr )
{
    if ( needUpdateCurrentSprite ) UpdateCurrentSprite();

    ptrToCurrentSprite->MakeSpriteOwnsItsImage(); //We want to modify only the image of the object, not all objects which have the same image.
    boost::shared_ptr<SFMLTextureWrapper> dest = ptrToCurrentSprite->GetSFMLTexture();

    std::vector < std::string > colors = SplitString <std::string> (colorStr, ';');

    if ( colors.size() < 3 ) return; //La couleur est incorrecte

    //Update texture and pixel perfect collision mask
    dest->image.createMaskFromColor(  sf::Color( ToInt(colors[0]), ToInt(colors[1]), ToInt(colors[2])));
    dest->texture.loadFromImage(dest->image);
}
示例#23
0
    DWriteRenderingParams *
DWriteContext::GetRenderingParams(
	DWriteRenderingParams *params)
{
    if (params != NULL && mRenderingParams != NULL)
    {
	params->gamma = mRenderingParams->GetGamma();
	params->enhancedContrast = mRenderingParams->GetEnhancedContrast();
	params->clearTypeLevel = mRenderingParams->GetClearTypeLevel();
	params->pixelGeometry = ToInt(mRenderingParams->GetPixelGeometry());
	params->renderingMode = ToInt(mRenderingParams->GetRenderingMode());
	params->textAntialiasMode = mTextAntialiasMode;
    }
    return params;
}
示例#24
0
int FColorCVar::ToInt2 (UCVarValue value, ECVarType type)
{
	int ret;

	if (type == CVAR_String)
	{
		FString string;
		// Only allow named colors after the screen exists (i.e. after
		// we've got some lumps loaded, so X11R6RGB can be read). Since
		// the only time this might be called before that is when loading
		// zdoom.ini, this shouldn't be a problem.
		if (screen && !(string = V_GetColorStringByName (value.String)).IsEmpty() )
		{
			ret = V_GetColorFromString (NULL, string);
		}
		else
		{
			ret = V_GetColorFromString (NULL, value.String);
		}
	}
	else
	{
		ret = ToInt (value, type);
	}
	return ret;
}
示例#25
0
void FMaskCVar::DoSet (UCVarValue value, ECVarType type)
{
	int val = ToInt(value, type) << BitNum;

	// Server cvars that get changed by this need to use a special message, because
	// changes are not processed until the next net update. This is a problem with
	// exec scripts because all flags will base their changes off of the value of
	// the "master" cvar at the time the script was run, overriding any changes
	// another flag might have made to the same cvar earlier in the script.
	if ((ValueVar.GetFlags() & CVAR_SERVERINFO) && gamestate != GS_STARTUP && !demoplayback)
	{
		// [BB] netgame && !players[consoleplayer].settings_controller -> NETWORK_InClientMode( )
		if ( NETWORK_InClientMode( ) )
		{
			Printf ("Only setting controllers can change %s\n", Name);
			return;
		}
		// Ugh...
		for(int i = 0; i < 32; i++)
		{
			if (BitVal & (1<<i))
			{
				D_SendServerFlagChange (&ValueVar, i, !!(val & (1<<i)));
			}
		}
	}
	else
	{
		int vval = *ValueVar;
		vval &= ~BitVal;
		vval |= val;
		ValueVar = vval;
	}
}
示例#26
0
// WinMain function
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, char *CmdLine, int CmdShow)
{
	INSTANCE *instance;
	is_debug = false;
	MayaquaMinimalMode();
	InitMayaqua(false, is_debug, 0, NULL);
	InitCedar();
	ViSetSkip();
	ViLoadStringTables();
	InitWinUi(_U(IDS_TITLE+skip), _A(IDS_FONT+skip), ToInt(_A(IDS_FONT_SIZE+skip)));
	instance = NewSingleInstance(VI_INSTANCE_NAME);
	if (instance == NULL)
	{
		MsgBox(NULL, MB_ICONINFORMATION, _U(IDS_INSTANCE_EXISTS+skip));
	}
	else
	{
		ViMain();
		FreeSingleInstance(instance);
		if (sleep_before_exit)
		{
			SleepThread(60 * 1000);
		}
	}
	FreeWinUi();
	ViFreeStringTables();
	FreeCedar();
	FreeMayaqua();
	return 0;
}
示例#27
0
bool PListFile::LoadValue(PListValue& value, const XMLElement& valueElem)
{
    String valueType = valueElem.GetName();

    if (valueType == "string")
        value.SetString(valueElem.GetValue());
    else if (valueType == "real")
        value.SetFloat(ToFloat(valueElem.GetValue()));
    else if (valueType == "integer")
        value.SetInt(ToInt(valueElem.GetValue()));
    else if (valueType == "true")
        value.SetBool(true);
    else if (valueType == "false")
        value.SetBool(false);
    else if (valueType == "dict")
    {
        if (!LoadDict(value.ConvertToValueMap(), valueElem))
            return false;
    }
    else if (valueType == "array")
    {
        if (!LoadArray(value.ConvertToValueVector(), valueElem))
            return false;
    }
    else
    {
        URHO3D_LOGERROR("Supported value type");
        return false;
    }

    return true;
}
示例#28
0
文件: XXVar.cpp 项目: hgl888/nashtest
void XXVar::ToIntIf()
{
	if(nType!=XODT_FLOAT) return;
	int v=(int)fData;
	if(v==fData)
		ToInt();
}
示例#29
0
// Convert the string to an integer list
LIST *StrToIntList(char *str, bool sorted)
{
	LIST *o;
	TOKEN_LIST *t;

	o = NewIntList(sorted);

	t = ParseTokenWithoutNullStr(str, " ,/;\t");

	if (t != NULL)
	{
		UINT i;

		for (i = 0;i < t->NumTokens;i++)
		{
			char *s = t->Token[i];

			if (IsEmptyStr(s) == false)
			{
				if (IsNum(s))
				{
					InsertIntDistinct(o, ToInt(s));
				}
			}
		}

		FreeToken(t);
	}

	return o;
}
示例#30
0
// Extract the build number from the version string
UINT ViVersionStrToBuild(char *str)
{
	TOKEN_LIST *t;
	UINT ret;
	// Validate arguments
	if (str == NULL)
	{
		return 0;
	}

	t = ParseToken(str, ".");
	if (t == NULL)
	{
		return 0;
	}

	ret = 0;

	if (t->NumTokens == 3)
	{
		ret = ToInt(t->Token[2]);
	}

	FreeToken(t);

	return ret;
}