Annotation of parser3/src/types/pa_vstring.C, revision 1.29

1.1       paf         1: /** @file
1.5       paf         2:        Parser: @b string class.
1.1       paf         3: 
1.28      moko        4:        Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com)
1.16      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.20      paf         6: */
1.1       paf         7: 
                      8: #include "pa_vstring.h"
                      9: #include "pa_vfile.h"
                     10: 
1.29    ! moko       11: volatile const char * IDENT_PA_VSTRING_C="$Id: pa_vstring.C,v 1.28 2012-03-16 09:24:19 moko Exp $" IDENT_PA_VSTRING_H;
1.28      moko       12: 
1.23      paf        13: VFile* VString::as_vfile(String::Language lang, const Request_charsets* charsets) {
                     14:        VFile& result=*new VFile;
1.27      misha      15:        String::Body sbody=fstring->cstr_to_string_body_untaint(lang, 0, charsets);
                     16:        result.set(false/*not tainted*/, sbody.cstr(), sbody.length());
1.1       paf        17:        return &result;
1.8       parser     18: }
1.29    ! moko       19: 
        !            20: void VString::serialize(Serialization_data &data){
        !            21:        if(!is_defined()){
        !            22:                data = Serialization_data(SERIALIZED_STRING);
        !            23:                return;
        !            24:        }
        !            25:        
        !            26:        if (string().is_not_just_lang()){
        !            27:                String::Cm cm = string().serialize(0);
        !            28:                data = Serialization_data(SERIALIZED_STRING, cm.str, cm.length);
        !            29:        } else {
        !            30:                data = Serialization_data(SERIALIZED_STRING + (unsigned int)string().just_lang(), string().cstr(), string().length());
        !            31:        }
        !            32: }
        !            33: 
        !            34: VString *VString::deserialize(Serialization_data &data){
        !            35:        String *result;
        !            36:        
        !            37:        if(data.flags==SERIALIZED_STRING){
        !            38:                result = new String();
        !            39:                if (data.length>0 && !result->deserialize(0, (void *)data.ptr, data.length))
        !            40:                        return 0;
        !            41:        } else {
        !            42:                // we can't use length from memcached as there can be '\0' inside
        !            43:                String::Language lang=(String::Language)(data.flags-SERIALIZED_STRING);
        !            44:                result = new String(data.ptr, lang);
        !            45:        }
        !            46: 
        !            47:        return new VString(*result);
        !            48: }

E-mail: