//--------------------------------------------------------------------------------------------------------------------------------- // File: Utility.h // Contents: Utility functions used in Microsoft Driver for Node.js for SQL Server // // Copyright Microsoft Corporation and contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // // You may obtain a copy of the License at: // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //--------------------------------------------------------------------------------------------------------------------------------- #pragma once #include #include #include #include #include namespace mssql { using namespace std; using namespace v8; shared_ptr> js2u16(Local str); vector wstr2wcvec(const wstring & s); vector str2wcvec(const string & cs); string swcvec2str(vector &v, size_t l); string w2sqlc(const wstring & s); wstring s2ws(const string & s); wstring FromV8String(Local input); void encode_numeric_struct(double v, int precision, int upscale_limit, SQL_NUMERIC_STRUCT & numeric); double decode_numeric_struct(const SQL_NUMERIC_STRUCT & numeric); struct nodeTypeFactory { static const int64_t NANOSECONDS_PER_MS = 1000000; Isolate *isolate; nodeTypeFactory(); Local new_long(int64_t i) const; Local new_int32(int32_t i) const; Local new_int64(int64_t i) const; Local new_number() const; Local new_string(const char *cstr) const; Local new_string(const char *cstr, int size) const; Local new_array() const; Local new_array(int count) const; Local new_buffer(int size) const; Local error(const stringstream &full_error) const; Local error(const char* full_error) const; Local new_date() const; Local new_date(double milliseconds, int32_t nanoseconds_delta) const; Local global() const; Local null() const; Local undefined() const; void throwError(const char * err) const; }; }