replace string file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric Kaplan

    replace string file

    I have a function that will take char buffer and dump all data into a
    file.

    How can I replace all
    <givenname xsi:nil='true'/>

    with

    <givenname>.</givenname>


    =============== ==============
    int my_block_reader (void *userdata, const char *buf, size_t len)
    {

    char *szBuffer = new char[len + 1];
    memcpy(szBuffer , buf, len);
    szBuffer[len] = 0;
    dumpfile << szBuffer;
    delete[] szBuffer;

    return 0;
    }
  • Nathan Mates

    #2
    Re: replace string file

    In article <r44ru3p72pvo62 cjhr79nnfj4khtt pae1p@4ax.com>,
    Eric Kaplan <tobycraftse@ya hoo.comwrote:
    >How can I replace all
    ><givenname xsi:nil='true'/>
    >
    >with
    >
    ><givenname>. </givenname>
    The PCRE library from http://www.pcre.org/ makes it really easy to
    replace a string based on regular expressions. Use PCRE as a
    library/DLL, and the C++ wrappers turn the (somewhat obscure) API into
    a rather trivial operation.

    Nathan Mates

    --
    <*Nathan Mates - personal webpage http://www.visi.com/~nathan/
    # Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
    # NOT speaking for Pandemic Studios. "Care not what the neighbors
    # think. What are the facts, and to how many decimal places?" -R.A. Heinlein

    Comment

    • Eric Kaplan

      #3
      Re: replace string file


      >It seems you're not using the 'userdata' argument. Why is it there, and why is
      >it a 'void*' rather than some reasonable type?
      I think it's a mistake
      >
      >Why does the function have a non-'void' result type when it always returns the
      >same value?
      >
      Yes, can be return void.
      >And if it's meant to be a boolean, why is it 'int' instead of 'bool'?
      >
      this can be changed too
      >Why is the function named 'reader' when its purpose is to write?
      >
      It's called by a function like - ne_add_response _body_reader(re q,
      ne_accept_alway s, my_block_reader , NULL);
      >Why are you using C-style coding when you're posting to [comp.lang.c++]?
      I am new to C++ I don't know it's C only
      >Why are you using Hungarian notation (that's the most silly about the whole
      >thing, it really beats me why anyone would willingly add warts)?
      >
      Hungarian notation? never heard of this though
      >Why is this cross-posted to three groups, two of which are vendor-specific?
      May be more people can see this question?

      Comment

      Working...