本文整理汇总了C++中data_type函数的典型用法代码示例。如果您正苦于以下问题:C++ data_type函数的具体用法?C++ data_type怎么用?C++ data_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了data_type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_null
void test_null()
{
xlnt::workbook wb;
const auto datatypes =
{
xlnt::cell::type::empty,
xlnt::cell::type::boolean,
xlnt::cell::type::error,
xlnt::cell::type::formula_string,
xlnt::cell::type::number,
xlnt::cell::type::shared_string
};
for (const auto &datatype : datatypes)
{
auto ws = wb.active_sheet();
auto cell = ws.cell(xlnt::cell_reference(1, 1));
cell.data_type(datatype);
xlnt_assert(cell.data_type() == datatype);
cell.clear_value();
xlnt_assert(cell.data_type() == xlnt::cell::type::empty);
}
}
开发者ID:Polymedia,项目名称:xlnt,代码行数:25,代码来源:cell_test_suite.hpp
示例2: construct
void entry::swap(entry& e)
{
bool clear_this = false;
bool clear_that = false;
if (m_type == undefined_t && e.m_type == undefined_t)
return;
if (m_type == undefined_t)
{
construct(data_type(e.m_type));
clear_that = true;
}
if (e.m_type == undefined_t)
{
e.construct(data_type(m_type));
clear_this = true;
}
if (m_type == e.m_type)
{
switch (m_type)
{
case int_t:
std::swap(*reinterpret_cast<integer_type*>(data)
, *reinterpret_cast<integer_type*>(e.data));
break;
case string_t:
std::swap(*reinterpret_cast<string_type*>(data)
, *reinterpret_cast<string_type*>(e.data));
break;
case list_t:
std::swap(*reinterpret_cast<list_type*>(data)
, *reinterpret_cast<list_type*>(e.data));
break;
case dictionary_t:
std::swap(*reinterpret_cast<dictionary_type*>(data)
, *reinterpret_cast<dictionary_type*>(e.data));
break;
default:
break;
}
if (clear_this)
destruct();
if (clear_that)
e.destruct();
}
else
{
// currently, only swapping entries of the same type or where one
// of the entries is uninitialized is supported.
TORRENT_ASSERT(false);
}
}
开发者ID:Jackarain,项目名称:libtorrent,代码行数:57,代码来源:entry.cpp
示例3: test_string
void test_string()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
auto cell = ws.cell(xlnt::cell_reference(1, 1));
cell.value("hello");
xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);
cell.value(".");
xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);
cell.value("0800");
xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);
}
开发者ID:Polymedia,项目名称:xlnt,代码行数:15,代码来源:cell_test_suite.hpp
示例4: data_color
/*!
* \brief Return the value of a color-type data node.
* @param data The XML node to read from
* @param col A place to store the resulting RGBA values. If the node does
* not contain a valid color value, an error message is registered in ctx
* and `col' is unchanged.
* @param ctx The context in which this function is called
* \ingroup DiagramXmlIn
*/
void
data_color(DataNode data, Color *col, DiaContext *ctx)
{
xmlChar *val;
int r=0, g=0, b=0, a=0;
if (data_type(data, ctx)!=DATATYPE_COLOR) {
dia_context_add_message (ctx, "Taking color value of non-color node.");
return;
}
val = xmlGetProp(data, (const xmlChar *)"val");
/* Format #RRGGBB */
/* 0123456 */
if ((val) && (xmlStrlen(val)>=7)) {
r = hex_digit(val[1], ctx)*16 + hex_digit(val[2], ctx);
g = hex_digit(val[3], ctx)*16 + hex_digit(val[4], ctx);
b = hex_digit(val[5], ctx)*16 + hex_digit(val[6], ctx);
if (xmlStrlen(val) >= 9) {
a = hex_digit(val[7], ctx)*16 + hex_digit(val[8], ctx);
} else {
a = 0xff;
}
}
if (val) xmlFree(val);
col->red = (float)(r/255.0);
col->green = (float)(g/255.0);
col->blue = (float)(b/255.0);
col->alpha = (float)(a/255.0);
}
开发者ID:UIKit0,项目名称:dia,代码行数:43,代码来源:dia_xml.c
示例5: R_NEW
R_API struct r_anal_refline_t *r_anal_reflines_get(struct r_anal_t *anal,
ut64 addr, ut8 *buf, ut64 len, int nlines, int linesout, int linescall)
{
RAnalRefline *list2, *list = R_NEW (RAnalRefline);
RAnalOp op = {0};
ut8 *ptr = buf;
ut8 *end = buf + len;
ut64 opc = addr;
int sz = 0, index = 0;
INIT_LIST_HEAD (&(list->list));
end -= 8; // XXX Fix some segfaults when r_anal backends are buggy
/* analyze code block */
while (ptr<end) {
if (nlines != -1 && --nlines == 0)
break;
#if 0
if (config.interrupted)
break;
int dt = data_type(config.seek+bsz);
if (dt != DATA_FUN && dt != DATA_CODE) {
ut64 sz = data_size (config.seek+bsz);
if (sz > 0) {
ptr += sz;
bsz += sz;
continue;
}
}
#endif
addr += sz;
// This can segflauta if opcode length and buffer check fails
r_anal_op_fini (&op);
sz = r_anal_op (anal, &op, addr, ptr, (int)(end-ptr));
if (sz > 0) {
/* store data */
switch (op.type) {
case R_ANAL_OP_TYPE_CALL:
if (!linescall)
break;
case R_ANAL_OP_TYPE_CJMP:
case R_ANAL_OP_TYPE_JMP:
if (!linesout && (op.jump > opc+len || op.jump < opc))
goto __next;
if (op.jump == 0LL)
goto __next;
list2 = R_NEW (RAnalRefline);
list2->from = addr;
list2->to = op.jump;
list2->index = index++;
list_add_tail (&(list2->list), &(list->list));
break;
}
} else sz = 1;
__next:
ptr += sz;
}
r_anal_op_fini (&op);
return list;
}
开发者ID:ReverseLab,项目名称:radare2,代码行数:60,代码来源:reflines.c
示例6: build_identity_form
//
//
//
/// @brief Build its identity form, if the current rank two array is square and
/// was previously initialized either by construction or the array::create()
/// member function. Otherwise nothing is done. Notice that the previous content,
/// if any, will be lost.
//
/// @return None.
//
void build_identity_form()
{
if(is_square())
{
OMP_STATIC_LOOP_POLICY
for(INIT_ITER(i, 1); i < first_rank(); ++i)
{
data[offset(i, i)] = data_type(1.0);
for(unsigned int j(i + 1); j <= second_rank(); ++j)
{
data[offset(i, j)] = data[offset(j, i)] = data_type(0.0);
}
}
data[data_length() - 1] = data_type(1.0);
}
};
开发者ID:violador,项目名称:catalyst,代码行数:26,代码来源:build_identity_form.cpp
示例7: data_color
/** Return the value of a color-type data node.
* @param data The XML node to read from
* @param col A place to store the resulting RGB values. If the node does
* not contain a valid color value, an error message is displayed to the
* user, and `col' is unchanged.
* @note Could be cool to use RGBA data here, even if we can't display it yet.
*/
void
data_color(DataNode data, Color *col)
{
xmlChar *val;
int r=0, g=0, b=0;
if (data_type(data)!=DATATYPE_COLOR) {
message_error("Taking color value of non-color node.");
return;
}
val = xmlGetProp(data, (const xmlChar *)"val");
/* Format #RRGGBB */
/* 0123456 */
if ((val) && (xmlStrlen(val)>=7)) {
r = hex_digit(val[1])*16 + hex_digit(val[2]);
g = hex_digit(val[3])*16 + hex_digit(val[4]);
b = hex_digit(val[5])*16 + hex_digit(val[6]);
}
if (val) xmlFree(val);
col->red = (float)(r/255.0);
col->green = (float)(g/255.0);
col->blue = (float)(b/255.0);
}
开发者ID:yjdwbj,项目名称:c_struct_gui,代码行数:35,代码来源:dia_xml.c
示例8: data_font
/** Return the value of a font-type data node. This handles both the current
* format (family and style) and the old format (name).
* @param data The data node to read from.
* @return The font value found in the node. If the node is not a
* font node, an error message is displayed and NULL is returned. The
* resulting value should be freed after use.
*/
DiaFont *
data_font(DataNode data)
{
xmlChar *family;
DiaFont *font;
if (data_type(data)!=DATATYPE_FONT) {
message_error("Taking font value of non-font node.");
return NULL;
}
family = xmlGetProp(data, (const xmlChar *)"family");
/* always prefer the new format */
if (family) {
DiaFontStyle style;
char* style_name = (char *) xmlGetProp(data, (const xmlChar *)"style");
style = style_name ? atoi(style_name) : 0;
font = dia_font_new ((char *)family, style, 1.0);
if (family) free(family);
if (style_name) xmlFree(style_name);
} else {
/* Legacy format support */
char *name = (char *)xmlGetProp(data, (const xmlChar *)"name");
font = dia_font_new_from_legacy_name(name);
free(name);
}
return font;
}
开发者ID:yjdwbj,项目名称:c_struct_gui,代码行数:36,代码来源:dia_xml.c
示例9: operator
typename T::return_type operator()(T& t, const char* d, typename T::size_type s)
{
_clear_flag = false;
data_type::size_type offset = 0;
if ( _data.empty() )
{
if (_data.capacity() > 0 )
data_type(_data).swap(_data);
offset = _parse_(t, d, s, 0, 0);
if (!_clear_flag)
{
if (offset == static_cast<data_type::size_type>(-1))
_assign(d, d + s);
else if ( static_cast<typename T::size_type>(offset) != s)
_assign(d + offset, d + s);
}
}
else
{
const size_t datasize = _data.size();
if (_data.capacity() < datasize + s) {
_data.reserve( datasize < 16384 ? datasize + s : datasize+(datasize>>1)+s);
}
std::copy(d, d + s, std::back_inserter(_data));
offset = _parse_(t, &(_data[0]), _data.size(), 0, datasize>size_sep ? datasize-size_sep : 0);
if (!_clear_flag)
{
if ( offset == static_cast<typename T::size_type>( _data.size() ) )
_data.clear();
else if ( offset!= static_cast<data_type::size_type>(-1) )
_data.erase( _data.begin(), _data.begin() + offset );
}
}
开发者ID:ApelSYN,项目名称:leveldb-daemon,代码行数:33,代码来源:ad_binary_splitter.hpp
示例10: test_basic_operations
void test_basic_operations(const T &value) {
constexpr grnxx::DataType data_type = T::type();
// Create a table and insert the first row.
auto db = grnxx::open_db("");
auto table = db->create_table("Table");
grnxx::Int row_id = table->insert_row();
// Create a column named "Column".
auto column = table->create_column("Column", data_type);
assert(column->table() == table);
assert(column->name() == "Column");
assert(column->data_type() == data_type);
assert(!column->reference_table());
assert(!column->is_key());
assert(column->num_indexes() == 0);
// Check if N/A is stored or not.
grnxx::Datum datum;
T stored_value;
column->get(row_id, &datum);
assert(datum.type() == data_type);
datum.force(&stored_value);
assert(stored_value.is_na());
// Set a value and get it.
column->set(row_id, value);
column->get(row_id, &datum);
assert(datum.type() == data_type);
datum.force(&stored_value);
assert(stored_value.match(value));
}
开发者ID:groonga,项目名称:grnxx,代码行数:32,代码来源:test_column.cpp
示例11: pessimistic_memory_manager
/**
* Construct a pessimitic memory manager, and initialize it.
*
* @param max_elements the maximum number of objects that will be allocated. This many objects
* will be allocated at startup
*
* @param prototype a prototypical instance of the object which is being managed.
*/
pessimistic_memory_manager(size_t max_elements, data_type prototype = data_type()):
free_data_stack_(max_elements),
current_free_position_(0)
{
for(size_t i = 0; i < max_elements; ++i){
free_data_stack_[i] = new data_type(prototype);
}
}
开发者ID:ShiningDrops,项目名称:switchflow,代码行数:16,代码来源:pessimistic_memory_manager.hpp
示例12: if
double ImageSlice::getPixelVal(double x, double y)
{
// x y is actor coord
vtkSmartPointer<vtkPropPicker> picker = vtkSmartPointer<vtkPropPicker>::New();
picker->Pick(x, y, 0.0, renderer);
double pos[3];
picker->GetPickPosition(pos);
//std::cout<<"picked position: "<<pos[0]<<"\t"<<pos[1]<<"\t"<<pos[2]<<"\n";
//double bounds[6];
//actor->GetBounds(bounds);
//std::cout<<"actor bounds: ";
//for (size_t i = 0; i < 6; ++i)
//{
// std::cout<<bounds[i]<<"\t";
//}
//std::cout<<"\n";
// X 0 Y 1 Z 2
int img_coord[3] = {0,0,0};
int img_extent[6] = {0,0,0,0,0,0};
int orient = mapper->GetOrientation();
double img_spcing[3];
nii_data->GetSpacing(img_spcing);
nii_data->GetExtent(img_extent);
if (orient == 0)
{
img_coord[0] = mapper->GetSliceNumber();
img_coord[1] = vtkMath::Round(pos[1]/img_spcing[1]);
img_coord[2] = vtkMath::Round(pos[2]/img_spcing[2]);
}
else if (orient == 1)
{
img_coord[0] = vtkMath::Round(pos[0]/img_spcing[0]);
img_coord[1] = mapper->GetSliceNumber();
img_coord[2] = vtkMath::Round(pos[2]/img_spcing[2]);
}
else if (orient == 2)
{
img_coord[0] = vtkMath::Round(pos[0]/img_spcing[0]);
img_coord[1] = vtkMath::Round(pos[1]/img_spcing[1]);
img_coord[2] = mapper->GetSliceNumber();
}
#ifdef DEBUG_PRINT
std::string data_type(nii_data->GetScalarTypeAsString());
std::cout<<"image data type: "<<data_type<<"\n";
#endif
if (img_coord[0] >= img_extent[0] && img_coord[0] <= img_extent[1]
&& img_coord[1] >= img_extent[2] && img_coord[1] <= img_extent[3]
&& img_coord[2] >= img_extent[4] && img_coord[2] <= img_extent[5])
{
return nii_data->GetScalarComponentAsDouble(img_coord[0], img_coord[1], img_coord[2], 0);
}
return 0.0;
}
开发者ID:zhuangfangwang,项目名称:cranioviewer,代码行数:57,代码来源:ImageSlice.cpp
示例13: test_decimal_add2
inline void test_decimal_add2(){
NValue v1 = NValue::getDecimalValueFromString("4.4");
NValue v2 = NValue::getDecimalValueFromString("-8");
column_type* op=new column_type(data_type(t_decimal),2);
op->operate->Multiply(&v1,&v2);
if(!print_test_name_result(op->operate->ToString(&v1)==string("-35.20"),"Decimal multiple")){
printf("Expected -35.20, actual: %s\n",op->operate->ToString(&v1).c_str());
}
}
开发者ID:yestodaylee,项目名称:CLAIMS,代码行数:9,代码来源:Expression_item.cpp
示例14: test_formula2
void test_formula2()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
auto cell = ws.cell(xlnt::cell_reference(1, 1));
cell.value("=if(A1<4;-1;1)", true);
xlnt_assert(cell.data_type() == xlnt::cell::type::number);
xlnt_assert(cell.has_formula());
}
开发者ID:Polymedia,项目名称:xlnt,代码行数:10,代码来源:cell_test_suite.hpp
示例15: dump_data_bytes
static void dump_data_bytes(const char *type, const unsigned char *data,
unsigned length)
{
char prefix[56];
sprintf(prefix, IPWIRELESS_PCCARD_NAME ": %s %s ",
type, data_type(data, length));
print_hex_dump_bytes(prefix, 0, (void *)data,
length < DUMP_MAX_BYTES ? length : DUMP_MAX_BYTES);
}
开发者ID:513855417,项目名称:linux,代码行数:10,代码来源:hardware.c
示例16: find
inline typename Map<KEY,DATA>::data_type& Map<KEY,DATA>::operator[] (const key_type& key)
{
iterator itr = find(key);
if (itr != end())
return itr->second;
else
{
return m_vectorMap[insert_blindly(key,data_type())].second;
}
}
开发者ID:xyuan,项目名称:coolfluid3,代码行数:10,代码来源:Map.hpp
示例17: test_not_formula
void test_not_formula()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
auto cell = ws.cell(xlnt::cell_reference(1, 1));
cell.value("=", true);
xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);
xlnt_assert(cell.value<std::string>() == "=");
xlnt_assert(!cell.has_formula());
}
开发者ID:Polymedia,项目名称:xlnt,代码行数:11,代码来源:cell_test_suite.hpp
示例18: test_boolean
void test_boolean()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
auto cell = ws.cell(xlnt::cell_reference(1, 1));
for (auto value : { true, false })
{
cell.value(value);
xlnt_assert(cell.data_type() == xlnt::cell::type::boolean);
}
}
开发者ID:Polymedia,项目名称:xlnt,代码行数:12,代码来源:cell_test_suite.hpp
示例19: test_error_codes
void test_error_codes()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
auto cell = ws.cell(xlnt::cell_reference(1, 1));
for (auto error_code : xlnt::cell::error_codes())
{
cell.value(error_code.first, true);
xlnt_assert(cell.data_type() == xlnt::cell::type::error);
}
}
开发者ID:Polymedia,项目名称:xlnt,代码行数:12,代码来源:cell_test_suite.hpp
示例20: test_insert_date
void test_insert_date()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
auto cell = ws.cell(xlnt::cell_reference(1, 1));
cell.value(xlnt::date(2010, 7, 13));
xlnt_assert(cell.data_type() == xlnt::cell::type::number);
xlnt_assert(cell.value<long double>() == 40372.L);
xlnt_assert(cell.is_date());
xlnt_assert(cell.number_format().format_string() == "yyyy-mm-dd");
}
开发者ID:Polymedia,项目名称:xlnt,代码行数:12,代码来源:cell_test_suite.hpp
注:本文中的data_type函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论