-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathCPP_CodeBlock.class.php
More file actions
113 lines (85 loc) · 2.49 KB
/
CPP_CodeBlock.class.php
File metadata and controls
113 lines (85 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* @desc An intermediary to collect and parse all of the information for a block
*/
class CPP_CodeBlock
{
// the type of code block
public $type;
// name of the block
public $name;
// all fields found
public $fields;
// the code between this block and the next
public $code;
// raw data
public $raw;
/**
* @desc Parse out our code block
*/
function __construct($data, $code)
{
//print $data;
$this->raw = $data . "\n" . $code;
// flatten out code lines
$code = str_replace("\n", "", $code);
$this->code= $code;
$lines = explode("\n", $data);
// if (preg_match("/\/\/\//", $lines[1]))
// var_dump($lines);
// print($lines[1] . "\n");
// look for type in line two
list($type, $name) = explode(":", $lines[1]);
$this->type = trim(substr($type, 3));
$this->name = trim($name);
/*if (preg_match("/Class/", $this->type))
{
print($this->type . ", " . $this->name . "\n");
print(chop($lines[1])."\n");
}*/
$lastkey = "";
$currentValue = "";
foreach($lines as $line)
{
$key = substr($line, 3, 17);
$value = substr($line, 20);
$key = trim($key);
$value = trim($value);
if(strstr($key, ":"))
{
if(!empty($currentKey))
{
$this->fields[$currentKey] = $currentValue;
$currentValue = "";
}
$currentKey = str_replace(":", "", $key);
}
$append = " ";
// append a newline if first letter is capital
if(strtoupper(substr($value, 0, 1)) == substr($value, 0, 1))
$append = "\n";
if(!strstr($value, '//'))
$currentValue .= $append . $value;
}
$this->fields[$currentKey] = $currentValue;
}
}
/*
//////////////////////////////////////////////////////////////////////////////////////////
// Virtual method: Create
//////////////////////////////////////////////////////////////////////////////////////////
// Description: Creates a Actor to be identical to another, by deep copy.
// Arguments: A reference to the Actor to deep copy.
// Return value: An error return value signaling sucess or any particular failure.
// Anything below 0 is an error signal.
virtual int Create(const Actor &reference);
becomes
//////////////////////////////////////////////////////////////////////////////////////////
// $type: $name
//////////////////////////////////////////////////////////////////////////////////////////
// $fields[Description]: $value
// $fields[Arguments]: $arguments
// $fields[Return value]: $return
$code
*/
?>