Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : c++

c++Öе÷ÓÃruby´úÂë

#include < ruby.h > //
static int id_sum;
int Values[] = {5, 10 ,15,-1,20,0};
static VALUE wrap_sum(VALUE args)
{
 VALUE * values = (VALUE *) args;
 VALUE summer = values[0]; 
 VALUE max = values[1];
 return rb_funcall(summer,id_sum,1,max);
}
static VALUE protected_sum(VALUE summer, VALUE max)
{
 int error;  VALUE args[2];
 VALUE result;
 args[0] = summer;
 args[1] = max;
 result = rb_protect(wrap_sum,(VALUE)args, &error);
 return error ? Qnil:result;
}
int main()
{
 int value;
 int *next = Values;
 ruby_init();
 ruby_init_loadpath();
 ruby_script("embedded");
 rb_require("sum.rb");
 VALUE summer = rb_class_new_instance(0,0,rb_const_get(rb_cObject,rb_intern("Summer")));
 id_sum = rb_intern("sum");
 while (value = *next++) 
 {
  VALUE result = protected_sum(summer,INT2NUM(value)); 
  if (NIL_P(re ......

c++Öе÷ÓÃruby´úÂë

#include < ruby.h > //
static int id_sum;
int Values[] = {5, 10 ,15,-1,20,0};
static VALUE wrap_sum(VALUE args)
{
 VALUE * values = (VALUE *) args;
 VALUE summer = values[0]; 
 VALUE max = values[1];
 return rb_funcall(summer,id_sum,1,max);
}
static VALUE protected_sum(VALUE summer, VALUE max)
{
 int error;  VALUE args[2];
 VALUE result;
 args[0] = summer;
 args[1] = max;
 result = rb_protect(wrap_sum,(VALUE)args, &error);
 return error ? Qnil:result;
}
int main()
{
 int value;
 int *next = Values;
 ruby_init();
 ruby_init_loadpath();
 ruby_script("embedded");
 rb_require("sum.rb");
 VALUE summer = rb_class_new_instance(0,0,rb_const_get(rb_cObject,rb_intern("Summer")));
 id_sum = rb_intern("sum");
 while (value = *next++) 
 {
  VALUE result = protected_sum(summer,INT2NUM(value)); 
  if (NIL_P(re ......

ruby c++

While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file can be found here: wtmplist.c.
Disclaimer: I’m not resposible if you should destroy something with your newfound skills, nor am I responsible if you should suddenly get the urge to leave your wife/loved ones in favor of Ruby.
Table of Contents:
What to Extend?
How Do I Want the Interface to Be?
Get to it! #include <ruby.h>
Groundwork.
Making it Compile.
Collect the Data th Make Available.
Adding More Functionality.
Test Your New Library.
What to Extend?
Obviously you start by figuring out what you want to extend Ruby with. Some library missing, or better implemented in C? Some library you wrote yourself and want to be able to use from Ruby scripts?
I have a project c ......

ruby c++

While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file can be found here: wtmplist.c.
Disclaimer: I’m not resposible if you should destroy something with your newfound skills, nor am I responsible if you should suddenly get the urge to leave your wife/loved ones in favor of Ruby.
Table of Contents:
What to Extend?
How Do I Want the Interface to Be?
Get to it! #include <ruby.h>
Groundwork.
Making it Compile.
Collect the Data th Make Available.
Adding More Functionality.
Test Your New Library.
What to Extend?
Obviously you start by figuring out what you want to extend Ruby with. Some library missing, or better implemented in C? Some library you wrote yourself and want to be able to use from Ruby scripts?
I have a project c ......

ʹÓÃCDHtmlDialog £¬ÊµÏÖjavascript µ÷ÓÃC++

.h Îļþ
class CHtmlSkinDlg : public CDHtmlDialog
{
      ¡£¡£¡£¡£¡£
    DECLARE_DISPATCH_MAP()     
//  !!! ¸²¸Ç»ùÀàµÄÕâ¸ö·½·¨
BOOL CanAccessExternal()
    {
        // we trust all com object (haha, you can make virus)
        return TRUE;
    }
// ×Ô¶¨Òå·½·¨
BOOL set_pos(int x, int y);
}
.cppÎļþ
BEGIN_DISPATCH_MAP(CHtmlSkinDlg, CDHtmlDialog)
        DISP_FUNCTION(CHtmlSkinDlg, "set_pos", set_pos, VT_BOOL, VTS_I4 VTS_I4)
END_DISPATCH_MAP()
.html Îļþ
<SCRIPT type=text/javascript>
//<![CDATA[
window.external.set_pos(600, 400);
//]]>
</SCRIPT> ......

ʹÓÃCDHtmlDialog £¬ÊµÏÖjavascript µ÷ÓÃC++

.h Îļþ
class CHtmlSkinDlg : public CDHtmlDialog
{
      ¡£¡£¡£¡£¡£
    DECLARE_DISPATCH_MAP()     
//  !!! ¸²¸Ç»ùÀàµÄÕâ¸ö·½·¨
BOOL CanAccessExternal()
    {
        // we trust all com object (haha, you can make virus)
        return TRUE;
    }
// ×Ô¶¨Òå·½·¨
BOOL set_pos(int x, int y);
}
.cppÎļþ
BEGIN_DISPATCH_MAP(CHtmlSkinDlg, CDHtmlDialog)
        DISP_FUNCTION(CHtmlSkinDlg, "set_pos", set_pos, VT_BOOL, VTS_I4 VTS_I4)
END_DISPATCH_MAP()
.html Îļþ
<SCRIPT type=text/javascript>
//<![CDATA[
window.external.set_pos(600, 400);
//]]>
</SCRIPT> ......

ÀûÓÃSocketʵÏÖC++ÓëFlexͨÐÅ


ÀûÓÃSocketʵÏÖC++ÓëFlexͨÐÅ
Ò»¡¢C++·þÎñÆ÷¶Ë
£¨ÓõÄÊÇVisual Studio 2008£¨05£¬03µÄÓ¦¸ÃÒ²¿ÉÒÔ£¬VC++µÄ¿ÉÄÜÐèÒªÉÔ΢¸Ä¶¯£©£©
´úÂëÈçÏ£º
#include <winsock2.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
 
void main(){ 
 WORD wVersionRequested;
 WSADATA wsaData;
 int err;
 short port=1300;//¶Ë¿ÚºÅ
 
 wVersionRequested = MAKEWORD( 1, 1 );
 
 err = WSAStartup( wVersionRequested, &wsaData );//³õʼ»¯Ì×½Ó×Ö
 if ( err != 0 )
 {
    return;
 }
 
 if ( LOBYTE( wsaData.wVersion ) != 1 || HIBYTE( wsaData.wVersion ) != 1 )
 {
    WSACleanup( );
    return;
 }
 
 SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0);//´´½¨Ì×½Ó×Ö
 SOCKET sockConn;//ÓÃÀ´ºÍ¿Í»§¶ËͨÐŵÄÌ×½Ó×Ö
 
 SOCKADDR_IN addrSrv;//ÓÃÀ´ºÍ¿Í»§¶ËͨÐŵÄÌ×½Ó×ÖµØÖ· ......

ÀûÓÃSocketʵÏÖC++ÓëFlexͨÐÅ


ÀûÓÃSocketʵÏÖC++ÓëFlexͨÐÅ
Ò»¡¢C++·þÎñÆ÷¶Ë
£¨ÓõÄÊÇVisual Studio 2008£¨05£¬03µÄÓ¦¸ÃÒ²¿ÉÒÔ£¬VC++µÄ¿ÉÄÜÐèÒªÉÔ΢¸Ä¶¯£©£©
´úÂëÈçÏ£º
#include <winsock2.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
 
void main(){ 
 WORD wVersionRequested;
 WSADATA wsaData;
 int err;
 short port=1300;//¶Ë¿ÚºÅ
 
 wVersionRequested = MAKEWORD( 1, 1 );
 
 err = WSAStartup( wVersionRequested, &wsaData );//³õʼ»¯Ì×½Ó×Ö
 if ( err != 0 )
 {
    return;
 }
 
 if ( LOBYTE( wsaData.wVersion ) != 1 || HIBYTE( wsaData.wVersion ) != 1 )
 {
    WSACleanup( );
    return;
 }
 
 SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0);//´´½¨Ì×½Ó×Ö
 SOCKET sockConn;//ÓÃÀ´ºÍ¿Í»§¶ËͨÐŵÄÌ×½Ó×Ö
 
 SOCKADDR_IN addrSrv;//ÓÃÀ´ºÍ¿Í»§¶ËͨÐŵÄÌ×½Ó×ÖµØÖ· ......

C++½âÎöXML

ÓÃmingw32-makeǰÐÞ¸ÄÒ»ÏÂmakefileÎļþ,¸ÄΪÈçÏÂ
# DEBUG can be set to YES to include debugging info, or NO otherwise(²»ÊÇDEBUG)
DEBUG          := NO
# PROFILE can be set to YES to include profiling info, or NO otherwise
PROFILE        := NO
# TINYXML_USE_STL can be used to turn on STL support. NO, then STL
# will not be used. YES will include the STL files.(ʹÓÃSTL,Ñ¡ÔñµÄ»°£¬Ôò¿ÉÒÔʹÓÃstd::string)
TINYXML_USE_STL := YES
Ò»¡¢      TinyXmlµÄÌØµã
TinyXmlÊÇÒ»¸ö»ùÓÚDOMÄ£Ð͵ġ¢·ÇÑéÖ¤µÄÇáÁ¿¼¶C++½âÊÍÆ÷¡£
1.      SAXºÍDOM
ĿǰXMLµÄ½âÎöÖ÷ÒªÓÐÁ½´óÄ£ÐÍ£ºSAXºÍDOM¡£
ÆäÖÐSAXÊÇ»ùÓÚʼþµÄ£¬Æä»ù±¾¹¤×÷Á÷³ÌÊÇ·ÖÎöXMLÎĵµ£¬µ±·¢ÏÖÁËÒ»¸öеÄÔªËØÊ±£¬²úÉúÒ»¸ö¶ÔӦʼþ£¬²¢µ÷ÓÃÏàÓ¦µÄÓû§´¦Àíº¯Êý¡£ÕâÖÖ·½Ê½Õ¼ÓÃÄÚ´æÉÙ£¬Ëٶȿ죬µ«Óû§³ÌÐòÏàÓ¦µÃ»á±È½Ï¸´ÔÓ¡£
¶øDOM£¨Îĵµ¶ÔÏóÄ£ÐÍ£©£¬ÔòÊÇÔÚ·ÖÎöʱ£¬Ò»´ÎÐԵĽ«Õû¸öXMLÎĵµ½øÐзÖÎö£¬²¢ÔÚÄÚ´æÖÐÐγɶÔÓ¦µÄÊ÷½á¹¹£¬Í¬Ê±£¬ÏòÓû§ÌṩһϵÁÐµÄ½Ó ......

TinyXML(C++ XML½âÎö¿â)

дһ¸öXMLÎļþ TinyXML ÊÇÒ»¸öminiµÄC++ XML½âÎö¿â,ËüÊÇ·ÇÑéÖ¤µÄ,Ëü¿ÉÒÔºÜÈÝÒ׵ɵ½ÆäËûµÄ³ÌÐòÖÐ.Ëü½âÎöÒ»·ÝXML doc,ÒÔ´Ë´´½¨Ò»¸ö¿ÉÒÔ±»¶Á¡¢Ð´£¬±£´æµÄDOM.ËüÖ÷ÒªµÄÀà²ã´Î¼Ü¹¹£¬º¯ÊýÔ­ÐÎÏêϸ˵Ã÷²Î¿´: http://www.grinninglizard.com/tinyxml/index.html
// ÒÔÏÂÒÔ¼òµ¥µÄ³ÌÐòTinyXMLTestΪÀý TinyXMLÖÐ×î¸ù±¾µÄ¾ÍÊÇDocument£¬ËùÒÔÎÞÂÛÊÇÐèҪдһ¸öXMLÎļþ£¬»¹ÊÇÒª¶Á£¬¶¼±ØÐë´ÓÒ»¸öDocument¿ªÊ¼,¾ÍÊÇ(1)µÄ¶¯×÷,ÔÚ´ËûÓиø¹¹Ô캯ÊýÒ»¸ö²ÎÊýÊÇÒòΪÎÒÃǵÄÄ¿µÄÊÇΪÁËд³öÒ»¸öXMLÎļþ£¬ÎļþµÄÃû×Ö¾ÍÊÇ´«¸øTiXmlDocumentµÄ²ÎÊý¡£ÉùÃ÷£¬Îĵµ£¬×¢ÊÍ£¬Îı¾,ÔªËØ£¬²»Ã÷ÀàÐͶ¼ÊÇTinyXmlNodeµÄ×ÓÀ࣬¶¼ÊÇÒ»¸öNode,TinyXmlNodeÊÇÒ»¸öºÜ¸´ÔӵĶ«Î÷£¬ËüÈçÉÏËùʾ:
#include
#include "tinyxml.h"
using namespace std;
int main(int argc, char** argv)
{
// (1) create a XML document
TiXmlDocument *myDoc = new TiXmlDocument();
DocumentÀàÐ͵Ľڵ㽨Á¢ºÃÒԺ󣬾ÍÐèÒª¸ø¸Ã£Ä£Ï£ÍÊ÷½á¹¹Ò»¸ö¸ù,¼´ÏÂÃæµÄ(2),(3),(5),ÓÉÓÚTinyXmlÊÇ·ÇÑéÖ¤µÄ£¬ËùÒÔÀíÂÛÉÏËûÊÇ¿ÉÒÔÓÐÁ½¸öDocumentµÄ£¬£¨ÔÚÄÚ²¿Í¨¹ý¶ÔÀàÐ͵ÄÅжÏÀ´±ÜÃâÕâÒ»Çé¿öµÄ·¢Éú£©,ÓÉÓÚ¸ùÊÇÒ»¸öÔªËØ£¬¶øÔªËر¾ÖÊÉϾÍÊÇÒ»¸öÈ ......

TinyXML(C++ XML½âÎö¿â)

дһ¸öXMLÎļþ TinyXML ÊÇÒ»¸öminiµÄC++ XML½âÎö¿â,ËüÊÇ·ÇÑéÖ¤µÄ,Ëü¿ÉÒÔºÜÈÝÒ׵ɵ½ÆäËûµÄ³ÌÐòÖÐ.Ëü½âÎöÒ»·ÝXML doc,ÒÔ´Ë´´½¨Ò»¸ö¿ÉÒÔ±»¶Á¡¢Ð´£¬±£´æµÄDOM.ËüÖ÷ÒªµÄÀà²ã´Î¼Ü¹¹£¬º¯ÊýÔ­ÐÎÏêϸ˵Ã÷²Î¿´: http://www.grinninglizard.com/tinyxml/index.html
// ÒÔÏÂÒÔ¼òµ¥µÄ³ÌÐòTinyXMLTestΪÀý TinyXMLÖÐ×î¸ù±¾µÄ¾ÍÊÇDocument£¬ËùÒÔÎÞÂÛÊÇÐèҪдһ¸öXMLÎļþ£¬»¹ÊÇÒª¶Á£¬¶¼±ØÐë´ÓÒ»¸öDocument¿ªÊ¼,¾ÍÊÇ(1)µÄ¶¯×÷,ÔÚ´ËûÓиø¹¹Ô캯ÊýÒ»¸ö²ÎÊýÊÇÒòΪÎÒÃǵÄÄ¿µÄÊÇΪÁËд³öÒ»¸öXMLÎļþ£¬ÎļþµÄÃû×Ö¾ÍÊÇ´«¸øTiXmlDocumentµÄ²ÎÊý¡£ÉùÃ÷£¬Îĵµ£¬×¢ÊÍ£¬Îı¾,ÔªËØ£¬²»Ã÷ÀàÐͶ¼ÊÇTinyXmlNodeµÄ×ÓÀ࣬¶¼ÊÇÒ»¸öNode,TinyXmlNodeÊÇÒ»¸öºÜ¸´ÔӵĶ«Î÷£¬ËüÈçÉÏËùʾ:
#include
#include "tinyxml.h"
using namespace std;
int main(int argc, char** argv)
{
// (1) create a XML document
TiXmlDocument *myDoc = new TiXmlDocument();
DocumentÀàÐ͵Ľڵ㽨Á¢ºÃÒԺ󣬾ÍÐèÒª¸ø¸Ã£Ä£Ï£ÍÊ÷½á¹¹Ò»¸ö¸ù,¼´ÏÂÃæµÄ(2),(3),(5),ÓÉÓÚTinyXmlÊÇ·ÇÑéÖ¤µÄ£¬ËùÒÔÀíÂÛÉÏËûÊÇ¿ÉÒÔÓÐÁ½¸öDocumentµÄ£¬£¨ÔÚÄÚ²¿Í¨¹ý¶ÔÀàÐ͵ÄÅжÏÀ´±ÜÃâÕâÒ»Çé¿öµÄ·¢Éú£©,ÓÉÓÚ¸ùÊÇÒ»¸öÔªËØ£¬¶øÔªËر¾ÖÊÉϾÍÊÇÒ»¸öÈ ......
×ܼǼÊý:969; ×ÜÒ³Êý:162; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [106] [107] [108] [109] 110 [111] [112] [113] [114] [115]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