boost::regex_replace issue

Y

Yahooooooooo

Just practicing BOOST regular expressions....giving errors...
-- wanted to replace SPACE with NULL.


#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <iterator>
#include <boost/regex.hpp>
#include <fstream>
#include <iostream>

using namespace std;
boost::regex rex1;
extern const char* pre_expression= " ";
extern const char* pre_format="";

int main(void)
{
string line;
//boost::regex rex1(" ",boost::regex::perl|boost::regex::icase);
rex1.assign(pre_expression);
boost::regex rex2;

ifstream fh("/tmp/log.conf");
getline(fh,line);
cout << line << endl;

std::eek:stringstream osstr(std::ios::eek:ut);
std::eek:stream_iterator<char,char> oi(osstr);


boost::regex_replace(oi,line.begin(),line.end(),rex1,pre_format,boost::
match_default | boost::format_all);

getline(fh,line);
cout << line << endl;
fh.close();
return 1;
}



##### g++ -o runme -ftemplate-depth-100 -I/home/azmath/dev/
boost_1_33_1/ -DBOOST_USER_CONFIG="</home/azmath/dev/boost_1_33_1/
boost/config/user.hpp>" -lboost_regex-gcc-d-1_33_1 classreadfile.cc

In file included from /home/azmath/dev/boost_1_33_1/boost/regex/v4/
regex.hpp:55,
from /home/azmath/dev/boost_1_33_1/boost/regex.hpp:
31,
from classreadfile.cc:6:
/home/azmath/dev/boost_1_33_1/boost/regex/v4/char_regex_traits.hpp: In
instantiation of
`boost::regex_traits<char,boost::cpp_regex_traits<char> >':

/home/azmath/dev/boost_1_33_1/boost/regex/v4/char_regex_traits.hpp:
38: instantiated from here

/home/azmath/dev/boost_1_33_1/boost/regex/v4/char_regex_traits.hpp:38:
base class `boost::cpp_regex_traits<char>' has incomplete type

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp: In
instantiation of
`boost::basic_regex<char,boost::regex_traits<char,boost::cpp_regex_trai
ts<char> > >':

classreadfile.cc:14: instantiated from here

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:186: no
type named `size_type' in `struct
boost::regex_traits<char,boost::cpp_regex_traits<char> >'

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:187: no
type named `string_type' in `struct
boost::regex_traits<char,boost::cpp_regex_traits<char> >'

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:202: no
type named `locale_type' in `struct
boost::regex_traits<char,boost::cpp_regex_traits<char> >'

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:530: no
type named `locale_type' in `struct
boost::regex_traits<char,boost::cpp_regex_traits<char> >'

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:530: no
type named `locale_type' in `struct
boost::regex_traits<char,boost::cpp_regex_traits<char> >'

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:339: no
type named `locale_type' in `struct
boost::regex_traits<char,boost::cpp_regex_traits<char> >'

/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp: In
method `class
boost::basic_regex<char,boost::regex_traits<char,boost::cpp_regex_trait
s<char> > > &
boost::basic_regex<char,boost::regex_traits<char,boost::cpp_regex_trait
s<char> > >::assign(const char *, unsigned int =
boost::regex_constants::normal)':

classreadfile.cc:26: instantiated from here
/home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:239: no
method `boost::regex_traits said:
::length'

classreadfile.cc: In function `int main()':
classreadfile.cc:48: wrong number of template arguments (2, should be
1)
/usr/include/g++/stl_iterator.h:875: provided for `template <class
_Tp> ostream_iterator<_Tp>'
classreadfile.cc:48: confused by earlier errors, bailing out
 
D

David Harmon

On 29 Jan 2007 21:55:08 -0800 in comp.lang.c++, "Yahooooooooo"
Just practicing BOOST regular expressions....giving errors...

Your example compiles fine for me with MSVC 7, Windows.
You might want to try the Boost forums.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top