Ejemplo n.º 1
0
void TBValue::SetFromStringAuto(const char *str, SET set)
{
	if (!str)
		SetNull();
	else if (is_number_only(str))
	{
		if (is_number_float(str))
			SetFloat((float)atof(str));
		else
			SetInt(atoi(str));
	}
	else if (is_start_of_number(str) && contains_non_trailing_space(str))
	{
		// If the number has nontrailing space, we'll assume a list of numbers (example: "10 -4 3.5")
		SetNull();
		if (TBValueArray *arr = new TBValueArray)
		{
			TBStr tmpstr;
			char *s3;
			if (tmpstr.Set(str))
			{
				char * pch = strtok_r(tmpstr, ", ", &s3);
				while (pch)
				{
					if (TBValue *new_val = arr->AddValue())
						new_val->SetFromStringAuto(pch, SET_NEW_COPY);
					pch = strtok_r(NULL, ", ", &s3);
				}
			}
			SetArray(arr, SET_TAKE_OWNERSHIP);
		}
	}
	else if (*str == '[')
	{
		SetNull();
		if (TBValueArray *arr = new TBValueArray)
		{
			assert(!"not implemented! Split out the tokenizer code above!");
			SetArray(arr, SET_TAKE_OWNERSHIP);
		}
	}
	else
	{
		SetString(str, set);
		return;
	}
	// We didn't set as string, so we might need to deal with the passed in string data.
	if (set == SET_TAKE_OWNERSHIP)
	{
		// Delete the passed in data
		TBValue tmp;
		tmp.SetString(str, SET_TAKE_OWNERSHIP);
	}
}
Ejemplo n.º 2
0
TBValue::TBValue(TYPE type)
	: m_packed_init(0)
{
	switch (type)
	{
	case TYPE_NULL:
		SetNull();
		break;
	case TYPE_STRING:
		SetString("", SET_AS_STATIC);
		break;
	case TYPE_FLOAT:
		SetFloat(0);
		break;
	case TYPE_INT:
		SetInt(0);
		break;
	case TYPE_OBJECT:
		SetObject(nullptr);
		break;
	case TYPE_ARRAY:
		if (TBValueArray *arr = new TBValueArray())
			SetArray(arr, SET_TAKE_OWNERSHIP);
		break;
	default:
		assert(!"Not implemented!");
	};
}
Ejemplo n.º 3
0
void CHRBLK::SetValue(char *sp, uint len, int n)
  {
  char  *p = Chrp + n * Long;

#if defined(_DEBUG)
  if (Check && (signed)len > Long) {
    PGLOBAL& g = Global;
    strcpy(g->Message, MSG(SET_STR_TRUNC));
    longjmp(g->jumper[g->jump_level], Type);
    } // endif Check
#endif   // _DEBUG

  if (sp)
    memcpy(p, sp, min((unsigned)Long, len));

  if (Blanks) {
    // Suppress eventual ending zero and right fill with blanks
    for (register int i = len; i < Long; i++)
      p[i] = ' ';

  } else if ((signed)len < Long)
    p[len] = 0;

  SetNull(n, false);
  } // end of SetValue
// ctor
wxMysqlPreparedStatementParameter::wxMysqlPreparedStatementParameter(MYSQL_BIND* pBind)
 : wxDatabaseErrorReporter()
{
  m_pBind = pBind;
  // Default to NULL
  SetNull();
}
dng_tone_curve::dng_tone_curve ()

	:	fCoord ()

	{
	
	SetNull ();
	
	}
