|
-
April 2nd, 2009, 02:22 AM
#1
I am a bit lost there ....
Good day lads. Please help me if you can, because I am stuck a bit.
Lets say I have this
Code:
-== Parseris ==-
Parsing file type: material
- 1.000 addr: 0x22fd5c
- 1.202 addr: 0x22fd5c
- ambient_shader addr: 0x22fd5c
-- default_ambient_shader.shader addr: 0x22fcbc
-- blend addr: 0x22fcbc
--- 1.00000 addr: 0x22fc1c
--- 2.000 addr: 0x22fc1c
--- 2.00000 addr: 0x22fc1c
--- 3.00000 addr: 0x22fc1c
--- 4.00000 addr: 0x22fc1c
-- diffuse addr: 0x22fc1c
--- 2.0000 addr: 0x22fb7c
--- alfa addr: 0x22fb7c
---- 99.99 addr: 0x22fadc
- texture_unit addr: 0x22fadc
-- textura.png addr: 0x22fa3c
-- RBGA addr: 0x22fa3c
- texture_unit addr: 0x22fa3c
-- 1.00 addr: 0x22f99c
I just writte each element pointer address.
Question:
1) Does it realy have to be like this
- 1.000 addr: 0x22fd5c
- 1.202 addr: 0x22fd5c
I allways thouth that
- 1.000 addr: 0x22fd5c
- 1.202 addr: 0x22fcbc
2) There is a different depht of data. as you see - -- ---- and so on. So as in first question where we see that the same level data have the same address. So why
- texture_unit addr: 0x22fadc <---------- This
-- textura.png addr: 0x22fa3c
-- RBGA addr: 0x22fa3c
- texture_unit addr: 0x22fa3c <----------- This
Why different address.
Thankyou in advice. I just lost a bit there ....
Share and always try to give back more.
-
April 2nd, 2009, 04:11 AM
#2
Re: I am a bit lost there ....
 Originally Posted by ulumulu
Good day lads. Please help me if you can, because I am stuck a bit.]
I don't see any C++ code.
No one knows what that output is, how it was produced, or what it represents. Show us real code and ask a question with respect to actual code.
Regards,
Paul McKenzie
-
April 2nd, 2009, 04:26 AM
#3
Re: I am a bit lost there ....
Look for fstream header file.
Thanks for your help.
-
April 2nd, 2009, 05:13 AM
#4
Re: I am a bit lost there ....
 Originally Posted by Peter_APIIT
Look for fstream header file.
What has fstream to do with this?
- Guido
-
April 2nd, 2009, 07:42 AM
#5
Re: I am a bit lost there ....
Are both texture_unit outputs from the same object (i.e. same instantiation). Or are they separate, because each time you create a new object, regardless of it's class, it will have its own memory address.
Intel Core Duo Macbook w/ Mac OS 10.5.6
gcc 4.2.1 (i386-apple-darwin9.1.0) and Xcode 3.1.1
-
April 2nd, 2009, 10:09 AM
#6
Re: I am a bit lost there ....
Code:
void Parser::materialParsing (char *source)
{
/*
{ - New Block
, /n /t/ /r ' ' - New element
} - The end of the block
*/
char *temp = source++;
tempVector.clear();
while (*source)
{
if ((strchr(", \n\r\t", *source)) && (alfaORnumber(*(source-1))))
{
*source++ = '\0';
if (!nameSet)
{
parsedMaterials[temp];
nameSet = true;
}
else
{
temp = getRidOfUseless (temp);
tempVector.push_back(temp);
source = getRidOfUseless (source);
std::cout<<line<<" "<<temp<<std::endl;
temp = source;
}
}
if (*source == '}')
{
*source++ = ' ';
depth--;
line.erase(line.length()-1);
}
if (*source == '{')
{
*source++ = '\0';
depth++;
line += '-';
/*
std::vector <char *>::iterator list_begin = tempVector.begin(), list_end = tempVector.end();
std::cout<<" ==== "<<std::endl;
while (list_begin < list_end)
{
std::cout<<*list_begin<<std::endl;
*list_begin++;
}
*/
materialParsing (source);
}
source++;
}
/*
#if 1
subStringPointers.clear();
readsubStrings( chunckOfData );
#endif
There is some code. Probably buggy a bit but the idea should be seen.
In other words all stuff should go in to there.
Code:
struct dataBlock
{
std::vector <char*> dataPointers;
std::vector <dataBlock*> structPointers;
};
std::map <std::string, dataBlock*> parsedMaterials;
Share and always try to give back more.
-
April 3rd, 2009, 03:20 AM
#7
Re: I am a bit lost there ....
 Originally Posted by Etherous
Are both texture_unit outputs from the same object (i.e. same instantiation). Or are they separate, because each time you create a new object, regardless of it's class, it will have its own memory address.
OK but if it is recursion ??? It does not create new objects. It should stay on the same address.
Does it ???
Share and always try to give back more.
-
April 3rd, 2009, 04:57 AM
#8
Re: I am a bit lost there ....
Code:
std::vector <char*> dataPointers;
So what happens when the data you've added changes what it points to? Your data in the vector also changes. Is this the behaviour you want?
Anytime I see a container of char*, that is a sign of bad things will happen.
Code:
#include <vector>
#include <cstdlib>
std::vector<char*> test;
int main()
{
char str[] = "Hello";
test.push_back(str);
strcpy(str, "World");
test.push_back(str);
}
So what is in test[0] and test[1] when this code is executed? Is it this?
test[0] == "Hello"
test[1] == "World"
The answer is no. Both test[0] and test[1] contain "World". So what happened to the first push_back? I leave it to you to figure it out, and the reason why a container of char* is dangerous and error-prone.
If you want the vector to contain strings, then make it a vector of strings, not char*
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|