本文整理汇总了C++中writeChar函数的典型用法代码示例。如果您正苦于以下问题:C++ writeChar函数的具体用法?C++ writeChar怎么用?C++ writeChar使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeChar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeCString
void VerticalRowOutputStream::writeSpecialRow(const Block & block, size_t row_num, const char * title)
{
writeCString("\n", ostr);
row_number = 0;
field_number = 0;
size_t columns = block.columns();
writeCString(title, ostr);
writeCString(":\n", ostr);
size_t width = strlen(title) + 1;
for (size_t i = 0; i < width; ++i)
writeCString("─", ostr);
writeChar('\n', ostr);
for (size_t i = 0; i < columns; ++i)
{
if (i != 0)
writeFieldDelimiter();
auto & col = block.getByPosition(i);
writeField(*col.column, *col.type, row_num);
}
}
示例2: writeNStringP
/**
* Writes a null terminated string from flash program memory to UART.
* You can use the macro writeString_P(STRING); , this macro
* ensures that the String is stored in program memory only!
* Otherwise you need to use PSTR("your string") from AVRLibC for this.
*
* Example:
*
* writeNStringP(PSTR("Robotarm System\n"));
*
* // There is also a Macro that makes life easier and
* // you can simply write:
* writeString_P("Robot ARm System\n");
*
*/
void writeNStringP(const char *pstring)
{
uint8_t c;
for (;(c = pgm_read_byte_near(pstring++));writeChar(c));
}
示例3: wb
String FieldVisitorToString::operator() (const Array & x) const
{
String res;
WriteBufferFromString wb(res);
writeChar('[', wb);
for (Array::const_iterator it = x.begin(); it != x.end(); ++it)
{
if (it != x.begin())
wb.write(", ", 2);
writeString(applyVisitor(*this, *it), wb);
}
writeChar(']', wb);
return res;
}
示例4: writeChar
void TabSeparatedRowOutputStream::writeExtremes()
{
if (extremes)
{
size_t rows = extremes.rows();
size_t columns = extremes.columns();
writeChar('\n', ostr);
for (size_t i = 0; i < rows; ++i)
{
if (i != 0)
writeRowBetweenDelimiter();
writeRowStartDelimiter();
for (size_t j = 0; j < columns; ++j)
{
if (j != 0)
writeFieldDelimiter();
writeField(*extremes.unsafeGetByPosition(j).column.get(), *extremes.unsafeGetByPosition(j).type.get(), i);
}
writeRowEndDelimiter();
}
}
}
示例5: ss
void FTPClient::storData(std::string param)
{
int32_t ch;
std::ifstream in;
std::string token, reply;
std::stringstream ss(param);
// arg may be a ',' seperated list of arguments.
while ( getline(ss, token, ','/* DELIMITER */) )
{
// Establish Data Connection
dataConnect();
//########## Send file character by character ############
in.open(token.c_str(),std::ifstream::in);
ch = in.get();
while ( in.good() )
{
//#TODO if the file contains NULL character.
writeChar(this->datafd, (char)ch);
ch = in.get();
}
//#######################################################
in.close();
// Close Data Connection (Indicates EOF )
close(this->datafd);
// Create a new data socket for FUTURE.
createDataSock();
}
}
示例6: wakeSensors
// 4.3 - this function sends out the characters of the String cmd, one by one
void SDI12::sendCommand(String cmd){
wakeSensors(); // wake up sensors
for (int i = 0; i < cmd.length(); i++){
writeChar(cmd[i]); // write each characters
}
setState(LISTENING); // listen for reply
}
示例7: MQTTSNSerialize_register
/**
* Serializes the supplied register data into the supplied buffer, ready for sending
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param topicid if sent by a gateway, contains the id for the topicname, otherwise 0
* @param packetid integer - the MQTT packet identifier
* @param topicname null-terminated topic name string
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTSNSerialize_register(unsigned char* buf, int buflen, unsigned short topicid, unsigned short packetid,
MQTTSNString* topicname)
{
unsigned char *ptr = buf;
int len = 0;
int rc = 0;
int topicnamelen = 0;
FUNC_ENTRY;
topicnamelen = (topicname->cstring) ? strlen(topicname->cstring) : topicname->lenstring.len;
if ((len = MQTTSNPacket_len(MQTTSNSerialize_registerLength(topicnamelen))) > buflen)
{
rc = MQTTSNPACKET_BUFFER_TOO_SHORT;
goto exit;
}
ptr += MQTTSNPacket_encode(ptr, len); /* write length */
writeChar(&ptr, MQTTSN_REGISTER); /* write message type */
writeInt(&ptr, topicid);
writeInt(&ptr, packetid);
memcpy(ptr, (topicname->cstring) ? topicname->cstring : topicname->lenstring.data, topicnamelen);
ptr += topicnamelen;
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
示例8: writeString
void writeString(char * string, int length) {
int i;
for (i = 0; i < length; i++) {
writeChar(string[i]);
}
}
示例9: MQTTSerialize_unsuback
/**
* Serializes the supplied unsuback data into the supplied buffer, ready for sending
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param packetid integer - the MQTT packet identifier
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTSerialize_unsuback(char* buf, int buflen, int packetid)
{
MQTTHeader header;
int rc = 0;
char *ptr = buf;
FUNC_ENTRY;
if (buflen < 2)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = UNSUBACK;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
writeInt(&ptr, packetid);
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
示例10: write
/* Blocking write to STDIN */
int write(char * buf, int len)
{
int i;
for(i = 0; i < len; i++)
writeChar(buf[i]);
return len;
}
示例11: writeChar
void JSONRowOutputStream::writeRowEndDelimiter()
{
writeChar('\n', *ostr);
writeCString("\t\t}", *ostr);
field_number = 0;
++row_count;
}
示例12: createFontAtlas
void createFontAtlas(u8 *buffer, u32 width, u32 height)
{
// write entire font set to buffer
u32 x = 1;
u32 y = 1;
u32 char_width = s_glyph_width + 1;
u32 char_height = s_glyph_height + 1;
for (u32 c = 32; c < 127; ++c, x += char_width)
{
// if at end of buffer, go to next line
if ((width - x) < char_width)
{
x = 1;
y += char_height;
}
// stop at end of buffer
if ((height - y) < char_height)
{
break;
}
// write char to buffer
writeChar(c, &buffer[(y * width) + x], width, 255);
}
}
示例13: MQTTSPacket_send_willTopic
int MQTTSPacket_send_willTopic(Clients* client)
{
char *buf, *ptr;
MQTTS_WillTopic packet;
int rc, len;
FUNC_ENTRY;
len = 1 + strlen(client->will->topic);
ptr = buf = malloc(len);
packet.header.type = MQTTS_WILLTOPIC;
packet.header.len = len+2;
packet.flags.all = 0;
packet.flags.QoS = client->will->qos;
packet.flags.retain = client->will->retained;
writeChar(&ptr, packet.flags.all);
memcpy(ptr, client->will->topic, len-1);
rc = MQTTSPacket_send(client, packet.header, buf, len);
free(buf);
Log(LOG_PROTOCOL, 44, NULL, client->socket, client->addr, client->clientID,
client->will->qos, client->will->retained, client->will->topic, rc);
FUNC_EXIT_RC(rc);
return rc;
}
示例14: MQTTSPacket_send_subscribe
int MQTTSPacket_send_subscribe(Clients* client, char* topicName, int qos, int msgId)
{
MQTTS_Subscribe packet;
int rc = 0;
char *buf, *ptr;
int datalen = 3 + strlen(topicName);
FUNC_ENTRY;
packet.header.len = datalen+2;
packet.header.type = MQTTS_SUBSCRIBE;
/* TODO: support TOPIC_TYPE_PREDEFINED/TOPIC_TYPE_SHORT */
packet.flags.all = 0;
packet.flags.topicIdType = MQTTS_TOPIC_TYPE_NORMAL;
packet.flags.QoS = qos;
ptr = buf = malloc(datalen);
writeChar(&ptr, packet.flags.all);
writeInt(&ptr, msgId);
memcpy(ptr, topicName, strlen(topicName));
rc = MQTTSPacket_send(client, packet.header, buf, datalen);
free(buf);
FUNC_EXIT_RC(rc);
return rc;
}
示例15: I2C_transmissionError
/**
* This function gets called automatically if there was an I2C Error like
* the slave sent a "not acknowledge" (NACK, error codes e.g. 0x20 or 0x30).
*/
void I2C_transmissionError(uint8_t errorState)
{
writeString_P("\n############ I2C ERROR!!!!! - TWI STATE: 0x");
writeInteger(errorState, HEX);
writeChar('\n');
errors++;
}