Ejemplo n.º 6
0
/* Restrict the match lengths so that they don't reach beyond index */
void RMF_bitpackLimitLengths(FL2_matchTable* const tbl, size_t const index)
{
    DEBUGLOG(5, "RMF_limitLengths : end %u, max length %u", (U32)index, RADIX_MAX_LENGTH);
    SetNull(index - 1);
    for (U32 length = 2; length < RADIX_MAX_LENGTH && length <= index; ++length) {
        U32 const link = tbl->table[index - length];
        if (link != RADIX_NULL_LINK)
            tbl->table[index - length] = (MIN(length, link >> RADIX_LINK_BITS) << RADIX_LINK_BITS) | (link & RADIX_LINK_MASK);
    }
}
Ejemplo n.º 7
0
CAccount::CAccount()
{
    SetNull();

    earliestPossibleCreationTime = GetTime();
    accountUUID = boost::uuids::random_generator()();
    parentUUID = boost::uuids::nil_generator()();
    m_Type = AccountType::Normal;
    m_SubType = AccountSubType::Desktop;
}
Ejemplo n.º 8
0
CAccount::CAccount()
{
    SetNull();
    //Start at current time and go backwards as we find transactions.
    earliestPossibleCreationTime = GetTime();
    accountUUID = boost::uuids::random_generator()();
    parentUUID = boost::uuids::nil_generator()();
    m_State = AccountState::Normal;
    m_Type = AccountType::Desktop;
    m_readOnly = false;
}
Ejemplo n.º 9
0
VError VUUID::FromJSONValue( const VJSONValue& inJSONValue)
{
	if (inJSONValue.IsNull())
		SetNull( true);
	else
	{
		VString s;
		inJSONValue.GetString( s);
		FromString( s);
	}
	return VE_OK;
}
Ejemplo n.º 10
0
void VJSObject::MakeConstructor( JS4D::ClassRef inClassRef, JS4D::ObjectCallAsConstructorCallback inConstructor)
{
	JS4D::ContextRef	contextRef;
		
	if ((contextRef = fContext) != NULL && inClassRef != NULL && inConstructor != NULL) 
		
		fObject = JSObjectMakeConstructor( contextRef, inClassRef, inConstructor);

	else

		SetNull();
}
Ejemplo n.º 11
0
void TBValue::SetArray(TBValueArray *arr, SET set)
{
	SetNull();
	m_packed.allocated = (set == SET_NEW_COPY || set == SET_TAKE_OWNERSHIP);
	if (set != SET_NEW_COPY)
	{
		val_arr = arr;
		m_packed.type = TYPE_ARRAY;
	}
	else if ((val_arr = TBValueArray::Clone(arr)))
		m_packed.type = TYPE_ARRAY;
}
Ejemplo n.º 12
0
void TBValue::SetString(const char *val, SET set)
{
	SetNull();
	m_packed.allocated = (set == SET_NEW_COPY || set == SET_TAKE_OWNERSHIP);
	if (set != SET_NEW_COPY)
	{
		val_str = const_cast<char *>(val);
		m_packed.type = TYPE_STRING;
	}
	else if ((val_str = strdup(val)))
		m_packed.type = TYPE_STRING;
}
Ejemplo n.º 13
0
void TYPBLK<double>::SetValue(PSZ p, int n)
  {
  ChkIndx(n);

  if (Check) {
    PGLOBAL& g = Global;
    strcpy(g->Message, MSG(BAD_SET_STRING));
    longjmp(g->jumper[g->jump_level], Type);
    } // endif Check

  Typp[n] = atof(p);
  SetNull(n, false);
  } // end of SetValue
Ejemplo n.º 14
0
void TYPBLK<TYPE>::SetValue(PVAL valp, int n)
  {
  bool b;

  ChkIndx(n);
  ChkTyp(valp);

  if (!(b = valp->IsNull()))
    Typp[n] = GetTypedValue(valp);
  else
    Reset(n);

  SetNull(n, b && Nullable);
  } // end of SetValue
Ejemplo n.º 15
0
 size_t SetText(const uint8_t *text, size_t len)
 {
     assert (len <= m_size);
     if (text == NULL) {
         return SetNull( true );
     }
     memcpy(m_buf, text, len);
     m_null = false;
     m_len = len;
     m_buf[len] = '\0';
     m_bytestr = true;
     InvalidateFmt( );
     return m_len;
 };
Ejemplo n.º 16
0
void VJSObject::MakeCallback( JS4D::ObjectCallAsFunctionCallback inCallbackFunction)
{
	JS4D::ContextRef	contextRef;
	
	if ((contextRef = fContext) != NULL && inCallbackFunction != NULL) 

		// Use NULL for function name (anonymous).

		fObject = JSObjectMakeFunctionWithCallback( contextRef, NULL, inCallbackFunction);

	else

		SetNull();
}
Ejemplo n.º 17
0
int main(void)
{
	SqList L;
	ElemType e;
	SetNull(&L);
	append_arr(&L, 3);
	append_arr(&L, 2);
	append_arr(&L, 6);
	append_arr(&L, 2);
	ListDelete(&L, 2, &e);
	DisLisy(&L);
	printf("\n\n%d", e);
	return 0;
}
Ejemplo n.º 18
0
void CHRBLK::SetValue(PVAL valp, int n)
  {
  bool b;

  ChkIndx(n);
  ChkTyp(valp);

  if (!(b = valp->IsNull()))
    SetValue((PSZ)valp->GetCharValue(), n);
  else
    Reset(n);

  SetNull(n, b && Nullable);
  } // end of SetValue
Ejemplo n.º 19
0
void TYPBLK<TYPE>::SetValue(PVBLK pv, int n1, int n2)
  {
  bool b;

  ChkIndx(n1);
  ChkTyp(pv);

  if (!(b = pv->IsNull(n2) && Nullable))
    Typp[n1] = GetTypedValue(pv, n2);
  else
    Reset(n1);

  SetNull(n1, b);
  } // end of SetValue
Ejemplo n.º 20
0
EXPORT_OBJ GAL_STATUS
galNullCell_id_short_display(GAL_CELL_ID   lpObject,
                             GAL_ERROR    *lpError)
{
  if (GAL_OBJECT_TYPE(lpObject) != GAL_CELL_ID_TYPE)
  {
    lpError->error_type = GAL_ERROR_TYPE;
    lpError->error_code = GAL_ARGUMENT_TYPE_ERROR;
    return GAL_FAILURE;
  }

  SetNull(GAL_CONTROL_BITS(lpObject, GAL_CELL_ID_SHORT_DISPLAY_FPOS));

  return GAL_SUCCESS;
}
Ejemplo n.º 21
0
EXPORT_OBJ GAL_STATUS
galNullAcctExtId_inactive_date(GAL_ACCTEXTID   lpObject,
                               GAL_ERROR      *lpError)
{
  if (GAL_OBJECT_TYPE(lpObject) != GAL_ACCTEXTID_TYPE)
  {
    lpError->error_type = GAL_ERROR_TYPE;
    lpError->error_code = GAL_ARGUMENT_TYPE_ERROR;
    return GAL_FAILURE;
  }

  SetNull(GAL_CONTROL_BITS(lpObject, GAL_ACCTEXTID_INACTIVE_DATE_FPOS));

  return GAL_SUCCESS;
}
Ejemplo n.º 22
0
EXPORT_OBJ GAL_STATUS
galNullStatusHistory_inactive_dt(GAL_STATUSHISTORY   lpObject,
                                 GAL_ERROR          *lpError)
{
    if (GAL_OBJECT_TYPE(lpObject) != GAL_STATUSHISTORY_TYPE)
    {
        lpError->error_type = GAL_ERROR_TYPE;
        lpError->error_code = GAL_ARGUMENT_TYPE_ERROR;
        return GAL_FAILURE;
    }

    SetNull(GAL_CONTROL_BITS(lpObject, GAL_STATUSHISTORY_INACTIVE_DT_FPOS));

    return GAL_SUCCESS;
}
Ejemplo n.º 23
0
 size_t SetStr(const char *s, bool is_bytestr=false)
 {
     if (s == NULL) {
         return SetNull( false );
     }
     m_len = strlen(s);
     if (m_len == 0) {
         m_buf[0] = '\0';
     }
     else {
         strncpy(m_buf, s, m_size);
     }
     m_null = false;
     m_bytestr = is_bytestr;
     InvalidateFmt( );
     return m_len;
 };
