equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "LayoutCompilerErr.h" |
|
22 #include <iostream> |
|
23 #include <algorithm> |
|
24 #include <string> |
|
25 using namespace std; |
|
26 |
|
27 void NotFoundErr::Show(ostream& stream) const |
|
28 { |
|
29 stream << iName << " not found" << endl; |
|
30 } |
|
31 |
|
32 void GeneralErr::Show(ostream& stream) const |
|
33 { |
|
34 stream << iMessage << endl; |
|
35 } |
|
36 |
|
37 string StreamLoc(const istream& aStream, const string& msg, int before, int after) |
|
38 { |
|
39 string out; |
|
40 istream stream(aStream.rdbuf()); |
|
41 int pos = stream.tellg(); |
|
42 #ifdef __VC32__ |
|
43 int start = _MAX(0, pos-before); |
|
44 #else |
|
45 int start = max(0, pos-before); |
|
46 #endif |
|
47 stream.seekg(start); |
|
48 bool record = (start==0); |
|
49 for (int i=0; i<(pos-start)+after; i++) |
|
50 { |
|
51 char ch = stream.get(); |
|
52 if (record) |
|
53 out.append(1,ch); |
|
54 if (ch == '\n' || ch == '\r') |
|
55 record = true; |
|
56 if (start+i == pos) |
|
57 out.append(msg); |
|
58 } |
|
59 return out; |
|
60 } |
|
61 |
|
62 // End of File |