本文整理汇总了C++中Header类的典型用法代码示例。如果您正苦于以下问题:C++ Header类的具体用法?C++ Header怎么用?C++ Header使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Header类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VerifyAgainstLog
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief Test method to verify ability to read/write message data from
/// an example wireshark log provided for testing systems for the JAUS
/// Interoperability Challenge hosted at several AUVSI competitions.
///
////////////////////////////////////////////////////////////////////////////////////
void VerifyAgainstLog()
{
Packet::List packets;
Packet::List::iterator packet;
Component component;
component.DiscoveryService()->SetSubsystemIdentification(Subsystem::OCU, "OCP");
component.AddService(new LocalPoseSensor());
component.AddService(new VelocityStateSensor());
component.AddService(new ListManager());
component.AddService(new TestLocalWaypointListDriver());
Packet::LoadWiresharkCapturePacketExport("logs/example-capture.txt", packets);
Address cop(42, 1, 1);
Address sim(6000, 1, 1);
//Packet::LoadWiresharkCapturePacketExport("logs/example_capture-2.txt", packets);
Message::List messages;
Message::List::iterator message;
// Delete UDP header data to get to just the JAUS message.
for(packet = packets.begin(); packet != packets.end();)
{
// Delete UDP header data.
packet->Delete(43);
// Read message header data.
Header jausHeader;
if(jausHeader.Read(*packet))
{
UShort messageCode = 0;
packet->Read(messageCode, Header::PayloadOffset);
Message* jausMessage = component.TransportService()->CreateMessage(messageCode);
if(jausMessage)
{
packet->SetReadPos(0);
if(jausMessage->Read(*packet))
{
messages.push_back(jausMessage);
if(jausMessage->GetMessageCode() == SET_ELEMENT)
{
Element::List::iterator m;
SetElement* setElement = (SetElement *)jausMessage;
for(m = setElement->GetElementList()->begin();
m != setElement->GetElementList()->end();
m++)
{
UShort code = 0;
m->mPayload.SetReadPos(0);
m->mPayload.Read(code);
Message* element = component.TransportService()->CreateMessage(code);
if(element)
{
element->CopyHeaderData(jausMessage);
if(element->ReadMessageBody(m->mPayload))
{
messages.push_back(element);
}
else
{
std::cout << "Failed to Read Message Data [" << std::hex << element->GetMessageCode() << "]:\n";
delete element;
}
}
}
}
}
else
{
std::cout << "Failed to Read Message Data [" << std::hex << jausMessage->GetMessageCode() << "]:\n";
}
}
else
{
std::cout << "Unknown Message Type [" << std::hex << messageCode << "]:\n";
}
}
else
{
std::cout << "Bad Header!\n";
}
packet++;
}
component.Initialize(cop);
message = messages.begin();
for(message = messages.begin();
message != messages.end();
message++)
{
//(*message)->Print();
if((*message)->GetSourceID() == cop)
{
//.........这里部分代码省略.........
示例2: populateHeader
void FourSectionDictionary::populateHeader(Header & header, string rootNode)
{
header.insert(rootNode, HDTVocabulary::DICTIONARY_TYPE, getType());
#if 0
header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMSUBJECTS, getNsubjects());
header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMPREDICATES, getNpredicates());
header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMOBJECTS, getNobjects());
header.insert(rootNode, HDTVocabulary::DICTIONARY_MAXSUBJECTID, getMaxSubjectID());
header.insert(rootNode, HDTVocabulary::DICTIONARY_MAXPREDICATEID, getMaxPredicateID());
header.insert(rootNode, HDTVocabulary::DICTIONARY_MAXOBJECTTID, getMaxObjectID());
#endif
header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMSHARED, getNshared());
header.insert(rootNode, HDTVocabulary::DICTIONARY_MAPPING, this->mapping);
header.insert(rootNode, HDTVocabulary::DICTIONARY_SIZE_STRINGS, size());
header.insert(rootNode, HDTVocabulary::DICTIONARY_BLOCK_SIZE, this->blocksize);
}
示例3: get_DW_scheme
Eigen::MatrixXd get_DW_scheme (const Header& header)
{
DEBUG ("searching for suitable gradient encoding...");
using namespace App;
Eigen::MatrixXd grad;
try {
const auto opt_mrtrix = get_options ("grad");
if (opt_mrtrix.size())
grad = load_matrix<> (opt_mrtrix[0][0]);
const auto opt_fsl = get_options ("fslgrad");
if (opt_fsl.size()) {
if (opt_mrtrix.size())
throw Exception ("Please provide diffusion gradient table using either -grad or -fslgrad option (not both)");
grad = load_bvecs_bvals (header, opt_fsl[0][0], opt_fsl[0][1]);
}
if (!opt_mrtrix.size() && !opt_fsl.size())
grad = parse_DW_scheme (header);
}
catch (Exception& e) {
throw Exception (e, "error importing diffusion gradient table for image \"" + header.name() + "\"");
}
if (!grad.rows())
return grad;
if (grad.cols() < 4)
throw Exception ("unexpected diffusion gradient table matrix dimensions");
INFO ("found " + str (grad.rows()) + "x" + str (grad.cols()) + " diffusion gradient table");
return grad;
}
示例4: SuccessOrExit
void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
Header responseHeader;
Header requestHeader;
RequestMetadata requestMetadata;
Message *message = NULL;
ThreadError error;
SuccessOrExit(error = responseHeader.FromMessage(aMessage));
aMessage.MoveOffset(responseHeader.GetLength());
message = FindRelatedRequest(responseHeader, aMessageInfo, requestHeader, requestMetadata);
if (message == NULL)
{
ExitNow();
}
switch (responseHeader.GetType())
{
case kCoapTypeReset:
if (responseHeader.IsEmpty())
{
FinalizeCoapTransaction(*message, requestMetadata, NULL, NULL, kThreadError_Abort);
}
// Silently ignore non-empty reset messages (RFC 7252, p. 4.2).
break;
case kCoapTypeAcknowledgment:
if (responseHeader.IsEmpty())
{
// Empty acknowledgment.
if (requestMetadata.mConfirmable)
{
requestMetadata.mAcknowledged = true;
requestMetadata.UpdateIn(*message);
}
// Remove the message if response is not expected, otherwise await response.
if (requestMetadata.mResponseHandler == NULL)
{
DequeueMessage(*message);
}
}
else if (responseHeader.IsResponse() && responseHeader.IsTokenEqual(requestHeader))
{
// Piggybacked response.
FinalizeCoapTransaction(*message, requestMetadata, &responseHeader, &aMessage, kThreadError_None);
}
// Silently ignore acknowledgments carrying requests (RFC 7252, p. 4.2)
// or with no token match (RFC 7252, p. 5.3.2)
break;
case kCoapTypeConfirmable:
case kCoapTypeNonConfirmable:
if (responseHeader.IsConfirmable())
{
// Send empty ACK if it is a CON message.
SendEmptyAck(aMessageInfo.GetPeerAddr(), aMessageInfo.mPeerPort, responseHeader.GetMessageId());
}
FinalizeCoapTransaction(*message, requestMetadata, &responseHeader, &aMessage, kThreadError_None);
break;
}
exit:
if (error == kThreadError_None && message == NULL)
{
if (responseHeader.IsConfirmable() || responseHeader.IsNonConfirmable())
{
// Successfully parsed a header but no matching request was found - reject the message by sending reset.
SendReset(aMessageInfo.GetPeerAddr(), aMessageInfo.mPeerPort, responseHeader.GetMessageId());
}
}
}
示例5: parse_scheme
Eigen::MatrixXd parse_scheme (const Header& header)
{
Eigen::MatrixXd PE;
const auto it = header.keyval().find ("pe_scheme");
if (it != header.keyval().end()) {
try {
PE = parse_matrix (it->second);
} catch (Exception& e) {
throw Exception (e, "malformed PE scheme in image \"" + header.name() + "\"");
}
if (ssize_t(PE.rows()) != ((header.ndim() > 3) ? header.size(3) : 1))
throw Exception ("malformed PE scheme in image \"" + header.name() + "\" - number of rows does not equal number of volumes");
} else {
// Header entries are cast to lowercase at some point
const auto it_dir = header.keyval().find ("PhaseEncodingDirection");
const auto it_time = header.keyval().find ("TotalReadoutTime");
if (it_dir != header.keyval().end() && it_time != header.keyval().end()) {
Eigen::Matrix<default_type, 4, 1> row;
row.head<3>() = Axes::id2dir (it_dir->second);
row[3] = to<default_type>(it_time->second);
PE.resize ((header.ndim() > 3) ? header.size(3) : 1, 4);
PE.rowwise() = row.transpose();
}
}
return PE;
}
示例6: readMagicNumberAndVersionField
void
MultiPartInputFile::initialize()
{
readMagicNumberAndVersionField(*_data->is, _data->version);
bool multipart = isMultiPart(_data->version);
bool tiled = isTiled(_data->version);
//
// Multipart files don't have and shouldn't have the tiled bit set.
//
if (tiled && multipart)
throw IEX_NAMESPACE::InputExc ("Multipart files cannot have the tiled bit set");
int pos = 0;
while (true)
{
Header header;
header.readFrom(*_data->is, _data->version);
//
// If we read nothing then we stop reading.
//
if (header.readsNothing())
{
pos++;
break;
}
_data->_headers.push_back(header);
if(multipart == false)
break;
}
//
// Perform usual check on headers.
//
for (size_t i = 0; i < _data->_headers.size(); i++)
{
//
// Silently invent a type if the file is a single part regular image.
//
if( _data->_headers[i].hasType() == false )
{
if(multipart)
throw IEX_NAMESPACE::ArgExc ("Every header in a multipart file should have a type");
_data->_headers[i].setType(tiled ? TILEDIMAGE : SCANLINEIMAGE);
}
else
{
//
// Silently fix the header type if it's wrong
// (happens when a regular Image file written by EXR_2.0 is rewritten by an older library,
// so doesn't effect deep image types)
//
if(!multipart && !isNonImage(_data->version))
{
_data->_headers[i].setType(tiled ? TILEDIMAGE : SCANLINEIMAGE);
}
}
if( _data->_headers[i].hasName() == false )
{
if(multipart)
throw IEX_NAMESPACE::ArgExc ("Every header in a multipart file should have a name");
}
if (isTiled(_data->_headers[i].type()))
_data->_headers[i].sanityCheck(true, multipart);
else
_data->_headers[i].sanityCheck(false, multipart);
}
//
// Check name uniqueness.
//
if (multipart)
{
set<string> names;
for (size_t i = 0; i < _data->_headers.size(); i++)
{
if (names.find(_data->_headers[i].name()) != names.end())
{
throw IEX_NAMESPACE::InputExc ("Header name " + _data->_headers[i].name() +
" is not a unique name.");
}
//.........这里部分代码省略.........
示例7: success
oc::result<void> AndroidFormatWriter::write_header(File &file,
const Header &header)
{
// Construct header
m_hdr = {};
memcpy(m_hdr.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE);
if (auto address = header.kernel_address()) {
m_hdr.kernel_addr = *address;
}
if (auto address = header.ramdisk_address()) {
m_hdr.ramdisk_addr = *address;
}
if (auto address = header.secondboot_address()) {
m_hdr.second_addr = *address;
}
if (auto address = header.kernel_tags_address()) {
m_hdr.tags_addr = *address;
}
if (auto page_size = header.page_size()) {
switch (*page_size) {
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072:
m_hdr.page_size = *page_size;
break;
default:
//DEBUG("Invalid page size: %" PRIu32, *page_size);
return AndroidError::InvalidPageSize;
}
} else {
return AndroidError::MissingPageSize;
}
if (auto board_name = header.board_name()) {
if (board_name->size() >= sizeof(m_hdr.name)) {
return AndroidError::BoardNameTooLong;
}
strncpy(reinterpret_cast<char *>(m_hdr.name), board_name->c_str(),
sizeof(m_hdr.name) - 1);
m_hdr.name[sizeof(m_hdr.name) - 1] = '\0';
}
if (auto cmdline = header.kernel_cmdline()) {
if (cmdline->size() >= sizeof(m_hdr.cmdline)) {
return AndroidError::KernelCmdlineTooLong;
}
strncpy(reinterpret_cast<char *>(m_hdr.cmdline), cmdline->c_str(),
sizeof(m_hdr.cmdline) - 1);
m_hdr.cmdline[sizeof(m_hdr.cmdline) - 1] = '\0';
}
// TODO: UNUSED
// TODO: ID
std::vector<SegmentWriterEntry> entries;
entries.push_back({ ENTRY_TYPE_KERNEL, 0, {}, m_hdr.page_size });
entries.push_back({ ENTRY_TYPE_RAMDISK, 0, {}, m_hdr.page_size });
entries.push_back({ ENTRY_TYPE_SECONDBOOT, 0, {}, m_hdr.page_size });
entries.push_back({ ENTRY_TYPE_DEVICE_TREE, 0, {}, m_hdr.page_size });
OUTCOME_TRYV(m_seg->set_entries(std::move(entries)));
// Start writing after first page
auto seek_ret = file.seek(m_hdr.page_size, SEEK_SET);
if (!seek_ret) {
if (file.is_fatal()) { m_writer.set_fatal(); }
return seek_ret.as_failure();
}
return oc::success();
}
示例8: main
int main(int argc, char** argv)
{
(void) argc;
(void) argv;
signal(SIGCHLD, SIG_IGN);
int iSocket = socket(AF_INET, SOCK_STREAM, 0);
if (iSocket < 0) {
fprintf(stderr, "socket failed %d, errno %d\n",
iSocket, errno);
return 0;
}
struct sockaddr_in servAddr, cliAddr;
socklen_t iCliLen = sizeof(cliAddr);
memset(&servAddr, 0, sizeof(servAddr));
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = inet_addr(*(argv + 1));
servAddr.sin_port = htons(atoi(*(argv + 2)));
int option = 1;
setsockopt(iSocket, SOL_SOCKET, SO_REUSEADDR, (const void *)&option, sizeof(option));
bind(iSocket, (struct sockaddr *)&servAddr, sizeof(servAddr));
listen(iSocket, 512);
while(1) {
int iCliFd;
iCliFd = accept(iSocket, (struct sockaddr *)&cliAddr, &iCliLen);
if (iCliFd < 0) {
fprintf(stderr, "accept failed %d, errno %d\n",
iCliFd, errno);
return 0;
}
pid_t pid = fork();
if (pid == 0)
{
#define USERID 1
char sBuf[10240];
ssize_t size;
uint64_t iMsgId = 1ull;
Encoder encoder(sBuf, sizeof(sBuf));
Decoder decoder;
{
ConnSvrConnectChallenge req;
char sRandomStr[256];
memset(sRandomStr, 'z', sizeof(sRandomStr));
req.set_random_msg(sRandomStr, 256);
Header header;
header.set_type(kMsgTypeConnSvrConnectChallenge);
header.set_msg_id(iMsgId++);
encoder.EncodeHeader(header);
encoder.Encode(req);
size = send(iCliFd, encoder.Data(), encoder.DataLen(), 0);
printf("send %ld\n", size);
}
{
Header header;
size = recv(iCliFd, sBuf, sizeof(sBuf), 0);
decoder.DecodeHeader(sBuf, size, &header);
ConnSvrConnectReq resp;
decoder.DecodePayload(&resp);
unsigned char sUserAgentBuf[1024];
UserAgent userAgent;
if (resp.has_user_agent()) {
const std::string &sUserAgent = resp.user_agent();
memcpy(sUserAgentBuf, sUserAgent.c_str(), sUserAgent.size());
if (sUserAgent.size()) {
unsigned char inputKey = sUserAgentBuf[0];
unsigned char outputKey;
for(int i = 1, n = sUserAgent.size(); i != n; i++) {
outputKey = sUserAgentBuf[i];
sUserAgentBuf[i] ^= inputKey;
inputKey = outputKey;
}
}
userAgent.ParseFromArray(sUserAgentBuf + 1, sUserAgent.size() - 1);
}
printf("type %d, msgid %lu, phonenum %s, role %d, secretchap %s, ostype %s, osver %s, model %s, clientver %s, network %s, location %s operator %s\n",
header.type(), header.has_msg_id() ? header.msg_id() : 0,
resp.phone_num().c_str(), resp.role(), resp.secret_chap().c_str(),
userAgent.has_os_type() ? userAgent.os_type().c_str() : "",
userAgent.has_os_ver() ? userAgent.os_ver().c_str() : "",
userAgent.has_model() ? userAgent.model().c_str() : "",
userAgent.has_client_ver() ? userAgent.client_ver().c_str() : "",
userAgent.has_network() ? userAgent.network().c_str() : "",
userAgent.has_location() ? userAgent.location().c_str() : "",
userAgent.has_carrier_operator() ? userAgent.carrier_operator().c_str() : "");
}
{
ConnSvrConnectRsp req;
RspMsg* pRspMsg = req.mutable_rsp_msg();
pRspMsg->set_rsp_code(0);
pRspMsg->set_rsp_msg("OK");
Header header;
header.set_type(kMsgTypeConnSvrConnectRsp);
header.set_msg_id(iMsgId++);
encoder.EncodeHeader(header);
encoder.Encode(req);
size = send(iCliFd, encoder.Data(), encoder.DataLen(), 0);
printf("send %ld\n", size);
}
int number = 0;
//.........这里部分代码省略.........
示例9: Exception
std::shared_ptr<Handler::Base> MRtrix_sparse::create (Header& H) const
{
Header::const_iterator name_it = H.find (Image::Sparse::name_key);
if (name_it == H.end())
throw Exception ("Cannot create sparse image " + H.name() + "; no knowledge of underlying data class type");
Header::const_iterator size_it = H.find (Image::Sparse::size_key);
if (size_it == H.end())
throw Exception ("Cannot create sparse image " + H.name() + "; no knowledge of underlying data class size");
H.datatype() = DataType::UInt64;
H.datatype().set_byte_order_native();
File::OFStream out (H.name(), std::ios::out | std::ios::binary);
out << "mrtrix sparse image\n";
write_mrtrix_header (H, out);
bool single_file = Path::has_suffix (H.name(), ".msf");
int64_t image_offset = 0, sparse_offset = 0;
std::string image_path, sparse_path;
if (single_file) {
image_offset = out.tellp() + int64_t(54);
image_offset += ((4 - (image_offset % 4)) % 4);
sparse_offset = image_offset + Image::footprint(H);
out << "file: . " << image_offset << "\nsparse_file: . " << sparse_offset << "\nEND\n";
File::resize (H.name(), sparse_offset);
image_path = H.name();
sparse_path = H.name();
} else {
image_path = Path::basename (H.name().substr (0, H.name().size()-4) + ".dat");
sparse_path = Path::basename (H.name().substr (0, H.name().size()-4) + ".sdat");
out << "file: " << image_path << "\nsparse_file: " << sparse_path << "\nEND\n";
File::create (image_path, Image::footprint(H));
File::create (sparse_path);
}
Handler::Default base_handler (H);
base_handler.files.push_back (File::Entry (image_path, image_offset));
std::shared_ptr<Handler::Base> handler (new Handler::Sparse (base_handler, name_it->second, to<size_t>(size_it->second), File::Entry (sparse_path, sparse_offset)));
return handler;
}
示例10: process
int Control::process(Header &header) {
size_ = header.payload_size() + 2;
Utilities::Utf8::Byte utf8;
uint8_t mask_offset = 0;
uint8_t *buffer = &(*buffer_.get())[0];
buffer[0] = header.begin()[0];
buffer[1] = header.begin()[1];
Utilities::Print::hex(&buffer[0],header.payload_size()+2); std::cout << std::endl;
if( (buffer[0] & 0x0F) == 0x08) {
if(header.payload_size() >= 2) {
Utilities::Websocket::applyMask(&buffer[2]
, 2
, &header.mask(), mask_offset
, false
, utf8);
Utilities::Websocket::applyMask(&buffer[4]
, header.payload_size() -2
, &header.mask(), mask_offset
, true
, utf8);
if(!utf8.complete()) {
std::cout << "invalid utf in control" << std::endl;
return 1007;
}
}
state_ = ControlState::KILL;
std::cout << "control kill" << std::endl;
buffer[1] &= 0x7F;
uint16_t code = buffer[2] << 8 | buffer[3] << 0;
if( code < 1000
||(code < 3000
&& code != 1000 && code != 1001 && code != 1002 && code != 1003
&& code != 1007 && code != 1008 && code != 1009 && code != 1010
&& code != 1011)
|| code > 4999
) {
buffer[2] = 0x03;
buffer[3] = 0xEA;
}
} else if ( (buffer[0] & 0x0F) == 0x09 ) {
Utilities::Websocket::applyMask(&buffer[2]
, header.payload_size()
, &header.mask(), mask_offset
, false
, utf8);
if(!utf8.complete()) {
std::cout << "invalid utf in control" << std::endl;
return 1007;
}
state_ = ControlState::PING;
buffer[0] = ( buffer[0] & 0xF0 ) | 0x0A;
buffer[1] &= 0x7F;
std::cout << "control pong"; Utilities::Print::hex(&buffer[0],2);std::cout <<std::endl;
} else if ( (buffer[0] & 0x0F) == 0x0A ) {
state_ = ControlState::PONG;
std::cout << "pong recieved" << std::endl;
} else {
state_ = ControlState::INVALID;
}
return 0;
}
示例11: GetHeader
result
EventListForm::OnInitializing(void)
{
result r = E_SUCCESS;
Header* pHeader = GetHeader();
AppAssert(pHeader);
DateTime today;
String formattedString;
SystemTime::GetCurrentTime(WALL_TIME, today);
__pLocaleCalendar = Tizen::Locales::Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
__pLocaleCalendar->SetTime(today);
DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(DATE_TIME_STYLE_DEFAULT);
String customizedPattern = L"dd MMM yyyy";
pDateFormatter->ApplyPattern(customizedPattern);
pDateFormatter->Format(*__pLocaleCalendar, formattedString);
HeaderItem headerDaily;
headerDaily.Construct(ID_HEADER_DAILY);
headerDaily.SetText(L"일");
HeaderItem headerMonthly;
headerMonthly.Construct(ID_HEADER_MONTHLY);
headerMonthly.SetText(L"월");
pHeader->SetStyle(HEADER_STYLE_SEGMENTED_WITH_TITLE);
pHeader->SetTitleText(formattedString);
pHeader->AddItem(headerDaily);
pHeader->AddItem(headerMonthly);
pHeader->AddActionEventListener(*this);
Footer* pFooter = GetFooter();
AppAssert(pFooter);
pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
FooterItem footerCreate;
footerCreate.Construct(ID_FOOTER_CREATE);
footerCreate.SetText(L"일정 생성");
pFooter->AddItem(footerCreate);
SetFormBackEventListener(this);
pFooter->AddActionEventListener(*this);
Tizen::Ui::Controls::Button* pPreviousButton = new (std::nothrow) Button();
pPreviousButton->Construct(Rectangle(0, 0, GetClientAreaBounds().width / 2, 72), L"이전");
pPreviousButton->SetActionId(ID_BUTTON_PREV);
pPreviousButton->AddActionEventListener(*this);
AddControl(pPreviousButton);
Tizen::Ui::Controls::Button* pNextButton = new (std::nothrow) Button();
pNextButton->Construct(Rectangle(GetClientAreaBounds().width / 2, 0, GetClientAreaBounds().width / 2, 72), L"다음");
pNextButton->SetActionId(ID_BUTTON_NEXT);
pNextButton->AddActionEventListener(*this);
AddControl(pNextButton);
__pGroupedListView = new (std::nothrow) GroupedListView();
__pGroupedListView->Construct(Rectangle(0, 72, GetClientAreaBounds().width, GetClientAreaBounds().height - 72), GROUPED_LIST_VIEW_STYLE_INDEXED, true, SCROLL_STYLE_FADE_OUT);
__pGroupedListView->SetTextOfEmptyList(L"일정 없음");
__pGroupedListView->SetItemProvider(*this);
__pGroupedListView->AddGroupedListViewItemEventListener(*this);
__pGroupedListView->SetItemDividerColor(Tizen::Graphics::Color::GetColor(COLOR_ID_BLACK));
AddControl(__pGroupedListView);
LocaleManager localeManager;
localeManager.Construct();
__timeZone = localeManager.GetSystemTimeZone();
return r;
}
示例12: writeToFile
void writeToFile(fs::path _path)
{
stringstream ss;
if (fileCount < 0){
fileCount = 0;
ss << fileCount;
outFile.open(fs::path(string(BASE_MODEL_PATH)+"/Data"+ss.str()+".bin"), ios::binary);
ss.flush();
}
else if (byteCount > BYTE_LIMIT){
outFile.flush();
outFile.close();
fileCount++;
ss << fileCount;
outFile.open(fs::path(string(BASE_DEST_PATH)+"/Data"+ss.str()+".bin"), ios::binary);
ss.flush();
byteCount = 0;
// close file and open new
}
Header head;
head.id = strToUint64(_path.stem());
idxFile.open(_path, ios::binary);
dataFile.open(_path.parent_path() / (_path.stem()+".data"), ios::binary);
idxFile.seekg(0, ios::beg);
idxFile.read((char*)&head.indexCount, sizeof(unsigned));
idxFile.seekg(4, ios::beg);
dataFile.seekg(0, ios::beg);
dataFile.read((char*)&head.vertexCount, sizeof(unsigned));
dataFile.seekg(4, ios::beg);
indexData = new unsigned[head.indexCount];
vertexData = new ooctools::V4N4[head.vertexCount];
idxFile.read((char*)indexData, sizeof(unsigned)*head.indexCount);
idxFile.close();
dataFile.read((char*)vertexData, sizeof(V4N4)*head.vertexCount);
dataFile.close();
// ------------------------------------
//write to file
outFile.seekp(byteCount, ios::beg);
//writing header-info
outFile.write((char*)&head, sizeof(Header));
outFile.seekp(byteCount+sizeof(Header), ios::beg);
//writing the indices
outFile.write((char*)indexData, head.indexCount*sizeof(unsigned));
outFile.seekp(byteCount + sizeof(Header) + head.indexCount*sizeof(unsigned), ios::beg);
//writing the vertices
outFile.write((char*)vertexData, head.vertexCount*sizeof(V4N4));
byteCount += head.sizeOf();
outFile.flush();
delete[] vertexData;
vertexData = 0;
delete[] indexData;
indexData = 0;
}
示例13: header
void Multipart::simplifyMimeStructure()
{
// If we're looking at a multipart with just a single part, change
// the mime type to avoid the middle multipart. This affects
// Kaiten Mail.
if ( header()->contentType() &&
header()->contentType()->type() == "multipart" &&
parts->count() == 1 &&
( !parts->firstElement()->header()->contentType() ||
parts->firstElement()->header()->contentType()->type() != "multipart" ) ) {
Header * me = header();
Header * sub = parts->firstElement()->header();
me->removeField( HeaderField::ContentType );
ContentType * ct = sub->contentType();
if ( ct )
me->add( ct );
me->removeField( HeaderField::ContentTransferEncoding );
ContentTransferEncoding * cte = sub->contentTransferEncoding();
if ( cte )
me->add( cte );
me->removeField( HeaderField::ContentDisposition );
ContentDisposition * cd = sub->contentDisposition();
if ( cd )
me->add( cd );
if ( !ct && !cte && !cd )
me->removeField( HeaderField::MimeVersion );
}
}
示例14: IsTokenEqual
/**
* This method checks if Tokens in two CoAP headers are equal.
*
* @param[in] aHeader A header to compare.
*
* @retval TRUE If two Tokens are equal.
* @retval FALSE If Tokens differ in length or value.
*
*/
bool IsTokenEqual(const Header &aHeader) const {
return ((this->GetTokenLength() == aHeader.GetTokenLength()) &&
(memcmp(this->GetToken(), aHeader.GetToken(), this->GetTokenLength()) == 0));
}
示例15: setIndirection
void GPUOctree::dumpIndirection(const char *filename)
{
m_idr = new short[INDIRECTIONPOOLSIZE*4];
m_dt = new float[DATAPOOLSIZE*4];
setIndirection(m_root);
half *idr_r = new half[INDIRECTIONPOOLSIZE];
half *idr_g = new half[INDIRECTIONPOOLSIZE];
half *idr_b = new half[INDIRECTIONPOOLSIZE];
half *idr_a = new half[INDIRECTIONPOOLSIZE];
for(long i=0; i<INDIRECTIONPOOLSIZE; i++) {
idr_r[i] = (half)m_idr[i*4];
idr_g[i] = (half)m_idr[i*4+1];
idr_b[i] = (half)m_idr[i*4+2];
idr_a[i] = (half)m_idr[i*4+3];
}
// save indirection
Header idrheader (INDIRECTIONPOOLWIDTH, INDIRECTIONPOOLWIDTH);
idrheader.insert ("root_size", FloatAttribute (m_rootSize));
idrheader.insert ("root_center", V3fAttribute (Imath::V3f(m_rootCenter.x, m_rootCenter.y, m_rootCenter.z)));
idrheader.channels().insert ("R", Channel (HALF));
idrheader.channels().insert ("G", Channel (HALF)); // 1
idrheader.channels().insert ("B", Channel (HALF));
idrheader.channels().insert ("A", Channel (HALF)); // 2
std::string idrname = filename;
idrname += ".idr";
OutputFile idrfile (idrname.c_str(), idrheader); // 4
FrameBuffer idrframeBuffer;
idrframeBuffer.insert ("R", // name // 6
Slice (HALF, // type // 7
(char *) idr_r, // base // 8
sizeof (*idr_r) * 1, // xStride// 9
sizeof (*idr_r) * INDIRECTIONPOOLWIDTH));
idrframeBuffer.insert ("G", // name // 6
Slice (HALF, // type // 7
(char *) idr_g, // base // 8
sizeof (*idr_g) * 1, // xStride// 9
sizeof (*idr_g) * INDIRECTIONPOOLWIDTH));
idrframeBuffer.insert ("B", // name // 6
Slice (HALF, // type // 7
(char *) idr_b, // base // 8
sizeof (*idr_b) * 1, // xStride// 9
sizeof (*idr_b) * INDIRECTIONPOOLWIDTH));
idrframeBuffer.insert ("A", // name // 6
Slice (HALF, // type // 7
(char *) idr_a, // base // 8
sizeof (*idr_a) * 1, // xStride// 9
sizeof (*idr_a) * INDIRECTIONPOOLWIDTH));
idrfile.setFrameBuffer (idrframeBuffer); // 16
idrfile.writePixels (INDIRECTIONPOOLWIDTH);
delete[] idr_r;
delete[] idr_g;
delete[] idr_b;
delete[] idr_a;
// save data
half *dt_r = new half[DATAPOOLSIZE];
half *dt_g = new half[DATAPOOLSIZE];
half *dt_b = new half[DATAPOOLSIZE];
half *dt_a = new half[DATAPOOLSIZE];
for(long i=0; i<DATAPOOLSIZE; i++) {
dt_r[i] = (half)m_dt[i*4];
dt_g[i] = (half)m_dt[i*4+1];
dt_b[i] = (half)m_dt[i*4+2];
dt_a[i] = (half)m_dt[i*4+3];
}
Header dtheader (DATAPOOLWIDTH, DATAPOOLWIDTH);
dtheader.channels().insert ("R", Channel (HALF));
dtheader.channels().insert ("G", Channel (HALF)); // 1
dtheader.channels().insert ("B", Channel (HALF));
dtheader.channels().insert ("A", Channel (HALF)); // 2
std::string dtname = filename;
dtname += ".exr";
OutputFile dtfile (dtname.c_str(), dtheader); // 4
FrameBuffer dtframeBuffer;
dtframeBuffer.insert ("R", // name // 6
Slice (HALF, // type // 7
(char *) dt_r, // base // 8
sizeof (*dt_r) * 1, // xStride// 9
sizeof (*dt_r) * DATAPOOLWIDTH));
dtframeBuffer.insert ("G", // name // 6
Slice (HALF, // type // 7
(char *) dt_g, // base // 8
sizeof (*dt_g) * 1, // xStride// 9
sizeof (*dt_g) * DATAPOOLWIDTH));
dtframeBuffer.insert ("B", // name // 6
Slice (HALF, // type // 7
(char *) dt_b, // base // 8
sizeof (*dt_b) * 1, // xStride// 9
sizeof (*dt_b) * DATAPOOLWIDTH));
//.........这里部分代码省略.........