inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> 
operator + (const sub_match<RandomAccessIterator>& m,
            const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
{
   std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
   result.reserve(s.size() + m.length() + 1);
   return result.append(m.first, m.second).append(s);
}
Example #2
0
inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> 
operator + (const sub_match<RandomAccessIterator>& m,
            typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
{
   std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> result;
   result.reserve(m.length() + 2);
   return result.append(m.first, m.second).append(1, s);
}
Example #3
0
 int compare(const sub_match& s)const
 {
    if(matched != s.matched)
       return static_cast<int>(matched) - static_cast<int>(s.matched);
    return str().compare(s.str());
 }
Example #4
0
inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> 
operator + (const sub_match<RandomAccessIterator>& m,
            typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const * s)
{
   return m.str() + s;
}
Example #5
0
inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> 
operator + (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
                  const sub_match<RandomAccessIterator>& m)
{
   std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> result;
   result.reserve(std::char_traits<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
   return result.append(s).append(m.first, m.second);
}
Example #6
0
inline bool operator >= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
                  const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
Example #7
0
inline bool operator <= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
                  const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(s) >= 0; }
Example #8
0
inline bool operator >= (const sub_match<RandomAccessIterator>& m,
                  const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
{ return m.str().compare(s) >= 0; }
Example #9
0
/// @brief Replaces any IDoc parameters with a the specified value from the input IDoc. IDoc
///     parameters should be in the format {IDoc:SegmentName:FieldName}
///     Note you must specify the input IDoc to use by first calling idoc_select_input_file
/// @param a new string with the IDoc parameters replaced with their values
/// @return a new string with the IDoc parameters replaced
IDOCREPLAYDLL_API LPCSTR idoc_eval_string(const LPCSTR parameterizedString)
{
    if (!ensure_valid_license())
    {
        return parameterizedString;
    }

    if (parameterizedString == NULL)
    {
        lr_error_message("Parameterized string cannot be empty.");
        return parameterizedString;
    }

    // TODO: move this check so that it only throws an error when parameterizedString contains something that looks like an IDoc parameter (i.e. {IDoc:xxx:yyy}
    // We don't want an error to be raised when idoc_create() is called with standard LoadRunner parameters.
    if (g_idocParamInputFilePath.empty())
    {
    //    lr_error_message("Input file is not selected. (Call idoc_select_input_file first.)");
        return parameterizedString;
    }

    g_allocatedStrings.push_back(std::string());

    string& result = g_allocatedStrings.back();

    const char* currentString = parameterizedString;

    cmatch matchResults;
    while (regex_search(currentString, matchResults, g_parameterRegex) && matchResults.size() == 3)
    {
        const cmatch::difference_type offset = matchResults.position();
        if (offset > 0)
        {
            result.append(currentString, offset);
            currentString += offset;
        }

        const sub_match<const char*> entireMatch = matchResults[0];
        const sub_match<const char*> segmentMatch = matchResults[1];
        const sub_match<const char*> fieldMatch = matchResults[2];

        const string segment(segmentMatch.first, segmentMatch.length());
        const string field(fieldMatch.first, fieldMatch.length());

        const xml_node segmentNode = get_node_value(g_idocParamInputFile.root(), segment);
        const xml_node fieldNode = get_node_value(segmentNode, field);

        if (segmentNode.empty() || fieldNode.empty())
        {
            result.append(currentString, entireMatch.length());
            currentString += entireMatch.length();

            if (is_param_log_enabled())
            {
                lr_output_message(
                    "Warning: [IDoc] Unable to find IDoc parameter '%s:%s'.",
                    segment.c_str(),
                    field.c_str());
            }

            continue;
        }

        const char_t* value = fieldNode.text().as_string();
        result.append(value);

        if (is_param_log_enabled())
        {
            lr_output_message(
                "[IDoc] Parameter substitution: '%s:%s' => '%s'.",
                segment.c_str(),
                field.c_str(),
                value);
        }

        currentString += entireMatch.length();
    }

    result.append(currentString);

    return result.c_str();
}
Example #10
0
typename sub_match<BidiIter>::string_type
operator + (typename sub_match<BidiIter>::string_type const &lhs, sub_match<BidiIter> const &rhs)
{
    return lhs + rhs.str();
}
Example #11
0
typename sub_match<BidiIter>::string_type
operator + (sub_match<BidiIter> const &lhs, typename iterator_value<BidiIter>::type const *rhs)
{
    return lhs.str() + rhs;
}
Example #12
0
bool operator <= (sub_match<BidiIter> const &lhs, typename iterator_value<BidiIter>::type const &rhs)
{
    return lhs.str() <= rhs;
}
Example #13
0
bool operator >= (typename iterator_value<BidiIter>::type const &lhs, sub_match<BidiIter> const &rhs)
{
    return lhs >= rhs.str();
}
Example #14
0
bool operator > (sub_match<BidiIter> const &lhs, sub_match<BidiIter> const &rhs)
{
    return lhs.compare(rhs) > 0;
}
Example #15
0
 /// \overload
 ///
 int compare(sub_match const &sub) const
 {
     return this->str().compare(sub.str());
 }