コード例 #1
0
//---------------------------------------------------------------------------
void MediaInfo_Config_MediaInfo::File_Curl_Set (const Ztring &NewValue)
{
    size_t Pos=NewValue.find(_T(','));
    if (Pos==string::npos)
        Pos=NewValue.find(_T(';'));
    if (Pos!=string::npos)
    {
        Ztring Field=NewValue.substr(0, Pos); Field.MakeLowerCase();
        Ztring Value=NewValue.substr(Pos+1, string::npos);
        CriticalSectionLocker CSL(CS);
        Curl[Field]=Value;
    }
}
コード例 #2
0
ファイル: Translation.cpp プロジェクト: johnkg/mpc-hc
//---------------------------------------------------------------------------
// Set
void Translation::Write(const Ztring &NewLanguage)
{
    clear();

    if (!&NewLanguage || !NewLanguage.size())
        return;

    size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0;

    while (Pos2_EOL!=(size_t)-1)
    {
        Pos2_EOL=NewLanguage.find(__T('\n'), Pos1);
        Pos2_Separator=NewLanguage.find(__T(';'), Pos1);
        if (Pos2_Separator<Pos2_EOL)
        {
            operator[](NewLanguage.substr(Pos1, Pos2_Separator-Pos1))=NewLanguage.substr(Pos2_Separator+1, Pos2_EOL-Pos2_Separator-1);
        }
        Pos1=Pos2_EOL+1;
    }
}
コード例 #3
0
ファイル: InfoMap.cpp プロジェクト: 0vermind/NeoLoader
//---------------------------------------------------------------------------
// Set
void InfoMap::Write(const Ztring &NewInfoMap)
{
    clear();

    if (NewInfoMap.empty())
        return;

    size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0;

    while (Pos2_EOL!=(size_t)-1)
    {
        Pos2_EOL=NewInfoMap.find(__T('\n'), Pos1);
        Pos2_Separator=NewInfoMap.find(__T(';'), Pos1);
        if (Pos2_Separator<Pos2_EOL)
        {
            ZtringList List; List.Write(NewInfoMap.substr(Pos1, Pos2_EOL-Pos1));
            insert (pair<Ztring, ZtringList>(NewInfoMap.substr(Pos1, Pos2_Separator-Pos1), List));
        }
        Pos1=Pos2_EOL+1;
    }
}
コード例 #4
0
ファイル: ZtringList.cpp プロジェクト: 3F/FlightSDCpp
//---------------------------------------------------------------------------
// Write
void ZtringList::Write(const Ztring &ToWrite)
{
    clear();

    if (ToWrite.empty())
        return;

    size_type PosC=0;
    bool Fini=false;
    Ztring C1;

    Ztring DelimiterL;
    Ztring DelimiterR;
    do
    {
        //Searching quotes
        if (ToWrite[PosC]==Quote[0])
        {
            size_t Pos_End=PosC+1;
            while (Pos_End<ToWrite.size())
            {
                if (ToWrite[Pos_End]==Quote[0] && Pos_End+1<ToWrite.size() && ToWrite[Pos_End+1]==Quote[0])
                    Pos_End+=2; //Double quote, skipping
                else
                {
                    if (ToWrite[Pos_End]==Quote[0])
                        break;
                    Pos_End++;
                }
            }
            C1=ToWrite.substr(PosC+Quote.size(), Pos_End-PosC);
            PosC+=C1.size()+Quote.size();
            if (C1.size()>0 && C1[C1.size()-1]==Quote[0])
            {
                C1.resize(C1.size()-1);
                PosC+=Quote.size();
            }
        }
        else //Normal
        {
            C1=ToWrite.SubString(tstring(), Separator[0], PosC, Ztring_AddLastItem);
            PosC+=C1.size()+Separator[0].size();
        }
        C1.FindAndReplace(Quote+Quote, Quote, 0, Ztring_Recursive);
        if (size()<Max[0])
            push_back(C1);
        if (PosC>=ToWrite.size())
            Fini=true;
    }
    while (!Fini);

    return;
}
コード例 #5
0
//---------------------------------------------------------------------------
void File__Duplicate__Writer::Configure (const Ztring &Target)
{
    //Form: "memory://pointer:size"  <--Memory block is specified by user
    //WARNING: pointer must be in ***DECIMAL*** format.
    //Example: "memory://123456789:1316"
    if (Target.find(__T("memory://"))==0 && Target.find(__T(":"), 9)!=std::string::npos)
    {
        size_t SemiColumn_Pos=Target.find(__T(":"), 9);
        Ztring Address=Target.substr(9, SemiColumn_Pos-9);
        Ztring Size=Target.substr(SemiColumn_Pos+1);
        Method=method_buffer;
        Buffer=(int8u*)Address.To_int64u();
        Buffer_Size_Max=(size_t)Size.To_int64u();
    }

    //Form: "file://filename" or     <--the exported filename is specified by user
    else if (Target.find(__T("file://"))==0)
    {
        Method=method_filename;
        File_Name=Target.substr(7, std::string::npos);
    }
}
コード例 #6
0
//---------------------------------------------------------------------------
// Nettoyage
bool ZtringListListF::NettoyerEspaces (Ztring &ANettoyer)
{
    size_t Debut=0;
    while (Debut<ANettoyer.size() && ANettoyer[Debut]==__T(' '))
        Debut++;
    size_t Fin=ANettoyer.size()-1;
    while (Fin!=(size_t)-2 && ANettoyer[Fin]==__T(' '))
        Fin--;
    if (Fin>=Debut)
        ANettoyer=ANettoyer.substr(Debut, Fin-Debut+1);
    else
        ANettoyer=Ztring();
    return true;
}
コード例 #7
0
ファイル: ZtringList.cpp プロジェクト: aidv/scripts
//---------------------------------------------------------------------------
// Write
void ZtringList::Write(const Ztring &ToWrite)
{
    clear();

    if (!&ToWrite || !ToWrite.size())
        return;

    size_type PosC=0;
    bool Fini=false;
    Ztring C1;

    Ztring DelimiterL;
    Ztring DelimiterR;
    do
    {
        if (ToWrite.size()>PosC && Quote.size()>0 && ToWrite[PosC]==Quote[0] && ToWrite.substr(PosC, Quote.size())==Quote) //Quote found (ToWrite[PosC]==Quote[0] is here for optimization
        {
            DelimiterL=Quote;
            DelimiterR=Quote+Separator[0];
        }
        else
        {
            DelimiterL.clear();
            DelimiterR=Separator[0];
        }

        C1=ToWrite.SubString(DelimiterL, DelimiterR, PosC, Ztring_AddLastItem);
        if (DelimiterR.size()>Separator[0].size() && C1.size()==ToWrite.size()-Quote.size()-PosC) //This is the last item of the line, we must suppress the Quote at the end
            C1.resize(C1.size()-Quote.size());

        if (size()<Max[0])
            push_back(C1);
        else
        {
            //No more adding is permit, we add to the last element (with the separator)
            at(size()-1)+=Separator[0];
            at(size()-1)+=C1;
        }

        PosC+=C1.size()+DelimiterL.size()+DelimiterR.size();
        if (PosC>=ToWrite.size())
            Fini=true;
    }
    while (!Fini);

    return;
}
コード例 #8
0
//---------------------------------------------------------------------------
// Write
void ZtringListList::Write(const Ztring &ToWrite)
{
    clear();

    if (ToWrite.empty())
        return;

    size_type PosC=0;
    bool Fini=false;
    Ztring C1;
    ZtringList ZL1;
    ZL1.Separator_Set(0, Separator[1]);
    ZL1.Quote_Set(Quote);
    ZL1.Max_Set(0, Max[1]);

    //Detecting carriage return format
    Ztring WriteSeparator;
    if (Separator[0]==EOL)
    {
        size_t CarriageReturn_Pos=ToWrite.find_first_of(__T("\r\n"));
        if (CarriageReturn_Pos!=string::npos)
        {
            if (ToWrite[CarriageReturn_Pos]==__T('\r'))
            {
                if (CarriageReturn_Pos+1<ToWrite.size() && ToWrite[CarriageReturn_Pos+1]==__T('\n'))
                    WriteSeparator=__T("\r\n");
                else
                    WriteSeparator=__T("\r");
            }
            else
                WriteSeparator=__T("\n");
        }
        else
            WriteSeparator=Separator[0];
    }
    else
        WriteSeparator=Separator[0];

    do
    {
        //Searching end of line, but it must not be in quotes
        bool InQuotes=false;
        Ztring CharsToFind=WriteSeparator+Quote;
        size_t Pos_End=PosC;
        while (Pos_End<ToWrite.size())
        {
            Pos_End=ToWrite.find(WriteSeparator, Pos_End);
            if (Pos_End!=string::npos)
            {
                if (Pos_End+Quote.size()<ToWrite.size() && ToWrite[Pos_End]==Quote[0] && ToWrite[Pos_End+1]!=Quote[0])
                {
                    InQuotes=!InQuotes; //This is not double quotes, so this is a normal quote
                    /*if (!InQuotes)
                    {
                        C1=ToWrite.substr(PosC, Pos_End-PosC);
                        break;
                    }*/
                }

                if (!InQuotes && Pos_End+WriteSeparator.size()<=ToWrite.size() && ToWrite[Pos_End]==WriteSeparator[0])
                {
                    C1=ToWrite.substr(PosC, Pos_End-PosC);
                    break;
                }

                if (InQuotes && Pos_End+Quote.size()*2<ToWrite.size() && ToWrite[Pos_End]==Quote[0] && ToWrite[Pos_End+1]==Quote[0])
                    Pos_End+=2;
                else
                    Pos_End++;
            }
        }
        if (Pos_End>=ToWrite.size())
            C1=ToWrite.substr(PosC, string::npos);

        ZL1.Write(C1);
        push_back(ZL1);
        PosC+=C1.size()+WriteSeparator.size();
        if (PosC>=ToWrite.size())
            Fini=true;
    }
    while (!Fini);
}