Ejemplo n.º 24
0
void TBValue::Copy(const TBValue &source_value)
{
	if (source_value.m_packed.type == TYPE_STRING)
		SetString(source_value.val_str, SET_NEW_COPY);
	else if (source_value.m_packed.type == TYPE_ARRAY)
		SetArray(source_value.val_arr, SET_NEW_COPY);
	else if (source_value.m_packed.type == TYPE_OBJECT)
	{
		assert(!"We can't copy objects! The value will be nulled!");
		SetObject(nullptr);
	}
	else
	{
		SetNull();
		memcpy(this, &source_value, sizeof(TBValue));
	}
}
Ejemplo n.º 25
0
void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
  {
  bool b;

  if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
    PGLOBAL& g = Global;
    strcpy(g->Message, MSG(BLKTYPLEN_MISM));
    longjmp(g->jumper[g->jump_level], Type);
    } // endif Type

  if (!(b = pv->IsNull(n2) && Nullable))
    memcpy(Chrp + n1 * Long, ((CHRBLK*)pv)->Chrp + n2 * Long, Long);
  else
    Reset(n1);

  SetNull(n1, b);
  } // end of SetValue
Ejemplo n.º 26
0
CVariant::CVariant(const CTime& v, EDateTimeFormat fmt)
    : m_data(0)
{

    switch(fmt) {
    case eShort:
        m_data = new CDB_SmallDateTime(v);
        break;
    case eLong:
        m_data = new CDB_DateTime(v);
        break;
    default:
        NCBI_THROW(CVariantException, eVariant, "CVariant::ctor(): unsupported datetime type");
    }

    if (v.IsEmpty()) {
        SetNull();
    }
}
Ejemplo n.º 27
0
Pathname::Pathname(const char *relpath, const Pathname &abspath)
{
  _path = _filetitle = _extension = _end ="";
  _fullpath = NULL;

  char *part;
  char *pth = strcpy((char *)alloca(sizeof(*relpath)+strlen(relpath)+1),relpath);
  part = strrchr(pth,'\\');  
  if (part) part++;else part = NULL;
  if (part)
  {
    SetFilename(part);
    *part = 0;
    SetDirectory(pth);
  }
  else
    SetFilename(pth);
  if (RelativeToFull(abspath) == false) SetNull();
}
Ejemplo n.º 28
0
void TYPBLK<TYPE>::SetValue(PSZ p, int n)
  {
  ChkIndx(n);

  if (Check) {
    PGLOBAL& g = Global;
    strcpy(g->Message, MSG(BAD_SET_STRING));
    longjmp(g->jumper[g->jump_level], Type);
    } // endif Check

  bool      minus;
  ulonglong maxval = MaxVal();
  ulonglong val = CharToNumber(p, strlen(p), maxval, Unsigned, &minus); 
    
  if (minus && val < maxval)
    Typp[n] = (TYPE)(-(signed)val);
  else
    Typp[n] = (TYPE)val;

  SetNull(n, false);
  } // end of SetValue
Ejemplo n.º 29
0
void Pathname::SetPathName(const char *pathname)
{
  if (pathname == NULL || pathname[0] == 0) 
  {
    SetNull();
    return;
  }
  char *part;
  DWORD needsz = GetFullPathName(pathname,0,NULL,&part);
  char *fpth = (char *)alloca(needsz*sizeof(*fpth));
  GetFullPathName(pathname,needsz,fpth,&part);
  part = strrchr(fpth,'\\');
  if (part) part++;else part = NULL;
  if (part)
  {
    SetFilename(part);
    *part = 0;
  }
  else
    SetFilename("");
  SetDirectory(fpth);
}
Ejemplo n.º 30
0
// Constructor
CAccount::CAccount()
{
	SetNull();
}