void ArraySet::From( I_PacketRcv* inPacket, bool inBlock ) { argused1( inBlock ); // Destroy existing content first. InitSelf( 0 ); // 1) Allocated len. vuint32 allocLen = inPacket->get_ULongParam(); if( allocLen > 0 ) { InitSelf( allocLen / sizeof(REC_ID) ); // 2) Actual len. vuint32 actualLen = inPacket->get_ULongParam(); if( actualLen > 0) { // 3) BitSet's data. inPacket->get_BinaryParam( mpStart, actualLen ); mpFinish = mpStart + (actualLen / sizeof(REC_ID)); // 4) 'Sorted' flag. mIsSorted = inPacket->get_BoolParam(); } } }
int Value_money_null::Compare( const I_Value& inOther, COMPARE_TYPE inCompareType ) const { argused1( inCompareType ); FBL_CHECK( get_Type() == inOther.get_Type() ); // If one of values (this or inOther) have null... if( get_IsNull() ) { if( inOther.get_IsNull() ) return 0; // Both are NULL else return -1; // Any NULL is less then NOT NULL } else { if( inOther.get_IsNull() ) return 1; // Any NOT NULL is greater then NULL else { // ... have not null values - compare them. return Value_money::Compare( inOther ); } } }
void ArraySet::From( I_IStream_Ptr inStream, bool inBlock ) { argused1( inBlock ); // Destroy existing content first. InitSelf( 0 ); // 1) Allocated len. vuint32 allocLen; inStream->get( allocLen ); if( allocLen > 0 ) { InitSelf( allocLen / sizeof(REC_ID) ); // 2) Actual len. vuint32 actualLen; inStream->get(actualLen); if( actualLen > 0) { // 3) BitSet's data. inStream->get((vuint8*)mpStart, actualLen); mpFinish = mpStart + (actualLen / sizeof(REC_ID)); // 4) 'Sorted' flag. inStream->get( mIsSorted ); } } }
void Value_Raw::From( I_PacketRcv* inPacket, bool inBlock ) { argused1(inBlock); Clear(); bool IsNull = inPacket->get_BoolParam(); if( !IsNull ) { put_IsNull(false); vuint32 Len = inPacket->get_ULongParam(); Alloc(Len); if( Len > 0 ) { vuint32 Available = get_Allocated(); Available = Len > Available ? Available : Len; inPacket->get_BinaryParam(reinterpret_cast<void*>(m_pStart), Available); m_pEnd = m_pStart + Len; } } else { put_IsNull(true); } }
void Value_Raw::From( I_IStream_Ptr inStream, bool inBlock ) { argused1(inBlock); Clear(); bool IsNull; inStream->get(IsNull); if( !IsNull ) { put_IsNull(false); vuint32 Len; inStream->get(Len); Alloc(Len); if( Len > 0 ) { vuint32 Available = get_Allocated(); Available = Len > Available ? Available : Len; inStream->get(reinterpret_cast<void*>(m_pStart), Available); m_pEnd = m_pStart + Len; } } else { put_IsNull(true); } }
FBL_Begin_Namespace #pragma mark === Convert functions === /**********************************************************************************************/ void Convert_str_time_aa_fast( const char* inString, const DTFormat* inDTFormat, TimeEncoded& outTimeEnc ) { argused1( inDTFormat ); if( !inString || *inString == 0 ) { outTimeEnc.encoded = 0; return; } char c; short unsigned int h, mn, s, ms; /// time h = mn = s = ms = 0; sscanf( inString, "%hu%c%hu%c%hu%c%hu", &h, &c, &mn, &c, &s, &c, &ms ); outTimeEnc.decoded.h = h; outTimeEnc.decoded.m = mn; outTimeEnc.decoded.s = s; outTimeEnc.decoded.ms = ms; }
void Value_time_imp::put_String( const char* inStart, const char* inEnd ) { argused1( inEnd ); const DTFormat* pDTFormat = get_DTFormat(); Convert_str_time_aa_aux( inStart, pDTFormat, (TimeEncoded&)mValue ); put_IsNull( false ); }
I_Value* CreateValueVarBinary( bool inNullable, void* inParam1, void* inParam2 ) { argused1( inParam2 ); vuint32 MaxLen = inParam1 ? *reinterpret_cast<vuint32*>(inParam1) : 20; if( inNullable ) return new Value_varbinary_null( MaxLen, 0 ); else return new Value_varbinary( MaxLen, 0 ); }
void Thread_Posix::Wait( TThreadHandle inThreadHandles[], vuint32 inSize, vuint32 inTimeout ) { argused1(inTimeout); // check the array of descriptors FBL_CHECK(inThreadHandles); if( !inThreadHandles ) { return; } for( vuint32 i = 0; i < inSize; ++i) { int Result = 0; PTHREAD_API_CALL( ::pthread_join(inThreadHandles[i], &Result) ); argused1( Result ); } }
void Value_money_imp::put_String( const char* inStart, const char* inEnd ) { argused1( inEnd ); if( IsTrueStr( inStart ) ) mValue = 1; else put_Double( atof(inStart) ); put_IsNull(false); }
I_Value* CreateValueVarChar( bool inNullable, void* inParam1, void* inParam2 ) { argused1( inNullable ); tslen MaxLen = inParam1 ? *reinterpret_cast<tslen*>(inParam1) : kMaxLengthOfVarChar_UTF16; I_Localizable* pLocalizable = (I_Localizable*) inParam2; if( inNullable ) return new Value_varchar_null( MaxLen, pLocalizable ); else return new Value_varchar( MaxLen, pLocalizable ); }
I_Value* CreateValueText( bool inNullable, void* inParam1, void* inParam2 ) { argused1( inNullable ); I_Localizable* pLocalizable = (I_Localizable*) inParam2; Value_text_null* pv = new Value_text_null( pLocalizable ); // We return text value with a buffer of the required size. if( inParam1 ) pv->ResizeChars( *(vint32*) inParam1 ); return pv; }
I_File_Ptr CreateTextFile( I_Location_Ptr inLoc ) { #if TARGET_OS_IPHONE argused1( inLoc ); return nullptr; #else I_File_Ptr pF = PrepareTextFile( inLoc ); pF->Create(); return pF; #endif // TARGET_OS_IPHONE }
I_Value* CreateValueDateTime( bool inNullable, void* inParam1, void* inParam2 ) { argused1( inParam2 ); if( !inParam1 ) { // set default ? } I_Database* p = reinterpret_cast<I_Database*>(inParam1); if( inNullable ) return new Value_datetime_null( p ); else return new Value_datetime( p ); }
void Value_datetime_imp::put_String( const UChar* inStart, const UChar* inEnd ) { argused1( inEnd ); const DTFormat* pDTFormat = get_DTFormat(); Convert_str_datetime_uu_aux( inStart, inEnd, pDTFormat, (DateTimeEncoded&) mValue ); put_IsNull( false ); }
I_Location_Ptr Location_Disk_FSSpec::get_ChildLocation( const char* inName ) const { const FSSpec* curr = get_FSSpec(); vint32 DirID; bool IsDir; GetDirectoryID( curr->vRefNum, curr->parID, curr->name, &DirID, &IsDir ); Str255 pasName; c2pstrcpy(inName, pasName); FSSpec childSpec; OSErr err = FSMakeFSSpec( curr->vRefNum, DirID, pasName, &childSpec ); argused1(err); return new Location_Disk_FSSpec( &childSpec ); }
void Value_Raw::To( I_OStream_Ptr inStream, bool inBlock ) const { argused1(inBlock); bool IsNull = bool( m_pStart == nullptr ); inStream->put(IsNull); if( !IsNull ) { vuint32 Len = vuint32(m_pEnd - m_pStart); inStream->put(Len); if( Len ) { inStream->put(reinterpret_cast<void*>(m_pStart), Len); } } }
// TEMPORARY: should be replaced! at least on binary search by sorted array. // String TypeCode2String( VALUE_TYPE inType, const char inLocale[] ) { argused1(inLocale); vuint32 Count = sizeof(lTypeMap) / sizeof(Type2String_en_US); for( vuint32 i = 0; i < Count; ++i ) { if( inType == lTypeMap[i].Type ) return lTypeMap[i].Name; } //FBL_CHECK(false); // return String::sEmpty(); static String strName; strName.setUInt(inType); return strName; }
I_File_Ptr CreateOrOpenTextFile( I_Location_Ptr inLoc ) { #if TARGET_OS_IPHONE argused1( inLoc ); return nullptr; #else I_File_Ptr pF = PrepareTextFile( inLoc ); if( pF->get_Exists() ) pF->Open(); else pF->Create(); return pF; #endif // TARGET_OS_IPHONE }
void Value_Raw::To( I_PacketSnd* inPacket, bool inBlock ) const { argused1(inBlock); FixParamCount fixParamCount( inPacket ); bool IsNull = bool( m_pStart == nullptr ); inPacket->put_BoolParam(IsNull); if( !IsNull ) { vuint32 Len = vuint32(m_pEnd - m_pStart); inPacket->put_ULongParam(Len); if( Len ) { inPacket->put_BinaryParam(reinterpret_cast<void*>(m_pStart), Len); } } }
void ArraySet::To( I_PacketSnd* inPacket, bool inBlock ) const { argused1(inBlock); FixParamCount fixParamCount( inPacket ); // Type of set. inPacket->put_UCharParam(vuint8(1)); if( mpStart ) { vuint32 allocLen = static_cast<vuint32>((mpStorageEnd - mpStart) * sizeof(vuint32)); vuint32 actualLen = static_cast<vuint32>((mpFinish - mpStart) * sizeof(vuint32)); // 1) Allocated len (in bytes). inPacket->put_ULongParam(allocLen); if( actualLen > 0 ) { // 2) Actual len (in bytes). inPacket->put_ULongParam(actualLen); // 3) Data of actual len. inPacket->put_BinaryParam( mpStart, actualLen ); // 4) 'Sorted' flag. inPacket->put_BoolParam(mIsSorted); } else { inPacket->put_ULongParam(0UL); } } else { inPacket->put_ULongParam(0UL); } }
const String& Location_Disk_FSSpec::get_Path( void ) const { if( mpFullPath ) return *mpFullPath; char Path[1024]; #if FBL_MAC_MACHO OSErr err = gUseCarbon ? FSMakePath_Carbon( mFSSpec.vRefNum, mFSSpec.parID, mFSSpec.name, Path, 1024 ) : FSMakePath_FSRef ( mFSSpec.vRefNum, mFSSpec.parID, mFSSpec.name, Path, 1024 ); #else OSErr err = FSMakePath_Carbon( mFSSpec.vRefNum, mFSSpec.parID, mFSSpec.name, Path, 1024 ); #endif // FBL_MAC_MACHO argused1(err); String* ps = new String( Path ); mpFullPath = ps; return *mpFullPath; }
void ArraySet::To( I_OStream_Ptr inStream, bool inBlock ) const { argused1(inBlock); // Type of set. inStream->put(vuint8(1)); if( mpStart ) { vuint32 allocLen = static_cast<vuint32>((mpStorageEnd - mpStart) * sizeof(vuint32)); vuint32 actualLen = static_cast<vuint32>((mpFinish - mpStart) * sizeof(vuint32)); // 1) Allocated len (in bytes). inStream->put(allocLen); if( actualLen > 0 ) { // 2) Actual len (in bytes). inStream->put(actualLen); // 3) Data of actual len. inStream->put((vuint8*)mpStart, actualLen); // 4) 'Sorted' flag. inStream->put(mIsSorted); } else { inStream->put( vuint32(0) ); } } else { inStream->put( vuint32(0) ); } }
Thread_Posix::Thread_Posix( I_Task_Ptr inTask, long inFlags, long inPriority, size_t inStackSize ) : mExitCode(0), mTask(inTask) { argused1(inPriority); // determine whether we must suspend self on creation mSuspended = (inFlags & kCreateSuspended) != 0; // operation success code // int error = 0; // initialize the internal lock PTHREAD_API_CALL(::pthread_mutex_init(&mLock, NULL)); // use helper to spawn the thread spawn_pthread( mThrID, &thread_entry_point, (void*)this, 0, 0, inStackSize ); }
void Init_ValentinaDlls( bool inUseClientStrings ) { #if FBL_STATIC argused1( inUseClientStrings ); InitBackpointers(); #else // FBL_STATIC // Kernel-dll string-factory has priority. if( String::sFactory && inUseClientStrings ) return; // At first search for already loaded symbols // to avoid conflicts (different betas of vshared/vclient/vkernel) on dlopen InitBackpointers_PTR pfn_app_client = nullptr; InitBackpointers_PTR pfn_app_kernel = nullptr; UnixHandle hDLL = ::dlopen( nullptr, RTLD_NOW | RTLD_GLOBAL ); if( hDLL ) { pfn_app_kernel = (InitBackpointers_PTR) ::dlsym( hDLL, "InitBackpointersKernel" ); if( !pfn_app_kernel ) pfn_app_client = (InitBackpointers_PTR) ::dlsym( hDLL, "InitBackpointersClient" ); } InitBackpointers_PTR pfn = pfn_app_kernel; if( !pfn && inUseClientStrings ) pfn = pfn_app_client; // Need to dynamically load libraries if( !pfn ) { // VKERNEL if( !inUseClientStrings ) { hDLL = ::dlopen( GetKernelDllName(), RTLD_NOW | RTLD_LOCAL ); if( hDLL ) { pfn = (InitBackpointers_PTR) ::dlsym( hDLL, "InitBackpointersKernel" ); if( !pfn ) pfn = (InitBackpointers_PTR) ::dlsym( hDLL, "InitBackpointers" ); } } // VCLIENT if( !pfn ) { hDLL = ::dlopen( GetClientDllName(), RTLD_NOW | RTLD_LOCAL ); if( hDLL ) { pfn = (InitBackpointers_PTR) ::dlsym( hDLL, "InitBackpointersClient" ); if( !pfn ) pfn = (InitBackpointers_PTR) ::dlsym( hDLL, "InitBackpointers" ); } } } if( pfn ) pfn(); #endif // FBL_STATIC }
void Value_money_imp::put_Boolean( bool inValue ) { argused1(inValue); }
// TEMPORARY: should be replaced !!! // VALUE_TYPE String2TypeCode( const UChar* inTypeStr, const char inLocale[] ) { argused1(inLocale); if( !inTypeStr ) { return static_cast<VALUE_TYPE>(-1); } switch( *inTypeStr ) { case 'L': if( vu_strcmp(inTypeStr, "Long") == 0 ) { return kTypeLong; } else if( vu_strcmp(inTypeStr, "Long Long") == 0 ) { return kTypeLLong; } else if( vu_strcmp(inTypeStr, "Long Double") == 0 ) { return kTypeLDouble; } break; case 'S': if( vu_strcmp(inTypeStr, "Short") == 0 ) { return kTypeShort; } else if( vu_strcmp(inTypeStr, "String") == 0 ) { return kTypeString; } break; case 'U': if( vu_strcmp(inTypeStr, "Unsigned Short") == 0 ) { return kTypeUShort; } else if( vu_strcmp(inTypeStr, "Unsigned Medium") == 0 ) { return kTypeUMedium; } else if( vu_strcmp(inTypeStr, "Unsigned Long") == 0 ) { return kTypeULong; } else if( vu_strcmp(inTypeStr, "Unsigned Long Long") == 0 ) { return kTypeULLong; } break; case 'V': if( vu_strcmp(inTypeStr, "VarChar") == 0 ) { return kTypeVarChar; } else if( vu_strcmp(inTypeStr, "VarBinary") == 0 ) { return kTypeVarBinary; } else if( vu_strcmp(inTypeStr, "Variant") == 0 ) { return kTypeVariant; } break; case 'F': if( vu_strcmp(inTypeStr, "Float") == 0 ) { return kTypeFloat; } else if( vu_strcmp(inTypeStr, "Fixed Binary") == 0 ) { return kTypeFixedBinary; } break; case 'D': if( vu_strcmp(inTypeStr, "Date") == 0 ) { return kTypeDate; } else if( vu_strcmp(inTypeStr, "Double") == 0 ) { return kTypeDouble; } else if( vu_strcmp(inTypeStr, "DateTime") == 0 ) { return kTypeDateTime; } else if( vu_strcmp(inTypeStr, "Decimal") == 0 ) { return kTypeDecimal; } break; case 'T': if( vu_strcmp(inTypeStr, "Time") == 0 ) { return kTypeTime; } else if( vu_strcmp(inTypeStr, "Text") == 0 ) { return kTypeText; } else if( vu_strcmp(inTypeStr, "TimeStamp") == 0 ) { return kTypeTimeStamp; } break; case 'B': if( vu_strcmp(inTypeStr, "Boolean") == 0 ) { return kTypeBoolean; } else if( vu_strcmp(inTypeStr, "Byte") == 0 ) { return kTypeByte; } else if( vu_strcmp(inTypeStr, "BLOB") == 0 ) { return kTypeBLOB; } break; case 'O': if( vu_strcmp(inTypeStr, "ObjectPtr") == 0 ) { return kTypeObjectPtr; } else if( vu_strcmp(inTypeStr, "ObjectsPtr") == 0 ) { return kTypeObjectsPtr; } else if( vu_strcmp(inTypeStr, "OID") == 0 ) { return kTypeOID; } break; case 'E': if( vu_strcmp(inTypeStr, "Empty") == 0 ) { return kTypeEmpty; } else if( vu_strcmp(inTypeStr, "Enum") == 0 ) { return kTypeEnum; } else if( vu_strcmp(inTypeStr, "Enum8") == 0 ) { return kTypeEnum8; } else if( vu_strcmp(inTypeStr, "Enum16") == 0 ) { return kTypeEnum16; } break; case 'M': if( vu_strcmp(inTypeStr, "Medium") == 0 ) { return kTypeMedium; } else if( vu_strcmp(inTypeStr, "Money") == 0 ) { return kTypeMoney; } break; default: if( vu_strcmp(inTypeStr, "RecID") == 0 ) { return kTypeRecID; } else if( vu_strcmp(inTypeStr, "Picture") == 0 ) { return kTypePicture; } else if( vu_strcmp(inTypeStr, "Sound") == 0 ) { return kTypeSound; } break; } return static_cast<VALUE_TYPE>(-1); }
void Convert_time_date( const I_Value* inValue, I_Value* outValue ) { argused1( inValue ); outValue->put_Long(0); }