|
1 /* |
|
2 * Copyright (c) 2009 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 using System; |
|
18 using System.Collections.Generic; |
|
19 using System.Text; |
|
20 using CrashItemLib.Crash.Symbols; |
|
21 using SymbianStructuresLib.Debug.Symbols; |
|
22 |
|
23 namespace CrashInfoFilePlugin.PluginImplementations.FileFormat |
|
24 { |
|
25 static class CCrashInfoFileUtilities |
|
26 { |
|
27 public static bool IsSymbolSerializable(CISymbol aSymbol) |
|
28 { |
|
29 bool ret = true; |
|
30 // |
|
31 if (aSymbol.IsNull) |
|
32 { |
|
33 ret = false; |
|
34 } |
|
35 else |
|
36 { |
|
37 TSymbolType type = aSymbol.Symbol.Type; |
|
38 ret = ( type != TSymbolType.EUnknown ); |
|
39 } |
|
40 return ret; |
|
41 } |
|
42 |
|
43 /** Write given value, if it exists, in tags to stream */ |
|
44 public static void WriteOutputTags(uint? aContent, string aTagText, System.IO.StreamWriter aOutput) |
|
45 { |
|
46 if (aContent.HasValue) |
|
47 { |
|
48 aOutput.Write(MakeOutputTags(aContent.Value.ToString(), aTagText)); |
|
49 } |
|
50 } |
|
51 |
|
52 /** Write given value, if it exists, in tags to stream */ |
|
53 public static void WriteOutputTags(int? aContent, string aTagText, System.IO.StreamWriter aOutput) |
|
54 { |
|
55 if (aContent.HasValue) |
|
56 { |
|
57 aOutput.Write(MakeOutputTags(aContent.Value.ToString(), aTagText)); |
|
58 } |
|
59 } |
|
60 |
|
61 /** Write given value, if it exists, in tags to stream */ |
|
62 public static void WriteOutputTags(ulong? aContent, string aTagText, System.IO.StreamWriter aOutput) |
|
63 { |
|
64 if (aContent.HasValue) |
|
65 { |
|
66 aOutput.Write(MakeOutputTags(aContent.Value.ToString(), aTagText)); |
|
67 } |
|
68 } |
|
69 |
|
70 |
|
71 /** Write given string, if not empty, in tags to stream */ |
|
72 public static void WriteOutputTags(string aContent, string aTagText, System.IO.StreamWriter aOutput) |
|
73 { |
|
74 if (aContent != string.Empty) |
|
75 { |
|
76 aOutput.Write(MakeOutputTags(aContent, aTagText)); |
|
77 } |
|
78 } |
|
79 /** Return the parameter string enclosed in crashinfofile identifier tags */ |
|
80 public static string MakeOutputTags(string aContent, string aTagText) |
|
81 { |
|
82 string output = CCrashInfoFileUtilities.BlockStartMarker(aTagText); |
|
83 output += aContent; |
|
84 output += CCrashInfoFileUtilities.BlockEndMarker(aTagText); |
|
85 return output; |
|
86 } |
|
87 |
|
88 /** Return the parameter integer enclosed in crashinfofile identifier tags */ |
|
89 public static string MakeOutputTags(uint aContent, string aTagText) |
|
90 { |
|
91 return MakeOutputTags(aContent.ToString(), aTagText); |
|
92 } |
|
93 |
|
94 public static string BlockEndMarker(string aId) |
|
95 { |
|
96 return CrashInfoConsts.KCloseIdStart + aId + CrashInfoConsts.KCloseIdEnd + CrashInfoConsts.KEOL; |
|
97 } |
|
98 |
|
99 public static string BlockStartMarker(string aId) |
|
100 { |
|
101 return CrashInfoConsts.KNewIdStart + aId + CrashInfoConsts.KNewIdEnd; |
|
102 } |
|
103 } |
|
104 } |