Changes to allow using STL vector class rather than home grown one.
[dyninst.git] / dyninstAPI / src / BPatch_sourceBlock.C
1 #define BPATCH_FILE
2
3 #include <stdio.h>
4 #include <iostream.h>
5 #include "BPatch_sourceBlock.h"
6
7 //constructor
8 BPatch_sourceBlock::BPatch_sourceBlock() 
9 {}
10
11 //constructor
12 BPatch_sourceBlock::BPatch_sourceBlock(BPatch_Set<unsigned short>& sln)
13         : sourceLines(sln) {}
14
15 //method to return vector of lines in the source block 
16 void 
17 BPatch_sourceBlock::getLines(BPatch_Vector<unsigned short>& lines){
18         unsigned short* elements = new unsigned short[sourceLines.size()];
19         sourceLines.elements(elements);
20         for(int i=0;i<sourceLines.size();i++)
21                 lines.push_back(elements[i]);
22         delete[] elements;
23 }
24
25 //print method 
26 ostream& operator<<(ostream& os,BPatch_sourceBlock& sb){
27         os << "{";
28         unsigned short* elements = new unsigned short[sb.sourceLines.size()];
29         sb.sourceLines.elements(elements);
30         for(int i=0;i<sb.sourceLines.size();i++)
31                 os << " " << elements[i];
32         delete[] elements;
33         os << " }\n";
34         return os;
35 }