NCBI C++ ToolKit
Classes | Macros | Functions
cleanup_utils.hpp File Reference
#include <corelib/ncbistd.hpp>
#include <algorithm>
#include <objects/seqloc/Seq_loc.hpp>
#include <objects/general/Dbtag.hpp>
#include <objects/seqfeat/Seq_feat.hpp>
#include <objects/seqfeat/BioSource.hpp>
#include <objmgr/scope.hpp>
+ Include dependency graph for cleanup_utils.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  SCaseInsensitiveStrComp
 

Macros

#define TRUNCATE_SPACES(o, x)
 
#define TRUNCATE_CHOICE_SPACES(o, x)
 
#define CONVERT_QUOTES(x)
 
#define COMPRESS_STRING_MEMBER(o, x)
 
#define CLEAN_STRING_MEMBER(o, x)
 
#define CLEAN_AND_COMPRESS_STRING_MEMBER(o, x)    do { COMPRESS_STRING_MEMBER(o, x); CLEAN_STRING_MEMBER(o, x); } while(false)
 
#define CLEAN_STRING_MEMBER_JUNK(o, x)
 
#define CLEAN_AND_COMPRESS_STRING_MEMBER_JUNK(o, x)    do { COMPRESS_STRING_MEMBER(o, x); CLEAN_STRING_MEMBER_JUNK(o, x); } while(false)
 
#define EXTENDED_CLEAN_STRING_MEMBER(o, x)
 
#define CLEAN_STRING_CHOICE(o, x)
 
#define CLEAN_STRING_LIST(o, x)
 
#define CLEAN_STRING_LIST_JUNK(o, x)
 
#define EXTENDED_CLEAN_STRING_LIST(o, x)
 
#define CLEAN_INTERNAL_STRING(o, x)
 clean a string member 'x' of an internal object 'o' More...
 
#define MERGEABLE_STRING_VALUE(o1, o2, x)
 
#define MERGEABLE_STRING_LIST(o1, o2, x)
 
#define MERGEABLE_INT_VALUE(o1, o2, x)
 
#define MATCH_STRING_VALUE(o1, o2, x)
 
#define MATCH_STRING_LIST(o1, o2, x)
 
#define MATCH_INT_VALUE(o1, o2, x)
 
#define MATCH_BOOL_VALUE(o1, o2, x)
 

Functions

bool ConvertDoubleQuotes (string &str)
 Cleaning functions may return true if they have changed something. More...
 
bool CleanVisString (string &str)
 
bool CleanVisStringJunk (string &str, bool allow_ellipses=false)
 
bool RemoveSpacesBetweenTildes (string &str)
 remove white space between pairs of tildes. More...
 
void TrimInternalSemicolons (string &str)
 remove duplicate internal semicolons. More...
 
bool Asn2gnbkCompressSpaces (string &val)
 weird space compression from C Toolkit More...
 
bool TrimSpacesSemicolonsAndCommas (string &val)
 
bool CleanDoubleQuote (string &str)
 Change double to single quotes. More...
 
bool RemoveSpaces (string &str)
 remove all spaces from a string More...
 
template<typename C >
bool CleanVisStringContainer (C &str_cont)
 
template<typename C >
bool CleanVisStringContainerJunk (C &str_cont)
 
template<typename Cont >
bool RemoveDupsNoSort (Cont &l, bool case_insensitive=false)
 
CRef< CSeq_locReadLocFromText (const string &text, const CSeq_id *id, CScope *scope)
 
char ValidAminoAcid (const string &abbrev)
 
bool s_DbtagCompare (const CRef< CDbtag > &dbt1, const CRef< CDbtag > &dbt2)
 
bool s_DbtagEqual (const CRef< CDbtag > &dbt1, const CRef< CDbtag > &dbt2)
 
bool s_OrgrefSynCompare (const string &syn1, const string &syn2)
 
bool s_OrgrefSynEqual (const string &syn1, const string &syn2)
 
template<class Iter , class Comp >
bool is_sorted (Iter first, Iter last, Comp comp)
 
template<class Iter >
bool is_sorted (Iter first, Iter last)
 

Macro Definition Documentation

◆ CLEAN_AND_COMPRESS_STRING_MEMBER

#define CLEAN_AND_COMPRESS_STRING_MEMBER (   o,
 
)     do { COMPRESS_STRING_MEMBER(o, x); CLEAN_STRING_MEMBER(o, x); } while(false)

Definition at line 223 of file cleanup_utils.hpp.

◆ CLEAN_AND_COMPRESS_STRING_MEMBER_JUNK

#define CLEAN_AND_COMPRESS_STRING_MEMBER_JUNK (   o,
 
)     do { COMPRESS_STRING_MEMBER(o, x); CLEAN_STRING_MEMBER_JUNK(o, x); } while(false)

Definition at line 238 of file cleanup_utils.hpp.

◆ CLEAN_INTERNAL_STRING

#define CLEAN_INTERNAL_STRING (   o,
 
)
Value:
if (o.IsSet##x()) { \
if ( CleanVisString(o.Set##x()) ) { \
} \
if (NStr::IsBlank(o.Get##x())) { \
o.Reset##x(); \
} \
}
bool CleanVisString(string &str)
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106

clean a string member 'x' of an internal object 'o'

Definition at line 291 of file cleanup_utils.hpp.

◆ CLEAN_STRING_CHOICE

#define CLEAN_STRING_CHOICE (   o,
 
)
Value:
if (CleanVisString((o).Set##x()) ) { \
} \
if (NStr::IsBlank((o).Get##x())) { \
(o).Reset(); \
}
const TYPE & Get(const CNamedParameterList *param)

Definition at line 250 of file cleanup_utils.hpp.

◆ CLEAN_STRING_LIST

#define CLEAN_STRING_LIST (   o,
 
)
Value:
if ((o).IsSet##x()) { \
if (CleanVisStringContainer((o).Set##x()) ) { \
} \
if ((o).Get##x().empty()) { \
(o).Reset##x(); \
} \
}
bool CleanVisStringContainer(C &str_cont)
constexpr bool empty(list< Ts... >) noexcept

Definition at line 259 of file cleanup_utils.hpp.

◆ CLEAN_STRING_LIST_JUNK

#define CLEAN_STRING_LIST_JUNK (   o,
 
)
Value:
if ((o).IsSet##x()) { \
if (CleanVisStringContainerJunk((o).Set##x()) ) { \
} \
if ((o).Get##x().empty()) { \
(o).Reset##x(); \
} \
}
bool CleanVisStringContainerJunk(C &str_cont)

Definition at line 270 of file cleanup_utils.hpp.

◆ CLEAN_STRING_MEMBER

#define CLEAN_STRING_MEMBER (   o,
 
)
Value:
if ((o).IsSet##x()) { \
if (CleanVisString((o).Set##x()) ) { \
} \
if (NStr::IsBlank((o).Get##x())) { \
(o).Reset##x(); \
} \
}

Definition at line 211 of file cleanup_utils.hpp.

◆ CLEAN_STRING_MEMBER_JUNK

#define CLEAN_STRING_MEMBER_JUNK (   o,
 
)
Value:
if ((o).IsSet##x()) { \
if (CleanVisStringJunk((o).Set##x()) ) { \
} \
if (NStr::IsBlank((o).Get##x())) { \
(o).Reset##x(); \
} \
}
bool CleanVisStringJunk(string &str, bool allow_ellipses=false)

Definition at line 226 of file cleanup_utils.hpp.

◆ COMPRESS_STRING_MEMBER

#define COMPRESS_STRING_MEMBER (   o,
 
)
Value:
if ((o).IsSet##x()) { \
const size_t old_len = (o).Set##x().length(); \
CompressSpaces((o).Set##x()); \
if( old_len != (o).Set##x().length() ) { \
} \
if (NStr::IsBlank((o).Get##x())) { \
(o).Reset##x(); \
} \
}

Definition at line 198 of file cleanup_utils.hpp.

◆ CONVERT_QUOTES

#define CONVERT_QUOTES (   x)
Value:
if (IsSet##x()) { \
if (ConvertDoubleQuotes(Set##x()) ) { \
} \
}
bool ConvertDoubleQuotes(string &str)
Cleaning functions may return true if they have changed something.

Definition at line 191 of file cleanup_utils.hpp.

◆ EXTENDED_CLEAN_STRING_LIST

#define EXTENDED_CLEAN_STRING_LIST (   o,
 
)
Value:
if ((o).IsSet##x()) { \
CleanVisStringList((o).Set##x()); \
if ((o).Get##x().empty()) { \
(o).Reset##x(); \
} \
}

Definition at line 281 of file cleanup_utils.hpp.

◆ EXTENDED_CLEAN_STRING_MEMBER

#define EXTENDED_CLEAN_STRING_MEMBER (   o,
 
)
Value:
if ((o).IsSet##x()) { \
CleanVisString((o).Set##x()); \
if (NStr::IsBlank((o).Get##x())) { \
(o).Reset##x(); \
} \
}

Definition at line 241 of file cleanup_utils.hpp.

◆ MATCH_BOOL_VALUE

#define MATCH_BOOL_VALUE (   o1,
  o2,
 
)
Value:
if (!(o1).IsSet##x()) { \
if ((o2).IsSet##x()) { \
return false; \
} \
} else if (!(o2).IsSet##x()) { \
return false; \
} else if (((o1).Get##x() && !(o2).Get##x()) \
|| (!(o2).Get##x() && (o2).Get##x())) { \
return false; \
}

Definition at line 365 of file cleanup_utils.hpp.

◆ MATCH_INT_VALUE

#define MATCH_INT_VALUE (   o1,
  o2,
 
)
Value:
((!(o1).CanGet##x() && !(o2).CanGet##x()) \
|| ((o1).CanGet##x() && (o2).CanGet##x() \
&& (o1).Get##x() == (o2).Get##x()) \
|| ((o1).CanGet##x() && (o1).Get##x() == 0 \
&& !(o2).CanGet##x()) \
|| ((o2).CanGet##x() && (o2).Get##x() == 0 \
&& !(o1).CanGet##x()))

Definition at line 356 of file cleanup_utils.hpp.

◆ MATCH_STRING_LIST

#define MATCH_STRING_LIST (   o1,
  o2,
 
)
Value:
if (((o1).CanGet##x() && (o1).Get##x().size() > 0 && !(o2).CanGet##x()) \
|| (!(o1).CanGet##x() && (o2).CanGet##x() && (o2).Get##x().size() > 0)) { \
return false; \
} else if ((o1).CanGet##x() && (o2).CanGet##x()) { \
list <string>::const_iterator it1 = (o1).Get##x().begin(); \
list <string>::const_iterator it2 = (o2).Get##x().begin(); \
while (it1 != (o1).Get##x().end() && it2 != (o2).Get##x().end()) { \
if (!NStr::Equal ((*it1), (*it2))) { \
return false; \
} \
++it1; ++it2; \
} \
if (it1 != (o1).Get##x().end() || it2 != (o2).Get##x().end()) { \
return false; \
} \
}
constexpr auto end(const ct_const_array< T, N > &in) noexcept
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5384
const struct ncbi::grid::netcache::search::fields::SIZE size

Definition at line 338 of file cleanup_utils.hpp.

◆ MATCH_STRING_VALUE

#define MATCH_STRING_VALUE (   o1,
  o2,
 
)
Value:
((!(o1).CanGet##x() && !(o2).CanGet##x()) \
|| ((o1).CanGet##x() && (o2).CanGet##x() \
&& NStr::Equal((o1).Get##x(), (o2).Get##x())))

Definition at line 333 of file cleanup_utils.hpp.

◆ MERGEABLE_INT_VALUE

#define MERGEABLE_INT_VALUE (   o1,
  o2,
 
)
Value:
(!(o1).CanGet##x() || !(o2).CanGet##x() \
|| (o1).Get##x() == 0 \
|| (o2).Get##x() == 0 \
|| (o1).Get##x() == (o2).Get##x())

Definition at line 327 of file cleanup_utils.hpp.

◆ MERGEABLE_STRING_LIST

#define MERGEABLE_STRING_LIST (   o1,
  o2,
 
)
Value:
if ((o1).CanGet##x() && (o2).CanGet##x() \
&& (o1).Get##x().size() > 0 \
&& (o2).Get##x().size() > 0) { \
list <string>::const_iterator it1 = (o1).Get##x().begin(); \
list <string>::const_iterator it2 = (o2).Get##x().begin(); \
while (it1 != (o1).Get##x().end() && it2 != (o2).Get##x().end()) { \
if (!NStr::Equal ((*it1), (*it2))) { \
return false; \
} \
++it1; ++it2; \
} \
if (it1 != (o1).Get##x().end() || it2 != (o2).Get##x().end()) { \
return false; \
} \
}

Definition at line 310 of file cleanup_utils.hpp.

◆ MERGEABLE_STRING_VALUE

#define MERGEABLE_STRING_VALUE (   o1,
  o2,
 
)
Value:
if ((o1).CanGet##x() && (o2).CanGet##x() \
&& !NStr::IsBlank ((o1).Get##x()) \
&& !NStr::IsBlank ((o2).Get##x()) \
&& !NStr::Equal ((o1).Get##x(), (o2).Get##x())) { \
return false; \
}

Definition at line 302 of file cleanup_utils.hpp.

◆ TRUNCATE_CHOICE_SPACES

#define TRUNCATE_CHOICE_SPACES (   o,
 
)
Value:
{ \
size_t n = (o).Get##x().size(); \
if (n != (o).Get##x().size() ) { \
} \
if (NStr::IsBlank((o).Get##x())) { \
(o).Reset(); \
} \
}
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3197
yy_size_t n

Definition at line 178 of file cleanup_utils.hpp.

◆ TRUNCATE_SPACES

#define TRUNCATE_SPACES (   o,
 
)
Value:
if ((o).IsSet##x()) { \
size_t n = (o).Get##x().size(); \
if (n != (o).Get##x().size() ) { \
} \
if (NStr::IsBlank((o).Get##x())) { \
(o).Reset##x(); \
} \
}

Definition at line 165 of file cleanup_utils.hpp.

Function Documentation

◆ Asn2gnbkCompressSpaces()

bool Asn2gnbkCompressSpaces ( string val)

◆ CleanDoubleQuote()

bool CleanDoubleQuote ( string str)

◆ CleanVisString()

bool CleanVisString ( string str)

◆ CleanVisStringContainer()

template<typename C >
bool CleanVisStringContainer ( C str_cont)

Definition at line 99 of file cleanup_utils.hpp.

References CleanVisString(), and NStr::IsBlank().

Referenced by CCleanup::CleanupAuthList().

◆ CleanVisStringContainerJunk()

template<typename C >
bool CleanVisStringContainerJunk ( C str_cont)

Definition at line 118 of file cleanup_utils.hpp.

References CleanVisStringJunk(), and NStr::IsBlank().

◆ CleanVisStringJunk()

bool CleanVisStringJunk ( string str,
bool  allow_ellipses = false 
)

◆ ConvertDoubleQuotes()

bool ConvertDoubleQuotes ( string str)
inline

Cleaning functions may return true if they have changed something.

false if no change was needed. convert double quotes to single quotes

Definition at line 59 of file cleanup_utils.hpp.

References NON_CONST_ITERATE, and str().

◆ is_sorted() [1/2]

template<class Iter >
bool is_sorted ( Iter  first,
Iter  last 
)

Definition at line 413 of file cleanup_utils.hpp.

References first(), last(), and next().

◆ is_sorted() [2/2]

template<class Iter , class Comp >
bool is_sorted ( Iter  first,
Iter  last,
Comp  comp 
)

Definition at line 396 of file cleanup_utils.hpp.

References first(), last(), and next().

◆ ReadLocFromText()

CRef<CSeq_loc> ReadLocFromText ( const string text,
const CSeq_id id,
CScope scope 
)

Definition at line 585 of file cleanup_utils.cpp.

References GetSeqLocFromString(), and text().

Referenced by CCleanup::ParseCodeBreak(), and s_ParseTRnaFromAnticodonString().

◆ RemoveDupsNoSort()

template<typename Cont >
bool RemoveDupsNoSort ( Cont &  l,
bool  case_insensitive = false 
)

Definition at line 145 of file cleanup_utils.hpp.

◆ RemoveSpaces()

bool RemoveSpaces ( string str)

remove all spaces from a string

Definition at line 548 of file cleanup_utils.cpp.

References isspace(), next(), NON_CONST_ITERATE, and str().

Referenced by CCitGenCleaner::Clean().

◆ RemoveSpacesBetweenTildes()

bool RemoveSpacesBetweenTildes ( string str)

remove white space between pairs of tildes.

"~ ~ ~ a~" -> "~~~ a~"

Definition at line 229 of file cleanup_utils.cpp.

References NPOS, and str().

Referenced by CNewCleanup_imp::x_RemoveSpacesBetweenTildesMarkChanged().

◆ s_DbtagCompare()

bool s_DbtagCompare ( const CRef< CDbtag > &  dbt1,
const CRef< CDbtag > &  dbt2 
)

◆ s_DbtagEqual()

bool s_DbtagEqual ( const CRef< CDbtag > &  dbt1,
const CRef< CDbtag > &  dbt2 
)

◆ s_OrgrefSynCompare()

bool s_OrgrefSynCompare ( const string syn1,
const string syn2 
)

Definition at line 669 of file cleanup_utils.cpp.

References NStr::CompareNocase().

Referenced by CNewCleanup_imp::x_PostOrgRef().

◆ s_OrgrefSynEqual()

bool s_OrgrefSynEqual ( const string syn1,
const string syn2 
)

Definition at line 674 of file cleanup_utils.cpp.

References NStr::EqualNocase().

Referenced by CNewCleanup_imp::x_PostOrgRef().

◆ TrimInternalSemicolons()

void TrimInternalSemicolons ( string str)

remove duplicate internal semicolons.

"a;;b" will become "a;b".

Definition at line 276 of file cleanup_utils.cpp.

References NStr::Find(), and str().

Referenced by CNewCleanup_imp::GBQualBC(), CNewCleanup_imp::ProtActivityBC(), CNewCleanup_imp::ProtNameBC(), CNewCleanup_imp::ProtRefEC(), and CNewCleanup_imp::x_TrimInternalSemicolonsMarkChanged().

◆ TrimSpacesSemicolonsAndCommas()

bool TrimSpacesSemicolonsAndCommas ( string val)

Definition at line 465 of file cleanup_utils.cpp.

References NStr::Equal(), str(), and val.

Referenced by CNewCleanup_imp::DbtagBC(), and CNewCleanup_imp::OrgrefModBC().

◆ ValidAminoAcid()

char ValidAminoAcid ( const string abbrev)

Definition at line 632 of file cleanup_utils.cpp.

Modified on Sat Mar 02 10:56:32 2024 by modify_doxy.py rev. 669887