// furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // Set up default timezone date_default_timezone_set('GMT'); // For non pear packaged versions use relative include path if (strpos('@php_bin@', '@php_bin') === 0) { set_include_path(__DIR__ . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR . get_include_path()); } // Disable strict errors for the compiler error_reporting(error_reporting() & ~E_STRICT); require_once 'DrSlump/Protobuf.php'; // Setup autoloader \DrSlump\Protobuf::autoload(); try { // Run the cli interface \DrSlump\Protobuf\Compiler\Cli::run(__FILE__); exit(0); } catch (Exception $e) { fputs(STDERR, (string) $e . PHP_EOL); exit(1); }
* Encodes a message using the default codec * * @static * @param \DrSlump\Protobuf\Message $message * @return string */ public static function encode(Protobuf\Message $message) { $codec = self::getCodec(); return $codec->encode($message); } /** * @static * @param String|Message $message * @param String $data * @return \DrSlump\Protobuf\Message */ public static function decode($message, $data) { if (is_string($message)) { $message = '\\' . ltrim($message, '\\'); $message = new $message(); } $codec = self::getCodec(); return $codec->decode($message, $data); } } // Register the autoloader automatically if not disabled via a constant if (!defined('DRSLUMP_PROTOBUF_AUTOLOAD') || DRSLUMP_PROTOBUF_AUTOLOAD) { Protobuf::autoload(); }