当前位置: 首页>>代码示例>>C++>>正文


C++ SPString::m方法代码示例

本文整理汇总了C++中SPString::m方法的典型用法代码示例。如果您正苦于以下问题:C++ SPString::m方法的具体用法?C++ SPString::m怎么用?C++ SPString::m使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPString的用法示例。


在下文中一共展示了SPString::m方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
char c, *infn;
ifstream ini("\\win3\\win.ini");
ofstream fout("t.sty");
int ln= 0;
SPString w;
SPStringList l;
SPStringList ttfonts;
Assoc<SPString> repfnts("", "");  // saves font replacement names

    if(argc < 2) infn= "test.sty";
    else infn= argv[1];

    ifstream fin(infn);

    if(!ini){
        cerr << "Can't open \\win3\\win.ini" << endl;
        exit(1);
    }

    if(!fin){
        cerr << "Can't open " << infn << endl;
        exit(1);
    }

    if(!fout){
        cerr << "Can't open t.sty for write" << endl;
        exit(1);
    }

    cout << "Reading in truetype fonts" << endl;

    while(ini >> w){ // find the [fonts] section
        if(w.m("\\[fonts\\]")) break;
    }

//    cout << buf << endl;

    if(!ini.good()){ // checks all file state
        cerr << "Couldn't find [fonts] section in win.ini" << endl;
        exit(1);
    }

    // make a list of truetype fonts
    Regexp r1("^([a-zA-Z ]+) \\(([a-zA-Z ]+)\\)=");
    Regexp r2("^TrueType$");
    Regexp r3("\\[.*\\]");

    while(ini >> w){
        if(w.m(r3)) break; // found the start of another section
        if(w.m(r1, l) != 3) continue; // ignore this line
//        cout << "Font match:" << l[1] << ", " << l[2] << endl;
        if(l[2].m(r2)){
            ttfonts.push(l[1]);
        } 
    }

    cout << "ttfonts: " << endl << ttfonts << endl;
    ini.close();

    cout << "Looking for non-truetype fonts" << endl;

    SPString s, fnt, newfnt;
    SPStringList sl;
    while(fin >> s){
        ln++;
//      cout << "line " << ln << ": <" << s << ">" << endl;
        if(s.m("\\[fnt\\]")){
            fout << s << endl; // write out [fnt] line
                               // read next line which should have font in it
            if(!(fin >> s)){
                cerr << "Error reading font line " << ln << endl;
                exit(1);
            }
            ln++;
            fnt= s.split("' '").join(" "); // This trims whitespace
//          cout << "font name: <" << fnt << ">" << endl;
            if(!ttfonts.grep("^" + fnt + "$", "i")){ // not a truetype font
                int pos= s.index(fnt); // get position in string of font
                if(pos < 0){
                    cerr << "Couldn't find <" << fnt << "> in string <" << s << "> line " << ln << endl;
                    exit(1);
                }

                // See if we already know what to exchange it with
                if(repfnts.isin(fnt)) // just replace it
                    s.substr(pos, strlen(fnt)) = repfnts(fnt);
                else{ // need to ask what the new font name will be
                    do{
                        cout << "Replace font <" << fnt << "> with:"; cout.flush();
                        cin >> newfnt;
                        if(!(sl=ttfonts.grep("^" + newfnt + "$", "i"))){
                            cerr << "<" << newfnt << "> is not a valid font" << endl;
                            continue;
                        }
                    break;
                    }while(1);
                    s.substr(pos, strlen(fnt)) = sl[0]; // replace it
                    repfnts(fnt) = sl[0];  // remember for next time
//.........这里部分代码省略.........
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:101,代码来源:chgfnt.c


注:本文中的SPString::m方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。