Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) BoostXpressiveExample2

 

Boost.Xpressive example 2 is a Boost.Xpressive example

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppBoostXpressiveExample2/CppBoostXpressiveExample2.pro

 

exists(../../ConsoleApplication.pri) {
  include(../../ConsoleApplication.pri)
}
!exists(../../ConsoleApplication.pri) {
  QT += core
  QT += gui
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  CONFIG   += console
  CONFIG   -= app_bundle
  TEMPLATE = app
  CONFIG(release, debug|release) {
    DEFINES += NDEBUG NTRACE_BILDERBIKKEL
  }
  QMAKE_CXXFLAGS += -std=c++1y -Wall -Wextra -Weffc++
  unix {
    QMAKE_CXXFLAGS += -Werror
  }
}

exists(../../Libraries/Boost.pri) {
  include(../../Libraries/Boost.pri)
}
!exists(../../Libraries/Boost.pri) {
  win32 {
    INCLUDEPATH += \
      ../../Libraries/boost_1_55_0
  }
}

SOURCES += main.cpp

 

 

 

 

 

./CppBoostXpressiveExample2/main.cpp

 

#include <cassert>
#include <string>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/xpressive/xpressive.hpp>
#pragma GCC diagnostic pop

int main()
{
  const std::string str = "The zip code 1234AB is correct";
  const boost::xpressive::sregex regex
    = boost::xpressive::sregex::compile("(\\d{4})()([A-Z]{2})");
  const std::string fix("($1) ($3)");
  const std::string s
    = boost::xpressive::regex_replace(
      str,
      regex,
      fix,
        boost::xpressive::regex_constants::match_default
      | boost::xpressive::regex_constants::format_all);
  assert(s == "The zip code 1234 AB is correct");
}

 

 

 

 

 

./CppBoostXpressiveExample2/CppBoostXpressiveExample2.sh

 

#!/bin/bash
#Script to check the status of compiles
#Copies executables (both Linux and Win32) executables to ~/bin (overwrites older)
#set -x verbose #echo on

mytempfile="tmp.txt"
if [ -e $mytempfile ]
then
  rm $mytempfile
fi

rm *.pro.user

for myprofile in `ls | egrep ".pro\>"`
do
  echo $myprofile
  mybasename=`echo $myprofile | sed "s/\.pro//"`

  #For every .pro file,
  # 0: compile
  # 1: crosscompile using Qt5
  for type in 0 1
  do
    myqmake=""
    mytypestr=""

    #Cleaning up
    rm Makefile
    rm Makefile.*
    rm -r release
    rm -r debug
    rm ui_*.h
    rm qrc_*.cpp
    rm moc_*.cpp
    rm object_script*.*
    rm *.o
    rm *_plugin_import.cpp

    case $type in
    0) myqmake="qmake" mytypestr="Lubuntu" ;;
    1) myqmake="../../Libraries/mxe/usr/i686-pc-mingw32/qt5/bin/qmake" mytypestr="Qt5LubuntuToWindows" ;;
    esac

    $myqmake $myprofile

    if [ ! -e Makefile ]
    then
      echo $myprofile", "$mytypestr": FAIL (Makefile not found)" >> ../$mytempfile
      continue
    fi

    make


    if [ -e $mybasename ] || [ -e ./release/$mybasename".exe" ]
    then
      echo $myprofile", "$mytypestr": SUCCESS" >> ../$mytempfile
      #echo "SUCCESS for mybasename: "$mybasename
      if [ -e $mybasename ]
      then
        #echo "(1) cp "$mybasename" ~/bin/"
        cp $mybasename ~/bin/
        rm $mybasename
      fi
      if [ -e ./release/$mybasename".exe" ]
      then
        #echo "(2) cp ./release/"$mybasename".exe ~/bin/"
        cp ./release/$mybasename".exe" ~/bin/
      fi
    else
      echo $myprofile", "$mytypestr": FAIL (executable not found)" >> ../$mytempfile
      #echo "FAIL for mybasename: "$mybasename
    fi

    #Cleaning up
    rm Makefile
    rm Makefile.*
    rm -r release
    rm -r debug
    rm ui_*.h
    rm qrc_*.cpp
    rm moc_*.cpp
    rm object_script*.*
    rm *.o
    rm *_plugin_import.cpp


  done #next type

done #next profile

cat $mytempfile

rm $mytempfile

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml