source: trunk/stoposzztostr.cpp

Last change on this file was 7, checked in by willem, 11 years ago

willem

File size: 1.3 KB
RevLine 
[7]1
2/*
3   Copyright 2013 Willem Vermin, SURFsara
4
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   You may obtain a copy of the License at
8
9       http://www.apache.org/licenses/LICENSE-2.0
10
11   Unless required by applicable law or agreed to in writing, software
12   distributed under the License is distributed on an "AS IS" BASIS,
13   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   See the License for the specific language governing permissions and
15   limitations under the License.
16 */
17#include <iostream>
18#include <string>
19#include "wutils.h"
20int main()
21{
22  size_t p,q;
23  size_t size_begin = ZBEGIN_.size();
24  size_t size_end   = ZEND_.size();
25  std::string line;
26
27  while(std::getline(std::cin,line))
28  {
29    p = 0;
30    q = 0;
31    while(1)
32    {
33      q = line.find(ZBEGIN_,p);
34      std::cout <<line.substr(p,q-p);
35      //std::cout <<__LINE__<<":"<<line.substr(p,q-p)<<std::endl;
36      if ( q == line.npos)
37        break;
38      else
39      {
40        p = q;
41        q = line.find(ZEND_,p+size_begin);
42        if (q == line.npos)
43        {
44          std::cout <<line.substr(p);
45          break;
46        }
47        else
48        {
49          std::cout <<zhextostr(line.substr(p,q-p+size_end));
50          p = q+size_end;
51        }
52      }
53    }
54    std::cout << std::endl;
55  }
56}
Note: See TracBrowser for help on using the repository browser.