Пример #1
0
FixedSizeRecord DataStore::ConvertToFixedSize(Record const &rec) const
{
    FixedSizeRecord fsr;

    CopyString(fsr.stb,                 rec.GetFieldValue(Field::STB),        64);
    CopyString(fsr.title,               rec.GetFieldValue(Field::TITLE),      64);
    CopyString(fsr.provider,            rec.GetFieldValue(Field::PROVIDER),   64);
    CopyString(fsr.date,                rec.GetFieldValue(Field::DATE),       11);
    CopyValue (fsr.dollars, fsr.cents,  rec.GetFieldValue(Field::REV),       '.');
    CopyValue (fsr.hours, fsr.mins,     rec.GetFieldValue(Field::VIEW_TIME), ':');

    return fsr;
}
Пример #2
0
 Variant::Variant(const Variant& var)
 {
   Type = var.Type;
   Dimensions = var.Dimensions;
   _array = var.IsArray();
   CopyValue(Type, var.Value, this->Value);
 }
CFStringRef	CACFPreferences::CopyStringValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost)
{
	CFStringRef theAnswer = NULL;
	
	//	get the raw value
	CFPropertyListRef theRawValue = CopyValue(inKey, inCurrentUser, inCurrentHost);
	
	if(theRawValue != NULL)
	{
		//	get it's type ID and make sure it's a CFString
		CFTypeID theTypeID = CFGetTypeID(theRawValue);
		if(theTypeID == CFStringGetTypeID())
		{
			//	cast the value
			theAnswer = static_cast<CFStringRef>(theRawValue);
		}
		else
		{
			CFRelease(theRawValue);
			DebugMessage("CACFPreferences::CopyStringValue: not a CFString");
		}
	}
	
	return theAnswer;
}
Пример #4
0
amqp_table_t TableValueImpl::CopyTableInner(const amqp_table_t &table, amqp_pool_t &pool)
{
  amqp_table_t new_table;

  new_table.num_entries = table.num_entries;
  new_table.entries = (amqp_table_entry_t*)amqp_pool_alloc(&pool,
                                                           sizeof(amqp_table_entry_t)*table.num_entries);
  if (NULL == new_table.entries)
  {
    throw std::bad_alloc();
  }

  for (int i = 0; i < table.num_entries; ++i)
  {
    amqp_table_entry_t *entry = &new_table.entries[i];
    amqp_pool_alloc_bytes(&pool, table.entries[i].key.len, &entry->key);

    if (NULL == entry->key.bytes)
    {
      throw std::bad_alloc();
    }
    memcpy(entry->key.bytes, table.entries[i].key.bytes, entry->key.len);

    entry->value = CopyValue(table.entries[i].value, pool);
  }

  return new_table;
}
Пример #5
0
void exec_dup(script_env *sc)
{
    int iTop = sc->iTopIndex;
    CopyValue(&sc->stack[iTop], &sc->stack[iTop - 1]);
    ++sc->iTopIndex;
    return;
}
Пример #6
0
amqp_field_value_t TableValueImpl::CopyValue(const amqp_field_value_t value, amqp_pool_t &pool)
{
  amqp_field_value_t new_value = value;

  switch (value.kind)
  {
    case AMQP_FIELD_KIND_UTF8:
    case AMQP_FIELD_KIND_BYTES:
      amqp_pool_alloc_bytes(&pool, value.value.bytes.len, &new_value.value.bytes);
      memcpy(new_value.value.bytes.bytes, value.value.bytes.bytes, value.value.bytes.len);
      return new_value;
    case AMQP_FIELD_KIND_ARRAY:
    {
      new_value.value.array.entries = (amqp_field_value_t*)amqp_pool_alloc(&pool,
                                                                           sizeof(amqp_field_value_t)*value.value.array.num_entries);
      for (int i = 0; i < value.value.array.num_entries; ++i)
      {
        new_value.value.array.entries[i] = CopyValue(value.value.array.entries[i], pool);
      }
      return new_value;
    }
    case AMQP_FIELD_KIND_TABLE:
      new_value.value.table = CopyTableInner(value.value.table, pool);
      return new_value;
    default:
      return new_value;
  }

}
Пример #7
0
void exec_push(script_env *sc, PolyObject *Val)
{
    // Put the value into the current top index
    int top = sc->iTopIndex;
    CopyValue(&sc->stack[top], Val);
    sc->iTopIndex++;
}
Пример #8
0
static	void
_GetData(
	char *id,
	SessionData *session,
	SessionCtrl *ctrl)
{
	ValueStruct *v,*a;
	int size;

	if (session == NULL) {
		return;
	}
	if (ctrl->sysdbvals == NULL) {
		Warning("ctrl->sysdbvals is null");
		return;
	}
	a = GetRecordItem(ctrl->sysdbvals,"values");
	size = ValueArraySize(a);
	if (ctrl->size >= size) {
		if (ctrl->size == size) {
			Warning("GetDataAll SYSDBVALS_SIZE(%d) over",size);
		}
		ctrl->size += 1;
		return;
	}
	v = GetArrayItem(a,ctrl->size);
	if (v != NULL) {
		CopyValue(v,session->sysdbval);
	}
	ctrl->size += 1;
}
Пример #9
0
 Variant& Variant::operator= (const Variant& var)
 {
   Type = var.Type;
   Dimensions = var.Dimensions;
   _array = var.IsArray();
   CopyValue(Type, var.Value, this->Value);
   return *this;
 }
