ww5 created page: build instructions authored by Wieselquist, William's avatar Wieselquist, William
```cpp
namespace scale{
bool isSameBuffer(int* a, int* b){
return a==b;
}
class Reader_Int{
private:
int *b_buffer;
Reader() : b_buffer(new int()){}
~Reader(){ delete b_buffer; }
public:
void read(std::istream& is){
is >> *b_buffer;
}
const int* buffer() const ( return b_buffer; }
void set_buffer(int* new_buffer){
if( !isSameBuffer(b_buffer,new_buffer) ){
delete b_buffer;
b_buffer=new_buffer;
}
}
};
}//end namespace scale
int main(){
scale::Reader_Int reader;
{
std::ofstream ofs("file.txt");
ofs << 7;
}
std::ifstream ifs("file.txt");
reader.read(ifs);
std::cout << *reader.buffer() << std::endl;
return 0;
}
//Note this could be generalized to a templated Reader.
template <typename T>
class Reader {
//contents
};
//Then it is natural to use these typedefs.
typedef Reader<int> Reader_Int;
typedef Reader<double> Reader_Dbl;
//This is preferable to defining IntReader, DoubleReader, etc., because Reader_Dbl, Reader_Int will be automatically sorted to show their relationship.
```
Basic ways of distinguishing word boundaries with ``<LWORD>=[a-z]+`` and ``<UWORD>=[A-Z][a-z]+``
* Camel case
* upper camel ``<UCAMEL>``=``<UWORD>+``, e.g. Nexus, HelloWorld, or MyGreatApi
......
......