C++ :: Stream Iterators And Buffers?

Feb 6, 2013

Do stream iterators, such as std::istreambuf_iterator<char>, read a chunk of bytes internally, or do they read the stream one byte at a time?

Because I am thinking to write a BufferedFile class which uses an std::vector<char>.

View 3 Replies


ADVERTISEMENT

Visual C++ :: File Stream Change Its Address During Writing Text Contents To The Stream

Apr 29, 2013

I wrote a program to write text contents to file stream through fputs, the file stream address was changed in the middle of writing text content to the stream (11% text content have been put into the file stream), that cause the file stream pointer can be evaluated problem and raise exception on stream validation code in fputs library function, my question is what things could go wrong to make file stream pointer changed its address to something else or a NULL pointer if the file stream have not been flushed and closed.

View 5 Replies View Related

C/C++ :: How To Use UMDF Driver Request Buffers

Feb 18, 2015

I am trying to create "dummy" drivers for testing purposes of another program of mine.

I want to be able to Call DeviceIoControl and pass a string in as the buffer and then receive that string in the driver, change it and return it. But right now I am not able to receive the string, when i get the buffer and print it out it is garbage. Where am I going wrong?

TEST

int _tmain(int argc, _TCHAR* argv[]) {
BOOL freeResult, runTimeLinkSuccess = FALSE;
HANDLE RTC_IOControlHandle = NULL;
HINSTANCE FRS_IOControlHandle = NULL;
RTC_IOControlHandle = CreateFile(L"\.ROOT#SAMPLE#0000#{db3d5a0e-63aa-4b97-9d05-b50d5093a20f}",
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,//FILE_SHARE_READ | FILE_SHARE_WRITE,

[code]....

View 4 Replies View Related

C :: How To Capture And Store Serial Communication Data In Buffers

Jun 18, 2013

I sent 1preample and 4bytes in transmitting side , preample contains only 1 and 0 with 4milliseconds delay, each byte contains 8bits with 2milliseconds delay , if a bit contains 1 it will send 1millisecond high and 1millisecond low signal ,and if a bit contains 0 it will send 2millisecond continuous delay, I have a problem at receiving side how to capture and store the preample and 4byte values in a buffer , i am using ARM processor it will update every 5microsecond ..

View 1 Replies View Related

C# :: Concurrent Sharp Panel Connection With Semaphores And Buffers

Apr 26, 2014

I have a problem with my C#. Trying to create the airstrip with planes heading out of the hangars and on to the road to the airstrip. Each Hangar pannel is connected with closes road to them. What i am stuck with right now is connecting the roads together so each one of them will see if the next road is free and if it is it will send the plane (colorder square for now) to it and then proceed to the next one when finaly they will line up for the final panel(airstrip) and take off.So far they are just going down the each road they are assigned with semaphore and thread.

using System;
using System.Windows.Forms;
using System.Threading;
using System.ComponentModel;
using System.Collections;
using System.Data;
using System.Drawing;

[Code] ....

Connecting the "p2" with "p5" so the graphics from "p1" the square will travel through P2 and P5 this would be great and will allow me to procede with my studies.

Also i do realise that this might not be the best ways of using concurrent Csharp and not the up to date one but this is what i have been assigned with and do not have any other options unfortunately.

How i understand this is that i need to have 3 buffers and 3 semaphores for each panel. But i do not know how to add those to each one of them and then connect it with the next one as if i try and add them it either puts a cross in the design view over that panel or says that there is limited options for this statement.

This is the way that i want to do it unfortunately it must be so. The most flexible this can be is by adding an array for semaphores and buffer ( do not know how to do that either).

View 7 Replies View Related

C/C++ :: Getting Values For Iterators

Dec 25, 2014

I'm having problem getting the values for iterators. This code:

auto sum = inputVec.begin() + itLast;

gave this error: no match for 'operator+'

#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
int main(){
vector<int> inputVec;

[Code] .....

View 4 Replies View Related

C++ :: Random Access Iterators

May 20, 2013

In this code:

vector<int> mydata(100);
mydata[2] = 999;

In statement 2 does that call the iterator to access the 3rd position and set its value to 999?

View 18 Replies View Related

C++ :: Checking Type With Iterators

Oct 13, 2013

Assuming I have a list of pointers to a generic type T:

#include <vector>
//...
list<T*> myList;

Now assuming I want to go on the list, and if T's type is matched to the type I'm looking for, then cast it to this type and do something. List shown here:

list<T*>:: const_iterator iter= myList.begin();
for(; iter!=myList.end(); ++iter){
if( typeid(*iter)==typeid(Something*)) //RUN-TIME ERROR
dynamic_cast<Something*>(*iter)->DoSomething();
}

how do I fix this run-time error?

View 1 Replies View Related

C++ :: Std Container Iterators - Category?

Jun 15, 2014

When using an iterator with a std container (list / vector etc) sometimes it's possible to modify the container (e.g. delete an item) yet still carry on using the iterator - whereas in other cases, modifying the container immediately invalidates any open iterators on it. Is there an easy way to know which containers fall into which category? (or does it vary from one compiler to another?)

View 2 Replies View Related

C++ :: Segmentation Fault With Vectors And Iterators?

Oct 8, 2014

I am working on very large code.

View 4 Replies View Related

C/C++ :: Segmentation Fault With Vectors And Iterators?

Oct 9, 2014

I am working on very large code. I got a segmentation fault when trying to use one cpp file and tried to locate the error using Valgrind

Since the code is very large, I will only post a short portion of it below. I think the problem may come because triann is a vector defined in the header class, so triann[tri] is causing problems?

void ADe::aNe(int v, set<int> &nei)
{
for(set<int>::iterator iter = vert2tri[v].begin(); iter != vert2tri[v].end(); iter++)
{

[Code].....

View 4 Replies View Related

C++ :: Custom (readonly) Container And Iterators?

Jul 5, 2012

I'm working on writing some classes around a ROM hardware addon card. The classes expose the data on the ROM as a container with iterators, much like a vector or a list.

The classes don't have any data themselves, since all the data is on the ROM.

I'm having some dillemma's as to how to approach/implement the classes. If you were to write somethign like this... Or were using something like this written by someone else.... How would you expect this to be done ?

1) Make all the member functions static, make a private constructor to prevent making instances. This works, but may look a bit weird...

Code:
for (auto it = RomTable::begin(); it != RomTable::end(); ++it)

2) expect users to make a (dummy) instance, then use it as a regular container. this might be a bit counter intuitive since the class has no datamembers.

3) create a single instance, expect users to use that everywhere. make the constructor inaccessible. Some C++ 'purists' might perceive this as global data and thus not a good solution ?

Additionally. Do I need to provide both a const_iterator and an iterator ? There's nothing to be modified, so I'm guessing an iterator isn't needed (?) Or will some STL stuff not work without an iterator ? I'm obviously not fussed about the STL functions that make changes to the container to not work (like sort, fill, swap...)

View 14 Replies View Related

C++ :: Custom STL Compatible Containers And Iterators?

Jul 18, 2012

So i made an STL compatible container.And to make this work I had to make my own iterator (derived from std::iterator).

What is the portable (if any) and "well behaved" thing to do in case of usage anomalies.such as iterating an iterator too far, or passing an invalid index to a operator[]

Looking at how VC++ does things in something like std::array or std::vector.

Code:

iterator_type& operator+=(difference_type offset)
{// increment by integer
#if _ITERATOR_DEBUG_LEVEL == 2
if (size < index + offset)
{// report error

[Code] .....

lots of names starting with underscores, so it's implementation specific. Is there even a "well behaved" thing to do ? Or is any such work always going to be compiler specific?

View 2 Replies View Related

C++ :: Graph Class - How To Provide Virtual Iterators

May 29, 2013

I have a 'Graph' class, which has derived classes for Adjacency Matrix and Adjacency List representations.

How do I provide iterators for traversing vertices and edges, when the iterator classes would have different implementations for the different derived classes ?

The following way is the only one I can think of, but seems quite cumbersome.

Code:
class Base {
public:
class BaseIterator {

};
virtual const BaseIterator& begin();
virtual const BaseIterator& end();

[Code] .....

Or is there a pattern for doing this that I'm not aware of ? Would composition be a better idea here compared to polymorphism ? I mean, I can think like..a Graph can 'have' several representation 'objects' within it.

All the involved classes are templates,not sure if that makes the situation different.

View 7 Replies View Related

C++ :: Vector Iterators Incompatible In Debug Mode

Jul 11, 2013

I get this error when i try to run this code for an inventory in debug mode in VS. But for some reason it works just fine in release mode.

void Push_Back_Item(Item *item){
for(int y = 0; y < InvSizeY; y ++)
for(int x = 0; x < InvSizeX; x ++){
auto Iter = ItemList.find(std::make_pair(x,y));
if(Iter != ItemList.end()){
item->SetDead(); // ERROR
}
}
}

This isnt the full code though but it still gives me the same error.

The only thing "item->SetDead()" does is to set a bool to true.

This is the map i get the iterator from
std::map<std::pair<int,int>,Item*> ItemList;

This have been bugging me for quite some time now.

View 4 Replies View Related

C++ :: File Stream Loop

Dec 4, 2013

Why does my loop loops 3 times when i have only 2 line of data in my file? From the cout << s.size , when i run it will show 1,2,3.

Information in txt file
Code:
local john 10/2/1990
international tom 2/5/2000 output Code: local john 10/2/1990
international tom 2/5/2000
international tom 2/5/2000 Code: ifstream in(filename);

[Code] ....

View 4 Replies View Related

C++ :: Displaying Image From Stream

Feb 24, 2013

I'm trying to display an image from a stream data. But there is no image when getting image::from stream.

It's my source code:

Code:
IStream* pstream = NULL;
if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream))) {
ULONG lreal = 0;
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );

[Code]...

There is no image from data.

View 5 Replies View Related

C++ :: Copying One File To Another - I/O Stream

Mar 4, 2013

I'm having some trouble with copying one I/O stream into another. I've put the first one into an array but I cannot get my second prompt to copy the .txt file the first prompt sees and outputs to the console. When I try and grab the info from the .txt file my first prompt sees I only see blank space in my .txt file.

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <fstream>
using std::ifstream;
using std::ofstream;

[Code] .....

View 1 Replies View Related

C++ ::  reading Stream Value From A File?

Oct 13, 2013

#include<fstream.h>
#include<conio.h>
#include<string>
class CLS {
public : string name;

[code]....

I have used the above code to write the class instanc to a file "Text.txt"...But it seems that "f.write((char*)&c, sizeof(CLS));" is not working properly with string. The data can easily be written using stream object!

#include<fstream.h>
#include<conio.h>
#include<string>
class CLS {
public : string name;

[code]....

When I tried to read the data on the file...., it gave an error "Thread stopped...violation.."

View 7 Replies View Related

C# :: Possible To Send Audio Over Mic Stream?

Mar 10, 2014

I'd like to be able to output sound over skype as if it were coming from my headset, how would I go about this?

View 1 Replies View Related

C/C++ :: To Delete Words (The) From Stream

Dec 14, 2014

I need to use getchar and putchar. The task is simple to say but not that easy to implement as it may seem. I end up with:

char c = 0, c_ = 0, c__ = 0;
while ((c = getchar()) != '.') {
if (c == 't') {
c__ = c;
c = getchar();

[Code] ....

If the word "the" is followed with another one, the last isn't eliminated. I enter "thethe" and get "the", what is not right.

View 1 Replies View Related

C++ :: File Stream And String Extraction?

Apr 7, 2014

I am currently trying to read in a file that takes in the input in the following form.

Code:
HANK>25 BOB>31 AL>54
BILL>41 ABE>63 JEFF>50

I have tried the following solution:

Code:
#include<ifstream>
#include<iostream>
using namespace std;
struct node
{
string name;
int age;
);
int main ()
{

[code]....

The problem is a.name, it's extracting the entire string before the space character causing p.age to contain "BOB" and so on. I've tried using p.get(p.name, sizeof(p.name), '-') with '-' as the delimiter and p.getline() using a character array instead of a string. How would it be possible to only copy the string into a.name before the '>' character?

View 1 Replies View Related

C++ :: Redirecting A File Stream To Stdout

Sep 20, 2013

Let us assume I have a program that takes the name of the output file from the command line. Now let us assume that a decided not to give any output file location but wanted my program to to print my strings/ints ... directly to stdout. how would one do this using file streams? Using file pointers and c that is pretty straight forward but how would i achieve this in c++.

View 12 Replies View Related

C++ :: Function That Brings In A Stream Object

Sep 23, 2014

I'm supposed to add two new functions to an existing class that I've written early on: readData(ifstream&)and writeData(ofstream&).

The parameters of the program are:
-Create three employee objects as shown,
-Create an ofstream object and open a file. Choose any name for the file that you want. Do not ask the user for the file name. Pass just the file name as the parameter (no path) so that your program assumes the file to be in the same folder as your executable file.
-Send messages to each of the three Employee objects to write themselves out to the file.
-Close the file.
...

If I get writeData(ofstream&) function bit to work! for brevity I've cut all the functions of the class that arent necessary. Here's what I have so far:

Employee.h
#pragma once
#include<string>
using namespace std;

[Code] ....

So I've tried a bunch of different ways to get my objects into the ofstream object to write them to the file, but I'm supposed to use the two new functions somehow...but I'm way lost.

View 5 Replies View Related

C++ :: How To Add Array Elements To String Stream

Oct 17, 2013

This is my code:

#include <iostream>
#include <string>
#include <istream>
#include <sstream>
using namespace std;
int main() {
string groups[3] = {};

[Code] ....

It outputs jibberish. I can do what I need to do but I would need to declare more variables and write more cout's, isn't there a way to add these elements to a stringstream or streambuffer? My goal is to write this program and make it as comprehensive as possible but also with very few lines.

View 1 Replies View Related

C++ :: Stream Buffer To Base64 String

Oct 2, 2013

I have problem with this code:

#include <windows.h>
#include <stdio.h>
#include <gdiplus.h>
#include "ScreenCap.h"
#include <wchar.h>
#include "base64.h"
#include <sstream>

using namespace Gdiplus;
int GetEncoderClsid(WCHAR *format, CLSID *pClsid) {

[Code] ....

This function return me a long series of Y ended with other chars but not the base64 string.

I think the problem is std::string encodedstring = base64_encode(buffer, dwBufferSize); but I can't figure out the problem.

The base64 function is: [URL] ....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved