Source& Source::operator<<(std::shared_ptr<Source> src) { SourceChunkRef new_src = SourceChunkRef(new SourceRef(src)); append_source_ref(new_src); return *this; }
Source& Source::operator<<(Source& src) { std::shared_ptr<Source> ref_src = std::shared_ptr<Source>(new Source(src)); SourceChunkRef new_src = SourceChunkRef(new SourceRef(ref_src)); append_source_ref(new_src); return *this; }
void Source::append_text_chunk(const std::string& str) { if (_chunk_list->empty()) { _chunk_list->push_back(SourceChunkRef(new SourceText(str))); } else { SourceChunkRef last = *(_chunk_list->rbegin()); if (last->is_source_text()) { std::shared_ptr<SourceText> text = std::static_pointer_cast<SourceText>(last); text->_source += str; } else { _chunk_list->push_back(SourceChunkRef(new SourceText(str))); } } }
void Source::append_text_chunk(const std::string& str) { if (_chunk_list->empty()) { _chunk_list->push_back(SourceChunkRef(new SourceText(str))); } else { SourceChunkRef last = *(_chunk_list->rbegin()); if (last->is_source_text()) { RefPtr<SourceText> text = RefPtr<SourceText>::cast_dynamic(last); text->_source += str; } else { _chunk_list->push_back(SourceChunkRef(new SourceText(str))); } } }
Source& Source::append_with_separator(Source& src, const std::string& separator) { if (!src.all_blanks()) { if (!all_blanks()) { append_text_chunk(separator); } std::shared_ptr<Source> ref_source = std::shared_ptr<Source>(new Source(src)); append_source_ref(SourceChunkRef(new SourceRef(ref_source))); } return (*this); }