Anyone remembers what major difference among these two sets of methods, from 
Paragraph and Inset?

Paragraph::stringify() and asString() look like almost identical, with the 
difference that
the former goes for Inset::plaintext(), and it doesn't detect deleted text, the 
latter uses
Inset::toString(), and it does care about the SKIPDELETED option.

Any clue of why we need them both?

        T.

docstring Paragraph::stringify(pos_type beg, pos_type end, int options,
        OutputParams const & runparams) const
{
        odocstringstream os;

        if (beg == 0
                && options & AS_STR_LABEL
                && !d->params_.labelString().empty())
                os << d->params_.labelString() << ' ';

        OutputParams op = runparams;
        op.for_search = true;

        for (pos_type i = beg; i < end; ++i) {
                char_type const c = d->text_[i];
                if (isPrintable(c) || c == '\t'
                    || (c == '\n' && (options & AS_STR_NEWLINES)))
                        os.put(c);
                else if (c == META_INSET && (options & AS_STR_INSETS)) {
                        getInset(i)->plaintext(os, op);
                }
        }

        return os.str();
}

docstring Paragraph::asString(pos_type beg, pos_type end, int options) const
{
        odocstringstream os;

        if (beg == 0
            && options & AS_STR_LABEL
            && !d->params_.labelString().empty())
                os << d->params_.labelString() << ' ';

        for (pos_type i = beg; i < end; ++i) {
                if ((options & AS_STR_SKIPDELETE) && isDeleted(i))
                        continue;
                char_type const c = d->text_[i];
                if (isPrintable(c) || c == '\t'
                    || (c == '\n' && (options & AS_STR_NEWLINES)))
                        os.put(c);
                else if (c == META_INSET && (options & AS_STR_INSETS)) {
                        getInset(i)->toString(os);
                        if (getInset(i)->asInsetMath())
                                os << " ";
                }
        }

        return os.str();
}

Reply via email to