Menu

[r11]: / trunk / SWFInvestigator / src / decompiler / Logging / StringWriter.as  Maximize  Restore  History

Download this file

128 lines (109 with data), 3.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/****************************************************************************
* ADOBE SYSTEMS INCORPORATED
* Copyright 2012 Adobe Systems Incorporated and it’s licensors
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file
* in accordance with the terms of the license agreement accompanying it.
* ****************************************************************************/
package decompiler.Logging {
import decompiler.Logging.ILog;
/**
* This is a class used by the decompiler to output data.
*/
final public class StringWriter implements ILog {
/**
* @public
* The String containing the output from the decompiler.
*/
public var output:String = "";
/**
* @public
* The STring containing the error output from the decompiler.
*/
public var errorOutput:String = "";
/**
* @public
* In the case of a long string, an array of strings can be used instead.
*/
public var outArray:Array = new Array();
/**
* @public
* How many characters per page in the text viewer
*/
public var wrapLength:uint = 75000;
/**
* @private
* The global defining whether to use a string or an array of Strings. The default is one string.
*/
private var outType:String = "String";
/**
* @private
* The current position within the array of output.
*/
private var currentIndex:int = 0;
/**
* @private
* Whether to keep errors seperate
*/
private var seperateErrors:Boolean;
/**
* @public
* Constructor
*
* @param diffErrors Whether to log errors seperately from the main stream
*/
public function StringWriter(outputType:String = "String", diffErrors:Boolean = true) {
this.outType = outputType;
this.seperateErrors = diffErrors;
}
/**
* @public
* The print function that acts as a callback for the decompiler. This will write information to a string and/or Array.
*
* @param rest A ... rest list of things to print to the desired location.
*/
public function print( ... rest ):void
{
var prepend:String = "";
if (rest.length == 0) {
return;
}
if (outType == "Array") {
if (this.outArray.length == 0) {
this.outArray.push(new String());
} else if (this.outArray[currentIndex].length >= this.wrapLength) {
this.outArray.push(new String());
this.currentIndex++;
}
}
if (outType == "Array") {
this.outArray[currentIndex] += prepend + rest;
} else {
this.output += prepend + rest;
}
}
/**
* @public
* Store errors separetly?
*
* @param ... The strings to save
*/
public function errorPrint (... rest):void {
if (this.seperateErrors) {
this.errorOutput += rest + "\r";
} else {
this.print(rest);
}
}
/**
* @public
* Clear previous strings for re-use
*/
public function clear():void {
this.errorOutput = "";
this.output = "";
this.outArray = [];
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.