Пример #10
0
		Value::Value( const Value & p_Value )
		{
			// Always clear the old data
			Clear( );

			// Get this value's pointer
			Value * pValue = const_cast<Value *>( this );

			// Copy the value
			CopyValue( p_Value, *pValue );
		}
Пример #11
0
int GetVarValue(char const *str, Value *val, Var *locals, ParsePtr p)
{
    Var *v;

    /* Try searching local variables first */
    v = locals;
    while (v) {
	if (! StrinCmp(str, v->name, VAR_NAME_LEN))
	    return CopyValue(val, &v->v);
	v = v->next;
    }

    /* Global variable... mark expression as non-constant */
    if (p) p->nonconst_expr = 1;
    v=FindVar(str, 0);

    if (!v) {
	Eprint("%s: %s", ErrMsg[E_NOSUCH_VAR], str);
	return E_NOSUCH_VAR;
    }
    return CopyValue(val, &v->v);
}
Пример #12
0
		Value & Value::operator = ( const Value & p_Value )
		{
			// Always clear the old data
			Clear( );

			// Get this value's pointer
			Value * pValue = const_cast<Value *>( this );

			// Copy the value
			CopyValue( p_Value, *pValue );

			// Return this value.
			return *pValue;
		}
Пример #13
0
bool wxRegKey::Copy(wxRegKey& keyDst)
{
    bool ok = true;

    // copy all sub keys to the new location
    wxString strKey;
    long lIndex;
    bool bCont = GetFirstKey(strKey, lIndex);
    while ( ok && bCont ) {
        wxRegKey key(*this, strKey);
        wxString keyName;
        keyName << GetFullName(&keyDst) << REG_SEPARATOR << strKey;
        ok = key.Copy(keyName);

        if ( ok )
            bCont = GetNextKey(strKey, lIndex);
        else
            wxLogError(_("Failed to copy the registry subkey '%s' to '%s'."),
                   GetFullName(&key), keyName.c_str());

    }

    // copy all values
    wxString strVal;
    bCont = GetFirstValue(strVal, lIndex);
    while ( ok && bCont ) {
        ok = CopyValue(strVal, keyDst);

        if ( !ok ) {
            wxLogSysError(m_dwLastError,
                          _("Failed to copy registry value '%s'"),
                          strVal.c_str());
        }
        else {
            bCont = GetNextValue(strVal, lIndex);
        }
    }

    if ( !ok ) {
        wxLogError(_("Failed to copy the contents of registry key '%s' to '%s'."),
                   GetFullName(this), GetFullName(&keyDst));
    }

    return ok;
}
Пример #14
0
static uint16_t CopyHttpHeader(	uint8_t* pBuffer,
								uint32_t nDataLen)
{
	uint16_t nBytes = 0;

	nBytes += CopyStringP(&pBuffer, PSTR("HTTP/1.1 200 OK"));
	nBytes += CopyStringP(&pBuffer, PSTR("\r\n"));

	nBytes += CopyStringP(&pBuffer, PSTR("Content-Length:"));
	nBytes += CopyValue(&pBuffer, nDataLen);
	nBytes += CopyStringP(&pBuffer, PSTR("\r\n"));

	nBytes += CopyStringP(&pBuffer, PSTR("Content-Type:text/html\r\n"));
	nBytes += CopyStringP(&pBuffer, PSTR("Connection:close\r\n"));
	nBytes += CopyStringP(&pBuffer, PSTR("\r\n"));

	return nBytes;
}
Пример #15
0
static	void
GetData(
	GHashTable *hash,
	SessionCtrl *ctrl)
{
	ValueStruct *v;

	ctrl->rc = SESSION_CONTROL_NG;
	if (ctrl->sysdbval == NULL) {
		Warning("ctrl->sysdbval is NULL");
		return;
	}
	v = GetRecordItem(ctrl->sysdbval,"id");
	if ((ctrl->session = g_hash_table_lookup(hash,ValueToString(v,NULL))) == NULL) {
		return;
	}
	if (ctrl->sysdbval != NULL) {
		CopyValue(ctrl->sysdbval,ctrl->session->sysdbval);
	}
	ctrl->rc = SESSION_CONTROL_OK;
}
Пример #16
0
		void Value::Append( const Value & p_Value )
		{
			// The value is not a list, turn it into a list
			if( m_Type != Array || !m_Value.Array )
			{
				// Clear the old data first
				Clear( );

				m_Type = Array;
				m_Value.Array = new ValueVector;
			}

			// Create a new value
			Value * pValue = new Value;
				
			// Copy the value
			CopyValue( p_Value, *pValue );
	
			// Push the new value value to the vector.
			m_Value.Array->push_back( pValue );
		}
