summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/replace_key.cpp
blob: d190e31c09940a7cd29c219b8b0e7db0dd81acfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "ace/OS_NS_string.h"
#include "ace/Log_Msg.h"
#include "tao/Object_KeyC.h"
#include <algorithm>

ACE_RCSID (EventChannel,
           replace_key,
           "$Id$")


/// This function was defined in IOGR_Maker.cpp. It is moved
/// here because the use of <algorithm> header
/// file conflicts with the use of auto_ptr in the
/// VxWorks5.5.1_PPC85XX_DIAB platform.


void replace_key(char* ior, char* end_ior,
                const TAO::ObjectKey& oldkey,
                const TAO::ObjectKey& newkey)
{
  size_t keylen = oldkey.length();
  ACE_ASSERT(keylen == newkey.length());

  char* pos = ior;
  const char* oldkey_begin = (const char*)oldkey.get_buffer();
  const char* oldkey_end = oldkey_begin + keylen;

  while ((pos = std::search(pos, end_ior,oldkey_begin, oldkey_end)) != end_ior) {
    ACE_OS::memcpy(pos, newkey.get_buffer(), keylen);
    pos+= keylen;
  }
}