-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathcom_String.js
More file actions
89 lines (73 loc) · 2.49 KB
/
com_String.js
File metadata and controls
89 lines (73 loc) · 2.49 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
/*
* Project Name : Visual Python
* Description : GUI-based Python code generator
* File Name : com_String.js
* Author : Black Logic
* Note : [CLASS] Make string
* License : GPLv3 (GNU General Public License v3.0)
* Date : 2021. 08. 14
* Change Date :
*/
//============================================================================
// [CLASS] Make string
//============================================================================
define ([
], function () {
'use strict';
//========================================================================
// [CLASS] com_String
//========================================================================
class com_String {
// constructor
constructor() {
this.buffer = new Array();
}
// Append string
append(str) {
this.buffer[this.buffer.length] = str;
}
// Append string & newline
appendLine(str) {
this.append((str == null ? '' : str) + '\n');
}
// Append format string: appendFormat('str_base {0} {1}','str0','str1')
appendFormat() {
var cnt = arguments.length;
if (cnt < 2)
return '';
var str = arguments[0];
for (var idx = 1; idx < cnt; idx++)
str = str.replace('{' + (idx - 1) + '}', arguments[idx]);
this.buffer[this.buffer.length] = str;
}
// Append format string & newline: appendFormatLine('str_base {0} {1}','str0','str1')
appendFormatLine() {
var cnt = arguments.length;
if (cnt < 2)
return '';
var str = arguments[0];
for (var idx = 1; idx < cnt; idx++)
str = str.replace('{' + (idx - 1) + '}', arguments[idx]);
this.buffer[this.buffer.length] = str + '\n';
}
// Replace string
replace(from, to) {
for (var i = this.buffer.length - 1; i >= 0; i--)
this.buffer[i] = this.buffer[i].replace(new RegExp(from, 'g'), to);
}
// Get string
toString() {
return this.buffer.join('');
}
// Clear string
clear() {
this.buffer = new Array();
}
// get Length
get length() {
return this.buffer.length;
}
}
return com_String;
}); /* function, define */
/* End of file */