Пример #17
0
bool
wxRegKey::RenameValue(const wxString& szValueOld, const wxString& szValueNew)
{
    bool ok = true;
    if ( HasValue(szValueNew) ) {
        wxLogError(_("Registry value '%s' already exists."), szValueNew);

        ok = false;
    }

    if ( !ok ||
         !CopyValue(szValueOld, *this, szValueNew) ||
         !DeleteValue(szValueOld) ) {
        wxLogError(_("Failed to rename registry value '%s' to '%s'."),
                   szValueOld, szValueNew);

        return false;
    }

    return true;
}
Пример #18
0
void CtrlMemView::contextMenu(const QPoint &pos)
{
	QMenu menu(this);

	QAction *gotoDisAsm = new QAction(tr("Go to in &disasm"), this);
	//connect(gotoDisAsm, SIGNAL(triggered()), this, SLOT(GotoDisAsm()));
	menu.addAction(gotoDisAsm);

	menu.addSeparator();

	QAction *copyValue = new QAction(tr("&Copy value"), this);
	connect(copyValue, SIGNAL(triggered()), this, SLOT(CopyValue()));
	menu.addAction(copyValue);

	QAction *changeValue = new QAction(tr("C&hange value"), this);
	connect(changeValue, SIGNAL(triggered()), this, SLOT(Change()));
	menu.addAction(changeValue);

	QAction *dump = new QAction(tr("Dump..."), this);
	connect(dump, SIGNAL(triggered()), this, SLOT(Dump()));
	menu.addAction(dump);

	menu.exec( mapToGlobal(pos));
}
Пример #19
0
void CtrlRegisterList::contextMenu(const QPoint &pos)
{
	QMenu menu(this);

	QAction *gotoMemory = new QAction(tr("Go to in &memory view"), this);
	connect(gotoMemory, SIGNAL(triggered()), this, SLOT(GotoMemory()));
	menu.addAction(gotoMemory);

	QAction *gotoDisAsm = new QAction(tr("Go to in &disasm"), this);
	connect(gotoDisAsm, SIGNAL(triggered()), this, SLOT(GotoDisAsm()));
	menu.addAction(gotoDisAsm);

	menu.addSeparator();

	QAction *copyValue = new QAction(tr("&Copy value"), this);
	connect(copyValue, SIGNAL(triggered()), this, SLOT(CopyValue()));
	menu.addAction(copyValue);

	QAction *change = new QAction(tr("C&hange..."), this);
	connect(change, SIGNAL(triggered()), this, SLOT(Change()));
	menu.addAction(change);

	menu.exec( mapToGlobal(pos));
}
Пример #20
0
PolyObject exec_pop(script_env *sc)
{
    PolyObject Val;
    CopyValue(&Val, &sc->stack[--sc->iTopIndex]);
    return Val;
}
Пример #21
0
nsresult nsAbIPCCard::GetABCOMCardStruct(PRBool isUnicode, nsABCOMCardStruct * card)
{
    NS_ENSURE_ARG_POINTER(card);

    // If memset() call is missing, callers of MS COM nsSynchronizeAB() will
    // receive a different return code even if nsSynchronizeAB() return S_OK.
    memset(card, 0, sizeof(nsABCOMCardStruct));
    card->dwRecordId = mRecordId;
    card->dwCategoryId = mCategoryId;
    card->dwStatus = mStatus;
    card->addressToUse = CPalmSyncImp::nsUseABHomeAddressForPalmAddress(); // 0 == home, 1 == work
    PR_LOG(PALMSYNC, PR_LOG_DEBUG, ("nsAbIPCCard::GetABCOMCardStruct using %d\n", card->addressToUse));

    CopyValue(isUnicode, m_FirstName, &card->firstName);
    CopyValue(isUnicode, m_LastName, &card->lastName);
    CopyValue(isUnicode, m_DisplayName, &card->displayName);
    CopyValue(isUnicode, m_NickName, &card->nickName);
    CopyValue(isUnicode, m_PrimaryEmail, &card->primaryEmail);
    CopyValue(isUnicode, m_SecondEmail, &card->secondEmail);
    CopyValue(isUnicode, m_WorkPhone, &card->workPhone);
    CopyValue(isUnicode, m_HomePhone, &card->homePhone);
    CopyValue(isUnicode, m_FaxNumber, &card->faxNumber);
    CopyValue(isUnicode, m_PagerNumber, &card->pagerNumber);
    CopyValue(isUnicode, m_CellularNumber, &card->cellularNumber);
    // See if home address contains multiple lines.
    JoinHomeAndWorkAddresses(isUnicode, card);
    CopyValue(isUnicode, m_HomeCity, &card->homeCity);
    CopyValue(isUnicode, m_HomeState, &card->homeState);
    CopyValue(isUnicode, m_HomeZipCode, &card->homeZipCode);
    CopyValue(isUnicode, m_HomeCountry, &card->homeCountry);
    CopyValue(isUnicode, m_WorkCity, &card->workCity);
    CopyValue(isUnicode, m_WorkState, &card->workState);
    CopyValue(isUnicode, m_WorkZipCode, &card->workZipCode);
    CopyValue(isUnicode, m_WorkCountry, &card->workCountry);
    CopyValue(isUnicode, m_JobTitle, &card->jobTitle);
    CopyValue(isUnicode, m_Department, &card->department);
    CopyValue(isUnicode, m_Company, &card->company);
    CopyValue(isUnicode, m_WebPage1, &card->webPage1);
    CopyValue(isUnicode, m_WebPage2, &card->webPage2);
    CopyValue(isUnicode, m_BirthYear, &card->birthYear);
    CopyValue(isUnicode, m_BirthMonth, &card->birthMonth);
    CopyValue(isUnicode, m_BirthDay, &card->birthDay);
    CopyValue(isUnicode, m_Custom1, &card->custom1);
    CopyValue(isUnicode, m_Custom2, &card->custom2);
    CopyValue(isUnicode, m_Custom3, &card->custom3);
    CopyValue(isUnicode, m_Custom4, &card->custom4);
    CopyValue(isUnicode, m_Note, &card->notes);

    card->lastModifiedDate = m_LastModDate;
    card->preferMailFormat = m_PreferMailFormat;
    card->addressToUse = CPalmSyncImp::nsUseABHomeAddressForPalmAddress(); // 0 == home, 1 == work
    if (CPalmSyncImp::nsPreferABHomePhoneForPalmPhone())
      card->preferredPhoneNum = (m_HomePhone.IsEmpty()) ? (m_WorkPhone.IsEmpty() ? 4 : 1) : 2;
    else
      card->preferredPhoneNum = (m_WorkPhone.IsEmpty()) ? 2 : (m_WorkPhone.IsEmpty() ? 4 : 1);
    card->isMailList = m_IsMailList;
    // Can't use ToNewCString() call here becasue MSCOM will complaint about
    // memory deallocation (ie, NdrPointerFree()) use CoTaskMemAlloc() instead.
    if (m_MailListURI.IsEmpty())
      card->mailListURI = NULL;
    else
    {
      PRInt32 length = m_MailListURI.Length()+1;
      char * str = (char *) CoTaskMemAlloc(sizeof(char) * length);
      strncpy(str, m_MailListURI.get(), length-1);
      str[length-1] = '\0';
      card->mailListURI = str;
    }

    return NS_OK;
}
Пример #22
0
static void CopyValuebyName(ValueStruct *to, char *to_name, ValueStruct *from,
                            char *from_name) {
  CopyValue(GetItemLongName(to, to_name), GetItemLongName(from, from_name));
}
Пример #23
0
		// Private functions
		void Value::CopyValue( const Value & p_From, Value & p_To ) const
		{
			// Set the type
			p_To.m_Type = p_From.m_Type;
			
			// Set the data
			switch( p_From.m_Type )
			{
				case Number:
				{
					p_To.m_Type = Number;
					p_To.m_IntegerFlag = p_From.m_IntegerFlag;

					if( p_From.m_IntegerFlag )
					{
						p_To.m_Value.Integer = p_From.m_Value.Integer;
					}
					else
					{
						p_To.m_Value.FloatingPoint = p_From.m_Value.FloatingPoint;
					}					
				}
				break;
				case String:
				{
					// Make sure that the string is valid.
					if( !p_From.m_Value.String )
					{
						p_To.m_Type = Null;
						break;
					}

					p_To.m_Type = String;
					p_To.m_Value.String = new std::string;
					p_To.m_Value.String->reserve( p_From.m_Value.String->size( ) );
					p_To.m_Value.String->append( *p_From.m_Value.String );
					
				}
				break;
				
				case Boolean:
				{
					p_To.m_Type = Boolean;
					p_To.m_Value.Boolean = p_From.m_Value.Boolean;
				}
				break;
				
				case Array:
				{
					// Make sure that the array is valid.
					if( !p_From.m_Value.Array )
					{
						p_To.m_Type = Null;
						break;
					}

					p_To.m_Type = Array;
					p_To.m_Value.Array = new ValueVector;

					// Go throguh all the values in the array, and make copies of them.
					for( ValueVector::iterator it = p_From.m_Value.Array->begin( ); it != p_From.m_Value.Array->end( ); it++ )
					{
						// Create a new value
						Value * pValue = new Value( );

						// Copy the value
						CopyValue( *(*(it)), * pValue );

						// Add the new value to the target array
						p_To.m_Value.Array->push_back( pValue );
					}
					
				}
				break;
				case Object:
				{
					// Make sure that the object is valid.
					if( !p_From.m_Value.Object )
					{
						p_To.m_Type = Null;
						break;
					}
					p_To.m_Type = Object;
					p_To.m_Value.Object = new ValueMap;

					// Go throguh all the values in the object, and make copies of them.
					for( ValueMap::iterator it = p_From.m_Value.Object->begin( ); it != p_From.m_Value.Object->end( ); it++ )
					{
						// Create a new value
						Value * pValue = new Value( );

						// Copy the value
						CopyValue( *(it->second), * pValue );

						// Add the new value to the target object
						(*p_To.m_Value.Object)[ it->first ] = pValue;
					}
				}
				break;
				default: // Null value
				{
					p_To.m_Type = Null;
				}
				break;
			}
		}
