bool StringValuesEqual(const char *refValue_ptr, const char *srcValue_ptr, int maxLength, bool leadingSpace, bool trailingSpace) // DESCRIPTION : Function to compare two "string" based VR types of the // (maximum) given length taking into account the // significance of any leading/trailing spaces. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { char *lSrcValue_ptr; char *lRefValue_ptr; // If 1 or both of the values is missing they are not equal! if ((!refValue_ptr) || (!srcValue_ptr)) { return false; } // get significant reference string content int refLength = StringStrip(refValue_ptr, maxLength, leadingSpace, trailingSpace, &lRefValue_ptr); // get significant received string content int srcLength = StringStrip(srcValue_ptr, maxLength, leadingSpace, trailingSpace, &lSrcValue_ptr); // significant lengths should be the same if (refLength != srcLength) { return false; } // compare the significant string parts if (memcmp(lRefValue_ptr, lSrcValue_ptr, refLength) == 0) { return true; } return false; }
DVT_STATUS VALUE_IS_CLASS::CompareStringValues(string ref_value, bool lead_spc, bool trail_spc) // DESCRIPTION : Compare the value of the class with the given string. // if leading spaces or trailing spaces are significant, set // the corresponding argument to true. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { string src_value_part; string ref_value_part; int ref_len; int src_len; int max_len; src_len = valueM.length(); ref_len = ref_value.length(); max_len = src_len; if (ref_len > max_len) { max_len = ref_len; } // get significant reference string content ref_len = StringStrip (ref_value, max_len, lead_spc, trail_spc, ref_value_part); // get significant received string content src_len = StringStrip (valueM, max_len, lead_spc, trail_spc, src_value_part); int src_int_value = atoi(src_value_part.c_str()); int ref_int_value = atoi(ref_value_part.c_str()); if (src_int_value == ref_int_value) { return (MSG_EQUAL); } if (src_int_value < ref_int_value) { return (MSG_SMALLER); } return (MSG_GREATER); }
string VALUE_UI_CLASS::GetStripped(void) // DESCRIPTION : Get stripped string. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { string stripped; StringStrip (valueM, valueM.length(), true, true, stripped); return stripped; }
string VALUE_UC_CLASS::GetStripped(void) // DESCRIPTION : Get stripped string. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { string stripped; StringStrip ((char*)valueM, sizeof(valueM), false, true, stripped); return stripped; }
static std::map<std::string, int> GetEnabledSections() { std::map<std::string, int> sectionLevelMap; std::string enabledSections = ","; std::string envSections = ","; #if defined(UNITSYNC) #if defined(DEBUG) // unitsync logging in debug mode always on // configHandler cannot be accessed here in unitsync, as it may not exist. enabledSections += "unitsync,ArchiveScanner,"; #endif #else #if defined(DEDICATED) enabledSections += "DedicatedServer,"; #endif #if !defined(DEBUG) // Always show at least INFO level of these sections enabledSections += "Sound,"; #endif enabledSections += StringToLower(configHandler->GetString("LogSections")); #endif if (getenv("SPRING_LOG_SECTIONS") != NULL) { // allow disabling all sections from the env var by setting it to "none" envSections += getenv("SPRING_LOG_SECTIONS"); envSections = StringToLower(envSections); if (envSections == "none") { enabledSections = ""; } else { enabledSections += envSections; } } enabledSections = StringToLower(enabledSections); enabledSections = StringStrip(enabledSections, " \t\n\r"); // make the last "section:level" substring findable if (!enabledSections.empty() && enabledSections.back() != ',') enabledSections += ","; // n=1 because <enabledSections> always starts with a ',' (if non-empty) for (size_t n = 1; n < enabledSections.size(); ) { const size_t k = enabledSections.find(",", n); if (k != std::string::npos) { const std::string& sub = enabledSections.substr(n, k - n); if (!sub.empty()) { const size_t sepChr = sub.find(":"); const std::string& logSec = (sepChr != std::string::npos)? sub.substr( 0, sepChr): sub; const std::string& logLvl = (sepChr != std::string::npos)? sub.substr(sepChr + 1, std::string::npos): ""; if (!logLvl.empty()) { sectionLevelMap[logSec] = StringToInt(logLvl); } else { #if defined(DEBUG) sectionLevelMap[logSec] = LOG_LEVEL_DEBUG; #else sectionLevelMap[logSec] = DEFAULT_LOG_LEVEL; #endif } } n = k + 1; } else { n = k; } } return sectionLevelMap; }