Пример #1
0
void utils::attributes_stack::attr_push_style( format::attributes::style::types type, int style_id )
{
	style tmp;
		tmp.id = style_id;
		tmp.type = type;
	styles_collection::const_iterator it = styles.find( tmp );
	if( it == styles.end() )
		return;

	const style & ref = (*it);
	if ( ref.bold == 1 )
		attr_push( ATTR_BOLD, 0);
	else if( ref.bold == 0 )
		attr_pop( ATTR_BOLD );

	if ( ref.italic == 1 )
		attr_push( ATTR_ITALIC, 0);
	else if( ref.italic == 0 )
		attr_pop( ATTR_ITALIC );

	if( ref.font.face >= 0 )
		attr_push( ATTR_FONTFACE, ref.font.face );

	if( ref.font.size >= 0 )
		attr_push( ATTR_FONTSIZE, ref.font.size );
}
Пример #2
0
int soap::ctx::parse(const char* buf,int len)
{
    for(int i=0;i<len && !err;i++)
    {
        unsigned char ch=((unsigned char*)buf)[i];

        int cht=types[ch];

        if(ch=='\n')
            line++;

        switch(st)
        {
        case 0:
            if(ch=='<')
            {
                st=10;
                data_push();
                tok_reset();
                st_text=0;
            }else
            {
                switch(st_text)
                {
                case 0:
#ifndef NO_TRIM_DATA
                    if(cht==cht_sp) continue;
#endif
                    st_text=10;
                case 10:
                    if(ch=='&') { tok_add(ch); st_text=20; } else ch_push(ch);
                    break;
                case 20:
                    tok_add(ch);
                    if(ch==';')
                    {
                        tok[tok_size]=0;

                        if(!strcmp(tok,"&lt;")) ch_push('<');
                        else if(!strcmp(tok,"&gt;")) ch_push('>');
                        else if(!strcmp(tok,"&apos;")) ch_push('\'');
                        else if(!strcmp(tok,"&quot;")) ch_push('\"');
                        else if(!strcmp(tok,"&amp;")) ch_push('&');
                        tok_reset();
                        st_text=10;
                    }
                    break;
                }
            }
            break;
        case 10:
            if(ch=='/')
            {
                st=20;
                st_close_tag=1;
                continue;
            }else if(ch=='?')
            {
                st=50;
                continue;
            }else if(ch=='!')
            {
                st=60;
                continue;
            }
            st=11;
        case 11:
            if(cht!=cht_sp)
            {
                if(cht==cht_al)
                {
                    tok_add(ch);
                    st=20;
                }else
                    err=1;
            }
            break;
        case 20:
            if(cht==cht_sp) continue; st=21;
        case 21:
            if(ch==':')
                tok_reset();
            else if(cht==cht_sp)
            {
                tok_push();
                st=30;
            }else if(cht&(cht_al|cht_num) || ch=='_' || ch=='-')
                tok_add(ch);
            else if(ch=='/')
                st=40;
            else if(ch=='>')
                tok_push();
            else
                err=1;
            break;
        case 30:
            if(ch==' ')
                continue;
            st=31;
        case 31:
            if(st_quot)
            {
                if(ch=='\"')
                    st_quot=0;
            }else
            {
                if(ch=='\"')
                    st_quot=1;
                else if(ch=='/')
                    { st=40; attr_push(); }
                else if(ch=='>')
                    { st=0; attr_push(); }
            }

            if(attributes && st==31) ch_push(ch);

            break;
        case 40:
            if(ch!='>') err=1; else tok_push();
            break;
        case 50:
            if(ch=='?') st=55;
            break;
        case 55:
            if(ch=='>') st=0; else if(ch!='?') st=50;
            break;
        case 60:
            if(ch=='-') st=61; else if(ch=='[') st=100; else err=1;
            break;
        case 61:
            if(ch=='-') st=62; else err=1;
            break;
        case 62:
            if(ch=='-') st=63;
            break;
        case 63:
            if(ch=='-') st=64; else st=62;
            break;
        case 64:
            if(ch=='>')
                st=0;
            else if(ch!='-')
                st=62;
            break;
        case 100: if(ch=='C') st++; else err=1; break;
        case 101: if(ch=='D') st++; else err=1; break;
        case 102: if(ch=='A') st++; else err=1; break;
        case 103: if(ch=='T') st++; else err=1; break;
        case 104: if(ch=='A') st++; else err=1; break;
        case 105: if(ch=='[') st++; else err=1; break;
        case 106: if(ch==']') st=107; else ch_push(ch); break;
        case 107: if(ch==']') st=108; else { ch_push(']'); ch_push(ch); st=106; } break;
        case 108:
            if(ch=='>')
                { st=0; data_push(); }
            else if(ch==']')
                { ch_push(ch); }
            else
                { ch_push(']'); ch_push(']'); ch_push(ch); st=106; }
            break;
        }
    }

    return err;
}