Search Results

Search found 763 results on 31 pages for 'namespaces'.

Page 12/31 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Using Dom Objects in PHP, the default namespace is redeclared in some nodes.

    - by TomcatExodus
    I'm working on a template engine, having migrated from regex driven to DOM driven. It appears though, that whenever I create a DomDocumentFragment to encapsulate some portion of a document temporarily, the namespace attribute is added to each node in the fragment. Since my default namespace for a given document will 99% of the time be XHTML, it's adding the XHTML namespace declaration. Being the default namespace, this seems fruitless, and ultimately nodes in any other namespace will be stripped out at render time anyways. Aside from iteratively removing namespace attributes, is there some way I can prevent this from occurring to begin with? Its quite problematic, as this will likely increase render time filesize considerably, as large portions of a given document may be stored in a fragment. I've tried $doc->normalizeDocument(), but as I assumed, it did nothing.

    Read the article

  • [c++] Resolving namespace conflicts

    - by Kyle
    I've got a namespace with a ton of symbols I use, but I want to overwrite one of them: external_library.h namespace lottaStuff { class LotsOfClasses {}; class OneMoreClass {}; }; my_file.h using namespace lottaStuff; namespace myCustomizations { class OneMoreClass {}; }; my_file.cpp using myCustomizations::OneMoreClass; int main() { OneMoreClass foo; // error: reference to 'OneMoreClass' is ambiguous return 0; } How do I get resolve the 'ambiguous' error without resorting to replacing 'using namespace lottaStuff' with a thousand individual "using xxx;" statements?

    Read the article

  • C++: namespace conflicht between extern "C" and class member

    - by plaisthos
    Hi, I stumbled upon a rather exotic c++ namespace problem: condensed example: extern "C" { void solve(lprec * lp); } class A { public: lprec * lp; void solve(int foo); } void A::solve(int foo) { solve(lp); } I want to call the c funcition solve in my C++ member function A::solve. The compiler is not happy with my intents: error C2664: 'lp_solve_ilp::solve' : cannot convert parameter 1 from 'lprec *' to 'int' Is there something I can prefix the solve function? C::solve does not work

    Read the article

  • Strange overloading rules in C++

    - by bucels
    I'm trying to compile this code with GCC 4.5.0: #include <algorithm> #include <vector> template <typename T> void sort(T, T) {} int main() { std::vector<int> v; sort(v.begin(), v.end()); } But it doesn't seem to work: $ g++ -c nm.cpp nm.cpp: In function ‘int main()’: nm.cpp:9:28: error: call of overloaded ‘sort(std::vector<int>::iterator, std::vector<int>::iterator)’ is ambiguous nm.cpp:4:28: note: candidates are: void sort(T, T) [with T = __gnu_cxx::__normal_iterator<int*, std::vector<int> >] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/stl_algo.h:5199:69: note: void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >] Comeau compiles this code without errors. (4.3.10.1 Beta2, strict C++03, no C++0x) Is this valid C++?

    Read the article

  • Scope of the c++ using directive

    - by ThomasMcLeod
    From section 7.3.4.2 of the c++11 standard: A using-directive specifies that the names in the nominated namespace can be used in the scope in which the using-directive appears after the using-directive. During unqualified name lookup (3.4.1), the names appear as if they were declared in the nearest enclosing namespace which contains both the using-directive and the nominated namespace. [ Note: In this context, “contains” means “contains directly or indirectly”. —end note ] What do the second and third sentences mean exactly? Please give example. Here is the code I am attempting to understand: namespace A { int i = 7; } namespace B { using namespace A; int i = i + 11; } int main(int argc, char * argv[]) { std::cout << A::i << " " << B::i << std::endl; return 0; } It print "7 7" and not "7 18" as I would expect. Sorry for the typo, the program actually prints "7 11".

    Read the article

  • Why is 'using namespace std;' considered a bad practice in C++?

    - by Mana
    Okay, sorry for the simplistic question, but this has been bugging me ever since I finished high school C++ last year. I've been told by others on numerous occasions that my teacher was wrong in saying that we should have "using namespace std;" in our programs, and that std::cout and std::cin are more proper. However, they would always be vague as to why this is a bad practice. So, I'm asking now: Why is "using namespace std;" considered bad? Is it really that inefficient, or risk declaring ambiguous vars(variables that share the same name as a function in std namespace) that much? Or does this impact program performance noticeably as you get into writing larger applications? I'm sorry if this is something I should have googled to solve; I figured it would be nice to have this question on here regardless in case anyone else was wondering.

    Read the article

  • A C# class with a null namespace

    - by Richard Ev
    While going through some legacy code today I discovered that you can declare a C# class without placing it in a namespace (in this scenario I have an ASP.NET WebForms application and some of the web forms are not declared within any namespace). A GetType() on such a class returns a type where the namespace property is set to null. I did not know that this was allowed - can anyone suggest why it would be desirable to have a class that is not declared within a namespace?

    Read the article

  • Python package name conventions

    - by deamon
    Is there a package naming convention for Python like Java's com.company.actualpackage? Most of the time I see simple, potentially colliding package names like "web". If there is no such convention, is there a reason for it? What do you think of using the Java naming convention in the Python world?

    Read the article

  • python interactive mode module import issue

    - by Jeff
    I believe I have what would be called a scope issue, perhaps name space. Not too sure I'm new to python. I'm trying to make a module that will search through a list using regular expressions. I'm sure there is a better way of doing it but this error that I'm getting is bugging me and I want to understand why. here's my code: class relist(list): def __init__(self, l): list.__init__(self, l) def __getitem__(self, rexp): r = re.compile(rexp) res = filter(r.match, self) return res if __name__ == '__main__': import re listl = [x+y for x in 'test string' for y in 'another string for testing'] print(listl) test = relist(listl) print('----------------------------------') print(test['[s.]']) When I run this code through the command line it works the way I expect it to; however when I run it through python interactive mode I get the error >>> test['[s.]'] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "relist.py", line 8, in __getitem__ r = re.compile(rexp) NameError: global name 're' is not defined While in the interactive mode I do import re and I am able to use the re functions, but for some reason when I'm trying to execute the module it doesn't work. Do I need to import re into the scope of the class? I wouldn't think so because doesn't python search through other scopes if it's not found in the current one? I appreciate your help, and if there is a better way of doing this search I would be interested in knowing. Thanks

    Read the article

  • Resolving C++ Name Collision

    - by jnm2
    InitializeQTML is a function in QTML.h. I'm writing a wrapper and I would like to use the name InitializeQTML for the wrapper function: #include <QTML.h> public class QuickTime { public: static void InitializeQTML(InitializationFlags flag) { InitializeQTML((long)flag)); }; }; How can I reference the original InitializeQTML function from inside the wrapper function and avoid the name collision without renaming the wrapper?

    Read the article

  • c++ when to put method out side the class

    - by user63898
    i saw that some times in c++ applications using only namespace declarations with header and source file like this : #ifndef _UT_ #define _UT_ #include <string> #include <windows.h> namespace UT { void setRootPath(char* program_path, char* file_path); char * ConvertStringToCharP(std::string str); }; #endif //and then in UT.cpp #include "UT.h" namespace UT { char * ConvertStringToCharP(std::string str) { char * writable = new char[str.size() + 1]; std::copy(str.begin(), str.end(), writable); writable[str.size()] = '\0'; return writable; } void setRootPath(char* program_path, char* file_path) { //... } } is it better then defining classic class with static methods? or just simple class ? dose this method has something better for the compiler linker ? the methods in this namespace are called allot of times .

    Read the article

  • Best way to implement a data structure in PHP ?

    - by Double Gras
    Hi, I want to use some kind of data structure in PHP (5.2), mainly in order to not pollute the global namespace. I think about two approaches, using an array or a class. Could you tell me which approach is better ? Thanks $SQL_PARAMETERS = array ( 'server' => '127.0.0.1', 'login' => 'root'); class SqlParameters { const SERVER = '127.0.0.1'; const LOGIN = 'root'; } echo $SQL_PARAMETERS['server']; echo SqlParameters::SERVER;

    Read the article

  • JavaScript constructors inside a namespace

    - by Joe
    I have read that creating a namespace for JavaScript projects helps to reduce conflicts with other libraries. I have some code with a lot of different types of objects for which I have defined constructor functions. Is it good practice to put these inside the namespace as well? For example: var shapes = { Rectangle: function(w, h) { this.width = w; this.height = h; } }; which can be called via: var square = new shapes.Rectangle(10,10);

    Read the article

  • getting the names of elements in JS/jQuery

    - by Mala
    I have some checkbox inputs like so: <input type="checkbox" name="1" class="filter"/> <input type="checkbox" name="2" class="filter"/> ...etc... I'm trying to write a function where any time a checkbox is selected, it generates a string with all the names concatenated. Here's what I have so far: $('.filter').click(function(event){ var filters = $('.filter').toArray(); var fstr = ""; for (f in filters) { fstr = fstr+","+f.name; } alert(fstr); }); The names keep coming up as 'undefined', though (i.e. the alert returns ,undefined,undefined,undefined,undefined,undefined,undefined). How do I access the names?

    Read the article

  • Rails 3 namespacing requires model to be defined twice?

    - by RSG
    I'm pulling my hair out trying to understand namespacing in Rails 3. I've tried following a few different tutorials, and the only way I can get my models to work is if I define my model in both the base directory and my namespace directory. If I only define the model in the namespace directory it expects it to define both Model and Namespace::Model, as below: LoadError (Expected .../app/models/plugins/chat.rb to define Chat): or LoadError (Expected .../app/models/plugins/chat.rb to define Plugins::Chat): I'm sure I'm missing something obvious, but I could really use a pointer in the right direction. Here are the relevant excerpts. /models/plugins/chat.rb class Plugins::Chat include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming ... end /controllers/plugins/chats_controller.rb class Plugins::ChatsController < Plugins::ApplicationController load_and_authorize_resource ... end /config/routes.rb namespace :plugins do resources :chats end /config/application.rb config.autoload_paths += Dir["#{config.root}/app/models/**/"]

    Read the article

  • No such file to load, Model/Lib naming conflict?

    - by Tom
    I'm working on a Rails application. I have a Module called Animals. Inside this Module is a Class with the same name as one of my Models (Dog). show_animal action: def show_animal require 'Animals/Bear.rb' #Works require 'Animals/Dog.rb' #Fails end So the first require definitely works, the seconds fails. MissingSourceFile (no such file to load -- Animals/Dog.rb): I noticed that Dog.rb is the same file name as one of my models, is that what's causing this? I'm using Webrick.

    Read the article

  • Rails - Dynamic name routes namespace

    - by Kuro
    Hi, Using Rails 2.3, I'm trying to configure my routes but I uncounter some difficulties. I would like to have something like : http:// mydomain.com/mycontroller/myaction/myid That should respond with controllers in :front namespace http:// mydomain.com/aname/mycontroller/myaction/mydi That should respond with controllers in :custom namespace I try something like this, but I'm totaly wrong : map.namespace :front, :path_prefix => "" do |f| f.root :controller => :home, :action => :index f.resources :home ... end map.namespace :custom, :path_prefix => "" do |m| m.root :controller => :home, :action => :index m.resources :home ... m.match ':sub_url/site/:controller/:action/:id' m.match ':sub_url/site/:controller/:action/:id' m.match ':sub_url/site/:controller/:action/:id.:format' m.match ':sub_url/site/:controller/:action.:format' end I put matching instruction in custom namespace but I'm not sure it's the right place for it. I think I really don't get the way to customize fields in url matching and I don't know how to find documentation about Rails 2.3, most of my research drove me to Rails 3 doc about the topic... Somebody to help me ?

    Read the article

  • Why are types found on an imported namepace but not on a fully qualified namespace after retargeting the framework?

    - by Paul Ferguson
    We've just re-targeted a VB.NET project from .Net 2.0 to 3.5. Various framework types are now missing from our project. Wherever the type is referenced using a fully qualified namespace it's missing. If the relevant namespace is imported for the type; it's found. For example, this doesn't find the type Object, with compiler error "System.Object is not defined.": Public Class Foo Inherits System.Object End Class However, this works ok: Imports System Public Class Foo Inherits [Object] End Class I've already tried re-opening the solution with no success.

    Read the article

  • Is there a Python module for handling Python object addresses?

    - by cool-RR
    (When I say "object address", I mean the string that you type in Python to access an object. For example 'life.State.step'. Most of the time, all the objects before the last dot will be packages/modules, but in some cases they can be classes or other objects.) In my Python project I often have the need to play around with object addresses. Some tasks that I have to do: Given an object, get its address. Given an address, get the object, importing any needed modules on the way. Shorten an object's address by getting rid of redundant intermediate modules. (For example, 'life.life.State.step' may be the official address of an object, but if 'life.State.step' points at the same object, I'd want to use it instead because it's shorter.) Shorten an object's address by "rooting" a specified module. (For example, 'garlicsim_lib.simpacks.prisoner.prisoner.State.step' may be the official address of an object, but I assume that the user knows where the prisoner package is, so I'd want to use 'prisoner.prisoner.State.step' as the address.) Is there a module/framework that handles things like that? I wrote a few utility modules to do these things, but if someone has already written a more mature module that does this, I'd prefer to use that. One note: Please, don't try to show me a quick implementation of these things. It's more complicated than it seems, there are plenty of gotchas, and any quick-n-dirty code will probably fail for many important cases. These kind of tasks call for battle-tested code. UPDATE: When I say "object", I mostly mean classes, modules, functions, methods, stuff like these. Sorry for not making this clear before.

    Read the article

  • The elements do not fall into document('').

    - by Kalinin
    xslt: <my:translations xmlns:my="my:my"> <w e="name" r="????????"/> <w e="model" r="??????"/> <w e="year" r="???"/> <w e="glass_type" r="???"/> <w e="scancode" r="???????"/> <w e="eurocode" r="???????"/> <w e="comment" r="???????????"/> <w e="glass_size" r="??????"/> <w e="vendor" r="?????????????"/> <w e="trademark" r="???????? ?????"/> <w e="fprice" r="????"/> </my:translations> <xsl:value-of select="count(document('')//w)"/> returns 0. In what may be the problem?

    Read the article

  • Does Adding more namespace in the code file affect performace ?

    - by Harikrishna
    If we imports more namespace in the code file(cs file) then it affects on perfomance ? Like we should add namespace in the cs file as needed. That is adding more namespace in the cs file affects performance ? Like using System; using System.Data.Sql; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Xml; using System.Data.SqlClient; using System.ComponentModel;

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >