-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathCPP_Class.class.php
More file actions
106 lines (91 loc) · 2.05 KB
/
CPP_Class.class.php
File metadata and controls
106 lines (91 loc) · 2.05 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
<?php
/**
* @desc This is actually better thought of a class to hold the contents of a header file
*/
class CPP_Class
{
public $name;
private $blocks;
function __construct($data)
{
// the first thing we do is split up the file into comment blocks
$lines = explode("\n", $data);
$commentBlocks = array();
$buffer = "";
$code = "";
$linecount = 0;
foreach($lines as $line)
{
// skip blank lines
if(strlen($line) == 1)
continue;
// Skip comments before the first proper comment line ///////////////
if ($linecount == 0 && !preg_match("/^\/\/\//", $line))
continue;
// if this line starts with //, add to current comment block
if(preg_match("/^\/\//", $line))
{
$buffer .= $line . "\n";
if(chop($line) == str_repeat('/', 90))
$linecount++;
}
// otherwise reset
else
{
// fill our code
$code .= $line;
// stop filling code and save block if we hit a semicolon or function start
if(preg_match("/[{;]/", $line))
{
// only save the block if we had two full comment lines (///////, etc)
if($linecount == 2)
$this->blocks[] = new CPP_CodeBlock($buffer, $code);
$linecount = 0;
$buffer = "";
$code = "";
}
}
}
}
/**
* @desc Get our class info
*/
function getClassBlock()
{
if(count($this->blocks) == 0)
return null;
foreach($this->blocks as $block)
{
/*
if (preg_match("/SettingsMan/", $block->name))
{
print("Searching for class block, found mention of: " . $block->name . "\n");
var_dump($this->blocks);
}
*/
if($block->type == "Class" ||
$block->type == "Abstract class" || $block->type == "Abstract Class" ||
$block->type == "Concrete class" || $block->type == "Concrete Class")
{
return $block;
}
}
}
function printClassBlock()
{
if(count($this->blocks) == 0)
return null;
foreach($this->blocks as $block)
{
print(".".$block->type." \t ".$block->name."\n");
}
}
/**
* @desc Get all of our blocks
*/
function getBlocks()
{
return $this->blocks;
}
}
?>