40 static void s_split(
const string &s,
string delim, vector<string> &elems)
43 while (start < s.length())
45 size_t finish = s.find(delim,start);
46 if (finish == string::npos) finish = s.length();
47 string item = s.substr(start,finish-start);
49 if (!item.empty()) elems.push_back(item);
50 start = finish+delim.length();
58 if (comment.find(
"-START##") != string::npos && comment.find(
"-END##") != string::npos && comment.find(m_DelimiterNameValue) != string::npos)
61 size_t e = comment.find(
"-START##");
62 size_t b = comment.rfind(
"##",e);
63 if (
b == string::npos)
b = 0;
64 e += strlen(
"-START##");
68 e = comment.find(
"-END##");
69 b = comment.rfind(
"##",e);
70 if (
b == string::npos)
b = 0;
71 e += strlen(
"-END##");
73 comment.erase(
b,string::npos);
77 vector< pair<string,string> > fields;
78 s_split(comment,m_DelimiterFields,lines);
79 for (
unsigned int i=0;
i<lines.size(); ++
i)
83 s_split(lines[
i],m_DelimiterNameValue,field);
84 if (field.size() == 2)
85 fields.push_back(pair<string,string>(field[0],field[1]));
86 else if (field.size() == 1)
90 fields.push_back(pair<string,string>(name,field[0]));
102 user.
SetType().SetStr(
"StructuredComment");
105 for (
unsigned int i=0;
i<fields.size(); ++
i)
106 user.
AddField(fields[
i].first,fields[
i].second);
113 e =
result.find(
"-START##");
115 if (
b == string::npos)
b = 0;
116 e =
result.find(
"-END##");
117 e += strlen(
"-END##");
130 if ((*it)->IsComment())
133 string modified = ApplyToComment((*it)->GetComment(),composite,seh);
134 if (modified != (*it)->GetComment())
136 if (modified.empty())
145 edited_object->
Assign(**it);
159 ApplyToCSeq_entry (tse, **it, composite);
169 m_DelimiterNameValue = delim_name_value;
170 m_DelimiterFields = delim_fields;
172 ApplyToCSeq_entry (tse, *(tse.GetCompleteSeq_entry()), composite);
void AddCommand(IEditCommand &command)
Base class for all serializable objects.
CUser_object & AddField(const string &label, const string &value, EParseField parse=eParse_String)
add a data field to the user object that holds a given value
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
CScope & GetScope(void) const
Get scope this handle belongs to.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
void SetType(TType &value)
Assign a value to Type data member.
const TSet & GetSet(void) const
Get the variant data.
bool IsSet(void) const
Check if variant Set is selected.
TComment & SetComment(void)
Select the variant.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TUser & SetUser(void)
Select the variant.
@ e_User
user defined object
static const char * suffix[]
static const char * prefix[]
#define FOR_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
FOR_EACH_SEQENTRY_ON_SEQSET EDIT_EACH_SEQENTRY_ON_SEQSET.
#define FOR_EACH_SEQDESC_ON_SEQENTRY(Itr, Var)
FOR_EACH_SEQDESC_ON_SEQENTRY EDIT_EACH_SEQDESC_ON_SEQENTRY.