Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-01-2004, 12:15 PM   #1 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
A "test" section

"We" haven't got a test-section to test things. Is it possible to implement one?
__________________
Valmont is offline   Reply With Quote
Old 05-01-2004, 12:31 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
u mean like a forum to test signatures?
__________________
Mike
sde is offline   Reply With Quote
Old 05-01-2004, 12:34 PM   #3 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Yes that too. But if you read your pm then you know what I am doing right now!
__________________
Valmont is offline   Reply With Quote
Old 05-01-2004, 12:44 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
ah, but if you read your pm, then you know how i responded! lol
__________________
Mike
sde is offline   Reply With Quote
Old 05-01-2004, 01:05 PM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
LOL
__________________
Valmont is offline   Reply With Quote
Old 05-01-2004, 01:35 PM   #6 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Code:
#include <iostream>

using namespace std; 

class String
{
private:
  friend int operator==(const String& lhs, const String& rhs);
  friend ostream& operator<<(ostream& os, String& s);
public:  
  String& operator=(const String&);
  String& operator+=(const String&);     

public:
  ~String ();
  String(const char* = "");
  String(const String&); 
private:
  char *m_pChars;
};

//Acts like a conversion operator: 'c-style char' to 'String'
String::String(const char *s) 
{
// need to copy the given string. If s is zero, make a null string!

  if (s)
  {  
    int len = strlen(s) + 1;
    m_pChars = new char[len];
    strcpy(m_pChars, s); 
  }
  else
  {
    m_pChars = new char[1];
    *m_pChars = '\0';
  }
}

String::String(const String& s)
{
  m_pChars = new char[strlen(s.m_pChars) + 1];
  strcpy(m_pChars, s.m_pChars);
} 

String::~String() { delete[] m_pChars; }

String& String::operator=(const String& s) 
{
  if (this != &s)
  {
    
    delete[] m_pChars; // first delete old
    int len = strlen(s.m_pChars) + 1;
    m_pChars = new char[len];
    strcpy(m_pChars, s.m_pChars);
  }  
  return *this;
} 

//MUST be defined outside class; So don't forget to make it a friend in the class that uses it.
ostream& operator<<(ostream& os, String& s)
{
  os<<s.m_pChars;
  return os; //Always return inserter/extractor.
}

int operator==(const String& lhs, const String& rhs) 
{ 
  return (strcmp(lhs.m_pChars,rhs.m_pChars) == 0); 
}

String& String::operator+=(const String& s)
{
  char* buffer = new char[strlen(m_pChars) + strlen(s.m_pChars) + 1]; 
  strcpy(buffer, m_pChars);
  strcat(buffer, s.m_pChars); 
  delete[] m_pChars;
  m_pChars = buffer;
  return *this;
} 

String operator+(const String& lhs, const String& rhs)
{
  String buffer(lhs); // calls copy ctor 
  buffer += rhs; // calls our overloaded +=
  return buffer;  
}

int main()
{
  String A("Hello! ");   
  A=A; //Test for self-assignment.
  
  String B="How are you?";
  cout<<("Hello! " == A)<<endl; //Hey... what's this? It works :)
  
  A+=B;
  cout<<A<<endl;

  return 0;
}
__________________
Valmont is offline   Reply With Quote
Old 05-01-2004, 02:03 PM   #7 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,139
Belisarius is on a distinguished road
I really need to learn C . . .
__________________
GitS
Belisarius is offline   Reply With Quote
Old 05-01-2004, 03:33 PM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
that looks great val!
__________________
Mike
sde is offline   Reply With Quote
Old 05-01-2004, 04:26 PM   #9 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
The "large tab" is also solved as you can see.
__________________
Valmont is offline   Reply With Quote
Old 05-01-2004, 04:29 PM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
so what is this? a windows graphical interface which formats the ubb code?
__________________
Mike
sde is offline   Reply With Quote
Old 05-01-2004, 04:52 PM   #11 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Yes.
Well, it has no GUI yet (console based) but that will come later. First the tough bit.

What it does is "in memory formatting". I copy the code, press a button (there will be soon a button), and then paste the C++ code(from dotnet IDE) into vBulletin. From that moment on, the code is automatically formatted the way you see above.

I am doing my best to analyze the structure of vBulletin and UBBclassis (like our clan site) so it works on both types of forums. That part doesn't seem to be so hard. Bunch of UBB tags are all the same to me .

The most interestng part is where I add functionality to preview my own formatted lines of text (non C++ code) in an editor (like UltraEdit or Word 2000). This way I don't have to access this site all the time to use the "preview" button.

But first some excercises on parsing. It's been a while since I parsed anything...
__________________
Valmont is offline   Reply With Quote
Old 05-01-2004, 05:51 PM   #12 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Uh oh. I am using .NET now. So no more VC++, so no more Qt 2.3 either. Now I have to learn .net and gui building. I avoided MFC and Win32 SDK like the plague...
__________________
Valmont is offline   Reply With Quote
Old 05-01-2004, 07:19 PM   #13 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
you coding in c++.net? or c#?
__________________
Mike
sde is offline   Reply With Quote
Old 05-01-2004, 08:20 PM   #14 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
C++ as usual. Haven't got much time for C#. Gotta make some time I suppose.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
An "Audio" Section? plonkeroo Feedback 2 10-28-2004 02:48 PM
How does the tutorial section work? DavH27 Lounge 3 08-27-2004 02:46 AM
Tutorials Section rdove Feedback 2 03-09-2004 04:52 AM
Code Section? rdove Feedback 5 02-18-2003 10:04 AM
General section anon Feedback 11 01-07-2003 08:21 PM


All times are GMT -8. The time now is 08:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting