#pragma once // Since this is example code that should be buildable outside the // Salmon baseline, it is possible (but perhaps not desirable) // to not use the full include path but instead rely on the // compiler having -I directives for all public header directories, // and to pick up local headers from the current directory. // So, we can include Api files as either // #include // #include // and local includes can be either // #include // #include "SOMETHING.h" // Using the Salmon convention does have its benefits, // as it allows more verification in the deploy scripts. #include #include template class Buffer { public: typedef T value_type; typedef int size_type; Buffer(size_type n = 0) : addr((n > 0)?new value_type[n]:0) { } ~Buffer() { if (addr != 0) { delete[] addr; } } value_type* get() { return addr; } const value_type* get() const { return addr; } value_type& operator[](size_type i) { return addr[i]; } const value_type& operator[](size_type i) const { return addr[i]; } private: value_type* addr; Buffer(const Buffer&); Buffer& operator=(const Buffer&); }; inline std::string StdStr(const Slb::Salmon::Zgy::ZgyApi::SimpleString& s) { const Buffer::size_type bufsize(s.size() + 1); Buffer buf(bufsize); return std::string((s.getCstr(buf.get(), bufsize) < bufsize)?"":buf.get()); } inline bool operator==(const Slb::Salmon::Zgy::ZgyApi::SimpleString& a, const Slb::Salmon::Zgy::ZgyApi::SimpleString& b) { return StdStr(a) == StdStr(b); } template inline Stream& operator<<(Stream& stream, const Slb::Salmon::Zgy::ZgyApi::SimpleString& s) { return stream << StdStr(s); }