Пример #24
0
// Default implementation for RFX functions
void CDaoFieldExchange::Default(LPCTSTR lpszName, void* pv,
	DWORD dwColumnType, DWORD dwBindOptions)
{
	switch (m_nOperation)
	{
	case AddToParameterList:
		if (m_nParam != 1)
			m_prs->m_strSQL += ",";
		m_prs->m_strSQL += lpszName;
		AppendParamType(m_prs->m_strSQL, dwColumnType);
		return;

	case AddToSelectList:
		if (m_nField != 1)
			m_prs->m_strSQL += ",";
		m_prs->m_strSQL += lpszName;
		return;

	case BindField:
		{
			// Query parser needs "[" & "]", GetRows can't tolerate them.
			LPTSTR lpszNoBracketName = new TCHAR[lstrlen(lpszName) + 1];
			m_prs->StripBrackets(lpszName, lpszNoBracketName);

			// Finish setting up column binding info struct
			LPDAOCOLUMNBINDING pcb =
				&m_prs->m_prgDaoColBindInfo[m_nField-1];
			pcb->cbInfoOffset =
				(DWORD)&m_prs->m_pulColumnLengths[m_nField-1];
#ifndef _UNICODE
			pcb->columnID.dwKind = DAOCOLKIND_STR;
			pcb->columnID.lpstr = lpszNoBracketName;
#else
			pcb->columnID.dwKind = DAOCOLKIND_WSTR;
			pcb->columnID.lpwstr = lpszNoBracketName;
#endif

			// Setup the field index map (and store value as void ptr)
			m_prs->m_pMapFieldIndex->SetAt(pv, (void*)m_nField);
		}
		return;

	case BindParam:
		{
			COleVariant* pvar = NULL;

			TRY
			{
				// NULL params not supported, use IS NULL in SQL
				// (i.e. - m_strFilter = _T("Foo IS NULL");
				FillVariant(pv, dwColumnType, &pvar);
				m_prs->m_pQueryDef->SetParamValue(lpszName, *pvar);
			}
			CATCH_ALL(e)
			{
				if (pvar != NULL)
					pvar->Clear();
				delete pvar;
				pvar = NULL;
				THROW_LAST();
			}
			END_CATCH_ALL

			pvar->Clear();
			delete pvar;
			pvar = NULL;
		}
		return;

	case Fixup:
		if (m_prs->GetFieldLength(m_nField-1) == DAO_NULL)
		{
			// Set the value to PSEUDO NULL and mark the status NULL
			SetNullValue(pv, dwColumnType);
			m_prs->SetNullFieldStatus(m_nField-1);
		}
		return;

	case AllocCache:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			CDaoFieldCache* pCache;

			// Allocate new storage and add to map
			AllocCacheValue(pCache, dwColumnType);
			m_prs->m_pMapFieldCache->SetAt(pv, pCache);
		}
		return;

	case StoreField:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			CDaoFieldCache* pCache = GetCacheValue(m_prs, pv);

			// Copy the data to the cache
			if (dwBindOptions & AFX_DAO_CACHE_BY_VALUE)
				CopyValue(pv, (void*)&pCache->m_pvData, dwColumnType);
			else
				CopyValue(pv, pCache->m_pvData, dwColumnType);

			// Cache the NULL status
			if (m_prs->IsFieldStatusNull(m_nField-1))
				pCache->m_nStatus |= AFX_DAO_FIELD_FLAG_NULL;
			else
				pCache->m_nStatus &= ~AFX_DAO_FIELD_FLAG_NULL;
		}
		return;

	case LoadField:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			CDaoFieldCache* pCache = GetCacheValue(m_prs, pv);

			// Copy the data from the cache
			if (dwBindOptions & AFX_DAO_CACHE_BY_VALUE)
				CopyValue((void*)&pCache->m_pvData, pv, dwColumnType);
			else
				CopyValue(pCache->m_pvData, pv, dwColumnType);

			// Set the NULL status from the cache
			if (pCache->m_nStatus & AFX_DAO_FIELD_FLAG_NULL)
				m_prs->SetNullFieldStatus(m_nField-1);
			else
				m_prs->ClearNullFieldStatus(m_nField-1);
		}
		return;

	case SetFieldNull:
		// Setting field NOT NULL doesn't require field exchange
		if ((m_pvField == NULL && m_nFieldType == outputColumn)
			|| m_pvField == pv)
		{
			SetNullValue(pv, dwColumnType);

			// Also set the status array if not a parameter
			if (m_nFieldType == outputColumn)
				m_prs->SetNullFieldStatus(m_nField-1);

#ifdef _DEBUG
			m_nFieldFound = m_nField;
#endif
		}
		return;

	case MarkForAddNew:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			// Don't need to do anything if field marked dirty
			if (!m_prs->IsFieldStatusDirty(m_nField-1))
			{
				// Mark dirty & not NULL if not set to pseudo NULL value
				if (!IsNullValue(pv, dwColumnType))
				{
					m_prs->SetDirtyFieldStatus(m_nField-1);
					m_prs->ClearNullFieldStatus(m_nField-1);
				}
			}
		}
		return;

	case MarkForEdit:
		if (dwBindOptions & AFX_DAO_ENABLE_FIELD_CACHE)
		{
			// If value not pseudo NULL value, clear NULL status
			if (!IsNullValue(pv, dwColumnType))
				m_prs->ClearNullFieldStatus(m_nField-1);

			// If field already marked dirty, don't need to check cache
			if (!m_prs->IsFieldStatusDirty(m_nField-1))
			{
				CDaoFieldCache* pCache = GetCacheValue(m_prs, pv);

				BOOL bNullField = m_prs->IsFieldStatusNull(m_nField-1);
				BOOL bNullCache = pCache->m_nStatus & AFX_DAO_FIELD_FLAG_NULL;

				void* pvData;
				if (dwBindOptions & AFX_DAO_CACHE_BY_VALUE)
					pvData = &pCache->m_pvData;
				else
					pvData = pCache->m_pvData;

				// Mark dirty if NULL status differs or value differs
				if ( (bNullCache && !bNullField) ||
					(!bNullCache && bNullField) ||
					CompareValue(pv, pvData, dwColumnType))
				{
					m_prs->SetDirtyFieldStatus(m_nField-1);
				}
			}
		}
		return;

	case SetDirtyField:
		if (m_prs->IsFieldStatusDirty(m_nField-1))
		{
			COleVariant* pvar = NULL;

			TRY
			{
				// If field is NULL don't set the value
				if (!m_prs->IsFieldStatusNull(m_nField-1))
					FillVariant(pv, dwColumnType, &pvar);
				else
				{
					pvar = new COleVariant;
					pvar->vt = VT_NULL;
				}

				// SetFieldValue (put_Collect) doesn't like brackets
				// Assumes no brackets if first char not a bracket
				LPTSTR lpszModifiedName = NULL;
				if (*lpszName == '[')
				{
					lpszModifiedName = new TCHAR[_tcslen(lpszName) + 1];

					// Copy the name with no brackets, and reset lpszName
					m_prs->StripBrackets(lpszName, lpszModifiedName);
					lpszName = lpszModifiedName;
				}

				m_prs->SetFieldValue(lpszName, *pvar);
				delete lpszModifiedName;
			}
			CATCH_ALL(e)
			{
				if (pvar != NULL)
					pvar->Clear();
				delete pvar;
				pvar = NULL;
				THROW_LAST();
			}
			END_CATCH_ALL

			pvar->Clear();
			delete pvar;
			pvar = NULL;
		}
		return;

	default:
		ASSERT(FALSE);
		return;
	}
