Example #1
0
bool DateTime::FromSQLDateTime(const uistring& sqlDate)
{
    // match YYYY-MM-DD HH:MM:SS
    // HH:MM:SS is optional
    boost::wcmatch matches;
    boost::wregex e(_T("(\\d{4})-(\\d{2})-(\\d{2})(?: (\\d{2}):(\\d{2}):(\\d{2}))?"));

    if(boost::regex_match(sqlDate.c_str(), matches, e))
    {
        for(unsigned int i = 1; i <= 6; i++)
        {
            int c;
            if(matches[i].matched)
            {
                std::string match(matches[i].first, matches[i].second);
                std::stringstream mstream(match);
                mstream >> c;
            }
            else
            {
                c = 0;
            }

            switch(i)
            {
            case 1: this->curDateTime.wYear   = c; break;
            case 2: this->curDateTime.wMonth  = c; break;
            case 3: this->curDateTime.wDay    = c; break;
            case 4: this->curDateTime.wHour   = c; break;
            case 5: this->curDateTime.wMinute = c; break;
            case 6: this->curDateTime.wSecond = c; break;
            }
        }
Example #2
0
BOOL Config::SetValue(const uistring &key, const uistring &value)
{
    // check if section name is empty
    if(this->currentSection.empty())
        throw Exception("Please provide a section!");

    // write value to ini file
    BOOL ret = ::WritePrivateProfileString(
        this->currentSection.c_str(),
        key.c_str(),
        value.c_str(),
        this->iniFileName.c_str());

    // throw an exception if call was invalid
    if(!ret)
        throw Win32Exception();

    return ret;
}
Example #3
0
BOOL Config::SectionExists(const uistring& section)
{
    DWORD bufferLen = 255, retLen;
    std::unique_ptr<TCHAR> buffer(new TCHAR[bufferLen]);

    // get section keys
    retLen = ::GetPrivateProfileSection(
        section.c_str(),
        buffer.get(),
        bufferLen,
        this->iniFileName.c_str());

    return (retLen > 0);
}
Example #4
0
uistring Config::Value(const uistring &key)
{
    uistring value;
    DWORD bufferLen = 255, retLen;
    std::unique_ptr<TCHAR> buffer(new TCHAR[bufferLen]);

    // get value
    retLen = ::GetPrivateProfileString(
        this->currentSection.c_str(),
        key.c_str(),
        NULL,
        buffer.get(),
        bufferLen,
        this->iniFileName.c_str());

    // if size exceeds the limit, realloc and read again
    while(retLen == bufferLen-1)
    {
        bufferLen += bufferLen;
        buffer.reset(new TCHAR[bufferLen]);

        retLen = ::GetPrivateProfileString(
            this->currentSection.c_str(),
            key.c_str(),
            NULL,
            buffer.get(),
            bufferLen,
            this->iniFileName.c_str());
    }

    if (retLen)
    {
        value = uistring(buffer.get());
    }

    return value;
}
Example #5
0
///\brief SetTooltip
///Sets the tooltip text for the edit control.
///\param text
///The tooltip text to set
void        EditView::SetTooltip(uistring text)
{
    Edit_SetCueBannerText(this->Handle(), text.c_str());
    //Edit_SetCueBannerTextFocused(this->headerHandle, text.c_str(), true);
    //The second one is vista only
}