rem: std::cout << out.utf8() << std::endl;
add: std::cout << out.data() << std::endl;
context: int addProperty( KCmdLineArgs *args ){  if ( args->count() != 3 ) {    std::cerr << "Usage: kode --add-property <class> <proprerty-type> "      << "<property-name>" << std::endl;    return 1;  }    QString className = args->arg( 0 );  QString type = args->arg( 1 );  QString name = args->arg( 2 );  kdDebug() << "Add property: class " << className << ": " << type << " " <<    name << endl;  QString headerFileName = className.lower() + ".h";    QFile headerFile( headerFileName );  if ( !headerFile.open( IO_ReadOnly ) ) {    std::cerr << "Unable to open file '" << headerFileName.utf8() << "'" <<      std::endl;    return 1;  }    QTextStream in( &headerFile );  enum State { FindClass, FindConstructor, FindProperties, FindPrivate,    FindVariables, Finish };  State state = FindClass;  QString accessor;  QString mutator;    QString out;    QString readAhead;    QString line;  while ( !( line = in.readLine() ).isNull() ) {//    std::cout << line.utf8() << std::endl;    kdDebug() << state << " LINE: " << line << endl;    QString readAheadPrevious = readAhead;    readAhead += line + "\n";//    out += line + "\n";    switch( state ) {      case FindClass://        if ( line.find( QRegExp( className ) ) >= 0 ) {        if ( line.find( QRegExp( "^\\s*class\\s+" + className ) ) >= 0 ) {          kdDebug() << "  FOUND CLASS" << endl;          state = FindConstructor;        }        break;      case FindConstructor:        if ( line.find( QRegExp( "^\\s*" + className + "\\s*\\(" ) ) >= 0 ) {          kdDebug() << "  FOUND CONSTRUCTOR" << endl;          out += readAhead;          readAhead = QString::null;          state = FindProperties;        }        break;      case FindProperties:        {          QRegExp re( "(\\w+)\\s*\\(" );          if ( re.search( line ) >= 0 ) {            QString function = re.cap( 1 ).lower();            if ( !function.isEmpty() ) {              kdDebug() << "Function: " << function << endl;              if ( function == className || function == "~" + className ) {                out += readAhead;                readAhead = QString::null;              } else {                if ( function.startsWith( "set" ) ) {                  mutator = function.mid( 3 );                  kdDebug() << "MUTATOR: " << mutator << endl;                } else {                  if ( function == mutator ) {                    accessor = function;                    kdDebug() << "ACCESSOR: " << accessor << endl;                    out += readAhead;                    readAhead = QString::null;                  } else {                    kdDebug() << "CREATE PROPERTY" << endl;                    out += readAheadPrevious;                    addPropertyFunctions( out, type, name );                    out += "\n";                    readAhead = line + "\n";                    state = FindPrivate;                  }                }              }            }          } else if ( line.find( QRegExp( "\\s*protected" ) ) >= 0 ) {            state = FindPrivate;          } else if ( line.find( QRegExp( "\\s*private" ) ) >= 0 ) {            if ( accessor.isEmpty() ) {              addPropertyFunctions( out, type, name );              out += readAhead;              readAhead = QString::null;              addPropertyVariable( out, type, name );              state = Finish;            } else {              if ( accessor == mutator ) {                out += readAheadPrevious;                addPropertyFunctions( out, type, name );                out += "\n";                out += line + "\n";                readAhead = QString::null;              }              state = FindVariables;            }          }        }        break;      case FindPrivate:        if ( line.find( QRegExp( "\\s*private" ) ) >= 0 ) {          if ( accessor.isEmpty() ) {            out += readAhead;            readAhead = QString::null;            addPropertyVariable( out, type, name );            state = Finish;          } else {            state = FindVariables;          }        }        break;      case FindVariables:        {          if ( line.find( "m" + accessor.lower(), 0, false ) >= 0 ) {            out += readAhead;            readAhead = QString::null;            addPropertyVariable( out, type, name );            state = Finish;          }        }        break;      case Finish:        break;    }  }  headerFile.close();  out += readAhead;  if ( args->isSet( "inplace" ) ) {    QString headerFileNameOut = headerFileName + ".kodeorig" ;    KProcess proc;    proc << "cp" << QFile::encodeName( headerFileName ) <<      QFile::encodeName( headerFileNameOut );        if ( !proc.start( KProcess::Block ) ) {      kdError() << "Copy failed" << endl;    } else {      kdDebug() << "Write to original file." << endl;      if ( !headerFile.open( IO_WriteOnly ) ) {        kdError() << "Unable to open file '" << headerFileName <<          "' for writing." << endl;        return 1;      }      QTextStream o( &headerFile );      o << out << endl;    }  } else {    std::cout << out.utf8() << std::endl;  }  return 0;}