63 size_t colIndex,
string format,
string name,
string description):
68 mDescription(description)
71 auto openBracket =
format.find(
'[');
72 if (openBracket != string::npos) {
102 string(
"BED: Unable to convert \"") +
key +
"\" value \"" +
value +
103 "\" to float. Defaulting to 0.0");
104 messageHandler.
Report(warning);
128 string(
"BED: Unable to convert \"") +
key +
"\" value \"" +
value +
129 "\" to int. Defaulting to 0");
130 messageHandler.
Report(warning);
146 vector<string> intStrs;
148 vector<int> realInts;
151 intStrs.begin(), intStrs.end(),
152 std::back_inserter(realInts),
153 [] (
const string&
str) ->
int { return NStr::StringToInt(str);} );
158 string(
"BED: Unable to convert \"") +
key +
"\" value \"" +
value +
159 "\" to int list. Defaulting to empty list");
160 messageHandler.
Report(warning);
191 unsigned uintVal = 0;
198 string(
"BED: Unable to convert \"") +
key +
"\" value \"" +
value +
199 "\" to uint. Defaulting to 0");
200 messageHandler.
Report(warning);
228 return xHandleSpecialCaseRgb(columnData, bedFlags, uo, messageHandler);
243 if (mFormat !=
"int" && mFormat !=
"uint") {
247 vector<string> knownRgbKeys = {
"itemrgb",
"color",
"colour"};
248 string lowerName(mName);
250 bool isRgbKey = (find(knownRgbKeys.begin(), knownRgbKeys.end(), lowerName) !=
252 if (mColIndex != 8 && !isRgbKey) {
255 string valueStr = columnData[mColIndex];
265 string(
"BED: Unable to convert \"") + mName +
"\" value \"" +
266 valueStr +
"\" to int. Defaulting to 0");
267 messageHandler.Report(warning);
269 uo.AddField(mName, intVal);
276 if (rgb.size() == 3) {
284 string(
"BED: Unable to convert \"") + mName +
"\" value \"" +
285 valueStr +
"\" to int. Defaulting to 0");
286 messageHandler.Report(warning);
288 uo.AddField(mName, rgbInt);
305 if (xHandleSpecialCases(columnData, bedFlags, uo, messageHandler)) {
308 string valueStr = columnData[mColIndex];
319 mName, valueStr, columnData.LineNo(), bedFlags, uo, messageHandler);
328 if (mFormatHandlers.find(mFormat) == mFormatHandlers.end()) {
332 string(
"AutoSql: Format \"") + mFormat +
333 "\" for \"" + mName +
334 "\" not recognized, processing as string");
335 messageHandler.Report(warning);
358 bool newUserObject {
false};
360 auto pDisplayData = feat.FindExt(
"DisplaySettings");
363 pDisplayData->SetType().SetStr(
"DisplaySettings");
364 newUserObject =
true;
368 for (
const auto& fieldInfo: mFields) {
369 if (! fieldInfo.SetUserField(
370 columnData, bedFlags, *pDisplayData, messageHandler)) {
376 feat.SetExts().push_back(pDisplayData);
387 for (
const auto& field: mFields) {
388 if (!field.Validate(messageHandler)) {
void transform(Container &c, UnaryFunction *op)
bool Validate(CReaderMessageHandler &) const
static bool AddUint(const string &, const string &, unsigned int, int, CUser_object &, CReaderMessageHandler &)
static FormatHandlers mFormatHandlers
bool SetUserField(const CBedColumnData &, int bedFlags, CUser_object &, CReaderMessageHandler &) const
static bool AddUintArray(const string &, const string &, unsigned int, int, CUser_object &, CReaderMessageHandler &)
bool xHandleSpecialCases(const CBedColumnData &, int bedFlags, CUser_object &, CReaderMessageHandler &) const
static bool AddString(const string &, const string &, unsigned int, int, CUser_object &, CReaderMessageHandler &)
static bool AddDouble(const string &, const string &, unsigned int, int, CUser_object &, CReaderMessageHandler &)
static bool AddInt(const string &, const string &, unsigned int, int, CUser_object &, CReaderMessageHandler &)
static bool AddIntArray(const string &, const string &, unsigned int, int, CUser_object &, CReaderMessageHandler &)
CAutoSqlCustomField(size_t colIndex, string format, string name, string description)
bool xHandleSpecialCaseRgb(const CBedColumnData &, int bedFlags, CUser_object &, CReaderMessageHandler &) const
vector< CAutoSqlCustomField > mFields
bool Validate(CReaderMessageHandler &) const
bool SetUserObject(const CBedColumnData &, int bedFlags, CSeq_feat &, CReaderMessageHandler &) const
void Append(const CAutoSqlCustomField &)
void Report(const CReaderMessage &)
namespace ncbi::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
const_iterator end() const
const_iterator find(const key_type &key) const
The NCBI C++ standard methods for dealing with std::string.
static const char * str(char *buf, int n)
@ eDiag_Warning
Warning message.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static void TrimSuffixInPlace(string &str, const CTempString suffix, ECase use_case=eCase)
Trim suffix from a string (in-place)
static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned int.
static string & ToLower(string &str)
Convert string to lower case – string& version.
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value