Пример #25
0
void calculate_expression(Expression *e)
{
    int d,i;
    ces->tos=0;
    expr_stack();
    while (e) {
	d=e->delta;
	switch (e->type) {
	case ArgType:
	    ces->vl[ces->tos]=get_value(e->val.arg);
	    if (e->restype) ces->tos++;
	    ces->tos+=d;
	    break;
	case LazyType:
	    {
		LazyExpression *le;
		ces->vl[ces->tos]=ces->tv+ces->tos;
		/* when will this be freed? */
		le=ces->tv[ces->tos].val.stval=malloc(sizeof(LazyExpression));
		le->expr=e->val.le;
		le->vlist=get_local_values(&le->len);
		ces->tv[ces->tos].type=e->restype;
		if (e->restype) ces->tos++;
	    }
	    break;
	case OpType:
	    if (e->delta==-1 && !e->val.op && e->restype) {
		/* dereference last element on stack */
		if (IsRef(ces->vl[ces->tos-1]->type)) {
		    ces->tv[ces->tos-1].type=e->restype;
		} else {
		    ces->tv[ces->tos-1].type=ces->vl[ces->tos-1]->type;
		}
		/* copy value */
		CopyValue(&(ces->tv[ces->tos-1]),ces->vl[ces->tos-1]);
		break;
	    }
	case IntFuncType:
	    if (e->restype) {
		ces->vl[ces->tos]=ces->tv+ces->tos;
		ces->tv[ces->tos].type=e->restype;
		ConstructValue(&(ces->tv[ces->tos]));
	    }
#ifdef DEBUG
	    printf("Calling function %p\n", e->val.ifunc);
#endif
	    call_function(e->val.ifunc, ces->vl+(ces->tos+e->delta));
	    /* clean up temporary values */
	    for (i=-1; i>=e->delta; i--) {
	      if (ces->vl[ces->tos+i]== &(ces->tv[ces->tos+i])) {
		DestructValue(&(ces->tv[ces->tos+i]));
	      }
	    }
	    /* move result */
	    if (e->restype) {
		ces->vl[ces->tos+d]=ces->tv+(ces->tos+d);
		ces->tv[ces->tos+d]=ces->tv[ces->tos];
		ces->tos++;
	    }
	    ces->tos+=d;
	    break;
	case UserFuncType:
	    if (e->restype) {
		ces->vl[ces->tos]=ces->tv+ces->tos;
		ces->tv[ces->tos].type=e->restype;
		ConstructValue(&(ces->tv[ces->tos]));
	    }
#ifdef DEBUG
	    printf("Calling user function %p\n", e->val.ufunc);
#endif
	    call_user_function(e->val.ufunc, ces->vl+(ces->tos+d));
	    /* clean up temporary values */
	    for (i=-1; i>=e->delta; i--) {
	      if (ces->vl[ces->tos+i]== &(ces->tv[ces->tos+i])) {
		DestructValue(&(ces->tv[ces->tos+i]));
	      }
	    }
	    /* move result */
	    if (e->restype) {
		ces->vl[ces->tos+d]=ces->tv+(ces->tos+d);
		ces->tv[ces->tos+d]=ces->tv[ces->tos];
		ces->tos++;
	    }
	    ces->tos+=d;
	    break;
	default:
	    break;
	}
	expr_stack();
	e=e->next;
    }
}
Пример #26
0
		// Private functions
		void Value::CopyValue( const Value & p_From, Value & p_To ) const
		{
			// Set the type
			p_To.m_Type = p_From.m_Type;
			
			// Set the data
			switch( p_From.m_Type )
			{
				case Integer:
				{
					p_To.m_Type = Integer;
					p_To.m_Value.Integer = p_From.m_Value.Integer;
				}
				break;
				case String:
				{
					// Make sure that the string is valid.
					if( !p_From.m_Value.String )
					{
						p_To.m_Type = Nil;
						break;
					}

					p_To.m_Type = String;
					p_To.m_Value.String = new std::string;
					p_To.m_Value.String->reserve( p_From.m_Value.String->size( ) );
					p_To.m_Value.String->append( *p_From.m_Value.String );
					
				}
				break;
				case List:
				{
					// Make sure that the list is valid.
					if( !p_From.m_Value.List )
					{
						p_To.m_Type = Nil;
						break;
					}

					p_To.m_Type = List;
					p_To.m_Value.List = new ValueVector;

					// Go throguh all the values in the list, and make copies of them.
					for( ValueVector::iterator it = p_From.m_Value.List->begin( ); it != p_From.m_Value.List->end( ); it++ )
					{
						// Create a new value
						Value * pValue = new Value( );

						// Copy the value
						CopyValue( *(*(it)), * pValue );

						// Add the new value to the target list
						p_To.m_Value.List->push_back( pValue );
					}
					
				}
				break;
				case Dictionary:
				{
					// Make sure that the dictionary is valid.
					if( !p_From.m_Value.Dictionary )
					{
						p_To.m_Type = Nil;
						break;
					}
					p_To.m_Type = Dictionary;
					p_To.m_Value.Dictionary = new ValueMap;

					// Go throguh all the values in the dictionary, and make copies of them.
					for( ValueMap::iterator it = p_From.m_Value.Dictionary->begin( ); it != p_From.m_Value.Dictionary->end( ); it++ )
					{
						// Create a new value
						Value * pValue = new Value( );

						// Copy the value
						CopyValue( *(it->second), * pValue );

						// Add the new value to the target dictionary
						(*p_To.m_Value.Dictionary)[ it->first ] = pValue;
					}
				}
				break;
				default: // Nil value
				{
					p_To.m_Type = Nil;
				}
				break;
			}
		}