CComVariant, string destructors
I've tried to find a definitive answer to this question but the WEB is full of text copies of half answers. So the CComVariant in the code below frees the string used to hold the text, right?
CComVariant cvFname(szFilename);
VARIANT result;
VariantInit(&result);
m_hr = OLEMethod(DISPATCH_METHOD, &result, m_pDocuments, L"Open", 1, cvFname);
m_pActiveDocument = result.pdispVal;
So when cvFName goes out of scope the memory for the string is releases,freed,...? I realise that szFilename is my responsability, but that is a different aspect.
Have I understood correctly?
http://www.ransen.com Cad and Graphics software
On 3/23/2015 10:03 AM, "Owen Ransen" wrote:
CComVariant cvFname(szFilename);
So when cvFName goes out of scope the memory for the string is releases,freed,...?
Depends on which string you mean by "the string" - there are at least two in this code. CComVariant's constructor makes a copy of szFilename. That copy is freed by CComVariant's destructor. szFilename is not in any way modified in the process.
Igor Tandetnik
Similar Messages
-
String allocation in ResultSet::getString() issue
Hi all :)
I have been learning the basics of OCCI and I am having a
problem with Debug mode in MSVC. When I retrieve a string from
ResultSet::getString, and the string goes out of scope, I get an
assert about an invalid heap pointer.
I think that somehow the ResultSet object is setting the pointer
inside of the string object in a way which would circumvent the
list of allocations on the debug heap. So that when the string
destructor is called, it tries to free the internal pointer, and
asserts.
Everything works correctly in Release mode.
Is there any suggested way of handling this? Or is there a debug
version of the OCCI?
Here is the simplistic offending code:
while (rs->next())
string username = rs->getString(1);
string passwd = rs->getString(2);
} <--- asserts here
Any help would be great :)
Thanks,
Gerald FishelOCCI has multiple copies of libraries that work with different compiler versions. Please make sure you are using the appropriate version of dll. You can search for this topic on OCCI forum.
C++ Call Interface (OCCI) -
Help with possibly noobish question
Hello,
I need to make some complex graph structures such that this format will not do
1: 2 ->4
2: 4 ->2
I have several additions to each node to take care of that is the main problem.
each node has aarity which I could hold as a separate array to be accessed for each object instance of a node
Part 1:
The problem is that i have to know which node is connected to which arity element and then I have to search for the free elements and label their indexes with characters. I think I can solve this
Part 2:
The second problem is maybe a little worse as I have to translate certain groups graphs to something like this and then connect them to any graph as needed. Will i need to make a separate object for this purpose??
| ..................| n input wires connected |
|???????????????????????????????????|
| Wires maped to edges from graph |
|___________________________________|
| ..................| n output wires wires connected |
Part 3:
To compound this I have to find a way to implement a menu selector to choose random graphs or parts of graphs for a Genetic Algorithm. Selection is not the problem here its is mapping the structures into a chromosone which is causing me the problem.
Part 4:
Each connection has the graphs triggers different application specific rules that cause the graph to reduce or change connections.
Any help on strategies for these problems would greatly be appreciated
kind regards
PrashantHello all and thanks for the replies positive or not. Sorry if I offended you bbritta. I guess its not such and easy question after all.
Well its not due tomorrow and I am doing some research into a wierd topic so you guys are along the right lines. The topic I am researching is non-determinstic interaction nets. I don't know too many people doing this. Interaction Nets invented by a guy named Yves Lafont and you can google this and the topic I am researching.
All the code written thus far exists in C and is very hard to interpret as it uses a Lex and Yacc parser to implement the creation of tokens and syntax rules of the Interaction Nets programming language.
Basically its a high level visual graph programming language however it can also be used on low level based on interpretation. Thus the need for graph data structures. Essentially I have to modify this programming language for non-determinism and demonstrate this in a Genetic Algorithm. The latter would be no problem if I could get the data structure sorted. People familiar with Lamda calculus, Linear Logic and Process Calculus might have seen this in some research papers.
However I have not had a very good theoretical background so finding the data structures to map the complexity of the graphs is a little problematic. I will outline my idea and what I have done a little clearer below.
So far I have broken the prob into smaller steps as suggested by someone, I hope the pseudo code helps a little more.
class Symbol
convertASCIItoINt( char value) : return int
getChar() : return char
checkAvailability() : return boolean;
//each Symbol is assigned to a free port and is traditionally input.
//several instances of this obj are used to
class Port implements Symbol
initialisePort( num);
checkFreePorts( ) : return boolean;
setPortSymbol (port [num])
private ports [ num ];
setEndPortAsSpecial( ports [ num ]) // each node has a special port called principal port
// each node has a set of port and each port can have a label as a string
class Node
setNodeSymbol()
getnodeSymbol()
public Port node_obj [ port_num ];
setSpecialSymbol( string)
//destructor to delete node connected to
//duplicator to create a copy of cell value
//constructor create a copy of the cell
getSpecialSymbol() : return string symbol;
checkSpecialSymbol(node_obj [ port_num ]): return string symbol;
//so far as a typical graph goes i think its acceptable to connect the nodes in an vector with
//a list at each element although this is not shown below.
class Net
connecNodes( node_obj [ port_num], node_obj [ port_num] )
checkDeadlock(): return boolean; //check for cycles
public Node net_obj [ node_num ];
checkConnected( node_obj [ port_num], node_obj [ port_num] ): return boolean;
//this is where the execution engine will be placed
class InteractionRules
ruleTrigger( )
Node n = new n
n.checkSpecialSymbol()
// its here where things get complicated with the data structure as according to the rules I have to delete
// add or copy a value of a particular node in a Net
determineReduction()
//if (ports [ num ] = num )
// a reduction occurs according to the rule in the method above ruleTrigger();
//at this point the relevant nodes will be removed and new nodes will be added according to the rules
storeCopyofOriginalNet()
//needed to rollback if rules are infeasable or deadlock occurs.
}I desperately still need help to complete the data structure I have also considered manipulating the complex associations between the sets as multimaps and maps
Sorry if I am not clear I am trying my best to explain something I have had little background and almost no help in as I am creating the special rules as I go along such as keeping an copy of a net / graph before modifying it in the Genetic Algorithm.
Kind Regards and Best Wishes
Prashant -
Porting from win to mac / expected constructor destructor or type conversion before
I am porting a plugin that works well with CS3/4/5 on Windows to CS3 on Mac.
I am able to compile the SDK samples with XCode. My plugin also compiles with XCode if i remove one cpp file from the project. If i try to compile it with the file (actioncomponent.cpp) compiling fails with the error:
expected constructor destructor or type conversion before .....
I tried to trace the error by commenting out ceveral includes and functions in that file. The error then point's to another place in the file itself or in one included in it, the error is the same.
I generated the project with dollyx, added my .fr, compiled it, added the .fr.rsrc, added source files and built it.
Since this is my first Indesign plugin for Mac I am sure that i miss something general.
Any suggestions?I checked my code against every SDK sample where context/session is used and cannot find any difference. I also took a sample project, included my sources what resulted in the same error messages.
One of them:
Checking Dependencies
CompileC build/myPluginName.build/Default/Release.build/Objects-normal/ppc/myPluginNameActionCompo nent.o /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../../../source/sdksa mples/myPluginName/myPluginNameActionComponent.cpp normal ppc c++ com.apple.compilers.gcc.4_0
cd /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj
/Developer/usr/bin/gcc-4.0 -x c++ -arch ppc -pipe -Wno-trigraphs -fno-exceptions -fpascal-strings -fasm-blocks -O3 -Werror -Wreturn-type -Wunused-value -DMACINTOSH -DBIB_NO_THROW -fmessage-length=0 -mtune=G5 -fvisibility=hidden -fvisibility-inlines-hidden -fno-threadsafe-statics -Wno-deprecated-declarations -mmacosx-version-min=10.4 -gdwarf-2 -I/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/build/myPluginName. build/Default/Release.build/myPluginName.hmap -Wno-deprecated -F/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../release/sdk -F../../../build/mac/release/packagefolder/contents/macos -F../../../build/mac/release/packagefolder/contents/Frameworks -I/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../release/sdk/incl ude -I/Developer/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon -I../../../external/adobesourcelibrary/third_party/boost_tp/boost -I../../../external/afl/includes -I../../../source/precomp/common -I../../../source/precomp/msvc -I../../../source/public/includes -I../../../source/public/interfaces/architecture -I../../../source/private/includes/architecture -I../../../source/private/interfaces/architecture -I../../../source/public/includes/utils -I../../../source/public/interfaces/utils -I../../../source/precomp/msvc -I../../../source/public/interfaces/xmedia -I../../../source/public/interfaces/ui -I../../../source/public/interfaces/tables -I../../../source/public/interfaces/text -I../../../source/public/interfaces/graphics -I../../../source/public/components/widgetbin/includes -I../../../source/public/interfaces/workgroup -I../../../source/public/interfaces/interactive -I../../../source/public/interfaces/interactive/ui -I../../../source/public/interfaces/colormgmt -I../../../source/public/interfaces/utils -I../../../source/public/interfaces/incopy -I../../../source/public/interfaces/layout -I../../../source/public/interfaces/architecture -I../../../source/public/interfaces/cjk -I../../../source/precomp/common -I../../../source/public/includes -I../../../source/public/components/publiclib/plugins -I../../../source/public/components/publiclib/files -I../../../source/public/components/publiclib/objectmodel -I../../../external/boost -I../../../source/sdksamples/common -I../../../external/afl/includes -I../../../source/sdksamples/myPluginName -I/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/build/myPluginName. build/Default/Release.build/DerivedSources -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include build/SharedPrecompiledHeaders/Release/PluginPrefix-hkopdumatdlxfjbkpugezhwgmujv/PluginPr efix.pch -c /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../../../source/sdksa mples/myPluginName/myPluginNameActionComponent.cpp -o /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/build/myPluginName.bu ild/Default/Release.build/Objects-normal/ppc/myPluginNameActionComponent.o
../../../source/public/includes/KeyValuePair.h:36: error: expected constructor, destructor, or type conversion before 'template'
../../../source/public/includes/KeyValuePair.h:82: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:82: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:82: error: 'bool operator==(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:82: error: 'bool operator==(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h: In function 'bool operator==(int)':
../../../source/public/includes/KeyValuePair.h:84: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:84: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:97: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:97: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:97: error: 'bool operator==(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:97: error: 'bool operator==(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h:97: error: redefinition of 'template<class _T1, class _T2> bool operator==(int)'
../../../source/public/includes/KeyValuePair.h:82: error: 'template<class _T1, class _T2> bool operator==(int)' previously declared here
../../../source/public/includes/KeyValuePair.h: In function 'bool operator==(int)':
../../../source/public/includes/KeyValuePair.h:99: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:99: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:112: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:112: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h: In function 'bool operator==(const _T1&, int)':
../../../source/public/includes/KeyValuePair.h:114: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:124: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:124: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:124: error: 'bool operator<(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:124: error: 'bool operator<(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h: In function 'bool operator<(int)':
../../../source/public/includes/KeyValuePair.h:126: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:126: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:135: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:135: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:135: error: 'bool operator<(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:135: error: 'bool operator<(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h:135: error: redefinition of 'template<class _T1, class _T2> bool operator<(int)'
../../../source/public/includes/KeyValuePair.h:124: error: 'template<class _T1, class _T2> bool operator<(int)' previously declared here
../../../source/public/includes/KeyValuePair.h: In function 'bool operator<(int)':
../../../source/public/includes/KeyValuePair.h:137: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:137: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:146: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:146: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h: In function 'bool operator<(const _T1&, int)':
../../../source/public/includes/KeyValuePair.h:148: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:157: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:157: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:157: error: 'bool operator!=(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:157: error: 'bool operator!=(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h: In function 'bool operator!=(int)':
../../../source/public/includes/KeyValuePair.h:158: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:158: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:167: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:167: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:167: error: 'bool operator>(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:167: error: 'bool operator>(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h: In function 'bool operator>(int)':
../../../source/public/includes/KeyValuePair.h:168: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:168: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:177: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:177: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:177: error: 'bool operator<=(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:177: error: 'bool operator<=(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h: In function 'bool operator<=(int)':
../../../source/public/includes/KeyValuePair.h:178: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:178: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:187: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:187: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h:187: error: 'bool operator>=(int)' must have an argument of class or enumerated type
../../../source/public/includes/KeyValuePair.h:187: error: 'bool operator>=(int)' must take exactly two arguments
../../../source/public/includes/KeyValuePair.h: In function 'bool operator>=(int)':
../../../source/public/includes/KeyValuePair.h:188: error: '__x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:188: error: '__y' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:197: error: expected initializer before '<' token
../../../source/public/includes/KeyValuePair.h:225: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:225: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h: In member function 'bool KeyMatchPredicate<Key, Value>::operator()(int)':
../../../source/public/includes/KeyValuePair.h:225: error: 'x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: At global scope:
../../../source/public/includes/KeyValuePair.h:252: error: expected ',' or '...' before '<' token
../../../source/public/includes/KeyValuePair.h:252: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/includes/KeyValuePair.h: In member function 'bool ValueMatchPredicate<Key, Value>::operator()(int)':
../../../source/public/includes/KeyValuePair.h:252: error: 'x' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: In function 'void InsertKeyValue(Container&, const Key&, const Value&)':
../../../source/public/includes/KeyValuePair.h:282: error: 'KeyValuePair' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:282: error: expected primary-expression before ',' token
../../../source/public/includes/KeyValuePair.h:282: error: expected primary-expression before '>' token
../../../source/public/includes/KeyValuePair.h: In function 'void InsertOrReplaceKeyValue(Container&, const Key&, const Value&)':
../../../source/public/includes/KeyValuePair.h:298: error: 'KeyValuePair' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:298: error: expected primary-expression before ',' token
../../../source/public/includes/KeyValuePair.h:298: error: expected primary-expression before '>' token
../../../source/public/includes/KeyValuePair.h: In function 'int32 InsertKeyValueInSorted(Container&, const Key&, const Value&)':
../../../source/public/includes/KeyValuePair.h:326: error: expected initializer before '<' token
../../../source/public/includes/KeyValuePair.h:328: error: 'el' was not declared in this scope
../../../source/public/includes/KeyValuePair.h: In function 'int32 InsertOrReplaceKeyValueInSorted(Container&, const Key&, const Value&)':
../../../source/public/includes/KeyValuePair.h:345: error: 'KeyValuePair' was not declared in this scope
../../../source/public/includes/KeyValuePair.h:345: error: expected primary-expression before ',' token
../../../source/public/includes/KeyValuePair.h:345: error: expected primary-expression before '>' token
../../../source/public/interfaces/architecture/IActiveContext.h: At global scope:
../../../source/public/interfaces/architecture/IActiveContext.h:56: error: ISO C++ forbids declaration of 'KeyValuePair' with no type
../../../source/public/interfaces/architecture/IActiveContext.h:56: error: expected ';' before '<' token
../../../source/public/interfaces/architecture/IActiveContext.h:57: error: 'ContextInfo' was not declared in this scope
../../../source/public/interfaces/architecture/IActiveContext.h:57: error: template argument 1 is invalid
../../../source/public/interfaces/architecture/IActiveContext.h:57: error: template argument 2 is invalid
../../../source/public/interfaces/architecture/ISelectionMessages.h:59: error: 'KeyValuePair' was not declared in this scope
../../../source/public/interfaces/architecture/ISelectionMessages.h:59: error: template argument 1 is invalid
../../../source/public/interfaces/architecture/ISelectionMessages.h:59: error: expected unqualified-id before '>' token
../../../source/public/interfaces/architecture/ISelectionMessages.h:172: error: ISO C++ forbids declaration of 'SuiteBroadcastData' with no type
../../../source/public/interfaces/architecture/ISelectionMessages.h:172: error: 'SuiteBroadcastData' declared as a 'virtual' field
../../../source/public/interfaces/architecture/ISelectionMessages.h:172: error: expected ';' before '*' token
../../../source/public/interfaces/architecture/ISelectionMessages.h:366: error: 'KeyValuePair' was not declared in this scope
../../../source/public/interfaces/architecture/ISelectionMessages.h:366: error: template argument 1 is invalid
../../../source/public/interfaces/architecture/ISelectionMessages.h:366: error: expected unqualified-id before '>' token
../../../source/public/interfaces/architecture/ISelectionManager.h:166: error: 'SuiteBroadcastData' has not been declared
../../../source/public/interfaces/architecture/ISelectionManager.h:212: error: 'SuiteBroadcastData' has not been declared
/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../../../source/sdksam ples/myPluginName/myPluginNameActionComponent.cpp:43: error: definition of implicitly-declared 'virtual myPluginNameActionComponent::~myPluginNameActionComponent()'
CompileC build/myPluginName.build/Default/Release.build/Objects-normal/i386/myPluginNameDialogObse rver.o /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../../../source/sdksa mples/myPluginName/myPluginNameDialogObserver.cpp normal i386 c++ com.apple.compilers.gcc.4_0
cd /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj
/Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fno-exceptions -fpascal-strings -fasm-blocks -O3 -Werror -Wreturn-type -Wunused-value -DMACINTOSH -DBIB_NO_THROW -fmessage-length=0 -fvisibility=hidden -fvisibility-inlines-hidden -fno-threadsafe-statics -Wno-deprecated-declarations -mmacosx-version-min=10.4 -gdwarf-2 -I/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/build/myPluginName. build/Default/Release.build/myPluginName.hmap -DMACTEL_SKIP -Wno-deprecated -F/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../release/sdk -F../../../build/mac/release/packagefolder/contents/macos -F../../../build/mac/release/packagefolder/contents/Frameworks -I/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../release/sdk/incl ude -I/Developer/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon -I../../../external/adobesourcelibrary/third_party/boost_tp/boost -I../../../external/afl/includes -I../../../source/precomp/common -I../../../source/precomp/msvc -I../../../source/public/includes -I../../../source/public/interfaces/architecture -I../../../source/private/includes/architecture -I../../../source/private/interfaces/architecture -I../../../source/public/includes/utils -I../../../source/public/interfaces/utils -I../../../source/precomp/msvc -I../../../source/public/interfaces/xmedia -I../../../source/public/interfaces/ui -I../../../source/public/interfaces/tables -I../../../source/public/interfaces/text -I../../../source/public/interfaces/graphics -I../../../source/public/components/widgetbin/includes -I../../../source/public/interfaces/workgroup -I../../../source/public/interfaces/interactive -I../../../source/public/interfaces/interactive/ui -I../../../source/public/interfaces/colormgmt -I../../../source/public/interfaces/utils -I../../../source/public/interfaces/incopy -I../../../source/public/interfaces/layout -I../../../source/public/interfaces/architecture -I../../../source/public/interfaces/cjk -I../../../source/precomp/common -I../../../source/public/includes -I../../../source/public/components/publiclib/plugins -I../../../source/public/components/publiclib/files -I../../../source/public/components/publiclib/objectmodel -I../../../external/boost -I../../../source/sdksamples/common -I../../../external/afl/includes -I../../../source/sdksamples/myPluginName -I/Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/build/myPluginName. build/Default/Release.build/DerivedSources -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include build/SharedPrecompiledHeaders/Release/PluginPrefix-ajenzpjyosjkeodzeqpqmcfnvjiw/PluginPr efix.pch -c /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/../../../source/sdksa mples/myPluginName/myPluginNameDialogObserver.cpp -o /Volumes/daten/adobe_indesign_cs3_products_sdk_504mac/build/mac/prj/build/myPluginName.bu ild/Default/Release.build/Objects-normal/i386/myPluginNameDialogObserver.o
What am I doing wrong? -
An application that I am working on has a bean that retains information about files uploaded by the user. The files are temporary, and need to be deleted at the end of the user's session-- hence the bean.
<jsp:useBean id="fileupload" class="changehoursrequest.FileUpload" scope="session" />
I was hoping that all that I would have to do is define a destructor in the bean (protected void finalize()) that deletes the temporary files. The destructor does what it's supposed to do, but doesn't seem to be called when the session ends. Is there a listener that I need to use? Am I doing something else wrong? Any suggestions?
Here's the skelaton of the bean..
public class FileUpload implements Enumeration
public FileUpload(HttpServletRequest request) { }
public FileUpload() {}
public MultipartRequest getRequest() {}
public void setRequest(HttpServletRequest request) { }
public String getFileName() {}
public String getFileType() {}
public String getFileSystemName() {}
public String getFileContents() {}
public boolean hasMoreElements() {}
public Object nextElement() {}
// destroy temporary files
protected void finalize() {}
thanks,
BryanInterestingly, Websphere seems to be making its own determination on when to call valueUnbound. I set session timeout to 2 seconds and it took at least 30 seconds for websphere to sweep up.
Websphere seems to have a lot of... personality.... I wonder if this is another part of its.... personality.
-Bryan -
Heap/stack, RVO, and destructors
yes, wonderful topic name...
I always wondered if the following (c++) code would work:
std::string& foo()
std::string* s = new std::string("bar");
return *s;
void test()
std::string s = foo();
} //does s get properly destroied here?
the problem is as follows:
in test(), s is declared as a stack (auto) variable...
in foo(), s is created on the heap, and returned by reference, instead of by pointer...
technically, this code is sound... however I don't know if proper destruction takes place... will RVO (return value optimization) take care of it?i3839 wrote:Perhaps I'm missing some hidden magick of references, but you said they were the same as pointers, and you made a new object and got a reference, no pointer in sight, so how can you blame pointers?
that's excatly it... "new" returns a pointer... technically one should just [return string("foo");] without the "new" - and RVO then takes the construction into account so it's not done twice (once on the return line, then a copy constructor when the actual return does it's job)
i3839 wrote:As for the memory management, what "internal memory management"? If you get data with new you need to free it yourself, either directly or indirectly (delete(this)?). All the memory management needs to be build into the classes as far as I can tell, or did C++ change so much recently?
I was talking specifically about the STL... which is C++, as much as some people don't like to admit... anyone can write a class that has resource issues in general... hell you can do it with database connections in java (and C#)
When you initialize an std::string, it calls new internally... and actually stores just the begin/end pointers, but it takes care or it's own resources...
the pseudo-techincal term is "RAII" (Resource Acquisition is Initialization) - constructor calls new, destructor deletes... it's all internal... when consuming that class, you never need worry about memory management if done correctly. -
Cannot assign an empty string to a parameter with JDBC type VARCHAR
Hi,
I am seeing the aforementioned error in the logs. I am guessing its happening whenever I am starting an agent instance in PCo. Can somebody explain whats going on?
Regards,
Chanti.
Heres the complete detail from logs -
Log Record Details
Message: Unable to retreive path for , com.sap.sql.log.OpenSQLException: Failed to set the parameter 1 of the statement >>SELECT ID, PARENTID, FULLPATH, CREATED, CREATEDBY, MODIFIED, MODIFIEDBY, REMOTEPATH, CHECKEDOUTBY FROM XMII_PATHS WHERE FULLPATH = ? <<: Cannot assign an empty string to a parameter with JDBC type >>VARCHAR<<.
Date: 2010-03-12
Time: 11:32:37:435
Category: com.sap.xmii.system.FileManager
Location: com.sap.xmii.system.FileManager
Application: sap.com/xappsxmiiearSounds like a UI browsing bug (when no path is selected from a catalog tree folder browser) - I would suggest logging a support ticket so that it can be addressed.
-
Problems with string comparison and\or If statement
Right now I'm trying to make a program that will look into all of my music folders, and rename the .mp3 files to a format i want, based on the id3 tags. The program so far looks in all of the folders I want it to, but I get stuck when I need to check if the files are .mp3 files or not. Here is my code so far:
package fileRenamer;
import java.io.File;
public class FileRenamer {
public static void main(String[] argv) {
File artistsFolders = new File("F:/Music (MP3)");
File[] artists = artistsFolders.listFiles();
for(int i = 0; i < artists.length; i++){
if(artists.isFile()) {
System.out.println(artists[i].getName());
} else if (artists[i].isDirectory()) {
System.out.println(artists[i].getName());
File albumsFolders = new File("F:/Music (MP3)/"+artists[i].getName());
File[] albums = albumsFolders.listFiles();
for(int a = 0; a < albums.length; a++){
if(albums[a].isFile()) {
System.out.println("-" + albums[a].getName());
} else if (albums[a].isDirectory()) {
System.out.println("-" + albums[a].getName());
File songsFolders = new File("F:/Music (MP3)/"+artists[i].getName()+"/"+albums[a].getName());
File[] songs = songsFolders.listFiles();
for(int s = 0; s < songs.length; s++){
if(songs[s].isFile()) {
int dotPos = songs[s].getName().toString().lastIndexOf(".");
String extension = songs[s].getName().toString().substring(dotPos);
System.out.println(extension);
if(extension == ".mp3"){
System.out.println("--" + songs[s].getName());
} else if (songs[s].isDirectory()) {
System.out.println("--" + songs[s].getName());
When I test the code, the line System.out.println(extension); prints .mp3 into the console for all of the .mp3 files. Whatever I try, the if(extension == ".mp3") never seems to declare the two equal. If anyone knows what my problem is, I greatly appreciate the advice and help.
Thanks in Advance,
JamesPojo226 wrote:
I just tried that and it worked perfectly. Thanks.You're welcome. -
Oracle, Null and empty Strings
Currently I'm facing problems with a class, which contains a String, which
is set to "" (empty String).
When the class is persistent, oracle writes null to the table column
(which seems to be common oracle behaviour) and when retrieving the class,
the field is set to null as well, giving me a lot of null-pointer
exceptions.
Anyway ... I can cope with that (just a lot of extra work)
far worse is the problem, wenn searching objects, that have this field set
to "" oder null.
Oracle can't find the records because JDO creates Querys "where
string=null" or "where string=''" , where oracle expects "where string is
null" to find the records.
Is there a workaround or solution ?Yeah, that would work as well, thx, but since I have to cope with
null-Strings now everywhere in my program, it doesn't hurt just to forbid
empty strings on the program side.
In future times I'll test on Oracle first, then porting to DB/2 - this way
I suppose work is far less to garant compability.
Nevertheless ... having to set the bankcode into quotes is a kodo bug in
my opinion.
Kodo knows the type of classfields (in this case string) and shouldn't
send the parameter as a BigDecimal to the database.
Given that, and having only bankcodes of null (only neccesary when using
Oracle), the method would look like:
public Collection getAccounts (String bankCode)
throws Exception
return getAccounts (Account.class, "bankcode=="+bankcode);
which is how a transparent persistent layer, um, should be , um , I mean
... just transparent ;-D
Marc Prud'hommeaux wrote:
Stefan-
Couldn't you just do something like:
public Collection getAccounts (String bankCode)
throws Exception
String filter;
if (bankCode == null || bankCode.length () == 0)
filter = "(bankCode == null || bankCode == "")";
else
filter = "bankCode == "" + bankCode + """;
return getAccounts (Account.class, filter);
If I understand the problem correctly, this should work for all the
databases.
In article <[email protected]>, Stefan wrote:
What operations are you performing to cause this SQL to be issued? You
say you are having trouble removing objects, but this is clearly not a
DELETE statement. Is this the SQL that is issued when looking up
objects by identity?I'm not removing objects, I was removing just quotes from parameters ;-)
A string column... is it also represented as a string field in your class?Yeah ... just to give you an impression of the code:
First we have a class, representing a bank account:
public class Account {
private AccountMgr myAccountMgr;
private String bankCode;
private String id;
Note, that in nearly all cases bankCode will be a number or null.
I have a second class "AccountMgr", which does all of the persistant stuff
(seaching, making persistent etc.)
This class has two methods, one versatile (protected) to retrieve accounts
by a given filterString and one who just returns accounts by bankCode,
building the expected filterstring. Here is my current working version:
public class AccountMgr {
public Collection getAccounts(String bankCode) throws Exception {
if (bankCode!=null) {
if (bankCode.equals("")) {
throw new Exception("check code, bankCode='' not allowed to get
same behavior from DB2 and Oracle");
// if set, quote the bankCode
bankCode="""+bankCode+""";
return getAccounts(Account.class,"bankCode=="+bankCode);
protected Collection getAccounts(Class accountClass, String filterAdd)
throws Exception {
PersistenceManager pm = MyHelper.getPersistenceManager();
String filter="";
if (filterAdd!=null && !filterAdd.trim().equals("")) {
filter+=filterAdd + " && ";
filter += "myAccountMgr==_accMgr";
Query query = pm.newQuery(accountClass, filter);
query.declareParameters("AccountMgr _accMgr");
return (Collection) query.execute(this);
As you can see, in the first method I have to set the bankCode into
quotes, when it's not null.
This is because otherwise a filter like "bankCode=1234" will be translated
in a way, where 1234 is send as a BigDecimal to the database:
[...] executing statement <4239745>: (SELECT [...] FROM JDO_ACCOUNT t0
WHERE t0.BANKCODE = ? : [reused=1;params={(BigDecimal) 1234}]
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Hi There,
As far as I know, Null is not the same as an empty string; however, when I try this out, I get some unexpected results (well, at least unexpected for my liking):
SQL> CREATE TABLE TS (MID NUMBER,
2 MDESC VARCHAR2(20) DEFAULT '' NOT NULL);
Table created.
SQL> INSERT INTO TS VALUES(1,'');
INSERT INTO TS VALUES(1,'')
ERROR at line 1:
ORA-01400: cannot insert NULL into ("TT"."TS"."MDESC")So, according to the above scenario, I can't insert an empty string!! However, an empty string is a valid string that doesn't have tuples/data!!
How come Oracle translates the null string '' as NULL?
ThanksWilliam Robertson wrote:
There is a special case to do with CHAR values, whereby '' counts as a string and so gets blank-padded, whereas NULL does not.Are you referring to:
SQL> DECLARE
2 flag CHAR(2);
3 PROCEDURE check_null (p_flag IN CHAR)
4 IS
5 BEGIN
6 IF p_flag = ' '
7 THEN
8 dbms_output.put_line ('flag is equal to '' ''');
9 ELSIF p_flag IS NULL
10 THEN
11 dbms_output.put_line ('flag is null');
12 ELSE
13 dbms_output.put_line ('other');
14 END IF;
15 END;
16 BEGIN
17 flag := '';
18 check_null (flag);
19 flag := NULL;
20 check_null (flag);
21 end;
22 /
flag is equal to ' '
flag is null
PL/SQL procedure successfully completed.
SQL> alter session set events '10932 trace name context forever, level 16384';
Session altered.
SQL> DECLARE
2 flag CHAR(2);
3 PROCEDURE check_null (p_flag IN CHAR)
4 IS
5 BEGIN
6 IF p_flag = ' '
7 THEN
8 dbms_output.put_line ('flag is equal to '' ''');
9 ELSIF p_flag IS NULL
10 THEN
11 dbms_output.put_line ('flag is null');
12 ELSE
13 dbms_output.put_line ('other');
14 END IF;
15 END;
16 BEGIN
17 flag := '';
18 check_null (flag);
19 flag := NULL;
20 check_null (flag);
21 end;
22 /
flag is null
flag is null
PL/SQL procedure successfully completed.
SQL> SY.
P.S. Don't ask me why normal (or at least consistent) behavior is not the default. -
Null and empty string not being the same in object?
Hello,
I know that null and empty string are interpreted the same in oracle.
However I discovered the strange behaviour concerning user defined objects:
create or replace
TYPE object AS OBJECT (
value VARCHAR2(2000)
declare
xml xmltype;
obj object;
begin
obj := object('abcd');
xml := xmltype(obj);
dbms_output.put_line(xml.getStringVal());
obj.value := '';
xml := xmltype(obj);
dbms_output.put_line(xml.getStringVal());
obj.value := null;
xml := xmltype(obj);
dbms_output.put_line(xml.getStringVal());
end;
When creating xml from object, all not-null fields are transformed into xml tag.
I supposed that obj.value being either '' or null will lead to the same result.
However this is output from Oracle 9i:
<OBJECT_ID><VALUE>abcd</VALUE></OBJECT_ID>
<OBJECT_ID><VALUE></VALUE></OBJECT_ID>
<OBJECT_ID/>
Oracle 10g behaves as expected:
<OBJECT><VALUE>abcd</VALUE></OBJECT>
<OBJECT/>
<OBJECT/>
However Oracle 9i behaviour leads me to the conclusion that oracle
must somehow distinguish between empty string and null in user defined objects...
Can someone clarify this behaviour?
Thus is it possible to test if object's field is empty or null?However Oracle 9i behaviour leads me to the conclusion that oracle
must somehow distinguish between empty string and null in user defined objects...
Can someone clarify this behaviour?
Thus is it possible to test if object's field is empty or null?A lot of "fixes" were done, relating to XML in 10g and the XML functionality of 9i was known to be buggy.
I think you can safely assume that null and empty strings are treated the same by Oracle regardless. If you're using anything less than 10g, it's not supported any more anyway, so upgrade. Don't rely on any assumptions that may appear due to bugs. -
Difference in Null and Empty String
Hi,
I have been wondering about the difference between Null and Empty String in Java. So I wrote a small program like this:
public class CompareEmptyAndNullString {
public static void main(String args[]) {
String sNull = null;
String sEmpty = "";
try {
if (sNull.equalsIgnoreCase(sEmpty)) {
System.out.println("Null and Empty Strings are Equal");
} else {
System.out.println("Null and Empty Strings are Equal");
} catch (Exception e) {
e.printStackTrace();
This program throws Exception: java.lang.NullPointerException
at practice.programs.CompareEmptyAndNullString.main(CompareEmptyAndNullString.java:10)
Now if I change the IF Clause to if (sEmpty.equalsIgnoreCase(sNull)) then the Program outputs this: Null and Empty Strings are Equal
Can anyone explain why this would happen ?
Thanks in Advance !!JavaProwler wrote:
Saish,
Whether you do any of the following code, the JUnit Test always passes: I mean he NOT Sign doesnt make a difference ...
assert (! "".equals(null));
assert ("".equals(null));
You probably have assertions turned off. Note the the assert keyword has nothing to do with JUnit tests.
I think that older versions of JUnit, before assert was a language keyword (which started in 1.4 or 1.5), had a method called assert. Thus, if you have old-style JUnit tests, they might still compile, but the behavior is completely different from what it was in JUnit, and has nothing to do with JUnit at all.
If you turn assertions on (-ea flag in the JVM command line, I think), the second one will throw AssertionError. -
SSRS Report Returning Double Quote string from a Single Quote String
Hi, I'm getting weird thing in resultset from SSRS report when executed. When I pass parameter to a report, which passes String that has single quote value to a split function , it returns rows with double quote.
For example following string:
'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
Returns:
''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
through SSRS report.
Here is the split function Im using in a report.
CREATE Function [dbo].[fnSplit] (
@List varchar(8000),
@Delimiter char(1)
Returns @Temp1 Table (
ItemId int Identity(1, 1) NOT NULL PRIMARY KEY ,
Item varchar(8000) NULL
As
Begin
Declare @item varchar(4000),
@iPos int
Set @Delimiter = ISNULL(@Delimiter, ';' )
Set @List = RTrim(LTrim(@List))
-- check for final delimiter
If Right( @List, 1 ) <> @Delimiter -- append final delimiter
Select @List = @List + @Delimiter -- get position of first element
Select @iPos = Charindex( @Delimiter, @List, 1 )
While @iPos > 0
Begin
-- get item
Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) )
If @@ERROR <> 0 Break -- remove item form list
Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 )
If @@ERROR <> 0 Break -- insert item
Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break
-- get position pf next item
Select @iPos = Charindex( @Delimiter, @List, 1 )
If @@ERROR <> 0 Break
End
Return
End
FYI: I'm getting @List value from a table and passing it as a string to split function.
Any help would be appreciated!
ZKAnother user from TSQL forum posted this code which is returning the same resultset but when I execute both codes in SQL server it works and return single quote as expected.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8d5c96f5-c498-4f43-b2fb-284b0e83b205/passing-string-which-has-single-quote-rowvalue-to-a-function-returns-double-quoate?forum=transactsql
CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
AS
BEGIN
WHILE CHARINDEX(@delim,@string) > 0
BEGIN
INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
END
INSERT INTO @result (value) VALUES (@string)
RETURN
END
GO
ZK -
How can I convert an int to a string?
Hi
How can I convert an int to a string?
/ad87geaoHere is some the code:
public class GUI
extends Applet {
public GUI() {
lastValue = 5;
String temp = Integer.toString(lastValue);
System.out.println(temp);
showText(temp);
private void showText(final String text) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
tArea2.setText(text + "\n");
} -
No calendar change for a single event in a recurrring string of events
Why won't iCal allow me to change the calendar for a single event in a string of recurring events? Why am I not allowed this, but can change other details and even get prompted whether I want these changes to take effect over the single event or all the recurring events????
Could this be implemented in a future version of iCal???
Thanks.How are you making the .ics file? What value has the METHOD: entry?
AK
Maybe you are looking for
-
Need help now! Preserving color in Pages to PDF format
I read the other recent post on PDF-CMYK and I may be in the same boat. Right now, I need to get my Pages newsletter (6 pages long) saved in a PDF format that will preserve the original colors I used in Pages. This PDF will be emailed and be posted o
-
ITunes upgrade and iPod syncing issues
I opened itunes and it said there was an upgrade for it. I installed it and when I plug in my ipod, it syncs, then when I try to sync it again, it does not. on the initial opening of itunes I noticed that windows has the ipod drive listed as "G". upo
-
Changed from PC to MAC - now cant control settings...
Hi, I have changed from a PC to a MAC but do not know how i now control my Home Hub. I have it set to go to sleep etc at certain times but i dont know what i need to do to be able to change them now that i have a nes computer. The Broadband is work
-
Colour and Black & White Images
Hello, I was just wondering about how can i classify or check if: an image is colour or black and white? Thank you very much for your help.
-
JBoss Starts but Stops Immediately
All I am trying to do a turnkey installation of LiveCycle 8.2.1 with JBoss yet when I run the Configuration Manager, and at the point at which JBoss gets started, the Configuration Manageer stops stating that it failed to start JBoss. When I go into